mirror of https://github.com/minetest/minetest.git
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d288909822
|
@ -12,7 +12,7 @@ set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
|
||||||
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
||||||
set(VERSION_MAJOR 0)
|
set(VERSION_MAJOR 0)
|
||||||
set(VERSION_MINOR 4)
|
set(VERSION_MINOR 4)
|
||||||
set(VERSION_PATCH 4-dev)
|
set(VERSION_PATCH 4)
|
||||||
if(VERSION_EXTRA)
|
if(VERSION_EXTRA)
|
||||||
set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA})
|
set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA})
|
||||||
endif()
|
endif()
|
||||||
|
|
25
README.txt
25
README.txt
|
@ -1,4 +1,4 @@
|
||||||
Minetest-c55
|
Minetest
|
||||||
============
|
============
|
||||||
|
|
||||||
An InfiniMiner/Minecraft inspired game.
|
An InfiniMiner/Minecraft inspired game.
|
||||||
|
@ -15,9 +15,10 @@ See the README.txt in it.
|
||||||
|
|
||||||
Further documentation
|
Further documentation
|
||||||
----------------------
|
----------------------
|
||||||
- Website: http://c55.me/minetest/
|
- Website: http://minetest.net/
|
||||||
- Wiki: http://c55.me/minetest/wiki/
|
- Wiki: http://wiki.minetest.com/
|
||||||
- Forum: http://c55.me/minetest/forum/
|
- Developer wiki: http://minetest.net/wiki/
|
||||||
|
- Forum: http://minetest.net/forum/
|
||||||
- Github: https://github.com/celeron55/minetest/
|
- Github: https://github.com/celeron55/minetest/
|
||||||
- doc/ directory of source distribution
|
- doc/ directory of source distribution
|
||||||
|
|
||||||
|
@ -128,8 +129,8 @@ Compiling on Windows:
|
||||||
* Optional: gettext bibrary and tools:
|
* Optional: gettext bibrary and tools:
|
||||||
http://gnuwin32.sourceforge.net/downlinks/gettext.php
|
http://gnuwin32.sourceforge.net/downlinks/gettext.php
|
||||||
- This is used for other UI languages. Feel free to leave it out.
|
- This is used for other UI languages. Feel free to leave it out.
|
||||||
* And, of course, Minetest-c55:
|
* And, of course, Minetest:
|
||||||
http://c55.me/minetest/download
|
http://minetest.net/download.php
|
||||||
- Steps:
|
- Steps:
|
||||||
- Select a directory called DIR hereafter in which you will operate.
|
- Select a directory called DIR hereafter in which you will operate.
|
||||||
- Make sure you have CMake and a compiler installed.
|
- Make sure you have CMake and a compiler installed.
|
||||||
|
@ -244,19 +245,19 @@ popd
|
||||||
echo Failed.
|
echo Failed.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
|
||||||
License of Minetest-c55 textures and sounds
|
License of Minetest textures and sounds
|
||||||
-------------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
This applies to textures and sounds contained in the main Minetest
|
This applies to textures and sounds contained in the main Minetest
|
||||||
distribution.
|
distribution.
|
||||||
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
License of Minetest-c55 source code
|
License of Minetest source code
|
||||||
-----------------------------------
|
-------------------------------
|
||||||
|
|
||||||
Minetest-c55
|
Minetest
|
||||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
|
|
@ -76,10 +76,10 @@ function minetest.get_node_drops(nodename, toolname)
|
||||||
local drop = ItemStack({name=nodename}):get_definition().drop
|
local drop = ItemStack({name=nodename}):get_definition().drop
|
||||||
if drop == nil then
|
if drop == nil then
|
||||||
-- default drop
|
-- default drop
|
||||||
return {ItemStack({name=nodename})}
|
return {nodename}
|
||||||
elseif type(drop) == "string" then
|
elseif type(drop) == "string" then
|
||||||
-- itemstring drop
|
-- itemstring drop
|
||||||
return {ItemStack(drop)}
|
return {drop}
|
||||||
elseif drop.items == nil then
|
elseif drop.items == nil then
|
||||||
-- drop = {} to disable default drop
|
-- drop = {} to disable default drop
|
||||||
return {}
|
return {}
|
||||||
|
|
|
@ -44,5 +44,9 @@ minetest.register_privilege("fast", {
|
||||||
description = "Can walk fast using the fast_move mode",
|
description = "Can walk fast using the fast_move mode",
|
||||||
give_to_singleplayer = false,
|
give_to_singleplayer = false,
|
||||||
})
|
})
|
||||||
|
minetest.register_privilege("noclip", {
|
||||||
|
description = "Can fly through walls",
|
||||||
|
give_to_singleplayer = false,
|
||||||
|
})
|
||||||
minetest.register_privilege("rollback", "Can use the rollback functionality")
|
minetest.register_privilege("rollback", "Can use the rollback functionality")
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
uniform mat4 mWorldViewProj;
|
uniform mat4 mWorldViewProj;
|
||||||
uniform mat4 mInvWorld;
|
uniform mat4 mInvWorld;
|
||||||
uniform mat4 mTransWorld;
|
uniform mat4 mTransWorld;
|
||||||
|
uniform float dayNightRatio;
|
||||||
|
|
||||||
varying vec3 vPosition;
|
varying vec3 vPosition;
|
||||||
|
|
||||||
|
@ -11,15 +12,47 @@ void main(void)
|
||||||
|
|
||||||
vPosition = (mWorldViewProj * gl_Vertex).xyz;
|
vPosition = (mWorldViewProj * gl_Vertex).xyz;
|
||||||
|
|
||||||
if(gl_Normal.y > 0.5)
|
vec4 color;
|
||||||
gl_FrontColor = gl_BackColor = gl_Color;
|
//color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
else
|
|
||||||
gl_FrontColor = gl_BackColor = gl_Color * 0.7;
|
|
||||||
|
|
||||||
/*if(gl_Normal.y > 0.5)
|
float day = gl_Color.r;
|
||||||
gl_FrontColor = gl_BackColor = vec4(1.0, 1.0, 1.0, 1.0);
|
float night = gl_Color.g;
|
||||||
else
|
float light_source = gl_Color.b;
|
||||||
gl_FrontColor = gl_BackColor = vec4(1.0, 1.0, 1.0, 1.0) * 0.7;*/
|
|
||||||
|
/*color.r = mix(night, day, dayNightRatio);
|
||||||
|
color.g = color.r;
|
||||||
|
color.b = color.r;*/
|
||||||
|
|
||||||
|
float rg = mix(night, day, dayNightRatio);
|
||||||
|
rg += light_source * 1.0; // Make light sources brighter
|
||||||
|
float b = rg;
|
||||||
|
|
||||||
|
// Moonlight is blue
|
||||||
|
b += (day - night) / 13.0;
|
||||||
|
rg -= (day - night) / 13.0;
|
||||||
|
|
||||||
|
// Emphase blue a bit in darker places
|
||||||
|
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||||
|
b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);
|
||||||
|
|
||||||
|
// Artificial light is yellow-ish
|
||||||
|
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||||
|
rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);
|
||||||
|
|
||||||
|
color.r = rg;
|
||||||
|
color.g = rg;
|
||||||
|
color.b = b;
|
||||||
|
|
||||||
|
// Make sides and bottom darker than the top
|
||||||
|
color = color * color; // SRGB -> Linear
|
||||||
|
if(gl_Normal.y <= 0.5)
|
||||||
|
color *= 0.6;
|
||||||
|
//color *= 0.7;
|
||||||
|
color = sqrt(color); // Linear -> SRGB
|
||||||
|
|
||||||
|
color.a = gl_Color.a;
|
||||||
|
|
||||||
|
gl_FrontColor = gl_BackColor = color;
|
||||||
|
|
||||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
uniform mat4 mWorldViewProj;
|
uniform mat4 mWorldViewProj;
|
||||||
uniform mat4 mInvWorld;
|
uniform mat4 mInvWorld;
|
||||||
uniform mat4 mTransWorld;
|
uniform mat4 mTransWorld;
|
||||||
|
uniform float dayNightRatio;
|
||||||
|
|
||||||
varying vec3 vPosition;
|
varying vec3 vPosition;
|
||||||
|
|
||||||
|
@ -13,8 +14,40 @@ void main(void)
|
||||||
|
|
||||||
vPosition = (mWorldViewProj * gl_Vertex).xyz;
|
vPosition = (mWorldViewProj * gl_Vertex).xyz;
|
||||||
|
|
||||||
gl_FrontColor = gl_BackColor = gl_Color;
|
vec4 color;
|
||||||
//gl_FrontColor = gl_BackColor = vec4(1.0, 1.0, 1.0, 1.0);
|
//color = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
|
||||||
|
float day = gl_Color.r;
|
||||||
|
float night = gl_Color.g;
|
||||||
|
float light_source = gl_Color.b;
|
||||||
|
|
||||||
|
/*color.r = mix(night, day, dayNightRatio);
|
||||||
|
color.g = color.r;
|
||||||
|
color.b = color.r;*/
|
||||||
|
|
||||||
|
float rg = mix(night, day, dayNightRatio);
|
||||||
|
rg += light_source * 1.0; // Make light sources brighter
|
||||||
|
float b = rg;
|
||||||
|
|
||||||
|
// Moonlight is blue
|
||||||
|
b += (day - night) / 13.0;
|
||||||
|
rg -= (day - night) / 13.0;
|
||||||
|
|
||||||
|
// Emphase blue a bit in darker places
|
||||||
|
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||||
|
b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);
|
||||||
|
|
||||||
|
// Artificial light is yellow-ish
|
||||||
|
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
|
||||||
|
rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);
|
||||||
|
|
||||||
|
color.r = rg;
|
||||||
|
color.g = rg;
|
||||||
|
color.b = b;
|
||||||
|
|
||||||
|
color.a = gl_Color.a;
|
||||||
|
|
||||||
|
gl_FrontColor = gl_BackColor = color;
|
||||||
|
|
||||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
#bilinear_filter = false
|
#bilinear_filter = false
|
||||||
#trilinear_filter = false
|
#trilinear_filter = false
|
||||||
# Set to true to pre-generate all item visuals
|
# Set to true to pre-generate all item visuals
|
||||||
#preload_item_visuals = false
|
#preload_item_visuals = true
|
||||||
# 0: disable shaders
|
# 0: disable shaders
|
||||||
# (1: low level shaders; not implemented)
|
# (1: low level shaders; not implemented)
|
||||||
# 2: enable high level shaders
|
# 2: enable high level shaders
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
|
#ifndef BASE64_HEADER
|
||||||
|
#define BASE64_HEADER
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
bool base64_is_valid(std::string const& s);
|
bool base64_is_valid(std::string const& s);
|
||||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||||
std::string base64_decode(std::string const& s);
|
std::string base64_decode(std::string const& s);
|
||||||
|
|
||||||
|
#endif // BASE64_HEADER
|
|
@ -544,7 +544,7 @@ void Camera::wield(const ItemStack &item)
|
||||||
void Camera::drawWieldedTool()
|
void Camera::drawWieldedTool()
|
||||||
{
|
{
|
||||||
// Set vertex colors of wield mesh according to light level
|
// Set vertex colors of wield mesh according to light level
|
||||||
u8 li = decode_light(m_wieldlight);
|
u8 li = m_wieldlight;
|
||||||
video::SColor color(255,li,li,li);
|
video::SColor color(255,li,li,li);
|
||||||
setMeshColor(m_wieldnode->getMesh(), color);
|
setMeshColor(m_wieldnode->getMesh(), color);
|
||||||
|
|
||||||
|
|
|
@ -1976,10 +1976,24 @@ void Client::sendPlayerPos()
|
||||||
{
|
{
|
||||||
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
|
//JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
|
||||||
|
|
||||||
Player *myplayer = m_env.getLocalPlayer();
|
LocalPlayer *myplayer = m_env.getLocalPlayer();
|
||||||
if(myplayer == NULL)
|
if(myplayer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Save bandwidth by only updating position when something changed
|
||||||
|
if(myplayer->last_position == myplayer->getPosition() &&
|
||||||
|
myplayer->last_speed == myplayer->getSpeed() &&
|
||||||
|
myplayer->last_pitch == myplayer->getPitch() &&
|
||||||
|
myplayer->last_yaw == myplayer->getYaw() &&
|
||||||
|
myplayer->last_keyPressed == myplayer->keyPressed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
myplayer->last_position = myplayer->getPosition();
|
||||||
|
myplayer->last_speed = myplayer->getSpeed();
|
||||||
|
myplayer->last_pitch = myplayer->getPitch();
|
||||||
|
myplayer->last_yaw = myplayer->getYaw();
|
||||||
|
myplayer->last_keyPressed = myplayer->keyPressed;
|
||||||
|
|
||||||
u16 our_peer_id;
|
u16 our_peer_id;
|
||||||
{
|
{
|
||||||
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
|
//JMutexAutoLock lock(m_con_mutex); //bulk comment-out
|
||||||
|
|
|
@ -352,13 +352,17 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
|
||||||
if(sector_blocks_drawn != 0)
|
if(sector_blocks_drawn != 0)
|
||||||
m_last_drawn_sectors[sp] = true;
|
m_last_drawn_sectors[sp] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_control.blocks_would_have_drawn = blocks_would_have_drawn;
|
||||||
|
m_control.blocks_drawn = blocks_drawn;
|
||||||
|
|
||||||
g_profiler->avg("CM: blocks in range", blocks_in_range);
|
g_profiler->avg("CM: blocks in range", blocks_in_range);
|
||||||
g_profiler->avg("CM: blocks occlusion culled", blocks_occlusion_culled);
|
g_profiler->avg("CM: blocks occlusion culled", blocks_occlusion_culled);
|
||||||
if(blocks_in_range != 0)
|
if(blocks_in_range != 0)
|
||||||
g_profiler->avg("CM: blocks in range without mesh (frac)",
|
g_profiler->avg("CM: blocks in range without mesh (frac)",
|
||||||
(float)blocks_in_range_without_mesh/blocks_in_range);
|
(float)blocks_in_range_without_mesh/blocks_in_range);
|
||||||
g_profiler->avg("CM: blocks drawn", blocks_drawn);
|
g_profiler->avg("CM: blocks drawn", blocks_drawn);
|
||||||
|
g_profiler->avg("CM: wanted max blocks", m_control.wanted_max_blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MeshBufList
|
struct MeshBufList
|
||||||
|
@ -467,9 +471,6 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||||
u32 mesh_animate_count = 0;
|
u32 mesh_animate_count = 0;
|
||||||
u32 mesh_animate_count_far = 0;
|
u32 mesh_animate_count_far = 0;
|
||||||
|
|
||||||
// Blocks that had mesh that would have been drawn according to
|
|
||||||
// rendering range (if max blocks limit didn't kick in)
|
|
||||||
u32 blocks_would_have_drawn = 0;
|
|
||||||
// Blocks that were drawn and had a mesh
|
// Blocks that were drawn and had a mesh
|
||||||
u32 blocks_drawn = 0;
|
u32 blocks_drawn = 0;
|
||||||
// Blocks which had a corresponding meshbuffer for this pass
|
// Blocks which had a corresponding meshbuffer for this pass
|
||||||
|
@ -665,9 +666,6 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
||||||
g_profiler->avg(prefix+"empty blocks (frac)",
|
g_profiler->avg(prefix+"empty blocks (frac)",
|
||||||
(float)blocks_without_stuff / blocks_drawn);
|
(float)blocks_without_stuff / blocks_drawn);
|
||||||
|
|
||||||
m_control.blocks_drawn = blocks_drawn;
|
|
||||||
m_control.blocks_would_have_drawn = blocks_would_have_drawn;
|
|
||||||
|
|
||||||
/*infostream<<"renderMap(): is_transparent_pass="<<is_transparent_pass
|
/*infostream<<"renderMap(): is_transparent_pass="<<is_transparent_pass
|
||||||
<<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
|
<<", rendered "<<vertex_count<<" vertices."<<std::endl;*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 0, data);
|
u16 l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(f.alpha, l);
|
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
|
||||||
|
|
||||||
video::S3DVertex vertices[4] =
|
video::S3DVertex vertices[4] =
|
||||||
{
|
{
|
||||||
|
@ -226,7 +226,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
// Otherwise use the light of this node (the liquid)
|
// Otherwise use the light of this node (the liquid)
|
||||||
else
|
else
|
||||||
l = getInteriorLight(n, 0, data);
|
l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(f.alpha, l);
|
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
|
||||||
|
|
||||||
// Neighbor liquid levels (key = relative position)
|
// Neighbor liquid levels (key = relative position)
|
||||||
// Includes current node
|
// Includes current node
|
||||||
|
@ -544,7 +544,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
AtlasPointer ap = tile.texture;
|
AtlasPointer ap = tile.texture;
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 1, data);
|
u16 l = getInteriorLight(n, 1, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
for(u32 j=0; j<6; j++)
|
for(u32 j=0; j<6; j++)
|
||||||
{
|
{
|
||||||
|
@ -604,7 +604,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
AtlasPointer pa_leaves = tile_leaves.texture;
|
AtlasPointer pa_leaves = tile_leaves.texture;
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 1, data);
|
u16 l = getInteriorLight(n, 1, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
v3f pos = intToFloat(p, BS);
|
v3f pos = intToFloat(p, BS);
|
||||||
aabb3f box(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2);
|
aabb3f box(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2);
|
||||||
|
@ -638,7 +638,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
|
|
||||||
AtlasPointer ap = tile.texture;
|
AtlasPointer ap = tile.texture;
|
||||||
|
|
||||||
video::SColor c(255,255,255,255);
|
u16 l = getInteriorLight(n, 1, data);
|
||||||
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
// Wall at X+ of node
|
// Wall at X+ of node
|
||||||
video::S3DVertex vertices[4] =
|
video::S3DVertex vertices[4] =
|
||||||
|
@ -683,7 +684,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
AtlasPointer ap = tile.texture;
|
AtlasPointer ap = tile.texture;
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 0, data);
|
u16 l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
float d = (float)BS/16;
|
float d = (float)BS/16;
|
||||||
// Wall at X+ of node
|
// Wall at X+ of node
|
||||||
|
@ -730,7 +731,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
AtlasPointer ap = tile.texture;
|
AtlasPointer ap = tile.texture;
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 1, data);
|
u16 l = getInteriorLight(n, 1, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
for(u32 j=0; j<4; j++)
|
for(u32 j=0; j<4; j++)
|
||||||
{
|
{
|
||||||
|
@ -793,7 +794,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
tile.texture.id) + "^[transformR90");
|
tile.texture.id) + "^[transformR90");
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 1, data);
|
u16 l = getInteriorLight(n, 1, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
const f32 post_rad=(f32)BS/8;
|
const f32 post_rad=(f32)BS/8;
|
||||||
const f32 bar_rad=(f32)BS/16;
|
const f32 bar_rad=(f32)BS/16;
|
||||||
|
@ -996,7 +997,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
AtlasPointer ap = tile.texture;
|
AtlasPointer ap = tile.texture;
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 0, data);
|
u16 l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
float d = (float)BS/64;
|
float d = (float)BS/64;
|
||||||
|
|
||||||
|
@ -1045,7 +1046,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 l = getInteriorLight(n, 0, data);
|
u16 l = getInteriorLight(n, 0, data);
|
||||||
video::SColor c = MapBlock_LightColor(255, l);
|
video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
|
||||||
|
|
||||||
v3f pos = intToFloat(p, BS);
|
v3f pos = intToFloat(p, BS);
|
||||||
|
|
||||||
|
|
|
@ -20,23 +20,49 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#ifndef DAYNIGHTRATIO_HEADER
|
#ifndef DAYNIGHTRATIO_HEADER
|
||||||
#define DAYNIGHTRATIO_HEADER
|
#define DAYNIGHTRATIO_HEADER
|
||||||
|
|
||||||
inline u32 time_to_daynight_ratio(u32 time_of_day)
|
inline u32 time_to_daynight_ratio(float time_of_day, bool smooth)
|
||||||
{
|
{
|
||||||
s32 t = time_of_day%24000;
|
float t = time_of_day;
|
||||||
if(t < 4500 || t >= 19500)
|
if(t < 0)
|
||||||
return 150;
|
t += ((int)(-t)/24000)*24000;
|
||||||
else if(t < 4750 || t >= 19250)
|
if(t >= 24000)
|
||||||
return 250;
|
t -= ((int)(t)/24000)*24000;
|
||||||
else if(t < 5000 || t >= 19000)
|
if(t > 12000)
|
||||||
return 350;
|
t = 24000 - t;
|
||||||
else if(t < 5250 || t >= 18750)
|
float values[][2] = {
|
||||||
return 500;
|
{4250+125, 150},
|
||||||
else if(t < 5500 || t >= 18500)
|
{4500+125, 150},
|
||||||
return 675;
|
{4750+125, 250},
|
||||||
else if(t < 5750 || t >= 18250)
|
{5000+125, 350},
|
||||||
return 875;
|
{5250+125, 500},
|
||||||
else
|
{5500+125, 675},
|
||||||
|
{5750+125, 875},
|
||||||
|
{6000+125, 1000},
|
||||||
|
{6250+125, 1000},
|
||||||
|
};
|
||||||
|
if(!smooth){
|
||||||
|
float lastt = values[0][0];
|
||||||
|
for(u32 i=1; i<sizeof(values)/sizeof(*values); i++){
|
||||||
|
float t0 = values[i][0];
|
||||||
|
float switch_t = (t0 + lastt) / 2;
|
||||||
|
lastt = t0;
|
||||||
|
if(switch_t <= t)
|
||||||
|
continue;
|
||||||
|
return values[i][1];
|
||||||
|
}
|
||||||
return 1000;
|
return 1000;
|
||||||
|
} else {
|
||||||
|
for(u32 i=0; i<sizeof(values)/sizeof(*values); i++){
|
||||||
|
if(values[i][0] <= t)
|
||||||
|
continue;
|
||||||
|
if(i == 0)
|
||||||
|
return values[i][1];
|
||||||
|
float td0 = values[i][0] - values[i-1][0];
|
||||||
|
float f = (t - values[i-1][0]) / td0;
|
||||||
|
return f * values[i][1] + (1.0 - f) * values[i-1][1];
|
||||||
|
}
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,6 +43,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
|
settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
|
||||||
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
||||||
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
||||||
|
settings->setDefault("keymap_noclip", "KEY_KEY_H");
|
||||||
settings->setDefault("keymap_screenshot", "KEY_F12");
|
settings->setDefault("keymap_screenshot", "KEY_F12");
|
||||||
settings->setDefault("keymap_toggle_hud", "KEY_F1");
|
settings->setDefault("keymap_toggle_hud", "KEY_F1");
|
||||||
settings->setDefault("keymap_toggle_chat", "KEY_F2");
|
settings->setDefault("keymap_toggle_chat", "KEY_F2");
|
||||||
|
@ -73,7 +74,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("wanted_fps", "30");
|
settings->setDefault("wanted_fps", "30");
|
||||||
settings->setDefault("fps_max", "60");
|
settings->setDefault("fps_max", "60");
|
||||||
// A bit more than the server will send around the player, to make fog blend well
|
// A bit more than the server will send around the player, to make fog blend well
|
||||||
settings->setDefault("viewing_range_nodes_max", "160");
|
settings->setDefault("viewing_range_nodes_max", "240");
|
||||||
settings->setDefault("viewing_range_nodes_min", "35");
|
settings->setDefault("viewing_range_nodes_min", "35");
|
||||||
settings->setDefault("screenW", "800");
|
settings->setDefault("screenW", "800");
|
||||||
settings->setDefault("screenH", "600");
|
settings->setDefault("screenH", "600");
|
||||||
|
@ -95,6 +96,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("shader_path", "");
|
settings->setDefault("shader_path", "");
|
||||||
settings->setDefault("video_driver", "opengl");
|
settings->setDefault("video_driver", "opengl");
|
||||||
settings->setDefault("free_move", "false");
|
settings->setDefault("free_move", "false");
|
||||||
|
settings->setDefault("noclip", "false");
|
||||||
settings->setDefault("continuous_forward", "false");
|
settings->setDefault("continuous_forward", "false");
|
||||||
settings->setDefault("fast_move", "false");
|
settings->setDefault("fast_move", "false");
|
||||||
settings->setDefault("invert_mouse", "false");
|
settings->setDefault("invert_mouse", "false");
|
||||||
|
@ -114,7 +116,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("anisotropic_filter", "false");
|
settings->setDefault("anisotropic_filter", "false");
|
||||||
settings->setDefault("bilinear_filter", "false");
|
settings->setDefault("bilinear_filter", "false");
|
||||||
settings->setDefault("trilinear_filter", "false");
|
settings->setDefault("trilinear_filter", "false");
|
||||||
settings->setDefault("preload_item_visuals", "false");
|
settings->setDefault("preload_item_visuals", "true");
|
||||||
settings->setDefault("enable_shaders", "2");
|
settings->setDefault("enable_shaders", "2");
|
||||||
|
|
||||||
// Server stuff
|
// Server stuff
|
||||||
|
|
|
@ -203,7 +203,8 @@ void Environment::printPlayers(std::ostream &o)
|
||||||
|
|
||||||
u32 Environment::getDayNightRatio()
|
u32 Environment::getDayNightRatio()
|
||||||
{
|
{
|
||||||
return time_to_daynight_ratio(m_time_of_day);
|
bool smooth = (g_settings->getS32("enable_shaders") != 0);
|
||||||
|
return time_to_daynight_ratio(m_time_of_day_f*24000, smooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::stepTimeOfDay(float dtime)
|
void Environment::stepTimeOfDay(float dtime)
|
||||||
|
@ -2132,15 +2133,15 @@ void ClientEnvironment::step(float dtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update lighting on all players on client
|
// Update lighting on all players on client
|
||||||
u8 light = LIGHT_MAX;
|
float light = 1.0;
|
||||||
try{
|
try{
|
||||||
// Get node at head
|
// Get node at head
|
||||||
v3s16 p = player->getLightPosition();
|
v3s16 p = player->getLightPosition();
|
||||||
MapNode n = m_map->getNode(p);
|
MapNode n = m_map->getNode(p);
|
||||||
light = n.getLightBlend(getDayNightRatio(), m_gamedef->ndef());
|
light = n.getLightBlendF1((float)getDayNightRatio()/1000, m_gamedef->ndef());
|
||||||
}
|
}
|
||||||
catch(InvalidPositionException &e){
|
catch(InvalidPositionException &e){
|
||||||
light = blend_light(getDayNightRatio(), LIGHT_SUN, 0);
|
light = blend_light_f1((float)getDayNightRatio()/1000, LIGHT_SUN, 0);
|
||||||
}
|
}
|
||||||
player->light = light;
|
player->light = light;
|
||||||
}
|
}
|
||||||
|
|
53
src/game.cpp
53
src/game.cpp
|
@ -841,13 +841,15 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
||||||
Sky *m_sky;
|
Sky *m_sky;
|
||||||
bool *m_force_fog_off;
|
bool *m_force_fog_off;
|
||||||
f32 *m_fog_range;
|
f32 *m_fog_range;
|
||||||
|
Client *m_client;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
|
GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
|
||||||
f32 *fog_range):
|
f32 *fog_range, Client *client):
|
||||||
m_sky(sky),
|
m_sky(sky),
|
||||||
m_force_fog_off(force_fog_off),
|
m_force_fog_off(force_fog_off),
|
||||||
m_fog_range(fog_range)
|
m_fog_range(fog_range),
|
||||||
|
m_client(client)
|
||||||
{}
|
{}
|
||||||
~GameGlobalShaderConstantSetter() {}
|
~GameGlobalShaderConstantSetter() {}
|
||||||
|
|
||||||
|
@ -873,10 +875,12 @@ public:
|
||||||
if(*m_force_fog_off)
|
if(*m_force_fog_off)
|
||||||
fog_distance = 10000*BS;
|
fog_distance = 10000*BS;
|
||||||
services->setPixelShaderConstant("fogDistance", &fog_distance, 1);
|
services->setPixelShaderConstant("fogDistance", &fog_distance, 1);
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
// Day-night ratio
|
||||||
IrrlichtDevice *m_device;
|
u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
|
||||||
|
float daynight_ratio_f = (float)daynight_ratio / 1000.0;
|
||||||
|
services->setPixelShaderConstant("dayNightRatio", &daynight_ratio_f, 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void the_game(
|
void the_game(
|
||||||
|
@ -1210,7 +1214,7 @@ void the_game(
|
||||||
|
|
||||||
// First line of debug text
|
// First line of debug text
|
||||||
gui::IGUIStaticText *guitext = guienv->addStaticText(
|
gui::IGUIStaticText *guitext = guienv->addStaticText(
|
||||||
L"Minetest-c55",
|
L"Minetest",
|
||||||
core::rect<s32>(5, 5, 795, 5+text_height),
|
core::rect<s32>(5, 5, 795, 5+text_height),
|
||||||
false, false);
|
false, false);
|
||||||
// Second line of debug text
|
// Second line of debug text
|
||||||
|
@ -1307,8 +1311,8 @@ void the_game(
|
||||||
/*
|
/*
|
||||||
Shader constants
|
Shader constants
|
||||||
*/
|
*/
|
||||||
shsrc->addGlobalConstantSetter(
|
shsrc->addGlobalConstantSetter(new GameGlobalShaderConstantSetter(
|
||||||
new GameGlobalShaderConstantSetter(sky, &force_fog_off, &fog_range));
|
sky, &force_fog_off, &fog_range, &client));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Main loop
|
Main loop
|
||||||
|
@ -1661,6 +1665,23 @@ void the_game(
|
||||||
statustext += L" (note: no 'fast' privilege)";
|
statustext += L" (note: no 'fast' privilege)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(input->wasKeyDown(getKeySetting("keymap_noclip")))
|
||||||
|
{
|
||||||
|
if(g_settings->getBool("noclip"))
|
||||||
|
{
|
||||||
|
g_settings->set("noclip","false");
|
||||||
|
statustext = L"noclip disabled";
|
||||||
|
statustext_time = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_settings->set("noclip","true");
|
||||||
|
statustext = L"noclip enabled";
|
||||||
|
statustext_time = 0;
|
||||||
|
if(!client.checkPrivilege("noclip"))
|
||||||
|
statustext += L" (note: no 'noclip' privilege)";
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(input->wasKeyDown(getKeySetting("keymap_screenshot")))
|
else if(input->wasKeyDown(getKeySetting("keymap_screenshot")))
|
||||||
{
|
{
|
||||||
irr::video::IImage* const image = driver->createScreenShot();
|
irr::video::IImage* const image = driver->createScreenShot();
|
||||||
|
@ -2501,8 +2522,7 @@ void the_game(
|
||||||
Calculate general brightness
|
Calculate general brightness
|
||||||
*/
|
*/
|
||||||
u32 daynight_ratio = client.getEnv().getDayNightRatio();
|
u32 daynight_ratio = client.getEnv().getDayNightRatio();
|
||||||
float time_brightness = (float)decode_light(
|
float time_brightness = decode_light_f((float)daynight_ratio/1000.0);
|
||||||
(daynight_ratio * LIGHT_SUN) / 1000) / 255.0;
|
|
||||||
float direct_brightness = 0;
|
float direct_brightness = 0;
|
||||||
bool sunlight_seen = false;
|
bool sunlight_seen = false;
|
||||||
if(g_settings->getBool("free_move")){
|
if(g_settings->getBool("free_move")){
|
||||||
|
@ -2604,7 +2624,7 @@ void the_game(
|
||||||
//TimeTaker guiupdatetimer("Gui updating");
|
//TimeTaker guiupdatetimer("Gui updating");
|
||||||
|
|
||||||
const char program_name_and_version[] =
|
const char program_name_and_version[] =
|
||||||
"Minetest-c55 " VERSION_STRING;
|
"Minetest " VERSION_STRING;
|
||||||
|
|
||||||
if(show_debug)
|
if(show_debug)
|
||||||
{
|
{
|
||||||
|
@ -2955,11 +2975,6 @@ void the_game(
|
||||||
//timer10.stop();
|
//timer10.stop();
|
||||||
//TimeTaker //timer11("//timer11");
|
//TimeTaker //timer11("//timer11");
|
||||||
|
|
||||||
/*
|
|
||||||
Draw gui
|
|
||||||
*/
|
|
||||||
// 0-1ms
|
|
||||||
guienv->drawAll();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Draw hotbar
|
Draw hotbar
|
||||||
|
@ -2985,6 +3000,12 @@ void the_game(
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Draw gui
|
||||||
|
*/
|
||||||
|
// 0-1ms
|
||||||
|
guienv->drawAll();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
End scene
|
End scene
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,6 +46,7 @@ enum
|
||||||
GUI_ID_KEY_FLY_BUTTON,
|
GUI_ID_KEY_FLY_BUTTON,
|
||||||
GUI_ID_KEY_FAST_BUTTON,
|
GUI_ID_KEY_FAST_BUTTON,
|
||||||
GUI_ID_KEY_JUMP_BUTTON,
|
GUI_ID_KEY_JUMP_BUTTON,
|
||||||
|
GUI_ID_KEY_NOCLIP_BUTTON,
|
||||||
GUI_ID_KEY_CHAT_BUTTON,
|
GUI_ID_KEY_CHAT_BUTTON,
|
||||||
GUI_ID_KEY_CMD_BUTTON,
|
GUI_ID_KEY_CMD_BUTTON,
|
||||||
GUI_ID_KEY_CONSOLE_BUTTON,
|
GUI_ID_KEY_CONSOLE_BUTTON,
|
||||||
|
@ -362,6 +363,7 @@ void GUIKeyChangeMenu::init_keys()
|
||||||
this->add_key(GUI_ID_KEY_CONSOLE_BUTTON, "Console", "keymap_console");
|
this->add_key(GUI_ID_KEY_CONSOLE_BUTTON, "Console", "keymap_console");
|
||||||
this->add_key(GUI_ID_KEY_FLY_BUTTON, "Toggle fly", "keymap_freemove");
|
this->add_key(GUI_ID_KEY_FLY_BUTTON, "Toggle fly", "keymap_freemove");
|
||||||
this->add_key(GUI_ID_KEY_FAST_BUTTON, "Toggle fast", "keymap_fastmove");
|
this->add_key(GUI_ID_KEY_FAST_BUTTON, "Toggle fast", "keymap_fastmove");
|
||||||
|
this->add_key(GUI_ID_KEY_NOCLIP_BUTTON, "Toggle noclip", "keymap_noclip");
|
||||||
this->add_key(GUI_ID_KEY_RANGE_BUTTON, "Range select", "keymap_rangeselect");
|
this->add_key(GUI_ID_KEY_RANGE_BUTTON, "Range select", "keymap_rangeselect");
|
||||||
this->add_key(GUI_ID_KEY_DUMP_BUTTON, "Print stacks", "keymap_print_debug_stacks");
|
this->add_key(GUI_ID_KEY_DUMP_BUTTON, "Print stacks", "keymap_print_debug_stacks");
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
||||||
core::rect<s32> rect(0, 0, size.X, 40);
|
core::rect<s32> rect(0, 0, size.X, 40);
|
||||||
rect += v2s32(4, 0);
|
rect += v2s32(4, 0);
|
||||||
Environment->addStaticText(narrow_to_wide(
|
Environment->addStaticText(narrow_to_wide(
|
||||||
"Minetest-c55 " VERSION_STRING).c_str(),
|
"Minetest " VERSION_STRING).c_str(),
|
||||||
rect, false, true, this, -1);
|
rect, false, true, this, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,11 +659,11 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
||||||
core::rect<s32> rect(0, 0, 454, 250);
|
core::rect<s32> rect(0, 0, 454, 250);
|
||||||
rect += m_topleft_client + v2s32(110, 50+35);
|
rect += m_topleft_client + v2s32(110, 50+35);
|
||||||
Environment->addStaticText(narrow_to_wide(
|
Environment->addStaticText(narrow_to_wide(
|
||||||
"Minetest-c55 " VERSION_STRING "\n"
|
"Minetest " VERSION_STRING "\n"
|
||||||
"http://minetest.net/\n"
|
"http://minetest.net/\n"
|
||||||
"\n"
|
"\n"
|
||||||
"by Perttu Ahola <celeron55@gmail.com>\n"
|
"by Perttu Ahola <celeron55@gmail.com>\n"
|
||||||
"and contributors: tango_, kahrl (kaaaaaahrl?), erlehmann (the hippie), SpeedProg, JacobF (sqlite worlds), teddydestodes, marktraceur, darkrose, Jonathan Neuschäfer (who the hell?), Felix Krausse (broke liquids, IIRC), sfan5... and >10 more random people."
|
"and contributors: PilzAdam, Taoki, tango_, kahrl (kaaaaaahrl?), darkrose, matttpt, erlehmann, SpeedProg, JacobF, teddydestodes, marktraceur, Jonathan Neuschäfer, thexyz, VanessaE, sfan5... and tens of more random people."
|
||||||
).c_str(), rect, false, true, this, -1);
|
).c_str(), rect, false, true, this, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,23 +169,8 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
|
||||||
max_texture_size = driver->getMaxTextureSize();
|
max_texture_size = driver->getMaxTextureSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*wchar_t text[200];
|
|
||||||
swprintf(text, 200,
|
|
||||||
L"Minetest-c55\n"
|
|
||||||
L"by Perttu Ahola\n"
|
|
||||||
L"celeron55@gmail.com\n\n"
|
|
||||||
SWPRINTF_CHARSTRING L"\n"
|
|
||||||
L"userdata path = "
|
|
||||||
SWPRINTF_CHARSTRING
|
|
||||||
,
|
|
||||||
BUILD_INFO,
|
|
||||||
porting::path_user.c_str()
|
|
||||||
);*/
|
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os<<"Minetest\n";
|
os<<"Minetest\n";
|
||||||
os<<"by Perttu Ahola and contributors\n";
|
|
||||||
os<<"celeron55@gmail.com\n";
|
|
||||||
os<<BUILD_INFO<<"\n";
|
os<<BUILD_INFO<<"\n";
|
||||||
os<<"path_user = "<<wrap_rows(porting::path_user, 20)<<"\n";
|
os<<"path_user = "<<wrap_rows(porting::path_user, 20)<<"\n";
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#endif
|
#endif
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "main.h" // g_settings
|
||||||
|
#include "settings.h"
|
||||||
#include "util/serialize.h"
|
#include "util/serialize.h"
|
||||||
#include "util/container.h"
|
#include "util/container.h"
|
||||||
#include "util/thread.h"
|
#include "util/thread.h"
|
||||||
|
@ -356,7 +358,10 @@ public:
|
||||||
|
|
||||||
scene::IMesh *node_mesh = mapblock_mesh.getMesh();
|
scene::IMesh *node_mesh = mapblock_mesh.getMesh();
|
||||||
assert(node_mesh);
|
assert(node_mesh);
|
||||||
setMeshColor(node_mesh, video::SColor(255, 255, 255, 255));
|
video::SColor c(255, 255, 255, 255);
|
||||||
|
if(g_settings->getS32("enable_shaders") != 0)
|
||||||
|
c = MapBlock_LightColor(255, 0xffff, decode_light(f.light_source));
|
||||||
|
setMeshColor(node_mesh, c);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Scale and translate the mesh so it's a unit cube
|
Scale and translate the mesh so it's a unit cube
|
||||||
|
|
28
src/light.h
28
src/light.h
|
@ -85,6 +85,24 @@ inline u8 decode_light(u8 light)
|
||||||
return light_decode_table[light];
|
return light_decode_table[light];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0.0 <= light <= 1.0
|
||||||
|
// 0.0 <= return value <= 1.0
|
||||||
|
inline float decode_light_f(float light_f)
|
||||||
|
{
|
||||||
|
s32 i = (u32)(light_f * LIGHT_MAX + 0.5);
|
||||||
|
|
||||||
|
if(i <= 0)
|
||||||
|
return (float)light_decode_table[0] / 255.0;
|
||||||
|
if(i >= LIGHT_MAX)
|
||||||
|
return (float)light_decode_table[LIGHT_MAX] / 255.0;
|
||||||
|
|
||||||
|
float v1 = (float)light_decode_table[i-1] / 255.0;
|
||||||
|
float v2 = (float)light_decode_table[i] / 255.0;
|
||||||
|
float f0 = (float)i - 0.5;
|
||||||
|
float f = light_f * LIGHT_MAX - f0;
|
||||||
|
return f * v2 + (1.0 - f) * v1;
|
||||||
|
}
|
||||||
|
|
||||||
// 0 <= daylight_factor <= 1000
|
// 0 <= daylight_factor <= 1000
|
||||||
// 0 <= lightday, lightnight <= LIGHT_SUN
|
// 0 <= lightday, lightnight <= LIGHT_SUN
|
||||||
// 0 <= return value <= LIGHT_SUN
|
// 0 <= return value <= LIGHT_SUN
|
||||||
|
@ -97,5 +115,15 @@ inline u8 blend_light(u32 daylight_factor, u8 lightday, u8 lightnight)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0.0 <= daylight_factor <= 1.0
|
||||||
|
// 0 <= lightday, lightnight <= LIGHT_SUN
|
||||||
|
// 0 <= return value <= 255
|
||||||
|
inline u8 blend_light_f1(float daylight_factor, u8 lightday, u8 lightnight)
|
||||||
|
{
|
||||||
|
u8 l = ((daylight_factor * decode_light(lightday) +
|
||||||
|
(1.0-daylight_factor) * decode_light(lightnight)));
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,11 @@ LocalPlayer::LocalPlayer(IGameDef *gamedef):
|
||||||
Player(gamedef),
|
Player(gamedef),
|
||||||
isAttached(false),
|
isAttached(false),
|
||||||
overridePosition(v3f(0,0,0)),
|
overridePosition(v3f(0,0,0)),
|
||||||
|
last_position(v3f(0,0,0)),
|
||||||
|
last_speed(v3f(0,0,0)),
|
||||||
|
last_pitch(0),
|
||||||
|
last_yaw(0),
|
||||||
|
last_keyPressed(0),
|
||||||
m_sneak_node(32767,32767,32767),
|
m_sneak_node(32767,32767,32767),
|
||||||
m_sneak_node_exists(false),
|
m_sneak_node_exists(false),
|
||||||
m_old_node_below(32767,32767,32767),
|
m_old_node_below(32767,32767,32767),
|
||||||
|
@ -68,9 +73,11 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip collision detection if a special movement mode is used
|
// Skip collision detection if noclip mode is used
|
||||||
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
|
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
|
||||||
bool free_move = fly_allowed && g_settings->getBool("free_move");
|
bool noclip = m_gamedef->checkLocalPrivilege("noclip") &&
|
||||||
|
g_settings->getBool("noclip");
|
||||||
|
bool free_move = noclip && fly_allowed && g_settings->getBool("free_move");
|
||||||
if(free_move)
|
if(free_move)
|
||||||
{
|
{
|
||||||
position += m_speed * dtime;
|
position += m_speed * dtime;
|
||||||
|
@ -295,7 +302,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
|
||||||
Report collisions
|
Report collisions
|
||||||
*/
|
*/
|
||||||
bool bouncy_jump = false;
|
bool bouncy_jump = false;
|
||||||
if(collision_info)
|
// Dont report if flying
|
||||||
|
if(collision_info && !g_settings->getBool("free_move"))
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<result.collisions.size(); i++){
|
for(size_t i=0; i<result.collisions.size(); i++){
|
||||||
const CollisionInfo &info = result.collisions[i];
|
const CollisionInfo &info = result.collisions[i];
|
||||||
|
|
|
@ -44,6 +44,14 @@ public:
|
||||||
void applyControl(float dtime);
|
void applyControl(float dtime);
|
||||||
|
|
||||||
v3s16 getStandingNodePos();
|
v3s16 getStandingNodePos();
|
||||||
|
|
||||||
|
// Used to check if anything changed and prevent sending packets if not
|
||||||
|
v3f last_position;
|
||||||
|
v3f last_speed;
|
||||||
|
float last_pitch;
|
||||||
|
float last_yaw;
|
||||||
|
unsigned int last_keyPressed;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This is used for determining the sneaking range
|
// This is used for determining the sneaking range
|
||||||
v3s16 m_sneak_node;
|
v3s16 m_sneak_node;
|
||||||
|
|
|
@ -1349,7 +1349,13 @@ int main(int argc, char *argv[])
|
||||||
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0));
|
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255,0,0,0));
|
||||||
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255,70,100,50));
|
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255,70,100,50));
|
||||||
skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255,255,255,255));
|
skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255,255,255,255));
|
||||||
|
|
||||||
|
#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
|
||||||
|
// Irrlicht 1.8 input colours
|
||||||
|
skin->setColor(gui::EGDC_EDITABLE, video::SColor(255,128,128,128));
|
||||||
|
skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255,96,134,49));
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GUI stuff
|
GUI stuff
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,6 +32,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "util/directiontables.h"
|
#include "util/directiontables.h"
|
||||||
|
|
||||||
|
float srgb_linear_multiply(float f, float m, float max)
|
||||||
|
{
|
||||||
|
f = f * f; // SRGB -> Linear
|
||||||
|
f *= m;
|
||||||
|
f = sqrt(f); // Linear -> SRGB
|
||||||
|
if(f > max)
|
||||||
|
f = max;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MeshMakeData
|
MeshMakeData
|
||||||
*/
|
*/
|
||||||
|
@ -435,7 +445,7 @@ struct FastFace
|
||||||
};
|
};
|
||||||
|
|
||||||
static void makeFastFace(TileSpec tile, u16 li0, u16 li1, u16 li2, u16 li3,
|
static void makeFastFace(TileSpec tile, u16 li0, u16 li1, u16 li2, u16 li3,
|
||||||
v3f p, v3s16 dir, v3f scale, core::array<FastFace> &dest)
|
v3f p, v3s16 dir, v3f scale, u8 light_source, core::array<FastFace> &dest)
|
||||||
{
|
{
|
||||||
FastFace face;
|
FastFace face;
|
||||||
|
|
||||||
|
@ -477,16 +487,16 @@ static void makeFastFace(TileSpec tile, u16 li0, u16 li1, u16 li2, u16 li3,
|
||||||
float h = tile.texture.size.Y;
|
float h = tile.texture.size.Y;
|
||||||
|
|
||||||
face.vertices[0] = video::S3DVertex(vertex_pos[0], normal,
|
face.vertices[0] = video::S3DVertex(vertex_pos[0], normal,
|
||||||
MapBlock_LightColor(alpha, li0),
|
MapBlock_LightColor(alpha, li0, light_source),
|
||||||
core::vector2d<f32>(x0+w*abs_scale, y0+h));
|
core::vector2d<f32>(x0+w*abs_scale, y0+h));
|
||||||
face.vertices[1] = video::S3DVertex(vertex_pos[1], normal,
|
face.vertices[1] = video::S3DVertex(vertex_pos[1], normal,
|
||||||
MapBlock_LightColor(alpha, li1),
|
MapBlock_LightColor(alpha, li1, light_source),
|
||||||
core::vector2d<f32>(x0, y0+h));
|
core::vector2d<f32>(x0, y0+h));
|
||||||
face.vertices[2] = video::S3DVertex(vertex_pos[2], normal,
|
face.vertices[2] = video::S3DVertex(vertex_pos[2], normal,
|
||||||
MapBlock_LightColor(alpha, li2),
|
MapBlock_LightColor(alpha, li2, light_source),
|
||||||
core::vector2d<f32>(x0, y0));
|
core::vector2d<f32>(x0, y0));
|
||||||
face.vertices[3] = video::S3DVertex(vertex_pos[3], normal,
|
face.vertices[3] = video::S3DVertex(vertex_pos[3], normal,
|
||||||
MapBlock_LightColor(alpha, li3),
|
MapBlock_LightColor(alpha, li3, light_source),
|
||||||
core::vector2d<f32>(x0+w*abs_scale, y0));
|
core::vector2d<f32>(x0+w*abs_scale, y0));
|
||||||
|
|
||||||
face.tile = tile;
|
face.tile = tile;
|
||||||
|
@ -658,7 +668,8 @@ static void getTileInfo(
|
||||||
v3s16 &p_corrected,
|
v3s16 &p_corrected,
|
||||||
v3s16 &face_dir_corrected,
|
v3s16 &face_dir_corrected,
|
||||||
u16 *lights,
|
u16 *lights,
|
||||||
TileSpec &tile
|
TileSpec &tile,
|
||||||
|
u8 &light_source
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VoxelManipulator &vmanip = data->m_vmanip;
|
VoxelManipulator &vmanip = data->m_vmanip;
|
||||||
|
@ -688,18 +699,20 @@ static void getTileInfo(
|
||||||
tile = tile0;
|
tile = tile0;
|
||||||
p_corrected = p;
|
p_corrected = p;
|
||||||
face_dir_corrected = face_dir;
|
face_dir_corrected = face_dir;
|
||||||
|
light_source = ndef->get(n0).light_source;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tile = tile1;
|
tile = tile1;
|
||||||
p_corrected = p + face_dir;
|
p_corrected = p + face_dir;
|
||||||
face_dir_corrected = -face_dir;
|
face_dir_corrected = -face_dir;
|
||||||
|
light_source = ndef->get(n1).light_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eg. water and glass
|
// eg. water and glass
|
||||||
if(equivalent)
|
if(equivalent)
|
||||||
tile.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
|
tile.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
|
||||||
|
|
||||||
if(data->m_smooth_lighting == false)
|
if(data->m_smooth_lighting == false)
|
||||||
{
|
{
|
||||||
lights[0] = lights[1] = lights[2] = lights[3] =
|
lights[0] = lights[1] = lights[2] = lights[3] =
|
||||||
|
@ -743,9 +756,10 @@ static void updateFastFaceRow(
|
||||||
v3s16 face_dir_corrected;
|
v3s16 face_dir_corrected;
|
||||||
u16 lights[4] = {0,0,0,0};
|
u16 lights[4] = {0,0,0,0};
|
||||||
TileSpec tile;
|
TileSpec tile;
|
||||||
|
u8 light_source = 0;
|
||||||
getTileInfo(data, p, face_dir,
|
getTileInfo(data, p, face_dir,
|
||||||
makes_face, p_corrected, face_dir_corrected,
|
makes_face, p_corrected, face_dir_corrected,
|
||||||
lights, tile);
|
lights, tile, light_source);
|
||||||
|
|
||||||
for(u16 j=0; j<MAP_BLOCKSIZE; j++)
|
for(u16 j=0; j<MAP_BLOCKSIZE; j++)
|
||||||
{
|
{
|
||||||
|
@ -759,6 +773,7 @@ static void updateFastFaceRow(
|
||||||
v3s16 next_face_dir_corrected;
|
v3s16 next_face_dir_corrected;
|
||||||
u16 next_lights[4] = {0,0,0,0};
|
u16 next_lights[4] = {0,0,0,0};
|
||||||
TileSpec next_tile;
|
TileSpec next_tile;
|
||||||
|
u8 next_light_source = 0;
|
||||||
|
|
||||||
// If at last position, there is nothing to compare to and
|
// If at last position, there is nothing to compare to and
|
||||||
// the face must be drawn anyway
|
// the face must be drawn anyway
|
||||||
|
@ -769,7 +784,7 @@ static void updateFastFaceRow(
|
||||||
getTileInfo(data, p_next, face_dir,
|
getTileInfo(data, p_next, face_dir,
|
||||||
next_makes_face, next_p_corrected,
|
next_makes_face, next_p_corrected,
|
||||||
next_face_dir_corrected, next_lights,
|
next_face_dir_corrected, next_lights,
|
||||||
next_tile);
|
next_tile, next_light_source);
|
||||||
|
|
||||||
if(next_makes_face == makes_face
|
if(next_makes_face == makes_face
|
||||||
&& next_p_corrected == p_corrected + translate_dir
|
&& next_p_corrected == p_corrected + translate_dir
|
||||||
|
@ -778,7 +793,8 @@ static void updateFastFaceRow(
|
||||||
&& next_lights[1] == lights[1]
|
&& next_lights[1] == lights[1]
|
||||||
&& next_lights[2] == lights[2]
|
&& next_lights[2] == lights[2]
|
||||||
&& next_lights[3] == lights[3]
|
&& next_lights[3] == lights[3]
|
||||||
&& next_tile == tile)
|
&& next_tile == tile
|
||||||
|
&& next_light_source == light_source)
|
||||||
{
|
{
|
||||||
next_is_different = false;
|
next_is_different = false;
|
||||||
}
|
}
|
||||||
|
@ -854,7 +870,7 @@ static void updateFastFaceRow(
|
||||||
}
|
}
|
||||||
|
|
||||||
makeFastFace(tile, lights[0], lights[1], lights[2], lights[3],
|
makeFastFace(tile, lights[0], lights[1], lights[2], lights[3],
|
||||||
sp, face_dir_corrected, scale,
|
sp, face_dir_corrected, scale, light_source,
|
||||||
dest);
|
dest);
|
||||||
|
|
||||||
g_profiler->avg("Meshgen: faces drawn by tiling", 0);
|
g_profiler->avg("Meshgen: faces drawn by tiling", 0);
|
||||||
|
@ -873,6 +889,7 @@ static void updateFastFaceRow(
|
||||||
lights[2] = next_lights[2];
|
lights[2] = next_lights[2];
|
||||||
lights[3] = next_lights[3];
|
lights[3] = next_lights[3];
|
||||||
tile = next_tile;
|
tile = next_tile;
|
||||||
|
light_source = next_light_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = p_next;
|
p = p_next;
|
||||||
|
@ -1058,18 +1075,28 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
|
||||||
os<<"^[verticalframe:"<<(int)p.tile.animation_frame_count<<":0";
|
os<<"^[verticalframe:"<<(int)p.tile.animation_frame_count<<":0";
|
||||||
p.tile.texture = tsrc->getTexture(os.str());
|
p.tile.texture = tsrc->getTexture(os.str());
|
||||||
}
|
}
|
||||||
// - Lighting
|
// - Classic lighting (shaders handle this by themselves)
|
||||||
for(u32 j = 0; j < p.vertices.size(); j++)
|
if(!enable_shaders)
|
||||||
{
|
{
|
||||||
video::SColor &vc = p.vertices[j].Color;
|
for(u32 j = 0; j < p.vertices.size(); j++)
|
||||||
u8 day = vc.getRed();
|
{
|
||||||
u8 night = vc.getGreen();
|
video::SColor &vc = p.vertices[j].Color;
|
||||||
finalColorBlend(vc, day, night, 1000);
|
// Set initial real color and store for later updates
|
||||||
if(day != night)
|
u8 day = vc.getRed();
|
||||||
m_daynight_diffs[i][j] = std::make_pair(day, night);
|
u8 night = vc.getGreen();
|
||||||
|
finalColorBlend(vc, day, night, 1000);
|
||||||
|
if(day != night)
|
||||||
|
m_daynight_diffs[i][j] = std::make_pair(day, night);
|
||||||
|
// Brighten topside (no shaders)
|
||||||
|
if(p.vertices[j].Normal.Y > 0.5)
|
||||||
|
{
|
||||||
|
vc.setRed (srgb_linear_multiply(vc.getRed(), 1.3, 255.0));
|
||||||
|
vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.3, 255.0));
|
||||||
|
vc.setBlue (srgb_linear_multiply(vc.getBlue(), 1.3, 255.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create material
|
// Create material
|
||||||
video::SMaterial material;
|
video::SMaterial material;
|
||||||
material.setFlag(video::EMF_LIGHTING, false);
|
material.setFlag(video::EMF_LIGHTING, false);
|
||||||
|
@ -1220,6 +1247,14 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
|
||||||
u8 night = j->second.second;
|
u8 night = j->second.second;
|
||||||
finalColorBlend(vertices[vertexIndex].Color,
|
finalColorBlend(vertices[vertexIndex].Color,
|
||||||
day, night, daynight_ratio);
|
day, night, daynight_ratio);
|
||||||
|
// Brighten topside (no shaders)
|
||||||
|
if(vertices[vertexIndex].Normal.Y > 0.5)
|
||||||
|
{
|
||||||
|
video::SColor &vc = vertices[vertexIndex].Color;
|
||||||
|
vc.setRed (srgb_linear_multiply(vc.getRed(), 1.3, 255.0));
|
||||||
|
vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.3, 255.0));
|
||||||
|
vc.setBlue (srgb_linear_multiply(vc.getBlue(), 1.3, 255.0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_last_daynight_ratio = daynight_ratio;
|
m_last_daynight_ratio = daynight_ratio;
|
||||||
|
|
|
@ -160,9 +160,10 @@ struct MeshCollector
|
||||||
// alpha in the A channel of the returned SColor
|
// alpha in the A channel of the returned SColor
|
||||||
// day light (0-255) in the R channel of the returned SColor
|
// day light (0-255) in the R channel of the returned SColor
|
||||||
// night light (0-255) in the G channel of the returned SColor
|
// night light (0-255) in the G channel of the returned SColor
|
||||||
inline video::SColor MapBlock_LightColor(u8 alpha, u16 light)
|
// light source (0-255) in the B channel of the returned SColor
|
||||||
|
inline video::SColor MapBlock_LightColor(u8 alpha, u16 light, u8 light_source=0)
|
||||||
{
|
{
|
||||||
return video::SColor(alpha, (light & 0xff), (light >> 8), 0);
|
return video::SColor(alpha, (light & 0xff), (light >> 8), light_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute light at node
|
// Compute light at node
|
||||||
|
|
|
@ -163,6 +163,16 @@ struct MapNode
|
||||||
return blend_light(daylight_factor, lightday, lightnight);
|
return blend_light(daylight_factor, lightday, lightnight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0.0 <= daylight_factor <= 1.0
|
||||||
|
// 0 <= return value <= LIGHT_SUN
|
||||||
|
u8 getLightBlendF1(float daylight_factor, INodeDefManager *nodemgr) const
|
||||||
|
{
|
||||||
|
u8 lightday = 0;
|
||||||
|
u8 lightnight = 0;
|
||||||
|
getLightBanks(lightday, lightnight, nodemgr);
|
||||||
|
return blend_light_f1(daylight_factor, lightday, lightnight);
|
||||||
|
}
|
||||||
|
|
||||||
u8 getFaceDir(INodeDefManager *nodemgr) const;
|
u8 getFaceDir(INodeDefManager *nodemgr) const;
|
||||||
u8 getWallMounted(INodeDefManager *nodemgr) const;
|
u8 getWallMounted(INodeDefManager *nodemgr) const;
|
||||||
v3s16 getWallMountedDir(INodeDefManager *nodemgr) const;
|
v3s16 getWallMountedDir(INodeDefManager *nodemgr) const;
|
||||||
|
|
|
@ -443,7 +443,7 @@ video::ITexture *generateTextureFromMesh(scene::IMesh *mesh,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set render target
|
// Set render target
|
||||||
driver->setRenderTarget(rtt, true, true, video::SColor(0,0,0,0));
|
driver->setRenderTarget(rtt, false, true, video::SColor(0,0,0,0));
|
||||||
|
|
||||||
// Get a scene manager
|
// Get a scene manager
|
||||||
scene::ISceneManager *smgr_main = device->getSceneManager();
|
scene::ISceneManager *smgr_main = device->getSceneManager();
|
||||||
|
@ -478,7 +478,7 @@ video::ITexture *generateTextureFromMesh(scene::IMesh *mesh,
|
||||||
smgr->drop();
|
smgr->drop();
|
||||||
|
|
||||||
// Unset render target
|
// Unset render target
|
||||||
driver->setRenderTarget(0, true, true, 0);
|
driver->setRenderTarget(0, false, true, 0);
|
||||||
|
|
||||||
return rtt;
|
return rtt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 keyPressed;
|
u32 keyPressed;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IGameDef *m_gamedef;
|
IGameDef *m_gamedef;
|
||||||
|
|
||||||
|
|
|
@ -3604,7 +3604,7 @@ private:
|
||||||
if(lua_isnumber(L, 3))
|
if(lua_isnumber(L, 3))
|
||||||
time_of_day = 24000.0 * lua_tonumber(L, 3);
|
time_of_day = 24000.0 * lua_tonumber(L, 3);
|
||||||
time_of_day %= 24000;
|
time_of_day %= 24000;
|
||||||
u32 dnr = time_to_daynight_ratio(time_of_day);
|
u32 dnr = time_to_daynight_ratio(time_of_day, true);
|
||||||
MapNode n = env->getMap().getNodeNoEx(pos);
|
MapNode n = env->getMap().getNodeNoEx(pos);
|
||||||
try{
|
try{
|
||||||
MapNode n = env->getMap().getNode(pos);
|
MapNode n = env->getMap().getNode(pos);
|
||||||
|
|
|
@ -60,7 +60,7 @@ inline void writeU8(u8 *data, u8 i)
|
||||||
data[0] = ((i>> 0)&0xff);
|
data[0] = ((i>> 0)&0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u64 readU64(u8 *data)
|
inline u64 readU64(const u8 *data)
|
||||||
{
|
{
|
||||||
return ((u64)data[0]<<56) | ((u64)data[1]<<48)
|
return ((u64)data[0]<<56) | ((u64)data[1]<<48)
|
||||||
| ((u64)data[2]<<40) | ((u64)data[3]<<32)
|
| ((u64)data[2]<<40) | ((u64)data[3]<<32)
|
||||||
|
@ -68,17 +68,17 @@ inline u64 readU64(u8 *data)
|
||||||
| ((u64)data[6]<<8) | ((u64)data[7]<<0);
|
| ((u64)data[6]<<8) | ((u64)data[7]<<0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 readU32(u8 *data)
|
inline u32 readU32(const u8 *data)
|
||||||
{
|
{
|
||||||
return (data[0]<<24) | (data[1]<<16) | (data[2]<<8) | (data[3]<<0);
|
return (data[0]<<24) | (data[1]<<16) | (data[2]<<8) | (data[3]<<0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u16 readU16(u8 *data)
|
inline u16 readU16(const u8 *data)
|
||||||
{
|
{
|
||||||
return (data[0]<<8) | (data[1]<<0);
|
return (data[0]<<8) | (data[1]<<0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u8 readU8(u8 *data)
|
inline u8 readU8(const u8 *data)
|
||||||
{
|
{
|
||||||
return (data[0]<<0);
|
return (data[0]<<0);
|
||||||
}
|
}
|
||||||
|
@ -86,28 +86,28 @@ inline u8 readU8(u8 *data)
|
||||||
inline void writeS32(u8 *data, s32 i){
|
inline void writeS32(u8 *data, s32 i){
|
||||||
writeU32(data, (u32)i);
|
writeU32(data, (u32)i);
|
||||||
}
|
}
|
||||||
inline s32 readS32(u8 *data){
|
inline s32 readS32(const u8 *data){
|
||||||
return (s32)readU32(data);
|
return (s32)readU32(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void writeS16(u8 *data, s16 i){
|
inline void writeS16(u8 *data, s16 i){
|
||||||
writeU16(data, (u16)i);
|
writeU16(data, (u16)i);
|
||||||
}
|
}
|
||||||
inline s16 readS16(u8 *data){
|
inline s16 readS16(const u8 *data){
|
||||||
return (s16)readU16(data);
|
return (s16)readU16(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void writeS8(u8 *data, s8 i){
|
inline void writeS8(u8 *data, s8 i){
|
||||||
writeU8(data, (u8)i);
|
writeU8(data, (u8)i);
|
||||||
}
|
}
|
||||||
inline s8 readS8(u8 *data){
|
inline s8 readS8(const u8 *data){
|
||||||
return (s8)readU8(data);
|
return (s8)readU8(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void writeF1000(u8 *data, f32 i){
|
inline void writeF1000(u8 *data, f32 i){
|
||||||
writeS32(data, i*1000);
|
writeS32(data, i*1000);
|
||||||
}
|
}
|
||||||
inline f32 readF1000(u8 *data){
|
inline f32 readF1000(const u8 *data){
|
||||||
return (f32)readS32(data)/1000.;
|
return (f32)readS32(data)/1000.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ inline void writeV3S32(u8 *data, v3s32 p)
|
||||||
writeS32(&data[4], p.Y);
|
writeS32(&data[4], p.Y);
|
||||||
writeS32(&data[8], p.Z);
|
writeS32(&data[8], p.Z);
|
||||||
}
|
}
|
||||||
inline v3s32 readV3S32(u8 *data)
|
inline v3s32 readV3S32(const u8 *data)
|
||||||
{
|
{
|
||||||
v3s32 p;
|
v3s32 p;
|
||||||
p.X = readS32(&data[0]);
|
p.X = readS32(&data[0]);
|
||||||
|
@ -132,7 +132,7 @@ inline void writeV3F1000(u8 *data, v3f p)
|
||||||
writeF1000(&data[4], p.Y);
|
writeF1000(&data[4], p.Y);
|
||||||
writeF1000(&data[8], p.Z);
|
writeF1000(&data[8], p.Z);
|
||||||
}
|
}
|
||||||
inline v3f readV3F1000(u8 *data)
|
inline v3f readV3F1000(const u8 *data)
|
||||||
{
|
{
|
||||||
v3f p;
|
v3f p;
|
||||||
p.X = (float)readF1000(&data[0]);
|
p.X = (float)readF1000(&data[0]);
|
||||||
|
@ -146,7 +146,7 @@ inline void writeV2F1000(u8 *data, v2f p)
|
||||||
writeF1000(&data[0], p.X);
|
writeF1000(&data[0], p.X);
|
||||||
writeF1000(&data[4], p.Y);
|
writeF1000(&data[4], p.Y);
|
||||||
}
|
}
|
||||||
inline v2f readV2F1000(u8 *data)
|
inline v2f readV2F1000(const u8 *data)
|
||||||
{
|
{
|
||||||
v2f p;
|
v2f p;
|
||||||
p.X = (float)readF1000(&data[0]);
|
p.X = (float)readF1000(&data[0]);
|
||||||
|
@ -160,7 +160,7 @@ inline void writeV2S16(u8 *data, v2s16 p)
|
||||||
writeS16(&data[2], p.Y);
|
writeS16(&data[2], p.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline v2s16 readV2S16(u8 *data)
|
inline v2s16 readV2S16(const u8 *data)
|
||||||
{
|
{
|
||||||
v2s16 p;
|
v2s16 p;
|
||||||
p.X = readS16(&data[0]);
|
p.X = readS16(&data[0]);
|
||||||
|
@ -174,7 +174,7 @@ inline void writeV2S32(u8 *data, v2s32 p)
|
||||||
writeS32(&data[2], p.Y);
|
writeS32(&data[2], p.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline v2s32 readV2S32(u8 *data)
|
inline v2s32 readV2S32(const u8 *data)
|
||||||
{
|
{
|
||||||
v2s32 p;
|
v2s32 p;
|
||||||
p.X = readS32(&data[0]);
|
p.X = readS32(&data[0]);
|
||||||
|
@ -189,7 +189,7 @@ inline void writeV3S16(u8 *data, v3s16 p)
|
||||||
writeS16(&data[4], p.Z);
|
writeS16(&data[4], p.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline v3s16 readV3S16(u8 *data)
|
inline v3s16 readV3S16(const u8 *data)
|
||||||
{
|
{
|
||||||
v3s16 p;
|
v3s16 p;
|
||||||
p.X = readS16(&data[0]);
|
p.X = readS16(&data[0]);
|
||||||
|
@ -206,7 +206,7 @@ inline void writeARGB8(u8 *data, video::SColor p)
|
||||||
writeU8(&data[3], p.getBlue());
|
writeU8(&data[3], p.getBlue());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline video::SColor readARGB8(u8 *data)
|
inline video::SColor readARGB8(const u8 *data)
|
||||||
{
|
{
|
||||||
video::SColor p;
|
video::SColor p;
|
||||||
p.setAlpha(readU8(&data[0]));
|
p.setAlpha(readU8(&data[0]));
|
||||||
|
|
Loading…
Reference in New Issue