general: Add constness to some methods where it is missing

This commit is contained in:
rdb 2022-10-17 16:57:04 +02:00
parent cee1de7338
commit 67fc72bdaf
13 changed files with 24 additions and 24 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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<NodePath> _cam_nodes;

View File

@ -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;
}

View File

@ -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<Camera*> CameraList;

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;