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.
This commit is contained in:
parent
1d2cb6b7dd
commit
0c754ec31e
@ -145,7 +145,6 @@ endif()
|
|||||||
# Client sources
|
# Client sources
|
||||||
set(minetest_SRCS
|
set(minetest_SRCS
|
||||||
${common_SRCS}
|
${common_SRCS}
|
||||||
MyBillboardSceneNode.cpp
|
|
||||||
content_mapblock.cpp
|
content_mapblock.cpp
|
||||||
content_cao.cpp
|
content_cao.cpp
|
||||||
mapblock_mesh.cpp
|
mapblock_mesh.cpp
|
||||||
@ -265,8 +264,9 @@ else()
|
|||||||
set(ARCH i386)
|
set(ARCH i386)
|
||||||
endif()
|
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_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_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}")
|
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)
|
if(USE_GPROF)
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
|
||||||
|
202
src/MyBillboardSceneNode.cpp.nul
Normal file
202
src/MyBillboardSceneNode.cpp.nul
Normal 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
|
||||||
|
|
77
src/MyBillboardSceneNode.h.nul
Normal file
77
src/MyBillboardSceneNode.h.nul
Normal 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
|
||||||
|
|
@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <SAnimatedMesh.h>
|
#include <SAnimatedMesh.h>
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#define MY_ETLM_READ_ONLY video::ETLM_READ_ONLY
|
||||||
|
|
||||||
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
|
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
|
||||||
m_smgr(smgr),
|
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
|
// Texture is in the correct color format, we can pass it
|
||||||
// to extrudeARGB right away.
|
// to extrudeARGB right away.
|
||||||
void* data = texture->lock(true);
|
void* data = texture->lock(MY_ETLM_READ_ONLY);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
mesh = extrudeARGB(size.Width, size.Height, (u8*) data);
|
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::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)
|
if (img1 == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -903,8 +903,8 @@ void MobV2CAO::addToScene(scene::ISceneManager *smgr)
|
|||||||
std::string texture_string = "[makealpha2:128,0,0;128,128,0:";
|
std::string texture_string = "[makealpha2:128,0,0;128,128,0:";
|
||||||
texture_string += m_texture_name;
|
texture_string += m_texture_name;
|
||||||
|
|
||||||
scene::MyBillboardSceneNode *bill = new scene::MyBillboardSceneNode(
|
scene::IBillboardSceneNode *bill = smgr->addBillboardSceneNode(
|
||||||
smgr->getRootSceneNode(), smgr, -1, v3f(0,0,0), v2f(1,1));
|
NULL, v2f(1, 1), v3f(0,0,0), -1);
|
||||||
bill->setMaterialTexture(0, g_texturesource->getTextureRaw(texture_string));
|
bill->setMaterialTexture(0, g_texturesource->getTextureRaw(texture_string));
|
||||||
bill->setMaterialFlag(video::EMF_LIGHTING, false);
|
bill->setMaterialFlag(video::EMF_LIGHTING, false);
|
||||||
bill->setMaterialFlag(video::EMF_BILINEAR_FILTER, 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 txs = txp*32;
|
||||||
const float typ = 1./240;
|
const float typ = 1./240;
|
||||||
const float tys = typ*48;
|
const float tys = typ*48;
|
||||||
bill->setTCoords(0, v2f(txs*1, tys*1));
|
setBillboardTextureMatrix(bill, txs, tys, 0, 0);
|
||||||
bill->setTCoords(1, v2f(txs*1, tys*0));
|
|
||||||
bill->setTCoords(2, v2f(txs*0, tys*0));
|
|
||||||
bill->setTCoords(3, v2f(txs*0, tys*1));
|
|
||||||
} else if(m_sprite_type == "simple"){
|
} else if(m_sprite_type == "simple"){
|
||||||
const float txs = 1.0;
|
const float txs = 1.0;
|
||||||
const float tys = 1.0 / m_simple_anim_frames;
|
const float tys = 1.0 / m_simple_anim_frames;
|
||||||
bill->setTCoords(0, v2f(txs*1, tys*1));
|
setBillboardTextureMatrix(bill, txs, tys, 0, 0);
|
||||||
bill->setTCoords(1, v2f(txs*1, tys*0));
|
|
||||||
bill->setTCoords(2, v2f(txs*0, tys*0));
|
|
||||||
bill->setTCoords(3, v2f(txs*0, tys*1));
|
|
||||||
} else {
|
} else {
|
||||||
infostream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\""
|
infostream<<"MobV2CAO: Unknown sprite type \""<<m_sprite_type<<"\""
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
@ -944,7 +938,7 @@ void MobV2CAO::removeFromScene()
|
|||||||
if(m_node == NULL)
|
if(m_node == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_node->drop();
|
// m_node->drop();
|
||||||
m_node->remove();
|
m_node->remove();
|
||||||
m_node = NULL;
|
m_node = NULL;
|
||||||
}
|
}
|
||||||
@ -992,7 +986,7 @@ void MobV2CAO::updateNodePos()
|
|||||||
|
|
||||||
void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
||||||
{
|
{
|
||||||
scene::MyBillboardSceneNode *bill = m_node;
|
scene::IBillboardSceneNode *bill = m_node;
|
||||||
if(!bill)
|
if(!bill)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1045,10 +1039,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
|||||||
const float txs = txp*32;
|
const float txs = txp*32;
|
||||||
const float typ = 1./240;
|
const float typ = 1./240;
|
||||||
const float tys = typ*48;
|
const float tys = typ*48;
|
||||||
bill->setTCoords(0, v2f(txs*(1+col), tys*(1+row)));
|
setBillboardTextureMatrix(bill, txs, tys, col, 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)));
|
|
||||||
} else if(m_sprite_type == "simple"){
|
} else if(m_sprite_type == "simple"){
|
||||||
m_walk_timer += dtime;
|
m_walk_timer += dtime;
|
||||||
if(m_walk_timer >= m_simple_anim_frametime){
|
if(m_walk_timer >= m_simple_anim_frametime){
|
||||||
@ -1059,10 +1050,7 @@ void MobV2CAO::step(float dtime, ClientEnvironment *env)
|
|||||||
int row = m_walk_frame;
|
int row = m_walk_frame;
|
||||||
const float txs = 1.0;
|
const float txs = 1.0;
|
||||||
const float tys = 1.0 / m_simple_anim_frames;
|
const float tys = 1.0 / m_simple_anim_frames;
|
||||||
bill->setTCoords(0, v2f(txs*(1+col), tys*(1+row)));
|
setBillboardTextureMatrix(bill, txs, tys, col, 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)));
|
|
||||||
} else {
|
} else {
|
||||||
infostream<<"MobV2CAO::step(): Unknown sprite type \""
|
infostream<<"MobV2CAO::step(): Unknown sprite type \""
|
||||||
<<m_sprite_type<<"\""<<std::endl;
|
<<m_sprite_type<<"\""<<std::endl;
|
||||||
|
@ -24,7 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "content_object.h"
|
#include "content_object.h"
|
||||||
#include "utility.h" // For IntervalLimiter
|
#include "utility.h" // For IntervalLimiter
|
||||||
class Settings;
|
class Settings;
|
||||||
#include "MyBillboardSceneNode.h"
|
//#include "MyBillboardSceneNode.h"
|
||||||
|
#include <IBillboardSceneNode.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SmoothTranslator
|
SmoothTranslator
|
||||||
@ -304,6 +305,31 @@ private:
|
|||||||
SmoothTranslator pos_translator;
|
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
|
MobV2CAO
|
||||||
*/
|
*/
|
||||||
@ -348,7 +374,7 @@ private:
|
|||||||
|
|
||||||
IntervalLimiter m_attack_interval;
|
IntervalLimiter m_attack_interval;
|
||||||
core::aabbox3d<f32> m_selection_box;
|
core::aabbox3d<f32> m_selection_box;
|
||||||
scene::MyBillboardSceneNode *m_node;
|
scene::IBillboardSceneNode *m_node;
|
||||||
v3f m_position;
|
v3f m_position;
|
||||||
std::string m_texture_name;
|
std::string m_texture_name;
|
||||||
float m_yaw;
|
float m_yaw;
|
||||||
|
@ -555,7 +555,7 @@ InventoryItem * InventoryList::takeItem(u32 i, u32 count)
|
|||||||
return item2;
|
return item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryList::decrementMaterials(u16 count)
|
void InventoryList::decrementMaterials(u16 count)
|
||||||
|
@ -1367,6 +1367,8 @@ int main(int argc, char *argv[])
|
|||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
u16 screenW = g_settings->getU16("screenW");
|
u16 screenW = g_settings->getU16("screenW");
|
||||||
u16 screenH = g_settings->getU16("screenH");
|
u16 screenH = g_settings->getU16("screenH");
|
||||||
|
//u8 screenW = 640;//g_settings->getU16("screenW");
|
||||||
|
//u8 screenH = 480;//g_settings->getU16("screenH");
|
||||||
|
|
||||||
// Determine driver
|
// Determine driver
|
||||||
|
|
||||||
|
@ -3481,15 +3481,15 @@ MapBlock* ServerMap::loadBlock(v3s16 blockpos)
|
|||||||
}
|
}
|
||||||
catch(InvalidFilenameException &e)
|
catch(InvalidFilenameException &e)
|
||||||
{
|
{
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch(FileNotGoodException &e)
|
catch(FileNotGoodException &e)
|
||||||
{
|
{
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,15 +33,15 @@ double cos_lookup[16] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
double dotProduct(double vx, double vy, double wx, double wy){
|
double dotProduct(double vx, double vy, double wx, double wy){
|
||||||
return vx*wx+vy*wy;
|
return (vx*wx)+(vy*wy);
|
||||||
}
|
}
|
||||||
|
|
||||||
double easeCurve(double t){
|
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){
|
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){
|
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 v001, double v101, double v011, double v111,
|
||||||
double x, double y, double z)
|
double x, double y, double z)
|
||||||
{
|
{
|
||||||
/*double tx = easeCurve(x);
|
//double tx = easeCurve(x);
|
||||||
double ty = easeCurve(y);
|
//double ty = easeCurve(y);
|
||||||
double tz = easeCurve(z);*/
|
//double tz = easeCurve(z); //localjclasjkcdsjlk
|
||||||
double tx = x;
|
double tx = x;
|
||||||
double ty = y;
|
double ty = y;
|
||||||
double tz = z;
|
double tz = z;
|
||||||
return(
|
return(
|
||||||
v000*(1-tx)*(1-ty)*(1-tz) +
|
(v000*(1-tx)*(1-ty)*(1-tz)) +
|
||||||
v100*tx*(1-ty)*(1-tz) +
|
(v100*tx*(1-ty)*(1-tz)) +
|
||||||
v010*(1-tx)*ty*(1-tz) +
|
(v010*(1-tx)*ty*(1-tz)) +
|
||||||
v110*tx*ty*(1-tz) +
|
(v110*tx*ty*(1-tz)) +
|
||||||
v001*(1-tx)*(1-ty)*tz +
|
(v001*(1-tx)*(1-ty)*tz) +
|
||||||
v101*tx*(1-ty)*tz +
|
(v101*tx*(1-ty)*tz) +
|
||||||
v011*(1-tx)*ty*tz +
|
(v011*(1-tx)*ty*tz) +
|
||||||
v111*tx*ty*tz
|
(v111*tx*ty*tz)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
double noise2d(int x, int y, int seed)
|
double noise2d(int x, int y, int seed)
|
||||||
{
|
{
|
||||||
int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y
|
int n = ((NOISE_MAGIC_X * x) + (NOISE_MAGIC_Y * y)
|
||||||
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
|
+ (NOISE_MAGIC_SEED * seed)) & 0x7fffffff;
|
||||||
n = (n>>13)^n;
|
n = (n>>13)^n;
|
||||||
n = (n * (n*n*60493+19990303) + 1376312589) & 0x7fffffff;
|
n = ((n * ((n*n*60493)+19990303)) + 1376312589) & 0x7fffffff;
|
||||||
return 1.0 - (double)n/1073741824;
|
return 1.0 - ((double)n/1073741824);
|
||||||
}
|
}
|
||||||
|
|
||||||
double noise3d(int x, int y, int z, int seed)
|
double noise3d(int x, int y, int z, int seed)
|
||||||
{
|
{
|
||||||
int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y + NOISE_MAGIC_Z * z
|
int n = ((NOISE_MAGIC_X * x) + (NOISE_MAGIC_Y * y) + (NOISE_MAGIC_Z * z)
|
||||||
+ NOISE_MAGIC_SEED * seed) & 0x7fffffff;
|
+ (NOISE_MAGIC_SEED * seed)) & 0x7fffffff;
|
||||||
n = (n>>13)^n;
|
n = (n>>13)^n;
|
||||||
n = (n * (n*n*60493+19990303) + 1376312589) & 0x7fffffff;
|
n = ((n * ((n*n*60493)+19990303)) + 1376312589) & 0x7fffffff;
|
||||||
return 1.0 - (double)n/1073741824;
|
return 1.0 - ((double)n/1073741824);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -124,8 +124,8 @@ double noise2d_gradient(double x, double y, int seed)
|
|||||||
double noise2d_gradient(double x, double y, int seed)
|
double noise2d_gradient(double x, double y, int seed)
|
||||||
{
|
{
|
||||||
// Calculate the integer coordinates
|
// Calculate the integer coordinates
|
||||||
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
|
int x0 = (x > 0.0 ? (int)x : ((int)x - 1));
|
||||||
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
|
int y0 = (y > 0.0 ? (int)y : ((int)y - 1));
|
||||||
// Calculate the remaining part of the coordinates
|
// Calculate the remaining part of the coordinates
|
||||||
double xl = x - (double)x0;
|
double xl = x - (double)x0;
|
||||||
double yl = y - (double)y0;
|
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)
|
double noise3d_gradient(double x, double y, double z, int seed)
|
||||||
{
|
{
|
||||||
// Calculate the integer coordinates
|
// Calculate the integer coordinates
|
||||||
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
|
int x0 = (x > 0.0 ? (int)x : ((int)x - 1));
|
||||||
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
|
int y0 = (y > 0.0 ? (int)y : ((int)y - 1));
|
||||||
int z0 = (z > 0.0 ? (int)z : (int)z - 1);
|
int z0 = (z > 0.0 ? (int)z : ((int)z - 1));
|
||||||
// Calculate the remaining part of the coordinates
|
// Calculate the remaining part of the coordinates
|
||||||
double xl = x - (double)x0;
|
double xl = x - (double)x0;
|
||||||
double yl = y - (double)y0;
|
double yl = y - (double)y0;
|
||||||
@ -170,7 +170,7 @@ double noise2d_perlin(double x, double y, int seed,
|
|||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
for(int i=0; i<octaves; i++)
|
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;
|
f *= 2.0;
|
||||||
g *= persistence;
|
g *= persistence;
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ double noise2d_perlin_abs(double x, double y, int seed,
|
|||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
for(int i=0; i<octaves; i++)
|
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;
|
f *= 2.0;
|
||||||
g *= persistence;
|
g *= persistence;
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ double noise3d_perlin(double x, double y, double z, int seed,
|
|||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
for(int i=0; i<octaves; i++)
|
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;
|
f *= 2.0;
|
||||||
g *= persistence;
|
g *= persistence;
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ double noise3d_perlin_abs(double x, double y, double z, int seed,
|
|||||||
double g = 1.0;
|
double g = 1.0;
|
||||||
for(int i=0; i<octaves; i++)
|
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;
|
f *= 2.0;
|
||||||
g *= persistence;
|
g *= persistence;
|
||||||
}
|
}
|
||||||
@ -307,9 +307,9 @@ void NoiseBuffer::create(const NoiseParams ¶m,
|
|||||||
m_samplelength_y = samplelength_y;
|
m_samplelength_y = samplelength_y;
|
||||||
m_samplelength_z = samplelength_z;
|
m_samplelength_z = samplelength_z;
|
||||||
|
|
||||||
m_size_x = (last_x - m_start_x)/samplelength_x + 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_y = ((last_y - m_start_y)/samplelength_y) + 2;
|
||||||
m_size_z = (last_z - m_start_z)/samplelength_z + 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];
|
m_data = new double[m_size_x*m_size_y*m_size_z];
|
||||||
|
|
||||||
@ -317,9 +317,9 @@ void NoiseBuffer::create(const NoiseParams ¶m,
|
|||||||
for(int y=0; y<m_size_y; y++)
|
for(int y=0; y<m_size_y; y++)
|
||||||
for(int z=0; z<m_size_z; z++)
|
for(int z=0; z<m_size_z; z++)
|
||||||
{
|
{
|
||||||
double xd = (m_start_x + (double)x*m_samplelength_x);
|
double xd = (m_start_x + ((double)x*m_samplelength_x));
|
||||||
double yd = (m_start_y + (double)y*m_samplelength_y);
|
double yd = (m_start_y + ((double)y*m_samplelength_y));
|
||||||
double zd = (m_start_z + (double)z*m_samplelength_z);
|
double zd = (m_start_z + ((double)z*m_samplelength_z));
|
||||||
double a = noise3d_param(param, xd,yd,zd);
|
double a = noise3d_param(param, xd,yd,zd);
|
||||||
intSet(x,y,z, a);
|
intSet(x,y,z, a);
|
||||||
}
|
}
|
||||||
@ -333,9 +333,9 @@ void NoiseBuffer::multiply(const NoiseParams ¶m)
|
|||||||
for(int y=0; y<m_size_y; y++)
|
for(int y=0; y<m_size_y; y++)
|
||||||
for(int z=0; z<m_size_z; z++)
|
for(int z=0; z<m_size_z; z++)
|
||||||
{
|
{
|
||||||
double xd = (m_start_x + (double)x*m_samplelength_x);
|
double xd = (m_start_x + ((double)x*m_samplelength_x));
|
||||||
double yd = (m_start_y + (double)y*m_samplelength_y);
|
double yd = (m_start_y + ((double)y*m_samplelength_y));
|
||||||
double zd = (m_start_z + (double)z*m_samplelength_z);
|
double zd = (m_start_z + ((double)z*m_samplelength_z));
|
||||||
double a = noise3d_param(param, xd,yd,zd);
|
double a = noise3d_param(param, xd,yd,zd);
|
||||||
intMultiply(x,y,z, a);
|
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)
|
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 >= 0);
|
||||||
assert(i < m_size_x*m_size_y*m_size_z);
|
assert(i < m_size_x*m_size_y*m_size_z);
|
||||||
m_data[i] = d;
|
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)
|
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 >= 0);
|
||||||
assert(i < m_size_x*m_size_y*m_size_z);
|
assert(i < m_size_x*m_size_y*m_size_z);
|
||||||
m_data[i] = m_data[i] * d;
|
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)
|
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 >= 0);
|
||||||
assert(i < m_size_x*m_size_y*m_size_z);
|
assert(i < m_size_x*m_size_y*m_size_z);
|
||||||
return m_data[i];
|
return m_data[i];
|
||||||
|
@ -902,7 +902,7 @@ inline bool is_yes(const std::string &s)
|
|||||||
return false;
|
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());
|
s32 i = atoi(s.c_str());
|
||||||
if(i < min)
|
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
|
// 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());
|
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());
|
return atoi(wide_to_narrow(s).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float stof(std::string s)
|
inline float mystof(std::string s)
|
||||||
{
|
{
|
||||||
float f;
|
float f;
|
||||||
std::istringstream ss(s);
|
std::istringstream ss(s);
|
||||||
@ -934,7 +934,9 @@ inline float stof(std::string s)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#define stoi mystoi
|
||||||
|
#define stof mystof
|
||||||
|
//#endif
|
||||||
|
|
||||||
inline std::string itos(s32 i)
|
inline std::string itos(s32 i)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user