general: fix many compilation warnings in GCC 8

This commit is contained in:
rdb 2018-06-18 22:12:19 +02:00
parent d89efcfda2
commit 886e1c2f16
68 changed files with 219 additions and 323 deletions

View File

@ -135,7 +135,7 @@ void InternalLightManager::setup_shadows(RPLight* light) {
}
// Init all sources
for (int i = 0; i < num_sources; ++i) {
for (size_t i = 0; i < num_sources; ++i) {
ShadowSource* source = light->get_shadow_source(i);
// Set the source as dirty, so it gets updated in the beginning

View File

@ -170,7 +170,7 @@ public:
_num_entries--;
// Update maximum index
if (slot == _max_index) {
if ((int)slot == _max_index) {
while (_max_index >= 0 && !_data[_max_index--]);
}
}

View File

@ -33,7 +33,7 @@
*
* @return Amount of shadow sources
*/
inline int RPLight::get_num_shadow_sources() const {
inline size_t RPLight::get_num_shadow_sources() const {
return _shadow_sources.size();
}

View File

@ -57,7 +57,7 @@ public:
virtual void update_shadow_sources() = 0;
virtual void write_to_command(GPUCommand &cmd);
inline int get_num_shadow_sources() const;
inline size_t get_num_shadow_sources() const;
inline ShadowSource* get_shadow_source(size_t index) const;
inline void clear_shadow_sources();

View File

@ -173,12 +173,12 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h
void ShadowAtlas::free_region(const LVecBase4i& region) {
// Out of bounds check, can't hurt
nassertv(region.get_x() >= 0 && region.get_y() >= 0);
nassertv(region.get_x() + region.get_z() <= _num_tiles && region.get_y() + region.get_w() <= _num_tiles);
nassertv(region.get_x() + region.get_z() <= (int)_num_tiles && region.get_y() + region.get_w() <= (int)_num_tiles);
_num_used_tiles -= region.get_z() * region.get_w();
for (size_t x = 0; x < region.get_z(); ++x) {
for (size_t y = 0; y < region.get_w(); ++y) {
for (int x = 0; x < region.get_z(); ++x) {
for (int y = 0; y < region.get_w(); ++y) {
// Could do an assert here, that the tile should have been used (=true) before
set_tile(region.get_x() + x, region.get_y() + y, false);
}

View File

@ -744,7 +744,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -169,7 +169,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -31,6 +31,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into) {
if (_IS_FINAL(T)) {
if (DtoolInstance_TYPE(self) == target_class) {
into = (T *)DtoolInstance_VOID_PTR(self);
} else {
return false;
}
} else {
into = (T *)DtoolInstance_UPCAST(self, *target_class);
@ -52,6 +54,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c
if (_IS_FINAL(T)) {
if (DtoolInstance_TYPE(self) == &target_class) {
into = (T *)DtoolInstance_VOID_PTR(self);
} else {
return false;
}
} else {
into = (T *)DtoolInstance_UPCAST(self, target_class);

View File

@ -1209,19 +1209,6 @@ static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) {
return result;
}
static PySequenceMethods Dtool_MappingWrapper_Keys_SequenceMethods = {
Dtool_SequenceWrapper_length,
nullptr, // sq_concat
nullptr, // sq_repeat
Dtool_MappingWrapper_Items_getitem,
nullptr, // sq_slice
nullptr, // sq_ass_item
nullptr, // sq_ass_slice
Dtool_MappingWrapper_contains,
nullptr, // sq_inplace_concat
nullptr, // sq_inplace_repeat
};
PyTypeObject Dtool_MappingWrapper_Keys_Type = {
PyVarObject_HEAD_INIT(nullptr, 0)
"sequence wrapper",

View File

@ -784,7 +784,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) {
PT(BulletTriangleMesh) mesh = nullptr;
for (int j=0; j<cnode->get_num_solids(); j++) {
for (size_t j = 0; j < cnode->get_num_solids(); ++j) {
CPT(CollisionSolid) solid = cnode->get_solid(j);
TypeHandle type = solid->get_type();
@ -819,9 +819,9 @@ add_shapes_from_collision_solids(CollisionNode *cnode) {
mesh = new BulletTriangleMesh();
}
for (int i=2; i < polygon->get_num_points(); i++ ) {
for (size_t i = 2; i < polygon->get_num_points(); ++i) {
LPoint3 p1 = polygon->get_point(0);
LPoint3 p2 = polygon->get_point(i-1);
LPoint3 p2 = polygon->get_point(i - 1);
LPoint3 p3 = polygon->get_point(i);
mesh->do_add_triangle(p1, p2, p3, true);

View File

@ -97,8 +97,7 @@ do_transform_changed() {
if (ts->has_scale()) {
LVecBase3 scale = ts->get_scale();
if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
for (int i=0; i < _shapes.size(); i++) {
PT(BulletShape) shape = _shapes[i];
for (BulletShape *shape : _shapes) {
shape->do_set_local_scale(scale);
}
}

View File

@ -83,7 +83,7 @@ from_collision_solids(NodePath &np, bool clear) {
bool BulletHelper::
is_tangible(CollisionNode *cnode) {
for (int j=0; j<cnode->get_num_solids(); j++) {
for (size_t j = 0; j < cnode->get_num_solids(); ++j) {
CPT(CollisionSolid) solid = cnode->get_solid(j);
if (solid->is_tangible()) {
return true;

View File

@ -883,7 +883,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon
}
// Read indices
for (int i=0; i<geom->get_num_primitives(); i++) {
for (size_t i = 0; i < geom->get_num_primitives(); ++i) {
CPT(GeomPrimitive) prim = geom->get_primitive(i);
prim = prim->decompose();

View File

@ -55,7 +55,7 @@ LPoint3 BulletTriangleMesh::
get_vertex(size_t index) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
nassertr(index < _vertices.size(), LPoint3::zero());
nassertr(index < (size_t)_vertices.size(), LPoint3::zero());
const btVector3 &vertex = _vertices[index];
return LPoint3(vertex[0], vertex[1], vertex[2]);
}
@ -68,7 +68,7 @@ get_triangle(size_t index) const {
LightMutexHolder holder(BulletWorld::get_global_lock());
index *= 3;
nassertr(index + 2 < _indices.size(), LVecBase3i::zero());
nassertr(index + 2 < (size_t)_indices.size(), LVecBase3i::zero());
return LVecBase3i(_indices[index], _indices[index + 1], _indices[index + 2]);
}
@ -228,7 +228,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState
}
}
for (int k = 0; k < geom->get_num_primitives(); ++k) {
for (size_t k = 0; k < geom->get_num_primitives(); ++k) {
CPT(GeomPrimitive) prim = geom->get_primitive(k);
prim = prim->decompose();
@ -271,7 +271,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState
}
// Add triangles
for (int k = 0; k < geom->get_num_primitives(); ++k) {
for (size_t k = 0; k < geom->get_num_primitives(); ++k) {
CPT(GeomPrimitive) prim = geom->get_primitive(k);
prim = prim->decompose();
@ -367,7 +367,7 @@ write(std::ostream &out, int indent_level) const {
indent(out, indent_level) << get_type() << ":" << endl;
const IndexedMeshArray &array = _mesh.getIndexedMeshArray();
for (size_t i = 0; i < array.size(); ++i) {
for (int i = 0; i < array.size(); ++i) {
indent(out, indent_level + 2) << "IndexedMesh " << i << ":" << endl;
const btIndexedMesh &mesh = array[0];
indent(out, indent_level + 4) << "num triangles:" << mesh.m_numTriangles << endl;

View File

@ -34,7 +34,7 @@ INLINE BulletWheelRaycastInfo::
INLINE BulletWheel BulletWheel::
empty() {
btWheelInfoConstructionInfo ci;
btWheelInfoConstructionInfo ci {};
btWheelInfo info(ci);
return BulletWheel(info);

View File

@ -42,7 +42,7 @@ BulletWorld::
BulletWorld() {
// Init groups filter matrix
for (int i=0; i<32; i++) {
for (size_t i = 0; i < 32; ++i) {
_filter_cb2._collide[i].clear();
_filter_cb2._collide[i].set_bit(i);
}
@ -253,20 +253,20 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) {
void BulletWorld::
do_sync_p2b(PN_stdfloat dt, int num_substeps) {
for (int i=0; i < _bodies.size(); i++) {
_bodies[i]->do_sync_p2b();
for (BulletRigidBodyNode *body : _bodies) {
body->do_sync_p2b();
}
for (int i=0; i < _softbodies.size(); i++) {
_softbodies[i]->do_sync_p2b();
for (BulletSoftBodyNode *softbody : _softbodies) {
softbody->do_sync_p2b();
}
for (int i=0; i < _ghosts.size(); i++) {
_ghosts[i]->do_sync_p2b();
for (BulletGhostNode *ghost : _ghosts) {
ghost->do_sync_p2b();
}
for (int i=0; i < _characters.size(); i++) {
_characters[i]->do_sync_p2b(dt, num_substeps);
for (BulletBaseCharacterControllerNode *character : _characters) {
character->do_sync_p2b(dt, num_substeps);
}
}
@ -276,24 +276,24 @@ do_sync_p2b(PN_stdfloat dt, int num_substeps) {
void BulletWorld::
do_sync_b2p() {
for (int i=0; i < _vehicles.size(); i++) {
_vehicles[i]->do_sync_b2p();
for (BulletVehicle *vehicle : _vehicles) {
vehicle->do_sync_b2p();
}
for (int i=0; i < _bodies.size(); i++) {
_bodies[i]->do_sync_b2p();
for (BulletRigidBodyNode *body : _bodies) {
body->do_sync_b2p();
}
for (int i=0; i < _softbodies.size(); i++) {
_softbodies[i]->do_sync_b2p();
for (BulletSoftBodyNode *softbody : _softbodies) {
softbody->do_sync_b2p();
}
for (int i=0; i < _ghosts.size(); i++) {
_ghosts[i]->do_sync_b2p();
for (BulletGhostNode *ghost : _ghosts) {
ghost->do_sync_b2p();
}
for (int i=0; i < _characters.size(); i++) {
_characters[i]->do_sync_b2p();
for (BulletBaseCharacterControllerNode *character : _characters) {
character->do_sync_b2p();
}
}
@ -1273,7 +1273,7 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co
// cout << mask0 << " " << mask1 << endl;
for (int i=0; i<32; i++) {
for (size_t i = 0; i < 32; ++i) {
if (mask0.get_bit(i)) {
if ((_collide[i] & mask1) != 0)
// cout << "collide: i=" << i << " _collide[i]" << _collide[i] << endl;

View File

@ -57,7 +57,7 @@ CollisionPolygon() {
/**
* Returns the number of vertices of the CollisionPolygon.
*/
INLINE int CollisionPolygon::
INLINE size_t CollisionPolygon::
get_num_points() const {
return _points.size();
}
@ -66,8 +66,8 @@ get_num_points() const {
* 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());
get_point(size_t n) const {
nassertr(n < _points.size(), LPoint3::zero());
LMatrix4 to_3d_mat;
rederive_to_3d_mat(to_3d_mat);
return to_3d(_points[n]._p, to_3d_mat);

View File

@ -45,8 +45,8 @@ public:
PUBLISHED:
virtual LPoint3 get_collision_origin() const;
INLINE int get_num_points() const;
INLINE LPoint3 get_point(int n) const;
INLINE size_t get_num_points() const;
INLINE LPoint3 get_point(size_t n) const;
MAKE_SEQ(get_points, get_num_points, get_point);

View File

@ -763,7 +763,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) {
// 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 && mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) {
if (mi >= 0 && (size_t)mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) {
PT(GeomMunger) munger = mungers.get_data(mi);
if (munger->is_registered()) {
return munger;

View File

@ -1145,7 +1145,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -200,7 +200,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -84,7 +84,7 @@ move_pointer(int device, int x, int y) {
return true;
} else {
// Move a raw mouse.
if ((device < 1)||(device >= _input_devices.size())) {
if (device < 1 || (size_t)device >= _input_devices.size()) {
return false;
}
_input_devices[device].set_pointer_in_window(x, y);

View File

@ -1111,7 +1111,7 @@ compute_mf_patches(ostream &write_stream,
index_orig, index_new)) {
return false;
}
nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_index_end(), false);
nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_index_end(), false);
}
// Now walk through each subfile in the new multifile. If a particular
@ -1120,7 +1120,7 @@ compute_mf_patches(ostream &write_stream,
// 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);
nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_subfile_internal_start(ni), false);
string name = mf_new.get_subfile_name(ni);
int oi = mf_orig.find_subfile(name);
@ -1517,7 +1517,7 @@ patch_subfile(ostream &write_stream,
const Filename &filename,
IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end,
IStreamWrapper &stream_new, streampos new_start, streampos new_end) {
nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + new_start, false);
nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)new_start, false);
size_t new_size = new_end - new_start;
size_t orig_size = orig_end - orig_start;

View File

@ -307,7 +307,7 @@ reload_buffer() {
// First, let's fill the codec's input buffer with as many packets as it'll
// take:
int ret;
int ret = 0;
while (_packet->data != nullptr) {
ret = avcodec_send_packet(_audio_ctx, _packet);

View File

@ -400,7 +400,7 @@ premunge_format_impl(const GeomVertexFormat *orig) {
CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
if (orig_a->count_unused_space() != 0) {
PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat;
for (size_t j = 0; j < orig_a->get_num_columns(); ++j) {
for (int j = 0; j < orig_a->get_num_columns(); ++j) {
const GeomVertexColumn *column = orig_a->get_column(j);
new_a->add_column(column->get_name(), column->get_num_components(),
column->get_numeric_type(), column->get_contents(),

View File

@ -1297,7 +1297,7 @@ set_size(int x, int y) {
*/
void CLP(GraphicsBuffer)::
select_target_tex_page(int page) {
nassertv(page >= 0 && page < _fbo.size());
nassertv(page >= 0 && (size_t)page < _fbo.size());
CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p();
@ -1574,10 +1574,10 @@ close_buffer() {
report_my_gl_errors();
// Delete the FBO itself.
for (int i = 0; i < _fbo.size(); ++i) {
glgsg->_glDeleteFramebuffers(1, &_fbo[i]);
if (!_fbo.empty()) {
glgsg->_glDeleteFramebuffers(_fbo.size(), _fbo.data());
_fbo.clear();
}
_fbo.clear();
report_my_gl_errors();

View File

@ -4374,9 +4374,9 @@ unbind_buffers() {
if (_current_vertex_buffers.size() > 1 && _supports_multi_bind) {
_glBindVertexBuffers(0, _current_vertex_buffers.size(), nullptr, nullptr, nullptr);
} else {
for (int i = 0; i < _current_vertex_buffers.size(); ++i) {
for (size_t i = 0; i < _current_vertex_buffers.size(); ++i) {
if (_current_vertex_buffers[i] != 0) {
_glBindVertexBuffer(i, 0, 0, 0);
_glBindVertexBuffer((GLuint)i, 0, 0, 0);
}
}
}
@ -13309,7 +13309,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
GLint wrap_u, wrap_v, wrap_w;
GLint minfilter, magfilter;
#ifndef OPENGLES
GLfloat border_color[4];
#endif
#ifdef OPENGLES
if (true) {
@ -13803,11 +13806,13 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
tex->set_wrap_u(get_panda_wrap_mode(wrap_u));
tex->set_wrap_v(get_panda_wrap_mode(wrap_v));
tex->set_wrap_w(get_panda_wrap_mode(wrap_w));
tex->set_border_color(LColor(border_color[0], border_color[1],
border_color[2], border_color[3]));
tex->set_minfilter(get_panda_filter_type(minfilter));
//tex->set_magfilter(get_panda_filter_type(magfilter));
#ifndef OPENGLES
tex->set_border_color(LColor(border_color[0], border_color[1],
border_color[2], border_color[3]));
#endif
}
PTA_uchar image;

View File

@ -352,7 +352,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
StorageBlock block;
block._name = InternalName::make(block_name_cstr);
block._binding_index = values[0];
block._min_size = values[1];
block._min_size = (GLuint)values[1];
_storage_blocks.push_back(block);
}
}
@ -681,6 +681,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b
break;
}
(void)numeric_type;
(void)contents;
(void)num_components;
// GeomVertexColumn column(InternalName::make(name_buffer),
// num_components, numeric_type, contents, offsets[ui], 4, param_size,
// astrides[ui]); block_format.add_column(column);
@ -1986,7 +1989,7 @@ issue_parameters(int altered) {
if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) {
// If we have an osg_FrameNumber input, set it now.
if ((altered | Shader::SSD_frame) != 0 && _frame_number_loc >= 0) {
if ((altered & Shader::SSD_frame) != 0 && _frame_number_loc >= 0) {
_glgsg->_glUniform1i(_frame_number_loc, _frame_number);
}
@ -2169,7 +2172,7 @@ update_transform_table(const TransformTable *table) {
#endif
}
}
for (; i < _transform_table_size; ++i) {
for (; i < (size_t)_transform_table_size; ++i) {
matrices[i] = LMatrix4f::ident_mat();
}
@ -2237,7 +2240,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
// Use experimental new separated formatbinding state.
const GeomVertexDataPipelineReader *data_reader = _glgsg->_data_reader;
for (int ai = 0; ai < data_reader->get_num_arrays(); ++ai) {
for (size_t ai = 0; ai < data_reader->get_num_arrays(); ++ai) {
array_reader = data_reader->get_array_reader(ai);
// Make sure the vertex buffer is up-to-date.
@ -2294,7 +2297,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
int start, stride, num_values;
size_t nvarying = _shader->_var_spec.size();
GLuint max_p = 0;
GLint max_p = 0;
for (size_t i = 0; i < nvarying; ++i) {
const Shader::ShaderVarSpec &bind = _shader->_var_spec[i];
@ -2312,7 +2315,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
}
}
GLuint p = bind._id._seqno;
GLint p = bind._id._seqno;
max_p = max(max_p, p + 1);
// Don't apply vertex colors if they are disabled with a ColorAttrib.
@ -2401,7 +2404,7 @@ disable_shader_texture_bindings() {
DO_PSTATS_STUFF(_glgsg->_texture_state_pcollector.add_level(1));
for (int i = 0; i < _shader->_tex_spec.size(); ++i) {
for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) {
#ifndef OPENGLES
// Check if bindless was used, if so, there's nothing to unbind.
if (_glgsg->_supports_bindless_texture) {

View File

@ -99,7 +99,7 @@ private:
struct StorageBlock {
CPT(InternalName) _name;
GLuint _binding_index;
GLint _min_size;
GLuint _min_size;
};
typedef pvector<StorageBlock> StorageBlocks;
StorageBlocks _storage_blocks;

View File

@ -145,7 +145,7 @@ make_adjacency() const {
// Add the actual vertices in the strip.
adj->add_vertex(v0);
int v1;
int v1 = v0;
while (vi < end) {
v1 = from.get_vertex(vi++);
adj->add_vertex(v1);

View File

@ -557,9 +557,7 @@ get_format_string(bool pad) const {
int fi = 0;
int offset = 0;
for (int ci = 0; ci < get_num_columns(); ++ci) {
const GeomVertexColumn *column = get_column(ci);
for (const GeomVertexColumn *column : _columns) {
if (offset < column->get_start()) {
// Add padding bytes to fill the gap.
int pad = column->get_start() - offset;

View File

@ -677,7 +677,7 @@ has_column(const InternalName *name) const {
/**
*
*/
INLINE int GeomVertexDataPipelineBase::
INLINE size_t GeomVertexDataPipelineBase::
get_num_arrays() const {
return _cdata->_arrays.size();
}
@ -686,8 +686,8 @@ get_num_arrays() const {
*
*/
INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase::
get_array(int i) const {
nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), nullptr);
get_array(size_t i) const {
nassertr(i < _cdata->_arrays.size(), nullptr);
return _cdata->_arrays[i].get_read_pointer();
}

View File

@ -344,7 +344,7 @@ void GeomVertexData::
clear_rows() {
Thread *current_thread = Thread::get_current_thread();
CDWriter cdata(_cycler, true, current_thread);
nassertv(cdata->_format->get_num_arrays() == (int)cdata->_arrays.size());
nassertv(cdata->_format->get_num_arrays() == cdata->_arrays.size());
Arrays::iterator ai;
for (ai = cdata->_arrays.begin();
@ -2243,7 +2243,7 @@ get_num_bytes() const {
*/
int GeomVertexDataPipelineReader::
get_num_rows() const {
nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0);
nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0);
nassertr(_got_array_readers, 0);
if (_cdata->_format->get_num_arrays() == 0) {
@ -2395,7 +2395,7 @@ make_array_readers() {
*/
int GeomVertexDataPipelineWriter::
get_num_rows() const {
nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0);
nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0);
nassertr(_got_array_writers, 0);
if (_cdata->_format->get_num_arrays() == 0) {
@ -2414,7 +2414,7 @@ get_num_rows() const {
bool GeomVertexDataPipelineWriter::
set_num_rows(int n) {
nassertr(_got_array_writers, false);
nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false);
nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false);
bool any_changed = false;
@ -2510,7 +2510,7 @@ set_num_rows(int n) {
bool GeomVertexDataPipelineWriter::
unclean_set_num_rows(int n) {
nassertr(_got_array_writers, false);
nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false);
nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false);
bool any_changed = false;
@ -2537,7 +2537,7 @@ unclean_set_num_rows(int n) {
bool GeomVertexDataPipelineWriter::
reserve_num_rows(int n) {
nassertr(_got_array_writers, false);
nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false);
nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false);
bool any_changed = false;

View File

@ -419,8 +419,8 @@ public:
INLINE bool has_column(const InternalName *name) const;
INLINE UsageHint get_usage_hint() const;
INLINE int get_num_arrays() const;
INLINE CPT(GeomVertexArrayData) get_array(int i) const;
INLINE size_t get_num_arrays() const;
INLINE CPT(GeomVertexArrayData) get_array(size_t i) const;
INLINE const TransformTable *get_transform_table() const;
INLINE CPT(TransformBlendTable) get_transform_blend_table() const;
INLINE const SliderTable *get_slider_table() const;

View File

@ -102,7 +102,7 @@ set_vertex_column(int array, const GeomVertexColumn *column,
#ifndef NDEBUG
_array = -1;
_packer = nullptr;
nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false);
nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false);
#endif
_array = array;

View File

@ -133,7 +133,7 @@ set_vertex_column(int array, const GeomVertexColumn *column,
#ifndef NDEBUG
_array = -1;
_packer = nullptr;
nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false);
nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false);
#endif
_array = array;

View File

@ -2652,7 +2652,7 @@ r_preprocess_source(ostream &out, const Filename &fn,
}
char pragma[64];
int nread = 0;
size_t nread = 0;
// What kind of directive is it?
if (strcmp(directive, "pragma") == 0 &&
sscanf(line.c_str(), " # pragma %63s", pragma) == 1) {
@ -2661,13 +2661,13 @@ r_preprocess_source(ostream &out, const Filename &fn,
Filename incfn, source_dir;
{
char incfile[2048];
if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %n", incfile, &nread) == 1
if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %zn", incfile, &nread) == 1
&& nread == line.size()) {
// A regular include, with double quotes. Probably a local file.
source_dir = full_fn.get_dirname();
incfn = incfile;
} else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %n", incfile, &nread) == 1
} else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %zn", incfile, &nread) == 1
&& nread == line.size()) {
// Angled includes are also OK, but we don't search in the directory
// of the source file.
@ -2696,7 +2696,7 @@ r_preprocess_source(ostream &out, const Filename &fn,
} else if (strcmp(pragma, "once") == 0) {
// Do a stricter syntax check, just to be extra safe.
if (sscanf(line.c_str(), " # pragma%*[ \t]once %n", &nread) != 0 ||
if (sscanf(line.c_str(), " # pragma%*[ \t]once %zn", &nread) != 0 ||
nread != line.size()) {
shader_cat.error()
<< "Malformed #pragma once at line " << lineno
@ -2788,7 +2788,7 @@ r_preprocess_source(ostream &out, const Filename &fn,
Filename incfn;
{
char incfile[2048];
if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %n", incfile, &nread) != 1
if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %zn", incfile, &nread) != 1
|| nread != line.size()) {
// Couldn't parse it.
shader_cat.error()
@ -2815,7 +2815,7 @@ r_preprocess_source(ostream &out, const Filename &fn,
} else if (ext_google_line > 0 && strcmp(directive, "line") == 0) {
// It's a #line directive. See if it uses a string instead of number.
char filestr[2048];
if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %n", &lineno, filestr, &nread) == 2
if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %zn", &lineno, filestr, &nread) == 2
&& nread == line.size()) {
// Warn about extension use if requested.
if (ext_google_line == 1) {

View File

@ -4224,7 +4224,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only)
}
// See: https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
uint32_t gl_type, type_size, gl_format, internal_format, gl_base_format,
uint32_t gl_type, /*type_size,*/ gl_format, internal_format, gl_base_format,
width, height, depth, num_array_elements, num_faces, num_mipmap_levels,
kvdata_size;
@ -4232,7 +4232,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only)
if (ktx.get_uint32() == 0x04030201) {
big_endian = false;
gl_type = ktx.get_uint32();
type_size = ktx.get_uint32();
/*type_size = */ktx.get_uint32();
gl_format = ktx.get_uint32();
internal_format = ktx.get_uint32();
gl_base_format = ktx.get_uint32();
@ -4246,7 +4246,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only)
} else {
big_endian = true;
gl_type = ktx.get_be_uint32();
type_size = ktx.get_be_uint32();
/*type_size = */ktx.get_be_uint32();
gl_format = ktx.get_be_uint32();
internal_format = ktx.get_be_uint32();
gl_base_format = ktx.get_be_uint32();

View File

@ -11,33 +11,6 @@
* @date 2011-12-15
*/
/**
*
*/
template <class FloatType, int NumRows, int NumCols>
INLINE LSimpleMatrix<FloatType, NumRows, NumCols>::
LSimpleMatrix() {
// No default initialization.
}
/**
*
*/
template <class FloatType, int NumRows, int NumCols>
INLINE LSimpleMatrix<FloatType, NumRows, NumCols>::
LSimpleMatrix(const LSimpleMatrix<FloatType, NumRows, NumCols> &copy) {
memcpy(_array, copy._array, sizeof(_array));
}
/**
*
*/
template <class FloatType, int NumRows, int NumCols>
INLINE void LSimpleMatrix<FloatType, NumRows, NumCols>::
operator = (const LSimpleMatrix<FloatType, NumRows, NumCols> &copy) {
memcpy(_array, copy._array, sizeof(_array));
}
/**
*
*/

View File

@ -28,9 +28,6 @@
template <class FloatType, int NumRows, int NumCols>
class LSimpleMatrix {
public:
INLINE LSimpleMatrix();
INLINE LSimpleMatrix(const LSimpleMatrix<FloatType, NumRows, NumCols> &copy);
INLINE void operator = (const LSimpleMatrix<FloatType, NumRows, NumCols> &copy);
INLINE const FloatType &operator () (int row, int col) const;
INLINE FloatType &operator () (int row, int col);
INLINE const FloatType &operator () (int col) const;

View File

@ -221,7 +221,7 @@ process_geom(const Geom *geom) {
CPT(GeomVertexData) vData = geom->get_vertex_data();
for (int i = 0; i < geom->get_num_primitives(); ++i) {
for (size_t i = 0; i < geom->get_num_primitives(); ++i) {
process_primitive(geom->get_primitive(i), vData);
}
}
@ -308,7 +308,7 @@ analyze(const Geom *geom) {
return;
}
for (int i = 0; i < geom->get_num_primitives(); ++i) {
for (size_t i = 0; i < geom->get_num_primitives(); ++i) {
analyze(geom->get_primitive(i));
}
}

View File

@ -62,10 +62,10 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis,
// 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));
memset(&geom_z, 0, sizeof(geom_z));
memset(&geom_w, 0, sizeof(geom_w));
geom_x.fill(0);
geom_y.fill(0);
geom_z.fill(0);
geom_w.fill(0);
for (int uni = 0; uni < 4; uni++) {
for (int vni = 0; vni < 4; vni++) {
@ -178,7 +178,7 @@ eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d)
int vn = _v_basis.get_vertex_index(vi);
LMatrix4 geom;
memset(&geom, 0, sizeof(geom));
geom.fill(0);
for (int uni = 0; uni < 4; uni++) {
for (int vni = 0; vni < 4; vni++) {
@ -223,7 +223,7 @@ 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));
geom.fill(0);
for (int uni = 0; uni < 4; uni++) {
for (int vni = 0; vni < 4; vni++) {

View File

@ -294,7 +294,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) {
GeomVertexReader texcoord(geom->get_vertex_data(),
InternalName::get_texcoord());
if (texcoord.has_column()) {
for (int pi = 0; pi < geom->get_num_primitives(); ++pi) {
for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) {
primitive = geom->get_primitive(pi);
for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) {
int vert = primitive->get_vertex(vi);
@ -338,7 +338,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) {
GeomVertexReader vertex(geom->get_vertex_data(),
InternalName::get_vertex());
if (vertex.has_column()) {
for (int pi = 0; pi < geom->get_num_primitives(); ++pi) {
for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) {
primitive = geom->get_primitive(pi);
for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) {
int vert = primitive->get_vertex(vi);

View File

@ -64,7 +64,7 @@ get_num_display_regions() const {
*/
INLINE DisplayRegion *Camera::
get_display_region(size_t n) const {
nassertr(n < (int)_display_regions.size(), nullptr);
nassertr(n < _display_regions.size(), nullptr);
return _display_regions[n];
}

View File

@ -1479,7 +1479,7 @@ remove_unused_vertices(const GeomVertexData *vdata) {
PT(GeomVertexData) new_vdata = new GeomVertexData(*vdata);
new_vdata->unclean_set_num_rows(new_num_vertices);
int num_arrays = vdata->get_num_arrays();
size_t num_arrays = vdata->get_num_arrays();
nassertv(num_arrays == new_vdata->get_num_arrays());
GeomVertexDataPipelineReader reader(vdata, current_thread);
@ -1487,7 +1487,7 @@ remove_unused_vertices(const GeomVertexData *vdata) {
GeomVertexDataPipelineWriter writer(new_vdata, true, current_thread);
writer.check_array_writers();
for (int a = 0; a < num_arrays; ++a) {
for (size_t a = 0; a < num_arrays; ++a) {
const GeomVertexArrayDataHandle *array_reader = reader.get_array_reader(a);
GeomVertexArrayDataHandle *array_writer = writer.get_array_writer(a);

View File

@ -261,7 +261,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
rs->get_attrib_def(la);
bool have_ambient = false;
for (int i = 0; i < la->get_num_on_lights(); ++i) {
for (size_t i = 0; i < la->get_num_on_lights(); ++i) {
NodePath np = la->get_on_light(i);
nassertv(!np.is_empty());
PandaNode *node = np.node();

View File

@ -112,7 +112,7 @@ add_impact(const LPoint3 &offset,
a = a.cross(b);
PN_stdfloat angle = a.length();
if (angle) {
LRotation torque;
LRotation torque(0, 0, 0, 0);
PN_stdfloat spin = force.length()*0.1; // todo: this should account for
// impact distance and mass.
a.normalize();

View File

@ -94,7 +94,7 @@ cycle() {
pvector< PT(CycleData) > saved_cdatas;
{
ReMutexHolder cycle_holder(_cycle_lock);
int prev_seq, next_seq;
unsigned int prev_seq, next_seq;
PipelineCyclerLinks prev_dirty;
{
// We can't hold the lock protecting the linked lists during the cycling

View File

@ -1726,35 +1726,32 @@ compute_planar_bounds(const LPoint2f &center, PN_float32 point_dist, PN_float32
// Now determine the minmax.
PN_float32 min_x, min_y, min_z, max_x, max_y, max_z;
bool got_point = false;
if (points_only) {
LPoint3f points[4] = {
const LPoint3f points[4] = {
p0 * rinv,
p1 * rinv,
p2 * rinv,
p3 * rinv,
};
for (int i = 0; i < 4; ++i) {
const LPoint3f &point = points[i];
if (!got_point) {
min_x = point[0];
min_y = point[1];
min_z = point[2];
max_x = point[0];
max_y = point[1];
max_z = point[2];
got_point = true;
} else {
min_x = min(min_x, point[0]);
min_y = min(min_y, point[1]);
min_z = min(min_z, point[2]);
max_x = max(max_x, point[0]);
max_y = max(max_y, point[1]);
max_z = max(max_z, point[2]);
}
}
const LPoint3f &point = points[0];
min_x = point[0];
min_y = point[1];
min_z = point[2];
max_x = point[0];
max_y = point[1];
max_z = point[2];
for (int i = 1; i < 4; ++i) {
const LPoint3f &point = points[i];
min_x = min(min_x, point[0]);
min_y = min(min_y, point[1]);
min_z = min(min_z, point[2]);
max_x = max(max_x, point[0]);
max_y = max(max_y, point[1]);
max_z = max(max_z, point[2]);
}
} else {
bool got_point = false;
for (int yi = 0; yi < _y_size; ++yi) {
for (int xi = 0; xi < _x_size; ++xi) {
if (!has_point(xi, yi)) {
@ -1780,6 +1777,14 @@ compute_planar_bounds(const LPoint2f &center, PN_float32 point_dist, PN_float32
}
}
}
if (!got_point) {
min_x = 0.0f;
min_y = 0.0f;
min_z = 0.0f;
max_x = 0.0f;
max_y = 0.0f;
max_z = 0.0f;
}
}
PT(BoundingHexahedron) bounds;

View File

@ -40,7 +40,7 @@ typedef unsigned char gray;
struct pixel {
PUBLISHED:
pixel() { }
pixel() = default;
pixel(gray fill) : r(fill), g(fill), b(fill) { }
pixel(gray r, gray g, gray b) : r(r), g(g), b(b) { }

View File

@ -721,8 +721,8 @@ get_pixel( istream *ifp, pixel *dest, int Size, gray *alpha_p) {
Red = getbyte( ifp );
if ( Size == 32 )
Alpha = getbyte( ifp );
else
Alpha = 0;
else
Alpha = 0;
l = 0;
break;

View File

@ -25,20 +25,6 @@ PStatCollector(PStatClient *client, int index) :
{
}
/**
* 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() :
_client(nullptr),
_index(0),
_level(0.0f)
{
}
/**
* Creates a new PStatCollector, ready to start accumulating data. The name
* of the collector uniquely identifies it among the other collectors; if two

View File

@ -47,7 +47,7 @@ private:
INLINE PStatCollector(PStatClient *client, int index);
public:
INLINE PStatCollector();
PStatCollector() = default;
PUBLISHED:
INLINE explicit PStatCollector(const std::string &name,
@ -99,9 +99,9 @@ PUBLISHED:
INLINE int get_index() const;
private:
PStatClient *_client;
int _index;
double _level;
PStatClient *_client = nullptr;
int _index = 0;
double _level = 0.0;
friend class PStatClient;

View File

@ -87,7 +87,7 @@ is_all_on() const {
*/
bool BitArray::
has_any_of(int low_bit, int size) const {
if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) {
if ((size_t)(low_bit + size) > get_num_bits()) {
// This range touches the highest bits.
if (_highest_bits) {
return true;
@ -97,7 +97,7 @@ has_any_of(int low_bit, int size) const {
int w = low_bit / num_bits_per_word;
int b = low_bit % num_bits_per_word;
if (w >= get_num_words()) {
if (w >= (int)get_num_words()) {
// This range is entirely among the highest bits.
return (_highest_bits != 0);
}
@ -126,7 +126,7 @@ has_any_of(int low_bit, int size) const {
size -= num_bits_per_word;
++w;
if (w >= get_num_words()) {
if (w >= (int)get_num_words()) {
// Now we're up to the highest bits.
return (_highest_bits != 0);
}
@ -140,7 +140,7 @@ has_any_of(int low_bit, int size) const {
*/
bool BitArray::
has_all_of(int low_bit, int size) const {
if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) {
if ((size_t)(low_bit + size) > get_num_bits()) {
// This range touches the highest bits.
if (!_highest_bits) {
return false;
@ -150,7 +150,7 @@ has_all_of(int low_bit, int size) const {
int w = low_bit / num_bits_per_word;
int b = low_bit % num_bits_per_word;
if (w >= get_num_words()) {
if (w >= (int)get_num_words()) {
// This range is entirely among the highest bits.
return (_highest_bits != 0);
}
@ -179,7 +179,7 @@ has_all_of(int low_bit, int size) const {
size -= num_bits_per_word;
++w;
if (w >= get_num_words()) {
if (w >= (int)get_num_words()) {
// Now we're up to the highest bits.
return (_highest_bits != 0);
}
@ -196,7 +196,7 @@ set_range(int low_bit, int size) {
int w = low_bit / num_bits_per_word;
int b = low_bit % num_bits_per_word;
if (w >= get_num_words() && _highest_bits) {
if (w >= (int)get_num_words() && _highest_bits) {
// All the highest bits are already on.
return;
}
@ -229,7 +229,7 @@ set_range(int low_bit, int size) {
size -= num_bits_per_word;
++w;
if (w >= get_num_words() && _highest_bits) {
if (w >= (int)get_num_words() && _highest_bits) {
// All the highest bits are already on.
normalize();
return;
@ -246,7 +246,7 @@ clear_range(int low_bit, int size) {
int w = low_bit / num_bits_per_word;
int b = low_bit % num_bits_per_word;
if (w >= get_num_words() && !_highest_bits) {
if (w >= (int)get_num_words() && !_highest_bits) {
// All the highest bits are already off.
return;
}
@ -279,7 +279,7 @@ clear_range(int low_bit, int size) {
size -= num_bits_per_word;
++w;
if (w >= get_num_words() && !_highest_bits) {
if (w >= (int)get_num_words() && !_highest_bits) {
// All the highest bits are already off.
normalize();
return;

View File

@ -214,8 +214,8 @@ has_any_of(int low_bit, int size) const {
} else {
int hi_portion = low_bit + size - half_bits;
int lo_portion = size - hi_portion;
return (_hi.has_any_of(0, hi_portion) << lo_portion) ||
_lo.has_any_of(low_bit, lo_portion);
return _hi.has_any_of(0, hi_portion)
|| _lo.has_any_of(low_bit, lo_portion);
}
}
@ -232,8 +232,8 @@ has_all_of(int low_bit, int size) const {
} else {
int hi_portion = low_bit + size - half_bits;
int lo_portion = size - hi_portion;
return (_hi.has_all_of(0, hi_portion) << lo_portion) &&
_lo.has_all_of(low_bit, lo_portion);
return _hi.has_all_of(0, hi_portion)
&& _lo.has_all_of(low_bit, lo_portion);
}
}

View File

@ -15,20 +15,6 @@
#include "indent.h"
#include "config_putil.h"
/**
*
*/
FactoryBase::
FactoryBase() {
}
/**
*
*/
FactoryBase::
~FactoryBase() {
}
/**
* 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
@ -145,7 +131,7 @@ register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) {
/**
* Returns the number of different types the Factory knows how to create.
*/
int FactoryBase::
size_t FactoryBase::
get_num_types() const {
return _creators.size();
}
@ -156,8 +142,8 @@ get_num_types() const {
* 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());
get_type(size_t n) const {
nassertr(n < get_num_types(), TypeHandle::none());
Creators::const_iterator ci;
for (ci = _creators.begin(); ci != _creators.end(); ++ci) {
if (n == 0) {
@ -193,7 +179,7 @@ add_preferred(TypeHandle handle) {
/**
* Returns the number of types added to the preferred-type list.
*/
int FactoryBase::
size_t FactoryBase::
get_num_preferred() const {
return _preferred.size();
}
@ -202,8 +188,8 @@ get_num_preferred() const {
* 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());
get_preferred(size_t n) const {
nassertr(n < get_num_preferred(), TypeHandle::none());
return _preferred[n];
}
@ -219,21 +205,6 @@ write_types(std::ostream &out, int indent_level) const {
}
}
/**
* Don't copy Factories.
*/
FactoryBase::
FactoryBase(const FactoryBase &) {
}
/**
* Don't copy Factories.
*/
void FactoryBase::
operator = (const FactoryBase &) {
}
/**
* 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
@ -262,9 +233,7 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) {
// First, walk through the established preferred list. Maybe one of these
// qualifies.
Preferred::const_iterator pi;
for (pi = _preferred.begin(); pi != _preferred.end(); ++pi) {
TypeHandle ptype = (*pi);
for (TypeHandle ptype : _preferred) {
if (ptype.is_derived_from(handle)) {
TypedObject *object = make_instance_exact(ptype, params);
if (object != nullptr) {

View File

@ -39,8 +39,11 @@ public:
// public interface
public:
FactoryBase();
~FactoryBase();
FactoryBase() = default;
FactoryBase(const FactoryBase &copy) = delete;
~FactoryBase() = default;
FactoryBase &operator = (const FactoryBase &copy) = delete;
TypedObject *make_instance(TypeHandle handle,
const FactoryParams &params);
@ -58,21 +61,17 @@ public:
void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = nullptr);
int get_num_types() const;
TypeHandle get_type(int n) const;
size_t get_num_types() const;
TypeHandle get_type(size_t n) const;
void clear_preferred();
void add_preferred(TypeHandle handle);
int get_num_preferred() const;
TypeHandle get_preferred(int n) const;
size_t get_num_preferred() const;
TypeHandle get_preferred(size_t n) const;
void write_types(std::ostream &out, int indent_level = 0) const;
private:
// These are private; we shouldn't be copy-constructing Factories.
FactoryBase(const FactoryBase &copy);
void operator = (const FactoryBase &copy);
// internal utility functions
TypedObject *make_instance_exact(TypeHandle handle, FactoryParams params);
TypedObject *make_instance_more_specific(TypeHandle handle,

View File

@ -13,45 +13,6 @@
#include "pnotify.h"
/**
*
*/
INLINE FactoryParams::
FactoryParams() : _user_data(nullptr) {
}
/**
*
*/
INLINE FactoryParams::
FactoryParams(const FactoryParams &copy) :
_params(copy._params),
_user_data(copy._user_data) {}
/**
*
*/
INLINE FactoryParams::
~FactoryParams() {
}
/**
*
*/
INLINE FactoryParams::
FactoryParams(FactoryParams &&from) noexcept :
_params(std::move(from._params)),
_user_data(from._user_data) {}
/**
*
*/
INLINE void FactoryParams::
operator = (FactoryParams &&from) noexcept {
_params = std::move(from._params);
_user_data = from._user_data;
}
/**
* Returns the custom pointer that was associated with the factory function.
*/

View File

@ -35,12 +35,12 @@
*/
class EXPCL_PANDA_PUTIL FactoryParams {
public:
INLINE FactoryParams();
INLINE FactoryParams(const FactoryParams &copy);
INLINE FactoryParams(FactoryParams &&from) noexcept;
INLINE ~FactoryParams();
FactoryParams() = default;
FactoryParams(const FactoryParams &copy) = default;
FactoryParams(FactoryParams &&from) noexcept = default;
~FactoryParams() = default;
INLINE void operator = (FactoryParams &&from) noexcept;
FactoryParams &operator = (FactoryParams &&from) noexcept = default;
void add_param(FactoryParam *param);
void clear();
@ -56,7 +56,7 @@ private:
typedef pvector< PT(TypedReferenceCount) > Params;
Params _params;
void *_user_data;
void *_user_data = nullptr;
friend class FactoryBase;
};

View File

@ -2251,10 +2251,10 @@ do_issue_texture() {
// 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) {
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;
} else if (wrap_u && SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) {
} else if (wrap_u == SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) {
texture_def->tex_minfilter_func = apply_wrap_clamp_minfilter;
texture_def->tex_magfilter_func = apply_wrap_clamp_magfilter;
}

View File

@ -14,7 +14,7 @@
int error, derror;
int x1, dxdy_min, dxdy_max;
/* warning: x2 is multiplied by 2^16 */
UNUSED int x2, dx2dy2;
int x2, dx2dy2;
#ifdef INTERP_Z
int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0;
@ -348,10 +348,10 @@
int n;
#ifdef INTERP_Z
ZPOINT *pz;
UNUSED unsigned int z,zz;
unsigned int z,zz;
#endif
#ifdef INTERP_RGB
UNUSED unsigned int or1,og1,ob1,oa1;
unsigned int or1,og1,ob1,oa1;
#endif
#ifdef INTERP_ST
unsigned int s,t;

View File

@ -1,3 +1,9 @@
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
static void
FNAME(white_untextured) (ZBuffer *zb,
ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
@ -229,7 +235,7 @@ FNAME(smooth_textured) (ZBuffer *zb,
c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \
if (c0 == c1 && c0 == c2) { \
/* It's really a flat-shaded triangle. */ \
if (c0 == 0xffffffff) { \
if (c0 == 0xffffffffu) { \
/* Actually, it's a white triangle. */ \
FNAME(white_textured)(zb, p0, p1, p2); \
return; \
@ -537,13 +543,13 @@ FNAME(smooth_perspective) (ZBuffer *zb,
#define EARLY_OUT() \
{ \
int c0, c1, c2; \
unsigned int c0, c1, c2; \
c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \
c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \
c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \
if (c0 == c1 && c0 == c2) { \
/* It's really a flat-shaded triangle. */ \
if (c0 == 0xffffffff) { \
if (c0 == 0xffffffffu) { \
/* Actually, it's a white triangle. */ \
FNAME(white_perspective)(zb, p0, p1, p2); \
return; \
@ -1008,3 +1014,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb,
#undef INTERP_MIPMAP
#undef CALC_MIPMAP_LEVEL
#undef ZB_LOOKUP_TEXTURE
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

View File

@ -174,7 +174,7 @@ move_pointer(int device, int x, int y) {
return true;
} else {
// Move a raw mouse.
if ((device < 1)||(device >= _input_devices.size())) {
if (device < 1 || (size_t)device >= _input_devices.size()) {
return false;
}
_input_devices[device].set_pointer_in_window(x, y);

View File

@ -649,7 +649,7 @@ process_f_node(vector_string &words) {
_f_given = true;
bool all_vn = true;
int non_vn_index = -1;
//int non_vn_index = -1;
pvector<VertexEntry> verts;
verts.reserve(words.size() - 1);
@ -658,7 +658,7 @@ process_f_node(vector_string &words) {
verts.push_back(entry);
if (entry._vni == 0) {
all_vn = false;
non_vn_index = i;
//non_vn_index = i;
}
}
@ -706,7 +706,7 @@ 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) {
_current_vertex_data->_entries.size() + verts.size() > (size_t)egg_max_vertices) {
// We'll exceed our specified limit with these triangles; start a new
// Geom.
_current_vertex_data->close_geom(this);

View File

@ -2883,7 +2883,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -159,7 +159,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -794,7 +794,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}

View File

@ -150,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Define this macro carefully, since different flex versions call it
// with a different type for result.
#define YY_INPUT(buffer, result, max_size) { \
int int_result; \
int int_result = 0; \
input_chars((buffer), int_result, (max_size)); \
(result) = int_result; \
}