Skip to content

Commit 3295f3c

Browse files
committedAug 5, 2015
Fix tiling issues for PLANTLIKE and FIRELIKE with FSAA
1 parent 7a6e4dc commit 3295f3c

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed
 

Diff for: ‎src/client/tile.h

+19-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ enum MaterialType{
168168
// defined by extra parameters
169169
#define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
170170
#define MATERIAL_FLAG_HIGHLIGHTED 0x10
171+
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
172+
#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
171173

172174
/*
173175
This fully defines the looks of a tile.
@@ -216,7 +218,9 @@ struct TileSpec
216218
alpha == other.alpha &&
217219
material_type == other.material_type &&
218220
material_flags == other.material_flags &&
219-
rotation == other.rotation
221+
rotation == other.rotation &&
222+
(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) &&
223+
(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)
220224
);
221225
}
222226

@@ -250,12 +254,26 @@ struct TileSpec
250254
}
251255
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
252256
? true : false;
257+
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
258+
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
259+
}
260+
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
261+
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
262+
}
253263
}
254264

255265
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
256266
{
257267
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
258268
? true : false;
269+
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
270+
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
271+
material.TextureLayer[1].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
272+
}
273+
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
274+
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
275+
material.TextureLayer[1].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
276+
}
259277
}
260278

261279
u32 texture_id;

Diff for: ‎src/nodedef.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1014,14 +1014,18 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
10141014
}
10151015
tile->flags_texture = tsrc->getShaderFlagsTexture(
10161016
tile->normal_texture ? true : false,
1017-
tiledef->tileable_horizontal, tiledef->tileable_vertical);
1017+
tiledef->tileable_vertical, tiledef->tileable_horizontal);
10181018

10191019
// Material flags
10201020
tile->material_flags = 0;
10211021
if (backface_culling)
10221022
tile->material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
10231023
if (tiledef->animation.type == TAT_VERTICAL_FRAMES)
10241024
tile->material_flags |= MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES;
1025+
if (tiledef->tileable_horizontal)
1026+
tile->material_flags |= MATERIAL_FLAG_TILEABLE_HORIZONTAL;
1027+
if (tiledef->tileable_vertical)
1028+
tile->material_flags |= MATERIAL_FLAG_TILEABLE_VERTICAL;
10251029

10261030
// Animation parameters
10271031
int frame_count = 1;

Diff for: ‎src/script/common/c_content.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,20 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
258258
}
259259

260260
/******************************************************************************/
261-
TileDef read_tiledef(lua_State *L, int index)
261+
TileDef read_tiledef(lua_State *L, int index, u8 drawtype)
262262
{
263263
if(index < 0)
264264
index = lua_gettop(L) + 1 + index;
265265

266266
TileDef tiledef;
267-
267+
bool default_tiling = (drawtype == NDT_PLANTLIKE || drawtype == NDT_FIRELIKE)
268+
? false : true;
268269
// key at index -2 and value at index
269270
if(lua_isstring(L, index)){
270271
// "default_lava.png"
271272
tiledef.name = lua_tostring(L, index);
273+
tiledef.tileable_vertical = default_tiling;
274+
tiledef.tileable_horizontal = default_tiling;
272275
}
273276
else if(lua_istable(L, index))
274277
{
@@ -279,9 +282,9 @@ TileDef read_tiledef(lua_State *L, int index)
279282
tiledef.backface_culling = getboolfield_default(
280283
L, index, "backface_culling", true);
281284
tiledef.tileable_horizontal = getboolfield_default(
282-
L, index, "tileable_horizontal", true);
285+
L, index, "tileable_horizontal", default_tiling);
283286
tiledef.tileable_vertical = getboolfield_default(
284-
L, index, "tileable_vertical", true);
287+
L, index, "tileable_vertical", default_tiling);
285288
// animation = {}
286289
lua_getfield(L, index, "animation");
287290
if(lua_istable(L, -1)){
@@ -357,7 +360,7 @@ ContentFeatures read_content_features(lua_State *L, int index)
357360
int i = 0;
358361
while(lua_next(L, table) != 0){
359362
// Read tiledef from value
360-
f.tiledef[i] = read_tiledef(L, -1);
363+
f.tiledef[i] = read_tiledef(L, -1, f.drawtype);
361364
// removes value, keeps key for next iteration
362365
lua_pop(L, 1);
363366
i++;
@@ -392,7 +395,7 @@ ContentFeatures read_content_features(lua_State *L, int index)
392395
int i = 0;
393396
while(lua_next(L, table) != 0){
394397
// Read tiledef from value
395-
f.tiledef_special[i] = read_tiledef(L, -1);
398+
f.tiledef_special[i] = read_tiledef(L, -1, f.drawtype);
396399
// removes value, keeps key for next iteration
397400
lua_pop(L, 1);
398401
i++;

Diff for: ‎src/script/common/c_content.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class Schematic;
6363

6464

6565
ContentFeatures read_content_features (lua_State *L, int index);
66-
TileDef read_tiledef (lua_State *L, int index);
66+
TileDef read_tiledef (lua_State *L, int index,
67+
u8 drawtype);
6768
void read_soundspec (lua_State *L, int index,
6869
SimpleSoundSpec &spec);
6970
NodeBox read_nodebox (lua_State *L, int index);

0 commit comments

Comments
 (0)