Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
f2129121
Commit
f2129121
authored
13 years ago
by
Jeija
Committed by
Perttu Ahola
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve raillike drawtype
parent
d834d6e0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/content_mapblock.cpp
+91
-22
91 additions, 22 deletions
src/content_mapblock.cpp
with
91 additions
and
22 deletions
src/content_mapblock.cpp
+
91
−
22
View file @
f2129121
...
...
@@ -883,22 +883,69 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
bool
is_rail_x
[]
=
{
false
,
false
};
/* x-1, x+1 */
bool
is_rail_z
[]
=
{
false
,
false
};
/* z-1, z+1 */
bool
is_rail_z_minus_y
[]
=
{
false
,
false
};
/* z-1, z+1; y-1 */
bool
is_rail_x_minus_y
[]
=
{
false
,
false
};
/* x-1, z+1; y-1 */
bool
is_rail_z_plus_y
[]
=
{
false
,
false
};
/* z-1, z+1; y+1 */
bool
is_rail_x_plus_y
[]
=
{
false
,
false
};
/* x-1, x+1; y+1 */
MapNode
n_minus_x
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
-
1
,
y
,
z
));
MapNode
n_plus_x
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
+
1
,
y
,
z
));
MapNode
n_minus_z
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
,
z
-
1
));
MapNode
n_plus_z
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
,
z
+
1
));
MapNode
n_plus_x_plus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
+
1
,
y
+
1
,
z
));
MapNode
n_plus_x_minus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
+
1
,
y
-
1
,
z
));
MapNode
n_minus_x_plus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
-
1
,
y
+
1
,
z
));
MapNode
n_minus_x_minus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
-
1
,
y
-
1
,
z
));
MapNode
n_plus_z_plus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
+
1
,
z
+
1
));
MapNode
n_minus_z_plus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
+
1
,
z
-
1
));
MapNode
n_plus_z_minus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
-
1
,
z
+
1
));
MapNode
n_minus_z_minus_y
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
-
1
,
z
-
1
));
content_t
thiscontent
=
n
.
getContent
();
if
(
n_minus_x
.
getContent
()
==
thiscontent
)
is_rail_x
[
0
]
=
true
;
if
(
n_minus_x_minus_y
.
getContent
()
==
thiscontent
)
is_rail_x_minus_y
[
0
]
=
true
;
if
(
n_minus_x_plus_y
.
getContent
()
==
thiscontent
)
is_rail_x_plus_y
[
0
]
=
true
;
if
(
n_plus_x
.
getContent
()
==
thiscontent
)
is_rail_x
[
1
]
=
true
;
if
(
n_plus_x_minus_y
.
getContent
()
==
thiscontent
)
is_rail_x_minus_y
[
1
]
=
true
;
if
(
n_plus_x_plus_y
.
getContent
()
==
thiscontent
)
is_rail_x_plus_y
[
1
]
=
true
;
if
(
n_minus_z
.
getContent
()
==
thiscontent
)
is_rail_z
[
0
]
=
true
;
if
(
n_minus_z_minus_y
.
getContent
()
==
thiscontent
)
is_rail_z_minus_y
[
0
]
=
true
;
if
(
n_minus_z_plus_y
.
getContent
()
==
thiscontent
)
is_rail_z_plus_y
[
0
]
=
true
;
if
(
n_plus_z
.
getContent
()
==
thiscontent
)
is_rail_z
[
1
]
=
true
;
if
(
n_plus_z_minus_y
.
getContent
()
==
thiscontent
)
is_rail_z_minus_y
[
1
]
=
true
;
if
(
n_plus_z_plus_y
.
getContent
()
==
thiscontent
)
is_rail_z_plus_y
[
1
]
=
true
;
bool
is_rail_x_all
[]
=
{
false
,
false
};
bool
is_rail_z_all
[]
=
{
false
,
false
};
is_rail_x_all
[
0
]
=
is_rail_x
[
0
]
||
is_rail_x_minus_y
[
0
]
||
is_rail_x_plus_y
[
0
];
is_rail_x_all
[
1
]
=
is_rail_x
[
1
]
||
is_rail_x_minus_y
[
1
]
||
is_rail_x_plus_y
[
1
];
is_rail_z_all
[
0
]
=
is_rail_z
[
0
]
||
is_rail_z_minus_y
[
0
]
||
is_rail_z_plus_y
[
0
];
is_rail_z_all
[
1
]
=
is_rail_z
[
1
]
||
is_rail_z_minus_y
[
1
]
||
is_rail_z_plus_y
[
1
];
bool
is_straight
=
(
is_rail_x_all
[
0
]
&&
is_rail_x_all
[
1
])
||
(
is_rail_z_all
[
0
]
&&
is_rail_z_all
[
1
]);
//is really straight, rails on both sides
int
adjacencies
=
is_rail_x_all
[
0
]
+
is_rail_x_all
[
1
]
+
is_rail_z_all
[
0
]
+
is_rail_z_all
[
1
];
int
adjacencies
=
is_rail_x
[
0
]
+
is_rail_x
[
1
]
+
is_rail_z
[
0
]
+
is_rail_z
[
1
];
if
(
is_rail_x_plus_y
[
0
]
||
is_rail_x_plus_y
[
1
]
||
is_rail_z_plus_y
[
0
]
||
is_rail_z_plus_y
[
1
])
//is straight because sloped
{
adjacencies
=
5
;
//5 means sloped
is_straight
=
true
;
}
// Assign textures
AtlasPointer
ap
=
f
.
tiles
[
0
].
texture
;
// straight
...
...
@@ -906,7 +953,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
ap
=
f
.
tiles
[
0
].
texture
;
// straight
else
if
(
adjacencies
==
2
)
{
if
(
(
is_
rail_x
[
0
]
&&
is_rail_x
[
1
])
||
(
is_rail_z
[
0
]
&&
is_rail_z
[
1
])
)
if
(
is_
straight
)
ap
=
f
.
tiles
[
0
].
texture
;
// straight
else
ap
=
f
.
tiles
[
1
].
texture
;
// curved
...
...
@@ -928,49 +975,71 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
u8
l
=
decode_light
(
n
.
getLightBlend
(
data
->
m_daynight_ratio
,
nodedef
));
video
::
SColor
c
=
MapBlock_LightColor
(
255
,
l
);
float
d
=
(
float
)
BS
/
16
;
float
d
=
(
float
)
BS
/
64
;
char
g
=-
1
;
if
(
is_rail_x_plus_y
[
0
]
||
is_rail_x_plus_y
[
1
]
||
is_rail_z_plus_y
[
0
]
||
is_rail_z_plus_y
[
1
])
g
=
1
;
//Object is at a slope
video
::
S3DVertex
vertices
[
4
]
=
{
video
::
S3DVertex
(
-
BS
/
2
,
-
BS
/
2
+
d
,
-
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x0
(),
ap
.
y1
()),
video
::
S3DVertex
(
BS
/
2
,
-
BS
/
2
+
d
,
-
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x1
(),
ap
.
y1
()),
video
::
S3DVertex
(
BS
/
2
,
-
BS
/
2
+
d
,
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x1
(),
ap
.
y0
()),
video
::
S3DVertex
(
-
BS
/
2
,
-
BS
/
2
+
d
,
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x0
(),
ap
.
y0
()),
video
::
S3DVertex
(
-
BS
/
2
,
-
BS
/
2
+
d
,
-
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x0
(),
ap
.
y1
()),
video
::
S3DVertex
(
BS
/
2
,
-
BS
/
2
+
d
,
-
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x1
(),
ap
.
y1
()),
video
::
S3DVertex
(
BS
/
2
,
g
*
BS
/
2
+
d
,
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x1
(),
ap
.
y0
()),
video
::
S3DVertex
(
-
BS
/
2
,
g
*
BS
/
2
+
d
,
BS
/
2
,
0
,
0
,
0
,
c
,
ap
.
x0
(),
ap
.
y0
()),
};
// Rotate textures
int
angle
=
0
;
if
(
adjacencies
==
1
)
{
if
(
is_rail_x
[
0
]
||
is_rail_x
[
1
])
if
(
is_rail_x
_all
[
0
]
or
is_rail_x
_all
[
1
])
angle
=
90
;
}
else
if
(
adjacencies
==
2
)
if
(
adjacencies
==
2
)
{
if
(
is_rail_x
[
0
]
&&
is_rail_x
[
1
])
if
(
is_rail_x_all
[
0
]
&&
is_rail_x_all
[
1
])
{
angle
=
90
;
else
if
(
is_rail_x
[
0
]
&&
is_rail_z
[
0
])
}
if
(
is_rail_z_all
[
0
]
&&
is_rail_z_all
[
1
])
{
if
(
n_minus_z_plus_y
.
getContent
()
==
thiscontent
)
angle
=
180
;
}
else
if
(
is_rail_x_all
[
0
]
&&
is_rail_z_all
[
0
])
angle
=
270
;
else
if
(
is_rail_x
[
0
]
&&
is_rail_z
[
1
])
else
if
(
is_rail_x
_all
[
0
]
&&
is_rail_z
_all
[
1
])
angle
=
180
;
else
if
(
is_rail_x
[
1
]
&&
is_rail_z
[
1
])
else
if
(
is_rail_x
_all
[
1
]
&&
is_rail_z
_all
[
1
])
angle
=
90
;
}
else
if
(
adjacencies
==
3
)
if
(
adjacencies
==
3
)
{
if
(
!
is_rail_x
[
0
])
if
(
!
is_rail_x
_all
[
0
])
angle
=
0
;
if
(
!
is_rail_x
[
1
])
if
(
!
is_rail_x
_all
[
1
])
angle
=
180
;
if
(
!
is_rail_z
[
0
])
if
(
!
is_rail_z
_all
[
0
])
angle
=
90
;
if
(
!
is_rail_z
[
1
])
if
(
!
is_rail_z
_all
[
1
])
angle
=
270
;
}
//adjacencies 4: Crossing
if
(
adjacencies
==
5
)
//sloped
{
if
(
is_rail_z_plus_y
[
0
])
angle
=
180
;
if
(
is_rail_x_plus_y
[
0
])
angle
=
90
;
if
(
is_rail_x_plus_y
[
1
])
angle
=
-
90
;
}
if
(
angle
!=
0
)
{
for
(
u16
i
=
0
;
i
<
4
;
i
++
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment