Skip to content

Instantly share code, notes, and snippets.

@sofar
Last active December 16, 2015 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sofar/88701507cadbe7199f10 to your computer and use it in GitHub Desktop.
Save sofar/88701507cadbe7199f10 to your computer and use it in GitHub Desktop.
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp
index 01a06b6..f9daca3 100644
--- a/src/content_mapblock.cpp
+++ b/src/content_mapblock.cpp
@@ -1294,7 +1294,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
const f32 post_rad=(f32)BS/8;
const f32 bar_rad=(f32)BS/16;
- const f32 bar_len=(f32)(BS/2)-post_rad;
v3f pos = intToFloat(p, BS);
@@ -1316,19 +1315,20 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
p2.X++;
MapNode n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
const ContentFeatures *f2 = &nodedef->get(n2);
- if(f2->drawtype == NDT_FENCELIKE)
+#if 0
+ if(f2->drawtype == NDT_FENCELIKE || f2->drawtype == NDT_NORMAL || f2->drawtype == NDT_GLASSLIKE_FRAMED)
{
- aabb3f bar(-bar_len+BS/2,-bar_rad+BS/4,-bar_rad,
- bar_len+BS/2,bar_rad+BS/4,bar_rad);
+ aabb3f bar(post_rad, -bar_rad+BS/4, -bar_rad,
+ BS/2, bar_rad+BS/4, bar_rad);
bar.MinEdge += pos;
bar.MaxEdge += pos;
f32 xrailuv[24]={
- 0/16.,2/16.,16/16.,4/16.,
- 0/16.,4/16.,16/16.,6/16.,
- 6/16.,6/16.,8/16.,8/16.,
- 10/16.,10/16.,12/16.,12/16.,
- 0/16.,8/16.,16/16.,10/16.,
- 0/16.,14/16.,16/16.,16/16.};
+ 10/16.,0/16.,16/16.,2/16., // xzxz +y
+ 10/16.,0/16.,16/16.,2/16., // xzxz -y
+ 6/16.,6/16.,8/16.,8/16., // yzyz +x
+ 10/16.,10/16.,12/16.,12/16., // yzyz -x
+ 10/16.,2/16.,16/16.,4/16., // xyxy +x
+ 10/16.,14/16.,16/16.,16/16.}; // xyxy -x
makeCuboid(&collector, bar, &tile_nocrack, 1,
c, xrailuv);
bar.MinEdge.Y -= BS/2;
@@ -1336,16 +1336,70 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
makeCuboid(&collector, bar, &tile_nocrack, 1,
c, xrailuv);
}
+#endif
+ // Now a section of fence, -X, if there's a post there
+ p2 = p;
+ p2.X--;
+ n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
+ f2 = &nodedef->get(n2);
+ if(f2->drawtype == NDT_FENCELIKE || f2->drawtype == NDT_NORMAL || f2->drawtype == NDT_GLASSLIKE_FRAMED)
+ {
+ aabb3f bar(-post_rad, -bar_rad+BS/4, -bar_rad,
+ -BS/2, bar_rad+BS/4, bar_rad);
+ bar.MinEdge += pos;
+ bar.MaxEdge += pos;
+ f32 xrailuv[24]={
+ 8/16.,8/16.,14/16.,10/16., // xzxz +y
+ 8/16.,12/16.,14/16.,14/16., // xzxz -y
+ 14/16.,8/16.,16/16.,10/16., // yzyz +x
+ 6/16.,8/16.,8/16.,10/16., // yzyz -x
+ 8/16.,10/16.,14/16.,12/16., // xyxy +z
+ 8/16.,14/16.,14/16.,16/16.}; // xyxy -z
+ makeCuboid(&collector, bar, &tile_nocrack, 1,
+ c, xrailuv);
+ bar.MinEdge.Y -= BS/2;
+ bar.MaxEdge.Y -= BS/2;
+ makeCuboid(&collector, bar, &tile_nocrack, 1,
+ c, xrailuv);
+ }
+
+#if 0
// Now a section of fence, +Z, if there's a post there
p2 = p;
p2.Z++;
n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
f2 = &nodedef->get(n2);
- if(f2->drawtype == NDT_FENCELIKE)
+ if(f2->drawtype == NDT_FENCELIKE || f2->drawtype == NDT_NORMAL || f2->drawtype == NDT_GLASSLIKE_FRAMED)
+ {
+ aabb3f bar(-bar_rad,-bar_rad+BS/4,post_rad,
+ bar_rad,bar_rad+BS/4,BS/2);
+ bar.MinEdge += pos;
+ bar.MaxEdge += pos;
+ f32 zrailuv[24]={
+ 3/16.,1/16.,5/16.,5/16., // cannot rotate; stretch
+ 4/16.,1/16.,6/16.,5/16., // for wood texture instead
+ 0/16.,9/16.,16/16.,11/16.,
+ 0/16.,6/16.,16/16.,8/16.,
+ 6/16.,6/16.,8/16.,8/16.,
+ 10/16.,10/16.,12/16.,12/16.};
+ makeCuboid(&collector, bar, &tile_nocrack, 1,
+ c, zrailuv);
+ bar.MinEdge.Y -= BS/2;
+ bar.MaxEdge.Y -= BS/2;
+ makeCuboid(&collector, bar, &tile_nocrack, 1,
+ c, zrailuv);
+ }
+
+ // Now a section of fence, -Z, if there's a post there
+ p2 = p;
+ p2.Z--;
+ n2 = data->m_vmanip.getNodeNoEx(blockpos_nodes + p2);
+ f2 = &nodedef->get(n2);
+ if(f2->drawtype == NDT_FENCELIKE || f2->drawtype == NDT_NORMAL || f2->drawtype == NDT_GLASSLIKE_FRAMED)
{
- aabb3f bar(-bar_rad,-bar_rad+BS/4,-bar_len+BS/2,
- bar_rad,bar_rad+BS/4,bar_len+BS/2);
+ aabb3f bar(-bar_rad,-bar_rad+BS/4,-BS/2,
+ bar_rad,bar_rad+BS/4,-post_rad);
bar.MinEdge += pos;
bar.MaxEdge += pos;
f32 zrailuv[24]={
@@ -1362,6 +1416,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
makeCuboid(&collector, bar, &tile_nocrack, 1,
c, zrailuv);
}
+#endif
break;}
case NDT_RAILLIKE:
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment