From 67fc72bdaf3504b45fd8490a9b11929b1c583c48 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 17 Oct 2022 16:57:04 +0200 Subject: [PATCH] general: Add constness to some methods where it is missing --- contrib/src/rplight/gpuCommandList.cxx | 2 +- contrib/src/rplight/gpuCommandList.h | 2 +- contrib/src/rplight/pssmCameraRig.I | 10 +++++----- contrib/src/rplight/pssmCameraRig.h | 10 +++++----- contrib/src/rplight/tagStateManager.I | 4 ++-- contrib/src/rplight/tagStateManager.h | 2 +- panda/src/pnmimage/pnmimage_base.h | 2 +- panda/src/skel/basicSkel.I | 2 +- panda/src/skel/basicSkel.cxx | 2 +- panda/src/skel/basicSkel.h | 4 ++-- panda/src/skel/typedSkel.I | 2 +- panda/src/skel/typedSkel.cxx | 2 +- panda/src/skel/typedSkel.h | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/contrib/src/rplight/gpuCommandList.cxx b/contrib/src/rplight/gpuCommandList.cxx index 3f92194f64..1d8b36f738 100644 --- a/contrib/src/rplight/gpuCommandList.cxx +++ b/contrib/src/rplight/gpuCommandList.cxx @@ -51,7 +51,7 @@ void GPUCommandList::add_command(const GPUCommand& cmd) { * list, and are waiting to get processed. * @return Amount of commands */ -size_t GPUCommandList::get_num_commands() { +size_t GPUCommandList::get_num_commands() const { return _commands.size(); } diff --git a/contrib/src/rplight/gpuCommandList.h b/contrib/src/rplight/gpuCommandList.h index 1551afe630..b4f7664974 100644 --- a/contrib/src/rplight/gpuCommandList.h +++ b/contrib/src/rplight/gpuCommandList.h @@ -42,7 +42,7 @@ PUBLISHED: GPUCommandList(); void add_command(const GPUCommand& cmd); - size_t get_num_commands(); + size_t get_num_commands() const; size_t write_commands_to(const PTA_uchar &dest, size_t limit = 32); MAKE_PROPERTY(num_commands, get_num_commands); diff --git a/contrib/src/rplight/pssmCameraRig.I b/contrib/src/rplight/pssmCameraRig.I index cd87718262..1f1e9d3285 100644 --- a/contrib/src/rplight/pssmCameraRig.I +++ b/contrib/src/rplight/pssmCameraRig.I @@ -175,7 +175,7 @@ inline void PSSMCameraRig::reset_film_size_cache() { * @param index Index of the camera. * @return [description] */ -inline NodePath PSSMCameraRig::get_camera(size_t index) { +inline NodePath PSSMCameraRig::get_camera(size_t index) const { nassertr(index >= 0 && index < _cam_nodes.size(), NodePath()); return _cam_nodes[index]; } @@ -193,7 +193,7 @@ inline NodePath PSSMCameraRig::get_camera(size_t index) { * @param split_index The index of the split * @return Distance of the split, ranging from 0 .. 1 */ -inline float PSSMCameraRig::get_split_start(size_t split_index) { +inline float PSSMCameraRig::get_split_start(size_t split_index) const { float x = (float)split_index / (float)_cam_nodes.size(); return (exp(_logarithmic_factor*x)-1) / (exp(_logarithmic_factor)-1); } @@ -209,7 +209,7 @@ inline float PSSMCameraRig::get_split_start(size_t split_index) { * * @return interpolated point in world space */ -inline LPoint3 PSSMCameraRig::get_interpolated_point(CoordinateOrigin origin, float depth) { +inline LPoint3 PSSMCameraRig::get_interpolated_point(CoordinateOrigin origin, float depth) const { nassertr(depth >= 0.0 && depth <= 1.0, LPoint3()); return _curr_near_points[origin] * (1.0 - depth) + _curr_far_points[origin] * depth; } @@ -222,7 +222,7 @@ inline LPoint3 PSSMCameraRig::get_interpolated_point(CoordinateOrigin origin, fl * * @return view-projection matrix array */ -inline const PTA_LMatrix4 &PSSMCameraRig::get_mvp_array() { +inline const PTA_LMatrix4 &PSSMCameraRig::get_mvp_array() const { return _camera_mvps; } @@ -238,6 +238,6 @@ inline const PTA_LMatrix4 &PSSMCameraRig::get_mvp_array() { * * @return Array of near and far planes */ -inline const PTA_LVecBase2 &PSSMCameraRig::get_nearfar_array() { +inline const PTA_LVecBase2 &PSSMCameraRig::get_nearfar_array() const { return _camera_nearfar; } diff --git a/contrib/src/rplight/pssmCameraRig.h b/contrib/src/rplight/pssmCameraRig.h index 33cefe6dc1..a05cf3b90b 100644 --- a/contrib/src/rplight/pssmCameraRig.h +++ b/contrib/src/rplight/pssmCameraRig.h @@ -72,11 +72,11 @@ PUBLISHED: void update(NodePath cam_node, const LVecBase3 &light_vector); inline void reset_film_size_cache(); - inline NodePath get_camera(size_t index); + inline NodePath get_camera(size_t index) const; void reparent_to(NodePath parent); - inline const PTA_LMatrix4 &get_mvp_array(); - inline const PTA_LVecBase2 &get_nearfar_array(); + inline const PTA_LMatrix4 &get_mvp_array() const; + inline const PTA_LVecBase2 &get_nearfar_array() const; public: // Used to access the near and far points in the array @@ -91,9 +91,9 @@ protected: void init_cam_nodes(); void compute_pssm_splits(const LMatrix4& transform, float max_distance, const LVecBase3 &light_vector); - inline float get_split_start(size_t split_index); + inline float get_split_start(size_t split_index) const; LMatrix4 compute_mvp(size_t cam_index); - inline LPoint3 get_interpolated_point(CoordinateOrigin origin, float depth); + inline LPoint3 get_interpolated_point(CoordinateOrigin origin, float depth) const; LVecBase3 get_snap_offset(const LMatrix4& mat, size_t resolution); std::vector _cam_nodes; diff --git a/contrib/src/rplight/tagStateManager.I b/contrib/src/rplight/tagStateManager.I index 2da15e4ecd..56228d16e8 100644 --- a/contrib/src/rplight/tagStateManager.I +++ b/contrib/src/rplight/tagStateManager.I @@ -83,11 +83,11 @@ apply_state(const std::string& state, NodePath np, Shader* shader, * @return Bit mask of the render pass */ inline BitMask32 TagStateManager:: -get_mask(const std::string &container_name) { +get_mask(const std::string &container_name) const { if (container_name == "gbuffer") { return BitMask32::bit(1); } - ContainerList::iterator entry = _containers.find(container_name); + ContainerList::const_iterator entry = _containers.find(container_name); nassertr(entry != _containers.end(), BitMask32()); return entry->second.mask; } diff --git a/contrib/src/rplight/tagStateManager.h b/contrib/src/rplight/tagStateManager.h index b05e364333..aca6a359c5 100644 --- a/contrib/src/rplight/tagStateManager.h +++ b/contrib/src/rplight/tagStateManager.h @@ -57,7 +57,7 @@ PUBLISHED: inline void register_camera(const std::string& state, Camera* source); inline void unregister_camera(const std::string& state, Camera* source); - inline BitMask32 get_mask(const std::string &container_name); + inline BitMask32 get_mask(const std::string &container_name) const; private: typedef std::vector CameraList; diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index f3db5ff226..5e45d9d57b 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -77,7 +77,7 @@ PUBLISHED: #ifdef HAVE_PYTHON static int size() { return 3; } - void output(std::ostream &out) { + void output(std::ostream &out) const { out << "pixel(r=" << r << ", g=" << g << ", b=" << b << ")"; } #endif diff --git a/panda/src/skel/basicSkel.I b/panda/src/skel/basicSkel.I index 8a8b830bcd..1b85444e42 100644 --- a/panda/src/skel/basicSkel.I +++ b/panda/src/skel/basicSkel.I @@ -37,6 +37,6 @@ set_value(int n) { * Retreives a value that was previously stored. */ INLINE int BasicSkel:: -get_value() { +get_value() const { return _value; } diff --git a/panda/src/skel/basicSkel.cxx b/panda/src/skel/basicSkel.cxx index 2b5eaab6ca..2978cae072 100644 --- a/panda/src/skel/basicSkel.cxx +++ b/panda/src/skel/basicSkel.cxx @@ -27,6 +27,6 @@ set_value_alt(int n) { * get_value, except that this isn't an inline function. */ int BasicSkel:: -get_value_alt() { +get_value_alt() const { return _value; } diff --git a/panda/src/skel/basicSkel.h b/panda/src/skel/basicSkel.h index 0186eb0f04..c8d82347ef 100644 --- a/panda/src/skel/basicSkel.h +++ b/panda/src/skel/basicSkel.h @@ -30,11 +30,11 @@ PUBLISHED: // These inline functions allow you to get and set _value. INLINE void set_value(int n); - INLINE int get_value(); + INLINE int get_value() const; // These do the same thing as the functions above. void set_value_alt(int n); - int get_value_alt(); + int get_value_alt() const; private: int _value; diff --git a/panda/src/skel/typedSkel.I b/panda/src/skel/typedSkel.I index d1b7f3d199..7b7150d886 100644 --- a/panda/src/skel/typedSkel.I +++ b/panda/src/skel/typedSkel.I @@ -37,6 +37,6 @@ set_value(int n) { * Retreives a value that was previously stored. */ INLINE int TypedSkel:: -get_value() { +get_value() const { return _value; } diff --git a/panda/src/skel/typedSkel.cxx b/panda/src/skel/typedSkel.cxx index 5a89030ec9..867877ad5c 100644 --- a/panda/src/skel/typedSkel.cxx +++ b/panda/src/skel/typedSkel.cxx @@ -29,6 +29,6 @@ set_value_alt(int n) { * get_value, except that this isn't an inline function. */ int TypedSkel:: -get_value_alt() { +get_value_alt() const { return _value; } diff --git a/panda/src/skel/typedSkel.h b/panda/src/skel/typedSkel.h index 7cd37f71ba..3d17026b4f 100644 --- a/panda/src/skel/typedSkel.h +++ b/panda/src/skel/typedSkel.h @@ -31,11 +31,11 @@ PUBLISHED: // These inline functions allow you to get and set _value. INLINE void set_value(int n); - INLINE int get_value(); + INLINE int get_value() const; // These do the same thing as the functions above. void set_value_alt(int n); - int get_value_alt(); + int get_value_alt() const; private: int _value;