Make it compile with latest GCC (10.0.2) and fix mapgen breaking from -O3 options, but it is forced to -O1 now, also -funroll-loops also broke mapgen, so it was removed.

master
MistUnky 2020-08-08 15:23:05 -05:00
parent 1d2cb6b7dd
commit 0c754ec31e
11 changed files with 378 additions and 80 deletions

View File

@ -145,7 +145,6 @@ endif()
# Client sources
set(minetest_SRCS
${common_SRCS}
MyBillboardSceneNode.cpp
content_mapblock.cpp
content_cao.cpp
mapblock_mesh.cpp
@ -265,8 +264,9 @@ else()
set(ARCH i386)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}")
###set(CMAKE_CXX_FLAGS_RELEASE "-std=gnu++98 -fpermissive -DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O0 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") ### O3
set(CMAKE_CXX_FLAGS_RELEASE "-std=gnu++98 -fpermissive -DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O0 -Wall -fomit-frame-pointer -pipe")
set(CMAKE_CXX_FLAGS_DEBUG "-std=gnu++98 -fpermissive -g -O0 -Wall ${WARNING_FLAGS}") ##O1
if(USE_GPROF)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")

View File

@ -0,0 +1,202 @@
// Copyright (C) 2002-2010 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "MyBillboardSceneNode.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "ICameraSceneNode.h"
namespace irr
{
namespace scene
{
//! constructor
MyBillboardSceneNode::MyBillboardSceneNode(ISceneNode* parent,
ISceneManager* mgr, s32 id,
const core::vector3df& position, const core::dimension2d<f32>& size)
: IBillboardSceneNode(parent, mgr, id, position)
{
#ifdef _DEBUG
setDebugName("MyBillboardSceneNode");
#endif
setSize(size);
indices[0] = 0;
indices[1] = 2;
indices[2] = 1;
indices[3] = 0;
indices[4] = 3;
indices[5] = 2;
video::SColor colorTop = video::SColor(0xFFFFFFFF);
video::SColor colorBottom = video::SColor(0xFFFFFFFF);
vertices[0].TCoords.set(1.0f, 1.0f);
vertices[0].Color = colorBottom;
vertices[1].TCoords.set(1.0f, 0.0f);
vertices[1].Color = colorTop;
vertices[2].TCoords.set(0.0f, 0.0f);
vertices[2].Color = colorTop;
vertices[3].TCoords.set(0.0f, 1.0f);
vertices[3].Color = colorBottom;
}
//! pre render event
void MyBillboardSceneNode::OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
//! render
void MyBillboardSceneNode::render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
ICameraSceneNode* camera = SceneManager->getActiveCamera();
if (!camera || !driver)
return;
// make billboard look to camera
core::vector3df pos = getAbsolutePosition();
core::vector3df campos = camera->getAbsolutePosition();
core::vector3df target = camera->getTarget();
core::vector3df up = camera->getUpVector();
core::vector3df view = target - campos;
view.normalize();
core::vector3df horizontal = up.crossProduct(view);
if ( horizontal.getLength() == 0 )
{
horizontal.set(up.Y,up.X,up.Z);
}
horizontal.normalize();
horizontal *= 0.5f * Size.Width;
core::vector3df vertical = horizontal.crossProduct(view);
vertical.normalize();
vertical *= 0.5f * Size.Height;
view *= -1.0f;
for (s32 i=0; i<4; ++i)
vertices[i].Normal = view;
vertices[0].Pos = pos + horizontal + vertical;
vertices[1].Pos = pos + horizontal - vertical;
vertices[2].Pos = pos - horizontal - vertical;
vertices[3].Pos = pos - horizontal + vertical;
// draw
if ( DebugDataVisible & scene::EDS_BBOX )
{
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
video::SMaterial m;
m.Lighting = false;
driver->setMaterial(m);
driver->draw3DBox(BBox, video::SColor(0,208,195,152));
}
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
driver->setMaterial(Material);
driver->drawIndexedTriangleList(vertices, 4, indices, 2);
}
//! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& MyBillboardSceneNode::getBoundingBox() const
{
return BBox;
}
//! sets the size of the billboard
void MyBillboardSceneNode::setSize(const core::dimension2d<f32>& size)
{
Size = size;
if (Size.Width == 0.0f)
Size.Width = 1.0f;
if (Size.Height == 0.0f )
Size.Height = 1.0f;
f32 avg = (size.Width + size.Height)/6;
BBox.MinEdge.set(-avg,-avg,-avg);
BBox.MaxEdge.set(avg,avg,avg);
}
video::SMaterial& MyBillboardSceneNode::getMaterial(u32 i)
{
return Material;
}
//! returns amount of materials used by this scene node.
u32 MyBillboardSceneNode::getMaterialCount() const
{
return 1;
}
//! gets the size of the billboard
const core::dimension2d<f32>& MyBillboardSceneNode::getSize() const
{
return Size;
}
//! Set the color of all vertices of the billboard
//! \param overallColor: the color to set
void MyBillboardSceneNode::setColor(const video::SColor & overallColor)
{
for(u32 vertex = 0; vertex < 4; ++vertex)
vertices[vertex].Color = overallColor;
}
//! Set the color of the top and bottom vertices of the billboard
//! \param topColor: the color to set the top vertices
//! \param bottomColor: the color to set the bottom vertices
void MyBillboardSceneNode::setColor(const video::SColor & topColor, const video::SColor & bottomColor)
{
vertices[0].Color = bottomColor;
vertices[1].Color = topColor;
vertices[2].Color = topColor;
vertices[3].Color = bottomColor;
}
//! Gets the color of the top and bottom vertices of the billboard
//! \param[out] topColor: stores the color of the top vertices
//! \param[out] bottomColor: stores the color of the bottom vertices
void MyBillboardSceneNode::getColor(video::SColor & topColor, video::SColor & bottomColor) const
{
bottomColor = vertices[0].Color;
topColor = vertices[1].Color;
}
void MyBillboardSceneNode::setTCoords(u32 i, core::vector2d<f32> c)
{
vertices[i].TCoords = c;
}
} // end namespace scene
} // end namespace irr

View File

@ -0,0 +1,77 @@
// Copyright (C) 2002-2010 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_BILLBOARD_SCENE_NODE_H_INCLUDED__
#define __C_BILLBOARD_SCENE_NODE_H_INCLUDED__
#include "IBillboardSceneNode.h"
#include "S3DVertex.h"
namespace irr
{
namespace scene
{
//! Scene node which is a billboard. A billboard is like a 3d sprite: A 2d element,
//! which always looks to the camera.
class MyBillboardSceneNode : virtual public IBillboardSceneNode
{
public:
//! constructor
MyBillboardSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id,
const core::vector3df& position, const core::dimension2d<f32>& size);
//! pre render event
virtual void OnRegisterSceneNode();
//! render
virtual void render();
//! returns the axis aligned bounding box of this node
virtual const core::aabbox3d<f32>& getBoundingBox() const;
//! sets the size of the billboard
virtual void setSize(const core::dimension2d<f32>& size);
//! gets the size of the billboard
virtual const core::dimension2d<f32>& getSize() const;
virtual video::SMaterial& getMaterial(u32 i);
//! returns amount of materials used by this scene node.
virtual u32 getMaterialCount() const;
//! Set the color of all vertices of the billboard
//! \param overallColor: the color to set
virtual void setColor(const video::SColor & overallColor);
//! Set the color of the top and bottom vertices of the billboard
//! \param topColor: the color to set the top vertices
//! \param bottomColor: the color to set the bottom vertices
virtual void setColor(const video::SColor & topColor, const video::SColor & bottomColor);
//! Gets the color of the top and bottom vertices of the billboard
//! \param[out] topColor: stores the color of the top vertices
//! \param[out] bottomColor: stores the color of the bottom vertices
virtual void getColor(video::SColor& topColor, video::SColor& bottomColor) const;
virtual void setTCoords(u32 i, core::vector2d<f32> c);
private:
core::dimension2d<f32> Size;
core::aabbox3d<f32> BBox;
video::SMaterial Material;
video::S3DVertex vertices[4];
u16 indices[6];
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <cmath>
#include <SAnimatedMesh.h>
#include "settings.h"
#define MY_ETLM_READ_ONLY video::ETLM_READ_ONLY
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
m_smgr(smgr),
@ -820,7 +821,7 @@ scene::IAnimatedMesh* ExtrudedSpriteSceneNode::extrude(video::ITexture* texture)
{
// Texture is in the correct color format, we can pass it
// to extrudeARGB right away.
void* data = texture->lock(true);
void* data = texture->lock(MY_ETLM_READ_ONLY);
if (data == NULL)
return NULL;
mesh = extrudeARGB(size.Width, size.Height, (u8*) data);
@ -830,7 +831,7 @@ scene::IAnimatedMesh* ExtrudedSpriteSceneNode::extrude(video::ITexture* texture)
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
video::IImage* img1 = driver->createImageFromData(format, size, texture->lock(true));
video::IImage* img1 = driver->createImageFromData(format, size, texture->lock(MY_ETLM_READ_ONLY));
if (img1 == NULL)
return NULL;

View File

@ -903,8 +903,8 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
std::string texture_string = "[makealpha2:128,0,0;128,128,0:";
texture_string += m_texture_name;
scene::MyBillboardSceneNode *bill = new scene::MyBillboardSceneNode(
smgr->getRootSceneNode(), smgr, -1, v3f(0,0,0), v2f(1,1));
scene::IBillboardSceneNode *bill = smgr->addBillboardSceneNode(
NULL, v2f(1, 1), v3f(0,0,0), -1);
bill->setMaterialTexture(0, g_texturesource->getTextureRaw(texture_string));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
@ -918,17 +918,11 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
const float txs = txp*32;
const float typ = 1./240;
const float tys = typ*48;
bill->setTCoords(0, v2f(txs*1, tys*1));
bill->setTCoords(1, v2f(txs*1, tys*0));
bill->setTCoords(2, v2f(txs*0, tys*0));
bill->setTCoords(3, v2f(txs*0, tys*1));
setBillboardTextureMatrix(bill, txs, tys, 0, 0);
} else if(m_sprite_type == "simple"){
const float txs = 1.0;
const float tys = 1.0 / m_simple_anim_frames;
bill->setTCoords(0, v2f(txs*1, tys*1));
bill->setTCoords(1, v2f(txs*1, tys*0));
bill->setTCoords(2, v2f(txs*0, tys*0));
bill->setTCoords(3, v2f(txs*0, tys*1));
setBillboardTextureMatrix(bill, txs, tys, 0, 0);
} else {
infostream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\""
<<std::endl;
@ -944,7 +938,7 @@ void MobV2CAO::removeFromScene()
if(m_node == NULL)
return;
m_node->drop();
// m_node->drop();
m_node->remove();
m_node = NULL;
}
@ -992,7 +986,7 @@ void MobV2CAO::updateNodePos()
void MobV2CAO::step(float dtime, ClientEnvironment *env)
{
scene::MyBillboardSceneNode *bill = m_node;
scene::IBillboardSceneNode *bill = m_node;
if(!bill)
return;
@ -1045,10 +1039,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
const float txs = txp*32;
const float typ = 1./240;
const float tys = typ*48;
bill->setTCoords(0, v2f(txs*(1+col), tys*(1+row)));
bill->setTCoords(1, v2f(txs*(1+col), tys*(0+row)));
bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row)));
bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row)));
setBillboardTextureMatrix(bill, txs, tys, col, row);
} else if(m_sprite_type == "simple"){
m_walk_timer += dtime;
if(m_walk_timer >= m_simple_anim_frametime){
@ -1059,10 +1050,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
int row = m_walk_frame;
const float txs = 1.0;
const float tys = 1.0 / m_simple_anim_frames;
bill->setTCoords(0, v2f(txs*(1+col), tys*(1+row)));
bill->setTCoords(1, v2f(txs*(1+col), tys*(0+row)));
bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row)));
bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row)));
setBillboardTextureMatrix(bill, txs, tys, col, row);
} else {
infostream<<"MobV2CAO::step(): Unknown sprite type \""
<<m_sprite_type<<"\""<<std::endl;

View File

@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_object.h"
#include "utility.h" // For IntervalLimiter
class Settings;
#include "MyBillboardSceneNode.h"
//#include "MyBillboardSceneNode.h"
#include <IBillboardSceneNode.h>
/*
SmoothTranslator
@ -304,6 +305,31 @@ private:
SmoothTranslator pos_translator;
};
static void setBillboardTextureMatrix(scene::IBillboardSceneNode *bill,
float txs, float tys, int col, int row)
{
video::SMaterial& material = bill->getMaterial(0);
core::matrix4& matrix = material.getTextureMatrix(0);
matrix.setTextureTranslate(txs*col, tys*row);
matrix.setTextureScale(txs, tys);
}
/*
MobV2CAO
*/
@ -348,7 +374,7 @@ private:
IntervalLimiter m_attack_interval;
core::aabbox3d<f32> m_selection_box;
scene::MyBillboardSceneNode *m_node;
scene::IBillboardSceneNode *m_node;
v3f m_position;
std::string m_texture_name;
float m_yaw;

View File

@ -555,7 +555,7 @@ InventoryItem * InventoryList::takeItem(u32 i, u32 count)
return item2;
}
return false;
return NULL;
}
void InventoryList::decrementMaterials(u16 count)

View File

@ -1367,6 +1367,8 @@ int main(int argc, char *argv[])
bool fullscreen = false;
u16 screenW = g_settings->getU16("screenW");
u16 screenH = g_settings->getU16("screenH");
//u8 screenW = 640;//g_settings->getU16("screenW");
//u8 screenH = 480;//g_settings->getU16("screenH");
// Determine driver

View File

@ -3481,15 +3481,15 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
}
catch(InvalidFilenameException &e)
{
return false;
return NULL;
}
catch(FileNotGoodException &e)
{
return false;
return NULL;
}
catch(std::exception &e)
{
return false;
return NULL;
}
}

View File

@ -33,15 +33,15 @@ double cos_lookup[16] = {
};
double dotProduct(double vx, double vy, double wx, double wy){
return vx*wx+vy*wy;
return (vx*wx)+(vy*wy);
}
double easeCurve(double t){
return 6*pow(t,5)-15*pow(t,4)+10*pow(t,3);
return (6*pow(t,5))-(15*pow(t,4))+(10*pow(t,3));
}
double linearInterpolation(double x0, double x1, double t){
return x0+(x1-x0)*t;
return (x0+((x1-x0)*t));
}
double biLinearInterpolation(double x0y0, double x1y0, double x0y1, double x1y1, double x, double y){
@ -59,40 +59,40 @@ double triLinearInterpolation(
double v001, double v101, double v011, double v111,
double x, double y, double z)
{
/*double tx = easeCurve(x);
double ty = easeCurve(y);
double tz = easeCurve(z);*/
//double tx = easeCurve(x);
//double ty = easeCurve(y);
//double tz = easeCurve(z); //localjclasjkcdsjlk
double tx = x;
double ty = y;
double tz = z;
return(
v000*(1-tx)*(1-ty)*(1-tz) +
v100*tx*(1-ty)*(1-tz) +
v010*(1-tx)*ty*(1-tz) +
v110*tx*ty*(1-tz) +
v001*(1-tx)*(1-ty)*tz +
v101*tx*(1-ty)*tz +
v011*(1-tx)*ty*tz +
v111*tx*ty*tz
(v000*(1-tx)*(1-ty)*(1-tz)) +
(v100*tx*(1-ty)*(1-tz)) +
(v010*(1-tx)*ty*(1-tz)) +
(v110*tx*ty*(1-tz)) +
(v001*(1-tx)*(1-ty)*tz) +
(v101*tx*(1-ty)*tz) +
(v011*(1-tx)*ty*tz) +
(v111*tx*ty*tz)
);
}
double noise2d(int x, int y, int seed)
{
int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
int n = ((NOISE_MAGIC_X * x) + (NOISE_MAGIC_Y * y)
+ (NOISE_MAGIC_SEED * seed)) & 0x7fffffff;
n = (n>>13)^n;
n = (n * (n*n*60493+19990303) + 1376312589) & 0x7fffffff;
return 1.0 - (double)n/1073741824;
n = ((n * ((n*n*60493)+19990303)) + 1376312589) & 0x7fffffff;
return 1.0 - ((double)n/1073741824);
}
double noise3d(int x, int y, int z, int seed)
{
int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y + NOISE_MAGIC_Z * z
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
int n = ((NOISE_MAGIC_X * x) + (NOISE_MAGIC_Y * y) + (NOISE_MAGIC_Z * z)
+ (NOISE_MAGIC_SEED * seed)) & 0x7fffffff;
n = (n>>13)^n;
n = (n * (n*n*60493+19990303) + 1376312589) & 0x7fffffff;
return 1.0 - (double)n/1073741824;
n = ((n * ((n*n*60493)+19990303)) + 1376312589) & 0x7fffffff;
return 1.0 - ((double)n/1073741824);
}
#if 0
@ -124,8 +124,8 @@ double noise2d_gradient(double x, double y, int seed)
double noise2d_gradient(double x, double y, int seed)
{
// Calculate the integer coordinates
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
int x0 = (x > 0.0 ? (int)x : ((int)x - 1));
int y0 = (y > 0.0 ? (int)y : ((int)y - 1));
// Calculate the remaining part of the coordinates
double xl = x - (double)x0;
double yl = y - (double)y0;
@ -142,9 +142,9 @@ double noise2d_gradient(double x, double y, int seed)
double noise3d_gradient(double x, double y, double z, int seed)
{
// Calculate the integer coordinates
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
int z0 = (z > 0.0 ? (int)z : (int)z - 1);
int x0 = (x > 0.0 ? (int)x : ((int)x - 1));
int y0 = (y > 0.0 ? (int)y : ((int)y - 1));
int z0 = (z > 0.0 ? (int)z : ((int)z - 1));
// Calculate the remaining part of the coordinates
double xl = x - (double)x0;
double yl = y - (double)y0;
@ -170,7 +170,7 @@ double noise2d_perlin(double x, double y, int seed,
double g = 1.0;
for(int i=0; i<octaves; i++)
{
a += g * noise2d_gradient(x*f, y*f, seed+i);
a += (g * noise2d_gradient(x*f, y*f, seed+i));
f *= 2.0;
g *= persistence;
}
@ -185,7 +185,7 @@ double noise2d_perlin_abs(double x, double y, int seed,
double g = 1.0;
for(int i=0; i<octaves; i++)
{
a += g * fabs(noise2d_gradient(x*f, y*f, seed+i));
a += (g * fabs(noise2d_gradient(x*f, y*f, seed+i)));
f *= 2.0;
g *= persistence;
}
@ -200,7 +200,7 @@ double noise3d_perlin(double x, double y, double z, int seed,
double g = 1.0;
for(int i=0; i<octaves; i++)
{
a += g * noise3d_gradient(x*f, y*f, z*f, seed+i);
a += (g * noise3d_gradient(x*f, y*f, z*f, seed+i));
f *= 2.0;
g *= persistence;
}
@ -215,7 +215,7 @@ double noise3d_perlin_abs(double x, double y, double z, int seed,
double g = 1.0;
for(int i=0; i<octaves; i++)
{
a += g * fabs(noise3d_gradient(x*f, y*f, z*f, seed+i));
a += (g * fabs(noise3d_gradient(x*f, y*f, z*f, seed+i)));
f *= 2.0;
g *= persistence;
}
@ -307,9 +307,9 @@ void NoiseBuffer::create(const NoiseParams &param,
m_samplelength_y = samplelength_y;
m_samplelength_z = samplelength_z;
m_size_x = (last_x - m_start_x)/samplelength_x + 2;
m_size_y = (last_y - m_start_y)/samplelength_y + 2;
m_size_z = (last_z - m_start_z)/samplelength_z + 2;
m_size_x = ((last_x - m_start_x)/samplelength_x) + 2;
m_size_y = ((last_y - m_start_y)/samplelength_y) + 2;
m_size_z = ((last_z - m_start_z)/samplelength_z) + 2;
m_data = new double[m_size_x*m_size_y*m_size_z];
@ -317,9 +317,9 @@ void NoiseBuffer::create(const NoiseParams &param,
for(int y=0; y<m_size_y; y++)
for(int z=0; z<m_size_z; z++)
{
double xd = (m_start_x + (double)x*m_samplelength_x);
double yd = (m_start_y + (double)y*m_samplelength_y);
double zd = (m_start_z + (double)z*m_samplelength_z);
double xd = (m_start_x + ((double)x*m_samplelength_x));
double yd = (m_start_y + ((double)y*m_samplelength_y));
double zd = (m_start_z + ((double)z*m_samplelength_z));
double a = noise3d_param(param, xd,yd,zd);
intSet(x,y,z, a);
}
@ -333,9 +333,9 @@ void NoiseBuffer::multiply(const NoiseParams &param)
for(int y=0; y<m_size_y; y++)
for(int z=0; z<m_size_z; z++)
{
double xd = (m_start_x + (double)x*m_samplelength_x);
double yd = (m_start_y + (double)y*m_samplelength_y);
double zd = (m_start_z + (double)z*m_samplelength_z);
double xd = (m_start_x + ((double)x*m_samplelength_x));
double yd = (m_start_y + ((double)y*m_samplelength_y));
double zd = (m_start_z + ((double)z*m_samplelength_z));
double a = noise3d_param(param, xd,yd,zd);
intMultiply(x,y,z, a);
}
@ -361,7 +361,7 @@ void NoiseBuffer::create(int seed, int octaves, double persistence,
void NoiseBuffer::intSet(int x, int y, int z, double d)
{
int i = m_size_x*m_size_y*z + m_size_x*y + x;
int i = (m_size_x*m_size_y*z) + (m_size_x*y) + x;
assert(i >= 0);
assert(i < m_size_x*m_size_y*m_size_z);
m_data[i] = d;
@ -369,7 +369,7 @@ void NoiseBuffer::intSet(int x, int y, int z, double d)
void NoiseBuffer::intMultiply(int x, int y, int z, double d)
{
int i = m_size_x*m_size_y*z + m_size_x*y + x;
int i = (m_size_x*m_size_y*z) + (m_size_x*y) + x;
assert(i >= 0);
assert(i < m_size_x*m_size_y*m_size_z);
m_data[i] = m_data[i] * d;
@ -377,7 +377,7 @@ void NoiseBuffer::intMultiply(int x, int y, int z, double d)
double NoiseBuffer::intGet(int x, int y, int z)
{
int i = m_size_x*m_size_y*z + m_size_x*y + x;
int i = (m_size_x*m_size_y*z) + (m_size_x*y) + x;
assert(i >= 0);
assert(i < m_size_x*m_size_y*m_size_z);
return m_data[i];

View File

@ -902,7 +902,7 @@ inline bool is_yes(const std::string &s)
return false;
}
inline s32 stoi(const std::string &s, s32 min, s32 max)
inline s32 mystoi(const std::string &s, s32 min, s32 max)
{
s32 i = atoi(s.c_str());
if(i < min)
@ -914,19 +914,19 @@ inline s32 stoi(const std::string &s, s32 min, s32 max)
// MSVC2010 includes it's own versions of these
#if !defined(_MSC_VER) || _MSC_VER < 1600
//#if !defined(_MSC_VER) || _MSC_VER < 1600
inline s32 stoi(std::string s)
inline s32 mystoi(std::string s)
{
return atoi(s.c_str());
}
inline s32 stoi(std::wstring s)
inline s32 mystoi(std::wstring s)
{
return atoi(wide_to_narrow(s).c_str());
}
inline float stof(std::string s)
inline float mystof(std::string s)
{
float f;
std::istringstream ss(s);
@ -934,7 +934,9 @@ inline float stof(std::string s)
return f;
}
#endif
#define stoi mystoi
#define stof mystof
//#endif
inline std::string itos(s32 i)
{