diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I index c7575db59e..ffa809820e 100644 --- a/dtool/src/dconfig/dconfig.I +++ b/dtool/src/dconfig/dconfig.I @@ -28,7 +28,7 @@ GetInt(const string &sym, int def) { float DConfig:: GetFloat(const string &sym, float def) { ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); + return (float)var.get_value(); } double DConfig:: diff --git a/dtool/src/dtoolbase/cmath.I b/dtool/src/dtoolbase/cmath.I index 03b03f5640..6e8ed6e618 100644 --- a/dtool/src/dtoolbase/cmath.I +++ b/dtool/src/dtoolbase/cmath.I @@ -142,7 +142,7 @@ cacos(float v) { //////////////////////////////////////////////////////////////////// INLINE float cmod(float x, float y) { - return x - cfloor(x / y) * y; + return x - floor(x / y) * y; } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 4c8b9b28cb..2c883f8220 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -55,6 +55,8 @@ #pragma warning (disable : 4355) /* C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data */ #pragma warning (disable : 4244) +/* C4267: 'var' : conversion from 'size_t' to 'type', possible loss of data */ +#pragma warning (disable : 4267) #if _MSC_VER >= 1300 #if _MSC_VER >= 1310 diff --git a/dtool/src/dtoolbase/typeRegistry.I b/dtool/src/dtoolbase/typeRegistry.I index 21f15f1f1d..3ba8796c45 100644 --- a/dtool/src/dtoolbase/typeRegistry.I +++ b/dtool/src/dtoolbase/typeRegistry.I @@ -64,5 +64,5 @@ look_up(TypeHandle handle, TypedObject *object) const { return look_up_invalid(handle, object); } #endif - return _handle_registry[handle._index]; + return _handle_registry[(size_t)handle._index]; } diff --git a/dtool/src/prc/configVariable.I b/dtool/src/prc/configVariable.I index 42500be57f..2b50e2a542 100644 --- a/dtool/src/prc/configVariable.I +++ b/dtool/src/prc/configVariable.I @@ -311,7 +311,7 @@ set_int_word(int n, int value) { INLINE void ConfigVariable:: set_int64_word(int n, PN_int64 value) { nassertv(is_constructed()); - _core->make_local_value()->set_int_word(n, value); + _core->make_local_value()->set_int64_word(n, value); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/drawableRegion.I b/panda/src/display/drawableRegion.I index 269c02c1a1..6383b5a40f 100644 --- a/panda/src/display/drawableRegion.I +++ b/panda/src/display/drawableRegion.I @@ -240,7 +240,7 @@ set_clear_stencil(const unsigned int stencil) { //////////////////////////////////////////////////////////////////// INLINE unsigned int DrawableRegion:: get_clear_stencil() const { - return (int)(get_clear_value(RTP_stencil)[0]); + return (unsigned int)(get_clear_value(RTP_stencil)[0]); } //////////////////////////////////////////////////////////////////// @@ -306,9 +306,9 @@ INLINE void DrawableRegion:: update_pixel_factor() { PN_stdfloat new_pixel_factor; if (supports_pixel_zoom()) { - new_pixel_factor = 1.0 / sqrt(max(_pixel_zoom, (PN_stdfloat)1.0)); + new_pixel_factor = (PN_stdfloat)1 / sqrt(max(_pixel_zoom, (PN_stdfloat)1.0)); } else { - new_pixel_factor = 1.0; + new_pixel_factor = 1; } if (new_pixel_factor != _pixel_factor) { _pixel_factor = new_pixel_factor; diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 123d428b1b..2853fe6447 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -353,7 +353,7 @@ add_string(const string &str) { nassertv(str.length() <= (PN_uint16)0xffff); // Strings always are preceded by their length - add_uint16(str.length()); + add_uint16((PN_uint16)str.length()); // Add the string append_data(str); @@ -368,7 +368,7 @@ add_string(const string &str) { INLINE void Datagram:: add_string32(const string &str) { // Strings always are preceded by their length - add_uint32(str.length()); + add_uint32((PN_uint32)str.length()); // Add the string append_data(str); diff --git a/panda/src/express/memoryUsage.I b/panda/src/express/memoryUsage.I index 8f52d9172d..ba2f8c197e 100644 --- a/panda/src/express/memoryUsage.I +++ b/panda/src/express/memoryUsage.I @@ -133,7 +133,7 @@ get_total_cpp_size() { //////////////////////////////////////////////////////////////////// INLINE size_t MemoryUsage:: get_panda_heap_single_size() { - return AtomicAdjust::get(get_global_ptr()->_total_heap_single_size); + return (size_t)AtomicAdjust::get(get_global_ptr()->_total_heap_single_size); } //////////////////////////////////////////////////////////////////// @@ -144,7 +144,7 @@ get_panda_heap_single_size() { //////////////////////////////////////////////////////////////////// INLINE size_t MemoryUsage:: get_panda_heap_array_size() { - return AtomicAdjust::get(get_global_ptr()->_total_heap_array_size); + return (size_t)AtomicAdjust::get(get_global_ptr()->_total_heap_array_size); } //////////////////////////////////////////////////////////////////// @@ -159,7 +159,7 @@ INLINE size_t MemoryUsage:: get_panda_heap_overhead() { #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) MemoryUsage *mu = get_global_ptr(); - return AtomicAdjust::get(mu->_requested_heap_size) - AtomicAdjust::get(mu->_total_heap_single_size) - AtomicAdjust::get(mu->_total_heap_array_size); + return (size_t)(AtomicAdjust::get(mu->_requested_heap_size) - AtomicAdjust::get(mu->_total_heap_single_size) - AtomicAdjust::get(mu->_total_heap_array_size)); #else return 0; #endif @@ -173,7 +173,7 @@ get_panda_heap_overhead() { //////////////////////////////////////////////////////////////////// INLINE size_t MemoryUsage:: get_panda_mmap_size() { - return AtomicAdjust::get(get_global_ptr()->_total_mmap_size); + return (size_t)AtomicAdjust::get(get_global_ptr()->_total_mmap_size); } //////////////////////////////////////////////////////////////////// @@ -206,7 +206,7 @@ get_external_size() { #else // Without alternative malloc, the Panda allocated memory is also // included in total_size, so we have to subtract it out. - return mu->_total_size - mu->_total_heap_single_size - mu->_total_heap_array_size; + return mu->_total_size - (size_t)mu->_total_heap_single_size - (size_t)mu->_total_heap_array_size; #endif } else { return 0; @@ -223,12 +223,12 @@ INLINE size_t MemoryUsage:: get_total_size() { MemoryUsage *mu = get_global_ptr(); if (mu->_count_memory_usage) { - return mu->_total_size + mu->_requested_heap_size; + return mu->_total_size + (size_t)mu->_requested_heap_size; } else { #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) - return mu->_requested_heap_size; + return (size_t)mu->_requested_heap_size; #else - return AtomicAdjust::get(mu->_total_heap_single_size) + AtomicAdjust::get(mu->_total_heap_array_size); + return (size_t)(AtomicAdjust::get(mu->_total_heap_single_size) + AtomicAdjust::get(mu->_total_heap_array_size)); #endif } } diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index 1c00d40197..a381cfffdd 100644 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -682,7 +682,7 @@ ShaderPtrData(const LVecBase2i &vec) : INLINE void Shader::ShaderPtrData:: write_datagram(Datagram &dg) const { dg.add_uint8(_type); - dg.add_uint32(_size); + dg.add_uint32((PN_uint32)_size); if (_type == SPT_double) { const double *data = (const double *) _ptr; @@ -867,7 +867,7 @@ get_filename_from_index(int index, ShaderType type) const { } } else if (glsl_preprocess && index >= 2048 && (index - 2048) < (int)_included_files.size()) { - return _included_files[index - 2048]; + return _included_files[(size_t)index - 2048]; } // Must be a mistake. Quietly put back the integer. char str[32]; diff --git a/panda/src/linmath/configVariableColor.I b/panda/src/linmath/configVariableColor.I index a686c988c5..1c5031bfb3 100644 --- a/panda/src/linmath/configVariableColor.I +++ b/panda/src/linmath/configVariableColor.I @@ -126,19 +126,23 @@ get_value() const { switch (get_num_words()) { case 1: - _cache.set(get_double_word(0), get_double_word(0), get_double_word(0), 1); + _cache.set((PN_stdfloat)get_double_word(0), (PN_stdfloat)get_double_word(0), + (PN_stdfloat)get_double_word(0), 1); break; case 2: - _cache.set(get_double_word(0), get_double_word(0), get_double_word(0), get_double_word(1)); + _cache.set((PN_stdfloat)get_double_word(0), (PN_stdfloat)get_double_word(0), + (PN_stdfloat)get_double_word(0), (PN_stdfloat)get_double_word(1)); break; case 3: - _cache.set(get_double_word(0), get_double_word(1), get_double_word(2), 1); + _cache.set((PN_stdfloat)get_double_word(0), (PN_stdfloat)get_double_word(1), + (PN_stdfloat)get_double_word(2), 1); break; case 4: - _cache.set(get_double_word(0), get_double_word(1), get_double_word(2), get_double_word(3)); + _cache.set((PN_stdfloat)get_double_word(0), (PN_stdfloat)get_double_word(1), + (PN_stdfloat)get_double_word(2), (PN_stdfloat)get_double_word(3)); break; default: @@ -161,17 +165,17 @@ get_default_value() const { if (decl != (ConfigDeclaration *)NULL) { switch (decl->get_num_words()) { case 1: - return LColor(decl->get_double_word(0), decl->get_double_word(0), - decl->get_double_word(0), 1); + return LColor((PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(0), + (PN_stdfloat)decl->get_double_word(0), 1); case 2: - return LColor(decl->get_double_word(0), decl->get_double_word(0), - decl->get_double_word(0), decl->get_double_word(1)); + return LColor((PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(0), + (PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(1)); case 3: - return LColor(decl->get_double_word(0), decl->get_double_word(1), - decl->get_double_word(2), 1); + return LColor((PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(1), + (PN_stdfloat)decl->get_double_word(2), 1); case 4: - return LColor(decl->get_double_word(0), decl->get_double_word(1), - decl->get_double_word(2), decl->get_double_word(3)); + return LColor((PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(1), + (PN_stdfloat)decl->get_double_word(2), (PN_stdfloat)decl->get_double_word(3)); default: prc_cat->warning() << "Invalid default color value for ConfigVariable " diff --git a/panda/src/linmath/lcast_to_src.I b/panda/src/linmath/lcast_to_src.I index acfcad19d5..9c4f83ca3e 100644 --- a/panda/src/linmath/lcast_to_src.I +++ b/panda/src/linmath/lcast_to_src.I @@ -74,47 +74,47 @@ lcast_to(FLOATTYPE *, const FLOATNAME(LMatrix4) &source) { INLINE_LINMATH FLOATNAME2(LVecBase2) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVecBase2) &source) { - return FLOATNAME2(LVecBase2)(source[0], source[1]); + return FLOATNAME2(LVecBase2)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1]); } INLINE_LINMATH FLOATNAME2(LVecBase3) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVecBase3) &source) { - return FLOATNAME2(LVecBase3)(source[0], source[1], source[2]); + return FLOATNAME2(LVecBase3)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1], (FLOATTYPE2)source[2]); } INLINE_LINMATH FLOATNAME2(LVecBase4) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVecBase4) &source) { - return FLOATNAME2(LVecBase4)(source[0], source[1], source[2], source[3]); + return FLOATNAME2(LVecBase4)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1], (FLOATTYPE2)source[2], (FLOATTYPE2)source[3]); } INLINE_LINMATH FLOATNAME2(LVector2) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVector2) &source) { - return FLOATNAME2(LVector2)(source[0], source[1]); + return FLOATNAME2(LVector2)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1]); } INLINE_LINMATH FLOATNAME2(LVector3) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVector3) &source) { - return FLOATNAME2(LVector3)(source[0], source[1], source[2]); + return FLOATNAME2(LVector3)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1], (FLOATTYPE2)source[2]); } INLINE_LINMATH FLOATNAME2(LVector4) lcast_to(FLOATTYPE2 *, const FLOATNAME(LVector4) &source) { - return FLOATNAME2(LVector4)(source[0], source[1], source[2], source[3]); + return FLOATNAME2(LVector4)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1], (FLOATTYPE2)source[2], (FLOATTYPE2)source[3]); } INLINE_LINMATH FLOATNAME2(LPoint2) lcast_to(FLOATTYPE2 *, const FLOATNAME(LPoint2) &source) { - return FLOATNAME2(LPoint2)(source[0], source[1]); + return FLOATNAME2(LPoint2)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1]); } INLINE_LINMATH FLOATNAME2(LPoint3) lcast_to(FLOATTYPE2 *, const FLOATNAME(LPoint3) &source) { - return FLOATNAME2(LPoint3)(source[0], source[1], source[2]); + return FLOATNAME2(LPoint3)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1], (FLOATTYPE2)source[2]); } INLINE_LINMATH FLOATNAME2(LPoint4) lcast_to(FLOATTYPE2 *, const FLOATNAME(LPoint4) &source) { - return FLOATNAME2(LPoint4)(source[0], source[1], source[2], source[3]); + return FLOATNAME2(LPoint4)((FLOATTYPE2)source[0], (FLOATTYPE2)source[1], (FLOATTYPE2)source[2], (FLOATTYPE2)source[3]); } INLINE_LINMATH FLOATNAME2(LQuaternion) @@ -125,16 +125,16 @@ lcast_to(FLOATTYPE2 *, const FLOATNAME(LQuaternion) &c) { INLINE_LINMATH FLOATNAME2(LMatrix3) lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix3) &source) { return FLOATNAME2(LMatrix3) - (source(0, 0), source(0, 1), source(0, 2), - source(1, 0), source(1, 1), source(1, 2), - source(2, 0), source(2, 1), source(2, 2)); + ((FLOATTYPE2)source(0, 0), (FLOATTYPE2)source(0, 1), (FLOATTYPE2)source(0, 2), + (FLOATTYPE2)source(1, 0), (FLOATTYPE2)source(1, 1), (FLOATTYPE2)source(1, 2), + (FLOATTYPE2)source(2, 0), (FLOATTYPE2)source(2, 1), (FLOATTYPE2)source(2, 2)); } INLINE_LINMATH FLOATNAME2(LMatrix4) lcast_to(FLOATTYPE2 *, const FLOATNAME(LMatrix4) &source) { return FLOATNAME2(LMatrix4) - (source(0, 0), source(0, 1), source(0, 2), source(0, 3), - source(1, 0), source(1, 1), source(1, 2), source(1, 3), - source(2, 0), source(2, 1), source(2, 2), source(2, 3), - source(3, 0), source(3, 1), source(3, 2), source(3, 3)); + ((FLOATTYPE2)source(0, 0), (FLOATTYPE2)source(0, 1), (FLOATTYPE2)source(0, 2), (FLOATTYPE2)source(0, 3), + (FLOATTYPE2)source(1, 0), (FLOATTYPE2)source(1, 1), (FLOATTYPE2)source(1, 2), (FLOATTYPE2)source(1, 3), + (FLOATTYPE2)source(2, 0), (FLOATTYPE2)source(2, 1), (FLOATTYPE2)source(2, 2), (FLOATTYPE2)source(2, 3), + (FLOATTYPE2)source(3, 0), (FLOATTYPE2)source(3, 1), (FLOATTYPE2)source(3, 2), (FLOATTYPE2)source(3, 3)); } diff --git a/panda/src/linmath/lvector3_src.I b/panda/src/linmath/lvector3_src.I index 5a23e12c43..318d32d2c9 100644 --- a/panda/src/linmath/lvector3_src.I +++ b/panda/src/linmath/lvector3_src.I @@ -319,7 +319,7 @@ relative_angle_rad(const FLOATNAME(LVector3) &other) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: relative_angle_deg(const FLOATNAME(LVector3) &other) const { - return relative_angle_rad(other)*180/3.1415926535; + return relative_angle_rad(other) * FLOATCONST(180.0) / FLOATCONST(3.1415926535); } #endif // FLOATTYPE_IS_INT