Assorted tweaks and compile warning fixes

This commit is contained in:
rdb 2016-07-14 12:54:39 +02:00
parent 106cf2cad0
commit 8381118a97
63 changed files with 132 additions and 172 deletions

View File

@ -11,10 +11,6 @@
* @date 2009-09-08
*/
#pragma warning (disable:4996)
#pragma warning (disable:4005)
#pragma warning(disable:4275)
#ifndef _AIBEHAVIORS_H
#define _AIBEHAVIORS_H

View File

@ -11,11 +11,6 @@
* @date 2009-09-08
*/
#pragma warning (disable:4996)
#pragma warning (disable:4005)
#pragma warning(disable:4275)
#ifndef _AICHARACTER_H
#define _AICHARACTER_H

View File

@ -11,10 +11,6 @@
* @date 2009-09-08
*/
#pragma warning (disable:4996)
#pragma warning (disable:4005)
#pragma warning(disable:4275)
#ifndef _AI_GLOBALS_H
#define _AI_GLOBALS_H

View File

@ -11,11 +11,6 @@
* @date 2009-09-08
*/
#pragma warning (disable:4996)
#pragma warning (disable:4005)
#pragma warning(disable:4275)
#ifndef _AIWORLD_H
#define _AIWORLD_H

View File

@ -34,7 +34,7 @@ obstacle_detection() {
CPT(BoundingSphere) np_sphere = np_bounds->as_bounding_sphere();
LVecBase3 avoidance(0.0, 0.0, 0.0);
double distance = 0x7fff ;
double expanded_radius;
double expanded_radius = 0;
LVecBase3 to_obstacle;
LVecBase3 prev_avoidance;
for(unsigned int i = 0; i < _ai_char->_world->_obstacles.size(); ++i) {
@ -89,8 +89,8 @@ do_obstacle_avoidance() {
CPT(BoundingSphere) bsphere = bounds->as_bounding_sphere();
PT(BoundingVolume) np_bounds = _ai_char->get_node_path().get_bounds();
CPT(BoundingSphere) np_sphere = np_bounds->as_bounding_sphere();
double distance_needed = offset.length() - bsphere->get_radius() - np_sphere->get_radius();
if((obstacle_detection())) {
if (obstacle_detection()) {
LVecBase3 direction = _ai_char->get_char_render().get_relative_vector(_ai_char->get_node_path(), LVector3::forward());
direction.normalize();
float forward_component = offset.dot(direction);

View File

@ -370,10 +370,8 @@ save_expansion(const string &exp, const vector_string &parameter_names) {
// Is this identifier one of our parameters?
int pnum = -1;
bool va_args = false;
if (ident == "__VA_ARGS__") {
va_args = true;
// C99-style variadics, ie. #define macro(...) __VA_ARGS__
pnum = _variadic_param;

View File

@ -806,7 +806,7 @@ expand_manifests(const string &input_expr, bool expand_undefined,
Manifests::const_iterator mi = _manifests.find(ident);
if (mi != _manifests.end()) {
const CPPManifest *manifest = (*mi).second;
expand_manifest_inline(expr, q, p, (*mi).second);
expand_manifest_inline(expr, q, p, manifest);
manifest_found = true;
} else if (expand_undefined && ident != "true" && ident != "false") {
@ -1192,8 +1192,6 @@ skip_c_comment(int c) {
} else {
CPPFile first_file = get_file();
int first_line_number = get_line_number();
int first_col_number = get_col_number() - 2;
while (c != EOF) {
if (c == '*') {
@ -1816,8 +1814,9 @@ get_identifier(int c) {
type = CPPExpression::T_u16string;
} else if (name == "U") {
type = CPPExpression::T_u32string;
} else {
type = CPPExpression::T_string;
}
get();
string str = scan_quoted(c);

View File

@ -40,7 +40,7 @@ CPPToken(int token, int line_number, int col_number,
*/
CPPToken::
CPPToken(int token, const YYLTYPE &loc, const string &str, const YYSTYPE &val) :
_token(token), _lloc(loc), _lval(val)
_token(token), _lval(val), _lloc(loc)
{
_lval.str = str;
}

View File

@ -70,23 +70,21 @@
#else
// #pragma message("VC 6.0")
#endif
#endif /* WIN32_VC */
// 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);
#define NODEFAULT default: assert(0); break;
#elif defined(_MSC_VER)
#define NODEFAULT default: __assume(0); // special VC keyword
#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || (defined(__has_builtin) && __has_builtin(__builtin_unreachable))
#define NODEFAULT default: __builtin_unreachable();
#else
# define NODEFAULT default: __assume(0); // special VC keyword
#define NODEFAULT
#endif
#else /* if !WIN32_VC */
#ifdef _DEBUG
# define NODEFAULT default: assert(0);
#else
# define NODEFAULT
#endif
#endif /* WIN32_VC */
/*
include win32 defns for everything up to WinServer2003, and assume

View File

@ -341,6 +341,8 @@ get_root_class(int n) {
TypeHandle handle;
if (n >= 0 && n < (int)_root_classes.size()) {
handle = _root_classes[n]->_handle;
} else {
handle = TypeHandle::none();
}
_lock->release();
@ -380,6 +382,8 @@ get_parent_class(TypeHandle child, int index) const {
assert(rnode != (TypeRegistryNode *)NULL);
if (index >= 0 && index < (int)rnode->_parent_classes.size()) {
handle = rnode->_parent_classes[index]->_handle;
} else {
handle = TypeHandle::none();
}
_lock->release();
return handle;
@ -415,6 +419,8 @@ get_child_class(TypeHandle child, int index) const {
assert(rnode != (TypeRegistryNode *)NULL);
if (index >= 0 && index < (int)rnode->_child_classes.size()) {
handle = rnode->_child_classes[index]->_handle;
} else {
handle = TypeHandle::none();
}
_lock->release();
return handle;

View File

@ -323,7 +323,7 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) {
// Posix case.
{
off_t li = lseek(_fd, off, SEEK_END);
if (li == (size_t)-1) {
if (li == (off_t)-1) {
return -1;
}
new_pos = (size_t)li;

View File

@ -4196,7 +4196,7 @@ write_function_forset(ostream &out,
return;
}
FunctionRemap *remap;
FunctionRemap *remap = NULL;
std::set<FunctionRemap *>::iterator sii;
bool all_nonconst = false;

View File

@ -1851,9 +1851,9 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
}
// The getter must either take no arguments, or all defaults.
if (ftype->_parameters->_parameters.size() == (int)is_seq ||
(ftype->_parameters->_parameters.size() > (int)is_seq &&
ftype->_parameters->_parameters[(int)is_seq]->_initializer != NULL)) {
if (ftype->_parameters->_parameters.size() == (size_t)is_seq ||
(ftype->_parameters->_parameters.size() > (size_t)is_seq &&
ftype->_parameters->_parameters[(size_t)is_seq]->_initializer != NULL)) {
// If this is a sequence getter, it must take an index argument.
if (is_seq && !TypeManager::is_integer(ftype->_parameters->_parameters[0]->_type)) {
continue;
@ -1909,7 +1909,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP
for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) {
CPPInstance *function = (*fi);
CPPFunctionType *ftype = function->_type->as_function_type();
if (ftype != NULL && ftype->_parameters->_parameters.size() == (int)is_seq) {
if (ftype != NULL && ftype->_parameters->_parameters.size() == (size_t)is_seq) {
deleter = function;
break;
}

View File

@ -41,7 +41,7 @@ resolve_type(CPPType *type, CPPScope *scope) {
scope = &parser;
}
CPPType *orig_type = type;
//CPPType *orig_type = type;
type = type->resolve_type(scope, &parser);
string name = type->get_local_name(&parser);
if (name.empty()) {

View File

@ -816,6 +816,7 @@ PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) {
int cmpval = DTOOL_PyObject_Compare(v1, v2);
bool result;
switch (op) {
NODEFAULT
case Py_LT:
result = (cmpval < 0);
break;
@ -833,6 +834,7 @@ PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) {
break;
case Py_GE:
result = (cmpval >= 0);
break;
}
return PyBool_FromLong(result);
}

View File

@ -219,9 +219,10 @@ static PyObject *Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyOb
}
// 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;\
// 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..
#ifdef NDEBUG

View File

@ -228,7 +228,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any,
// 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) {
for (size_t i = 0; i < parents.get_num_parents(); ++i) {
PandaNode *parent = parents.get_parent(i);
parent->get_bounds();
}

View File

@ -638,9 +638,6 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) {
Region &region = cdata->_regions[i];
int old_w = region._pixels[1] - region._pixels[0];
int old_h = region._pixels[3] - region._pixels[2];
region._pixels[0] = int((region._dimensions[0] * x_size) + 0.5);
region._pixels[1] = int((region._dimensions[1] * x_size) + 0.5);
region._pixels_i[0] = region._pixels[0];

View File

@ -1527,7 +1527,7 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
// 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);
PStatGPUTimer timer(gsg, win->get_draw_window_pcollector(), current_thread);
win->clear(current_thread);
if (display_cat.is_spam()) {
@ -1547,8 +1547,8 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
if (_auto_flip) {
#ifdef DO_PSTATS
// This is a good time to perform a latency query.
if (win->get_gsg()->get_timer_queries_active()) {
win->get_gsg()->issue_timer_query(GraphicsStateGuardian::_command_latency_pcollector.get_index());
if (gsg->get_timer_queries_active()) {
gsg->issue_timer_query(GraphicsStateGuardian::_command_latency_pcollector.get_index());
}
#endif
@ -1560,7 +1560,7 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) {
win->begin_flip();
}
{
PStatGPUTimer timer(win->get_gsg(), GraphicsEngine::_flip_end_pcollector, current_thread);
PStatGPUTimer timer(gsg, GraphicsEngine::_flip_end_pcollector, current_thread);
win->end_flip();
}
}

View File

@ -105,6 +105,8 @@ get_pipe_type(int n) const {
LightMutexHolder holder(_lock);
if (n >= 0 && n < (int)_pipe_types.size()) {
result = _pipe_types[n]._type;
} else {
result = TypeHandle::none();
}
}
return result;

View File

@ -2061,8 +2061,6 @@ flush_timer_queries() {
_last_num_queried = first;
int frame_index = ClockObject::get_global_clock()->get_frame_count();
for (int i = 0; i < first; ++i) {
CPT(TimerQueryContext) query = _pending_timer_queries[i];

View File

@ -138,11 +138,7 @@ has_uvw(const string &name) const {
bool EggVertex::
has_aux(const string &name) const {
AuxMap::const_iterator xi = _aux_map.find(name);
if (xi != _aux_map.end()) {
EggVertexAux *aux_obj = (*xi).second;
return true;
}
return false;
return (xi != _aux_map.end());
}
/**

View File

@ -108,7 +108,7 @@ determine_dynamic_type() {
return;
}
TypeHandle orig_type = _dynamic_type;
//TypeHandle orig_type = _dynamic_type;
update_type_handle(_dynamic_type, got_type);
}
}

View File

@ -129,7 +129,7 @@ node_ref() const {
#endif
ref();
AtomicAdjust::inc(((NodeReferenceCount *)this)->_node_ref_count);
AtomicAdjust::inc(_node_ref_count);
}
/**
@ -174,7 +174,7 @@ node_unref_only() const {
// you can't use PointerTo's?
nassertv(_node_ref_count > 0);
AtomicAdjust::dec(((NodeReferenceCount *)this)->_node_ref_count);
AtomicAdjust::dec(_node_ref_count);
}
/**

View File

@ -42,14 +42,13 @@ PUBLISHED:
INLINE void node_ref() const;
INLINE bool node_unref() const;
INLINE bool test_ref_count_integrity() const;
protected:
INLINE void node_unref_only() const;
protected:
bool do_test_ref_count_integrity() const;
private:
AtomicAdjust::Integer _node_ref_count;
mutable AtomicAdjust::Integer _node_ref_count;
public:
static TypeHandle get_class_type() {

View File

@ -280,7 +280,6 @@ TYPENAME ordered_vector<Key, Compare, Vector>::SIZE_TYPE ordered_vector<Key, Com
r_count(TYPENAME ordered_vector<Key, Compare, Vector>::CONST_ITERATOR first,
TYPENAME ordered_vector<Key, Compare, Vector>::CONST_ITERATOR last,
const TYPENAME ordered_vector<Key, Compare, Vector>::KEY_TYPE &key) const {
typedef pair<TYPENAME ordered_vector<Key, Compare, Vector>::CONST_ITERATOR, TYPENAME ordered_vector<Key, Compare, Vector>::CONST_ITERATOR> pair_type;
if (first == last) {
// The list is empty; the key is not on the list.

View File

@ -1753,7 +1753,7 @@ resolve_multisamples() {
if (_rbm[RTP_depth_stencil] != 0 || _rbm[RTP_depth] != 0) {
if (_shared_depth_buffer) {
CLP(GraphicsBuffer) *graphics_buffer = NULL;
CLP(GraphicsBuffer) *highest_sort_graphics_buffer = NULL;
//CLP(GraphicsBuffer) *highest_sort_graphics_buffer = NULL;
list <CLP(GraphicsBuffer) *>::iterator graphics_buffer_iterator;
int max_sort_order = 0;
@ -1765,7 +1765,7 @@ resolve_multisamples() {
// this call removes the entry from the list
if (graphics_buffer->get_sort() >= max_sort_order) {
max_sort_order = graphics_buffer->get_sort();
highest_sort_graphics_buffer = graphics_buffer;
//highest_sort_graphics_buffer = graphics_buffer;
}
}
}

View File

@ -10804,8 +10804,6 @@ do_issue_tex_matrix() {
*/
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
@ -10849,7 +10847,6 @@ do_issue_tex_gen() {
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
force_normal = true;
break;
case TexGenAttrib::M_eye_cube_map:
@ -10872,7 +10869,6 @@ do_issue_tex_gen() {
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
force_normal = true;
}
break;
@ -10900,7 +10896,6 @@ do_issue_tex_gen() {
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
force_normal = true;
}
break;
@ -10924,7 +10919,6 @@ do_issue_tex_gen() {
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
force_normal = true;
}
break;
@ -10952,7 +10946,6 @@ do_issue_tex_gen() {
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
force_normal = true;
}
break;

View File

@ -174,7 +174,6 @@ open_window() {
<< "No X visual: cannot open window.\n";
return false;
}
Visual *visual = _visual_info->visual;
if (glxgsg->_fbconfig != None) {
setup_colormap(glxgsg->_fbconfig);

View File

@ -3374,7 +3374,7 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only)
unsigned int dimension = dds.get_uint32();
unsigned int misc_flag = dds.get_uint32();
unsigned int array_size = dds.get_uint32();
unsigned int alpha_mode = dds.get_uint32();
/*unsigned int alpha_mode = */dds.get_uint32();
switch (format) {
case 2: // DXGI_FORMAT_R32G32B32A32_FLOAT
@ -4947,8 +4947,8 @@ do_compress_ram_image_bc4(const RamImage &uncompressed_image,
// 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);
nassertv((size_t)x_blocks * (size_t)y_blocks * 4 * 4 <= uncompressed_image._page_size);
nassertv((size_t)x_size * (size_t)y_size == uncompressed_image._page_size);
static const int remap[] = {1, 7, 6, 5, 4, 3, 2, 0};
@ -5046,8 +5046,8 @@ do_compress_ram_image_bc5(const RamImage &uncompressed_image,
// 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);
nassertv((size_t)x_blocks * (size_t)y_blocks * 4 * 4 * 2 <= uncompressed_image._page_size);
nassertv((size_t)stride * (size_t)y_size == uncompressed_image._page_size);
static const int remap[] = {1, 7, 6, 5, 4, 3, 2, 0};

View File

@ -53,6 +53,6 @@ get_z_size() const {
* 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 < _x_size && y < _y_size;
has_pixel(int x, int y) const {
return x >= 0 && y >= 0 && x < _x_size && y < _y_size;
}

View File

@ -176,7 +176,7 @@ lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const {
* coordinates are used.
*/
void TexturePeeker::
fetch_pixel(LColor& color, size_t x, size_t y) const {
fetch_pixel(LColor& color, int x, int 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);

View File

@ -36,10 +36,10 @@ PUBLISHED:
INLINE int get_y_size() const;
INLINE int get_z_size() const;
INLINE bool has_pixel(size_t x, size_t y) const;
INLINE bool has_pixel(int x, int 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;
void fetch_pixel(LColor &color, int x, int 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,

View File

@ -756,17 +756,13 @@ make_texture_layer(const NodePath &render,
case TextureStage::CM_modulate:
{
TextureStage::CombineSource source0 = stage_info._stage->get_combine_rgb_source0();
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).
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 &&

View File

@ -673,8 +673,6 @@ show_results(int num_fragments, const Geom *geom,
TransparencyAttrib::make(TransparencyAttrib::M_alpha),
ColorAttrib::make_flat(color));
GraphicsStateGuardian *gsg = _buffer->get_gsg();
CullableObject *internal_viz =
new CullableObject(geom, state, internal_transform);
_internal_cull_handler->record_object(internal_viz, _internal_trav);

View File

@ -534,7 +534,7 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat
// After rendering, increment the view index
++_current_view_index;
if (_current_view_index > stm_max_views) {
if (_current_view_index > (size_t)stm_max_views) {
shader_terrain_cat.error() << "More views than supported! Increase the stm-max-views config variable!" << endl;
}

View File

@ -154,11 +154,9 @@ void CurveFitter::
sample(ParametricCurveCollection *curves, int count) {
nassertv(curves != (ParametricCurveCollection *)NULL);
PN_stdfloat max_t = curves->get_max_t();
PN_stdfloat t, last_t, d;
PN_stdfloat t;
DataPoint dp;
last_t = 0.0f;
d = 0.0f;
int i;
for (i = 0; i < count; i++) {
t = max_t * (PN_stdfloat)i / (PN_stdfloat)(count-1);

View File

@ -911,7 +911,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
AttribNodeRegistry *areg = AttribNodeRegistry::get_global_ptr();
if (manager->get_file_minor_ver() >= 40) {
for (int i = 0; i < _off_planes.size(); ++i) {
for (size_t i = 0; i < _off_planes.size(); ++i) {
pi += _off_planes[i].complete_pointers(p_list + pi, manager);
int n = areg->find_node(_off_planes[i]);
@ -921,7 +921,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
}
}
for (int i = 0; i < _on_planes.size(); ++i) {
for (size_t i = 0; i < _on_planes.size(); ++i) {
pi += _on_planes[i].complete_pointers(p_list + pi, manager);
int n = areg->find_node(_on_planes[i]);

View File

@ -935,11 +935,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
int pi = RenderAttrib::complete_pointers(p_list, manager);
if (manager->get_file_minor_ver() >= 40) {
for (int i = 0; i < _off_lights.size(); ++i) {
for (size_t i = 0; i < _off_lights.size(); ++i) {
pi += _off_lights[i].complete_pointers(p_list + pi, manager);
}
for (int i = 0; i < _on_lights.size(); ++i) {
for (size_t i = 0; i < _on_lights.size(); ++i) {
pi += _on_lights[i].complete_pointers(p_list + pi, manager);
}
@ -978,7 +978,7 @@ finalize(BamReader *manager) {
// Check if any of the nodes we loaded are mentioned in the
// AttribNodeRegistry. If so, replace them.
for (int i = 0; i < _off_lights.size(); ++i) {
for (size_t i = 0; i < _off_lights.size(); ++i) {
int n = areg->find_node(_off_lights[i]);
if (n != -1) {
// If it's in the registry, replace it.
@ -986,7 +986,7 @@ finalize(BamReader *manager) {
}
}
for (int i = 0; i < _on_lights.size(); ++i) {
for (size_t i = 0; i < _on_lights.size(); ++i) {
int n = areg->find_node(_on_lights[i]);
if (n != -1) {
// If it's in the registry, replace it.
@ -1067,12 +1067,12 @@ fillin(DatagramIterator &scan, BamReader *manager) {
if (manager->get_file_minor_ver() >= 40) {
_off_lights.resize(scan.get_uint16());
for (int i = 0; i < _off_lights.size(); ++i) {
for (size_t i = 0; i < _off_lights.size(); ++i) {
_off_lights[i].fillin(scan, manager);
}
_on_lights.resize(scan.get_uint16());
for (int i = 0; i < _on_lights.size(); ++i) {
for (size_t i = 0; i < _on_lights.size(); ++i) {
_on_lights[i].fillin(scan, manager);
}
} else {

View File

@ -431,8 +431,6 @@ save_file(const Filename &filename, const LoaderOptions &options,
return false;
}
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
bool result = try_save_file(this_filename, this_options, node, requested_type);
if (!result) {
if (report_errors) {
@ -451,10 +449,7 @@ save_file(const Filename &filename, const LoaderOptions &options,
bool Loader::
try_save_file(const Filename &pathname, const LoaderOptions &options,
PandaNode *node, LoaderFileType *requested_type) const {
bool report_errors = ((options.get_flags() & LoaderOptions::LF_report_errors) != 0 || loader_cat.is_debug());
bool result = requested_type->save_file(pathname, options, node);
return result;
return requested_type->save_file(pathname, options, node);
}
/**

View File

@ -47,10 +47,6 @@ 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<Occluders::iterator, bool> insert_result =
effect->_on_occluders.insert(Occluders::value_type(occluder));
return return_new(effect);
}
@ -170,7 +166,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
AttribNodeRegistry *areg = AttribNodeRegistry::get_global_ptr();
if (manager->get_file_minor_ver() >= 40) {
for (int i = 0; i < _on_occluders.size(); ++i) {
for (size_t i = 0; i < _on_occluders.size(); ++i) {
pi += _on_occluders[i].complete_pointers(p_list + pi, manager);
int n = areg->find_node(_on_occluders[i]);

View File

@ -1597,7 +1597,7 @@ replace_node(PandaNode *other) {
// Switch the parents.
Thread *current_thread = Thread::get_current_thread();
Parents other_parents = other->get_parents();
for (int i = 0; i < other_parents.get_num_parents(); ++i) {
for (size_t 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.
@ -1902,7 +1902,7 @@ is_under_scene_root() const {
}
Parents parents = get_parents();
for (int i = 0; i < parents.get_num_parents(); ++i) {
for (size_t i = 0; i < parents.get_num_parents(); ++i) {
PandaNode *parent = parents.get_parent(i);
if (parent->find_stashed((PandaNode *)this) == -1) {
if (parent->is_under_scene_root()) {
@ -2401,7 +2401,7 @@ void PandaNode::
r_mark_geom_bounds_stale(Thread *current_thread) {
Children children = get_children(current_thread);
int i;
size_t i;
for (i = 0; i < children.get_num_children(); i++) {
PandaNode *child = children.get_child(i);
child->r_mark_geom_bounds_stale(current_thread);
@ -2550,7 +2550,7 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state,
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.
int i;
size_t i;
for (i = 0; i < children.get_num_children(); i++) {
PandaNode *child = children.get_child(i);
CPT(RenderState) child_state = node_state->compose(child->get_state());
@ -2760,7 +2760,7 @@ find_node_above(PandaNode *node) {
}
Parents parents = get_parents();
for (int i = 0; i < parents.get_num_parents(); ++i) {
for (size_t i = 0; i < parents.get_num_parents(); ++i) {
PandaNode *parent = parents.get_parent(i);
if (parent->find_node_above(node)) {
return true;

View File

@ -368,7 +368,13 @@ get_write_count() const {
INLINE PT(CycleData) PipelineCyclerTrueImpl::
cycle_2() {
TAU_PROFILE("PT(CycleData) PipelineCyclerTrueImpl::cycle_2()", " ", TAU_USER);
PT(CycleData) last_val = _data[1]._cdata.p();
// This trick moves an NPT into a PT without unnecessarily incrementing and
// subsequently decrementing the regular reference count.
PT(CycleData) last_val;
last_val.swap(_data[1]._cdata);
last_val->node_unref_only();
nassertr(_lock.debug_is_locked(), last_val);
nassertr(_dirty, last_val);
nassertr(_num_stages == 2, last_val);
@ -389,7 +395,13 @@ cycle_2() {
INLINE PT(CycleData) PipelineCyclerTrueImpl::
cycle_3() {
TAU_PROFILE("PT(CycleData) PipelineCyclerTrueImpl::cycle_3()", " ", TAU_USER);
PT(CycleData) last_val = _data[2]._cdata.p();
// This trick moves an NPT into a PT without unnecessarily incrementing and
// subsequently decrementing the regular reference count.
PT(CycleData) last_val;
last_val.swap(_data[2]._cdata);
last_val->node_unref_only();
nassertr(_lock.debug_is_locked(), last_val);
nassertr(_dirty, last_val);
nassertr(_num_stages == 3, last_val);

View File

@ -255,7 +255,12 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread
*/
PT(CycleData) PipelineCyclerTrueImpl::
cycle() {
PT(CycleData) last_val = _data[_num_stages - 1]._cdata.p();
// This trick moves an NPT into a PT without unnecessarily incrementing and
// subsequently decrementing the regular reference count.
PT(CycleData) last_val;
last_val.swap(_data[_num_stages - 1]._cdata);
last_val->node_unref_only();
nassertr(_lock.debug_is_locked(), last_val);
nassertr(_dirty, last_val);

View File

@ -86,7 +86,8 @@ clear() {
void PfmFile::
clear(int x_size, int y_size, int num_channels) {
nassertv(x_size >= 0 && y_size >= 0);
nassertv(num_channels > 0 && num_channels <= 4 || (x_size == 0 && y_size == 0 && num_channels == 0));
nassertv((num_channels > 0 && num_channels <= 4) ||
(x_size == 0 && y_size == 0 && num_channels == 0));
_x_size = x_size;
_y_size = y_size;
@ -632,7 +633,6 @@ calc_average_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radi
continue;
}
const LPoint3f &p = get_point(xi, yi);
int gi = (yi - min_y) * y_size + (xi - min_x);
nassertr(gi >= 0 && gi < size, false);
mini_grid[gi]._sxi = xi;
@ -1541,7 +1541,7 @@ apply_crop(int x_begin, int x_end, int y_begin, int y_end) {
int new_x_size = x_end - x_begin;
int new_y_size = y_end - y_begin;
Table new_table;
int new_size = new_x_size * new_y_size * _num_channels;
size_t new_size = (size_t)new_x_size * (size_t)new_y_size * (size_t)_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

View File

@ -25,7 +25,6 @@ FUNCTION_NAME(IMAGETYPE &dest, const IMAGETYPE &source,
// the image xelvals scaled in the A direction only. This will hold the
// adjusted xel data from our first pass.
typedef StoreType *StoreTypeP;
StoreType **matrix = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() * sizeof(StoreType *));
int a, b;

View File

@ -27,7 +27,6 @@ FUNCTION_NAME(IMAGETYPE &dest, const IMAGETYPE &source,
// the image xelvals scaled in the A direction only. This will hold the
// adjusted xel data from our first pass.
typedef StoreType *StoreTypeP;
StoreType **matrix = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() * sizeof(StoreType *));
StoreType **matrix_weight = (StoreType **)PANDA_MALLOC_ARRAY(dest.ASIZE() * sizeof(StoreType *));

View File

@ -114,10 +114,10 @@ static void cb_skip(void *user, int n) {
// Implement skip by just reading and discarding the result.
static const int size = 4096;
char data[4096];
while (n > 4096) {
in->read(data, 4096);
n -= 4096;
char data[size];
while (n > size) {
in->read(data, size);
n -= size;
}
if (n > 0) {
in->read(data, n);

View File

@ -241,8 +241,8 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) {
// 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++) {
for (int yi = 0; yi < (int)bitmap.rows; yi++) {
for (int xi = 0; xi < (int)bitmap.width; xi++) {
image.set_gray_val(xi, yi, buffer_row[xi]);
}
buffer_row += bitmap.pitch;
@ -252,11 +252,11 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &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++) {
for (int yi = 0; yi < (int)bitmap.rows; yi++) {
xelval maxval = image.get_maxval();
int bit = 0x80;
unsigned char *b = buffer_row;
for (int xi = 0; xi < bitmap.width; xi++) {
for (int xi = 0; xi < (int)bitmap.width; xi++) {
if (*b & bit) {
image.set_gray_val(xi, yi, maxval);
} else {
@ -277,8 +277,8 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) {
// 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++) {
for (int yi = 0; yi < (int)bitmap.rows; yi++) {
for (int xi = 0; xi < (int)bitmap.width; xi++) {
image.set_gray(xi, yi, (PN_stdfloat)buffer_row[xi] / (bitmap.num_grays - 1));
}
buffer_row += bitmap.pitch;
@ -691,7 +691,6 @@ outline_nurbs(NurbsCurveResult *ncr) {
PN_stdfloat st0 = st, st1 = st;
if (i > 0) {
PN_stdfloat last_t = ncr->get_sample_t(i - 1);
st0 = ncr->get_sample_t(i - 1) * 0.1f + st * 0.9f;
}
if (i < num_samples - 1) {

View File

@ -700,7 +700,7 @@ operator ^= (const DoubleBitMask<BMType> &other) {
template<class BMType>
INLINE void DoubleBitMask<BMType>::
operator <<= (int shift) {
_hi = (_hi << shift) | ((_lo >> half_bits - shift) & BitMaskType::lower_on(shift));
_hi = (_hi << shift) | ((_lo >> (half_bits - shift)) & BitMaskType::lower_on(shift));
_lo <<= shift;
}
@ -710,7 +710,7 @@ operator <<= (int shift) {
template<class BMType>
INLINE void DoubleBitMask<BMType>::
operator >>= (int shift) {
_lo = (_lo >> shift) | ((_hi & BitMaskType::lower_on(shift)) << half_bits - shift);
_lo = (_lo >> shift) | ((_hi & BitMaskType::lower_on(shift)) << (half_bits - shift));
_hi >>= shift;
}

View File

@ -553,7 +553,6 @@ expand_table() {
nassertv(_num_entries == 0);
// Now copy the entries from the old table into the new table.
int num_added = 0;
for (size_t i = 0; i < old_table_size; ++i) {
if (old_map.has_element(i)) {
size_t new_index = get_hash(old_map._table[i]._key);

View File

@ -600,7 +600,6 @@ expand_table() {
nassertv(_num_entries == 0);
// Now copy the entries from the old table into the new table.
int num_added = 0;
for (size_t i = 0; i < old_table_size; ++i) {
if (old_map.has_element(i)) {
size_t new_index = get_hash(old_map._table[i]._key.get_orig());

View File

@ -152,7 +152,6 @@ get_rocket_key(const ButtonHandle handle) {
void RocketInputHandler::
do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
DataNodeTransmit &output) {
Thread *current_thread = trav->get_current_thread();
MutexHolder holder(_lock);
if (input.has_data(_pixel_xy_input)) {

View File

@ -220,7 +220,6 @@ write(ostream &out, int indent_level) const {
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)
<< glyph_index;
@ -630,7 +629,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) {
// 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++) {
for (int yi = 0; yi < (int)bitmap.rows; yi++) {
unsigned char *texture_row = glyph->get_row(yi);
nassertv(texture_row != (unsigned char *)NULL);
@ -642,13 +641,13 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) {
// 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++) {
for (int yi = 0; yi < (int)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++) {
for (int xi = 0; xi < (int)bitmap.width; xi++) {
if (*b & bit) {
texture_row[xi] = 0xff;
} else {
@ -669,10 +668,10 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) {
// 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 yi = 0; yi < (int)bitmap.rows; yi++) {
unsigned char *texture_row = glyph->get_row(yi);
nassertv(texture_row != (unsigned char *)NULL);
for (int xi = 0; xi < bitmap.width; xi++) {
for (int xi = 0; xi < (int)bitmap.width; xi++) {
texture_row[xi] = (int)(buffer_row[xi] * 255) / (bitmap.num_grays - 1);
}
buffer_row += bitmap.pitch;

View File

@ -1329,10 +1329,9 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) {
// 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;
PN_stdfloat xpos = 0;
switch (align) {
case TextProperties::A_left:
xpos = 0.0f;
_lr[0] = max(_lr[0], row_width);
break;
@ -1348,7 +1347,6 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) {
break;
case TextProperties::A_boxed_left:
xpos = 0.0f;
_lr[0] = max(_lr[0], max(row_width, wordwrap));
break;

View File

@ -911,7 +911,7 @@ count_geoms(PandaNode *node) {
}
Children children = node->get_children();
for (int i = 0; i < children.get_num_children(); ++i) {
for (size_t i = 0; i < children.get_num_children(); ++i) {
num_geoms += count_geoms(children.get_child(i));
}

View File

@ -1474,10 +1474,10 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
<< " seconds of inactivity; releasing held buttons.\n";
}
{
for (int i = 0; i < _current_buttons_down.get_num_bits(); ++i) {
for (size_t i = 0; i < _current_buttons_down.get_num_bits(); ++i) {
if (_current_buttons_down.get_bit(i)) {
release(ButtonHandle(i));
new_button_events.add_event(ButtonEvent(ButtonHandle(i), ButtonEvent::T_up));
release(ButtonHandle((int)i));
new_button_events.add_event(ButtonEvent(ButtonHandle((int)i), ButtonEvent::T_up));
}
}
}
@ -1488,10 +1488,10 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input,
case IS_inactive_to_active:
// "Press" all of the buttons we "released" before.
{
for (int i = 0; i < _current_buttons_down.get_num_bits(); ++i) {
for (size_t i = 0; i < _current_buttons_down.get_num_bits(); ++i) {
if (_current_buttons_down.get_bit(i)) {
press(ButtonHandle(i), false);
new_button_events.add_event(ButtonEvent(ButtonHandle(i), ButtonEvent::T_down));
press(ButtonHandle((int)i), false);
new_button_events.add_event(ButtonEvent(ButtonHandle((int)i), ButtonEvent::T_down));
}
}
}

View File

@ -81,7 +81,7 @@ FNAME(smooth_untextured) (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); \
@ -223,7 +223,7 @@ FNAME(smooth_textured) (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); \

View File

@ -60,8 +60,8 @@ init_libvision() {
PandaSystem *ps = PandaSystem::get_global_ptr();
ps->add_system("OpenCV");
TexturePool *ts = TexturePool::get_global_ptr();
#ifndef HAVE_FFMPEG
TexturePool *ts = TexturePool::get_global_ptr();
ts->register_texture_type(OpenCVTexture::make_texture, "avi");
#endif
#endif

View File

@ -305,7 +305,7 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) {
// Set up the mmap buffers
struct v4l2_buffer buf;
for (int i = 0; i < _bufcount; ++i) {
for (unsigned int i = 0; i < (unsigned int)_bufcount; ++i) {
memset(&buf, 0, sizeof buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
@ -367,7 +367,7 @@ WebcamVideoCursorV4L::
close(_fd);
}
if (_buffers) {
for (int i = 0; i < _bufcount; ++i) {
for (unsigned int i = 0; i < (unsigned int)_bufcount; ++i) {
munmap(_buffers[i], _buflens[i]);
}
free(_buffers);
@ -455,7 +455,7 @@ fetch_buffer() {
}
// Flip the image vertically
for (size_t row = 0; row < _size_y; ++row) {
for (int row = 0; row < _size_y; ++row) {
memcpy(block + (_size_y - row - 1) * new_bpl, newbuf + row * new_bpl, new_bpl);
}
free(newbuf);

View File

@ -33,7 +33,7 @@ find_all_webcams_opencv() {
"numbers that are assumed to be available via OpenCV to the "
"WebcamVideo interface. The default camera index is 0. "
"Specify empty string if there are no available cameras."));
for (int i = 0; i < wemcam_opencv_camera_index.get_num_words(); ++i) {
for (size_t i = 0; i < wemcam_opencv_camera_index.get_num_words(); ++i) {
PT(WebcamVideo) wc = new WebcamVideoOpenCV(wemcam_opencv_camera_index[i]);
WebcamVideoOpenCV::_all_webcams.push_back(wc);
}

View File

@ -177,7 +177,7 @@ influence_vertex(int index, EggVertex *vertex) {
for (size_t pa = 0; pa < influence->GetPairCount(); ++pa) {
const FCDJointWeightPair* jwpair = influence->GetPair(pa);
if (jwpair->jointIndex >= 0 && jwpair->jointIndex < _joints.size()) {
if (jwpair->jointIndex >= 0 && jwpair->jointIndex < (int)_joints.size()) {
EggGroup *joint = _joints[jwpair->jointIndex]._group.p();
if (joint != NULL) {
joint->ref_vertex(vertex, jwpair->weight);

View File

@ -1508,7 +1508,7 @@ do_defpose() {
nassertv(anim_index != -1);
// Now we can recursively apply the default pose to the hierarchy.
ch->get_root_joint()->apply_default_pose(anim_index, frame);
root_joint->apply_default_pose(anim_index, frame);
}
int main(int argc, char *argv[]) {