Merge changes from the witness.

pull/216/head
castano 14 years ago
parent 30b9545d75
commit 9094756997

@ -275,12 +275,14 @@ namespace nv
}
/// Remove the first instance of the given element.
void remove(const T & element)
bool remove(const T & element)
{
for (uint i = 0; i < m_size; i++) {
removeAt(i);
break;
uint index;
if (find(element, &index)) {
removeAt(index);
return true;
}
return false;
}
/// Insert the given element at the given index shifting all the elements up.
@ -342,7 +344,7 @@ namespace nv
}
if( m_size == 0 ) {
//Allocate(0); // Don't shrink automatically.
//allocate(0); // Don't shrink automatically.
}
else if( m_size <= m_buffer_size/* && m_size > m_buffer_size >> 1*/) {
// don't compact yet.
@ -382,7 +384,7 @@ namespace nv
}
if( m_size == 0 ) {
//Allocate(0); // Don't shrink automatically.
//allocate(0); // Don't shrink automatically.
}
else if( m_size <= m_buffer_size && m_size > m_buffer_size >> 1 ) {
// don't compact yet.

@ -48,9 +48,6 @@
# endif
#endif
#include <stdexcept> // std::runtime_error
#undef assert // defined on mingw
using namespace nv;
namespace
@ -356,7 +353,7 @@ namespace
if( ret == NV_ABORT_EXIT ) {
// Exit cleanly.
throw std::runtime_error("Assertion failed");
throw "Assertion failed";
}
return ret;

@ -24,7 +24,6 @@
#if _MSC_VER < 1500
# define vsnprintf _vsnprintf
#endif
#define vsscanf _vsscanf
#define chdir _chdir
#define getcwd _getcwd

@ -5,12 +5,13 @@
#include "nvcore.h"
#include "Debug.h"
#include "RefCounted.h" // WeakProxy
namespace nv
{
class WeakProxy;
/** Simple auto pointer template class.
*
* This is very similar to the standard auto_ptr class, but with some
@ -273,7 +274,7 @@ namespace nv
void operator=(T * p)
{
if (p != NULL) {
if (p) {
m_proxy = p->getWeakProxy();
nvDebugCheck(m_proxy != NULL);
nvDebugCheck(m_proxy->ptr() == p);

@ -9,12 +9,6 @@
#include <stdarg.h> // vsnprintf
#endif
#if NV_OS_WIN32
#define NV_PATH_SEPARATOR '\\'
#else
#define NV_PATH_SEPARATOR '/'
#endif
using namespace nv;
namespace
@ -230,7 +224,7 @@ StringBuilder & StringBuilder::format( const char * fmt, ... )
va_list arg;
va_start( arg, fmt );
format( fmt, arg );
formatList( fmt, arg );
va_end( arg );
@ -239,7 +233,7 @@ StringBuilder & StringBuilder::format( const char * fmt, ... )
/** Format a string safely. */
StringBuilder & StringBuilder::format( const char * fmt, va_list arg )
StringBuilder & StringBuilder::formatList( const char * fmt, va_list arg )
{
nvDebugCheck(fmt != NULL);
@ -315,14 +309,14 @@ StringBuilder & StringBuilder::append( const char * s )
/** Append a formatted string. */
StringBuilder & StringBuilder::appendFormat( const char * format, ... )
StringBuilder & StringBuilder::appendFormat( const char * fmt, ... )
{
nvDebugCheck( format != NULL );
nvDebugCheck( fmt != NULL );
va_list arg;
va_start( arg, format );
va_start( arg, fmt );
appendFormat( format, arg );
appendFormatList( fmt, arg );
va_end( arg );
@ -331,16 +325,21 @@ StringBuilder & StringBuilder::appendFormat( const char * format, ... )
/** Append a formatted string. */
StringBuilder & StringBuilder::appendFormat( const char * format, va_list arg )
StringBuilder & StringBuilder::appendFormatList( const char * fmt, va_list arg )
{
nvDebugCheck( format != NULL );
nvDebugCheck( fmt != NULL );
va_list tmp;
va_copy(tmp, arg);
if (m_size == 0) {
formatList(fmt, arg);
}
else {
StringBuilder tmp_str;
tmp_str.format( format, tmp );
tmp_str.formatList( fmt, tmp );
append( tmp_str );
}
va_end(tmp);
@ -459,17 +458,13 @@ const char * Path::extension() const
/// Toggles path separators (ie. \\ into /).
void Path::translatePath()
void Path::translatePath(char pathSeparator /*= NV_PATH_SEPARATOR*/)
{
nvCheck( m_str != NULL );
for (int i = 0; ; i++) {
if (m_str[i] == '\0') break;
#if NV_PATH_SEPARATOR == '/'
if( m_str[i] == '\\' ) m_str[i] = NV_PATH_SEPARATOR;
#else
if( m_str[i] == '/' ) m_str[i] = NV_PATH_SEPARATOR;
#endif
if (m_str[i] == '\\' || m_str[i] == '/') m_str[i] = pathSeparator;
}
}
@ -507,7 +502,7 @@ void Path::stripExtension()
return; // no extension
}
}
if( length ) {
if (length > 0) {
m_str[length] = 0;
}
}

@ -10,6 +10,11 @@
#include <string.h> // strlen, strcmp, etc.
#if NV_OS_WIN32
#define NV_PATH_SEPARATOR '\\'
#else
#define NV_PATH_SEPARATOR '/'
#endif
namespace nv
{
@ -32,6 +37,7 @@ namespace nv
};
NVCORE_API int strCaseCmp(const char * s1, const char * s2) NV_PURE;
NVCORE_API int strCmp(const char * s1, const char * s2) NV_PURE;
@ -60,11 +66,11 @@ namespace nv
~StringBuilder();
StringBuilder & format( const char * format, ... ) __attribute__((format (printf, 2, 3)));
StringBuilder & format( const char * format, va_list arg );
StringBuilder & formatList( const char * format, va_list arg );
StringBuilder & append( const char * str );
StringBuilder & appendFormat( const char * format, ... ) __attribute__((format (printf, 2, 3)));
StringBuilder & appendFormat( const char * format, va_list arg );
StringBuilder & appendFormatList( const char * format, va_list arg );
StringBuilder & number( int i, int base = 10 );
StringBuilder & number( uint i, int base = 10 );
@ -142,7 +148,7 @@ namespace nv
const char * fileName() const;
const char * extension() const;
void translatePath();
void translatePath(char pathSeparator = NV_PATH_SEPARATOR);
void stripFileName();
void stripExtension();
@ -361,6 +367,10 @@ namespace nv
};
template <> struct Hash<String> {
uint operator()(const String & str) const { return str.hash(); }
};
} // nv namespace
#endif // NV_CORE_STRING_H

@ -151,8 +151,8 @@
/// @hideinitializer
#define NV_UNUSED(a) ((a)=(a))
/// Null index. @@ Move this somewhere else... This could have collisions with other definitions!
#define NIL uint(~0)
/// Null index. @@ Move this somewhere else... it's only used by nvmesh.
const unsigned int NIL = unsigned int(~0);
/// Null pointer.
#ifndef NULL

@ -22,7 +22,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
#include "BlockDXT.h"
#include "ColorBlock.h"
#include "nvcore/Stream.h"
@ -39,9 +38,9 @@ using namespace nv;
uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
{
// Does bit expansion before interpolation.
color_array[0].r = (col0.r << 3) | (col0.r >> 2);
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
color_array[0].r = (col0.r << 3) | (col0.r >> 2);
color_array[0].a = 0xFF;
// @@ Same as above, but faster?
@ -97,14 +96,14 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
{
// Does bit expansion before interpolation.
color_array[0].r = (3 * col0.r * 22) / 8;
color_array[0].b = col0.b * 22 / 8;
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
color_array[0].b = (3 * col0.b * 22) / 8;
color_array[0].r = col0.r * 22 / 8;
color_array[0].a = 0xFF;
color_array[1].r = (3 * col1.r * 22) / 8;
color_array[1].r = col1.r * 22 / 8;
color_array[1].g = (col1.g << 2) | (col1.g >> 4);
color_array[1].b = (3 * col1.b * 22) / 8;
color_array[1].b = col1.b * 22 / 8;
color_array[1].a = 0xFF;
if( col0.u > col1.u ) {
@ -117,8 +116,8 @@ uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
color_array[3].r = (2 * col1.r + col0.r) * 22 / 8;
color_array[3].g = (256 * color_array[1].g + (color_array[0].g - color_array[1].g)/4 + 128 + (color_array[0].g - color_array[1].g) * 80) / 256;
color_array[3].b = (2 * col1.b + col0.b) * 22 / 8;
color_array[3].a = 0xFF;
return 4;
}
else {
@ -224,7 +223,6 @@ void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const
}
}
void BlockDXT1::setIndices(int * idx)
{
indices = 0;

@ -21,12 +21,13 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#ifndef NV_IMAGE_BLOCKDXT_H
#define NV_IMAGE_BLOCKDXT_H
#include <nvmath/Color.h>
#include "nvimage.h"
#include <nvimage/nvimage.h>
#include "nvmath/Color.h"
namespace nv
{

@ -165,10 +165,7 @@ Color32 c;
int i;
for(i = 0; i < 16; i++)
{
if (m_color[i].a != 0) {
c = m_color[i];
break;
}
if (m_color[i].a != 0) c = m_color[i];
}
Color32 mask(0xFF, 0xFF, 0xFF, 0x00);
@ -483,10 +480,10 @@ void FloatColorBlock::init(const Image * img, uint x, uint y)
const uint bx = e % w;
Color32 c = img->pixel(x+bx, y+by);
Vector4 & v = color(e, i);
v.x = c.r / 255;
v.y = c.g / 255;
v.z = c.b / 255;
v.w = c.a / 255;
v.x = c.r / 255.0f;
v.y = c.g / 255.0f;
v.z = c.b / 255.0f;
v.w = c.a / 255.0f;
}
}
}

@ -1,5 +1,6 @@
// This code is in the public domain -- jim@tilander.org
#pragma once
#ifndef NV_IMAGE_COLORSPACE_H
#define NV_IMAGE_COLORSPACE_H

@ -25,7 +25,7 @@
#ifndef NV_IMAGE_DIRECTDRAWSURFACE_H
#define NV_IMAGE_DIRECTDRAWSURFACE_H
#include <nvimage/nvimage.h>
#include "nvimage.h"
namespace nv
{

@ -39,6 +39,7 @@ const Image & Image::operator=(const Image & img)
void Image::allocate(uint w, uint h)
{
free();
m_width = w;
m_height = h;
m_data = (Color32 *)nv::mem::realloc(m_data, w * h * sizeof(Color32));

@ -21,14 +21,14 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#include <nvimage/NormalMap.h>
#include <nvimage/Filter.h>
#include <nvimage/FloatImage.h>
#include <nvimage/Image.h>
#include "NormalMap.h"
#include "Filter.h"
#include "FloatImage.h"
#include "Image.h"
#include <nvmath/Color.h>
#include "nvmath/Color.h"
#include <nvcore/Ptr.h>
#include "nvcore/Ptr.h"
using namespace nv;

@ -21,12 +21,14 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#ifndef NV_IMAGE_NORMALMAP_H
#define NV_IMAGE_NORMALMAP_H
#include <nvmath/Vector.h>
#include <nvimage/nvimage.h>
#include <nvimage/FloatImage.h>
#include "nvimage.h"
#include "FloatImage.h"
#include "nvmath/Vector.h"
namespace nv

@ -21,10 +21,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
#pragma once
#ifndef NV_IMAGE_PIXELFORMAT_H
#define NV_IMAGE_PIXELFORMAT_H
#include <nvimage/nvimage.h>
#include "nvimage.h"
namespace nv

@ -1,9 +1,10 @@
// This code is in the public domain -- castanyo@yahoo.es
#pragma once
#ifndef NV_IMAGE_PSDFILE_H
#define NV_IMAGE_PSDFILE_H
#include <nvcore/Stream.h>
#include "nvcore/Stream.h"
namespace nv
{

@ -1,9 +1,10 @@
// This code is in the public domain -- castanyo@yahoo.es
#pragma once
#ifndef NV_IMAGE_QUANTIZE_H
#define NV_IMAGE_QUANTIZE_H
#include <nvimage/nvimage.h>
#include "nvimage.h"
namespace nv

@ -1,9 +1,10 @@
// This code is in the public domain -- castanyo@yahoo.es
#pragma once
#ifndef NV_IMAGE_TGAFILE_H
#define NV_IMAGE_TGAFILE_H
#include <nvcore/Stream.h>
#include "nvcore/Stream.h"
namespace nv
{

@ -1,5 +1,6 @@
// This code is in the public domain -- castanyo@yahoo.es
#pragma once
#ifndef NV_IMAGE_H
#define NV_IMAGE_H

@ -26,7 +26,7 @@
#include "Compressor.h"
struct Tile;
class Tile;
namespace nv
{

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
float gamma = 2.2f;
image.toLinear(gamma);
float alphaRef = 0.95;
float alphaRef = 0.95f;
float coverage = image.alphaTestCoverage(alphaRef);
// Build mimaps.

Loading…
Cancel
Save