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
709f4a50
Commit
709f4a50
authored
10 years ago
by
SmallJoker
Committed by
Zeno-
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Connect rails with connect_to_raillike and shorten the codes
parent
03e0dd33
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
+49
-107
49 additions, 107 deletions
src/content_mapblock.cpp
with
49 additions
and
107 deletions
src/content_mapblock.cpp
+
49
−
107
View file @
709f4a50
...
...
@@ -1398,97 +1398,42 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
break
;}
case
NDT_RAILLIKE
:
{
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
));
bool
is_rail_x
[
6
];
/* (-1,-1,0) X (1,-1,0) (-1,0,0) X (1,0,0) (-1,1,0) X (1,1,0) */
bool
is_rail_z
[
6
];
content_t
thiscontent
=
n
.
getContent
();
std
::
string
groupname
=
"connect_to_raillike"
;
// name of the group that enables connecting to raillike nodes of different kind
int
self_group
=
((
ItemGroupList
)
nodedef
->
get
(
n
).
groups
)[
groupname
];
if
((
nodedef
->
get
(
n_minus_x
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_minus_x
).
groups
)[
groupname
]
!=
self_group
)
||
n_minus_x
.
getContent
()
==
thiscontent
)
is_rail_x
[
0
]
=
true
;
if
((
nodedef
->
get
(
n_minus_x_minus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_minus_x_minus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_minus_x_minus_y
.
getContent
()
==
thiscontent
)
is_rail_x_minus_y
[
0
]
=
true
;
if
((
nodedef
->
get
(
n_minus_x_plus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_minus_x_plus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_minus_x_plus_y
.
getContent
()
==
thiscontent
)
is_rail_x_plus_y
[
0
]
=
true
;
if
((
nodedef
->
get
(
n_plus_x
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_plus_x
).
groups
)[
groupname
]
!=
self_group
)
||
n_plus_x
.
getContent
()
==
thiscontent
)
is_rail_x
[
1
]
=
true
;
if
((
nodedef
->
get
(
n_plus_x_minus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_plus_x_minus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_plus_x_minus_y
.
getContent
()
==
thiscontent
)
is_rail_x_minus_y
[
1
]
=
true
;
if
((
nodedef
->
get
(
n_plus_x_plus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_plus_x_plus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_plus_x_plus_y
.
getContent
()
==
thiscontent
)
is_rail_x_plus_y
[
1
]
=
true
;
if
((
nodedef
->
get
(
n_minus_z
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_minus_z
).
groups
)[
groupname
]
!=
self_group
)
||
n_minus_z
.
getContent
()
==
thiscontent
)
is_rail_z
[
0
]
=
true
;
if
((
nodedef
->
get
(
n_minus_z_minus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_minus_z_minus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_minus_z_minus_y
.
getContent
()
==
thiscontent
)
is_rail_z_minus_y
[
0
]
=
true
;
if
((
nodedef
->
get
(
n_minus_z_plus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_minus_z_plus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_minus_z_plus_y
.
getContent
()
==
thiscontent
)
is_rail_z_plus_y
[
0
]
=
true
;
if
((
nodedef
->
get
(
n_plus_z
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_plus_z
).
groups
)[
groupname
]
!=
self_group
)
||
n_plus_z
.
getContent
()
==
thiscontent
)
is_rail_z
[
1
]
=
true
;
if
((
nodedef
->
get
(
n_plus_z_minus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_plus_z_minus_y
).
groups
)[
groupname
]
!=
self_group
)
||
n_plus_z_minus_y
.
getContent
()
==
thiscontent
)
is_rail_z_minus_y
[
1
]
=
true
;
if
((
nodedef
->
get
(
n_plus_z_plus_y
).
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
nodedef
->
get
(
n_plus_z_plus_y
).
groups
)[
groupname
]
!=
self_group
)
||
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
];
u8
index
=
0
;
for
(
s8
y0
=
-
1
;
y0
<=
1
;
y0
++
)
{
// Prevent from indexing never used coordinates
for
(
s8
xz
=
-
1
;
xz
<=
1
;
xz
++
)
{
if
(
xz
==
0
)
continue
;
MapNode
n_xy
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
+
xz
,
y
+
y0
,
z
));
MapNode
n_zy
=
data
->
m_vmanip
.
getNodeNoEx
(
blockpos_nodes
+
v3s16
(
x
,
y
+
y0
,
z
+
xz
));
ContentFeatures
def_xy
=
nodedef
->
get
(
n_xy
);
ContentFeatures
def_zy
=
nodedef
->
get
(
n_zy
);
// Check if current node would connect with the rail
is_rail_x
[
index
]
=
((
def_xy
.
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
def_xy
.
groups
)[
groupname
]
==
self_group
)
||
n_xy
.
getContent
()
==
thiscontent
);
is_rail_z
[
index
]
=
((
def_zy
.
drawtype
==
NDT_RAILLIKE
&&
((
ItemGroupList
)
def_zy
.
groups
)[
groupname
]
==
self_group
)
||
n_zy
.
getContent
()
==
thiscontent
);
index
++
;
}
}
bool
is_rail_x_all
[
2
];
// [0] = negative x, [1] = positive x coordinate from the current node position
bool
is_rail_z_all
[
2
];
is_rail_x_all
[
0
]
=
is_rail_x
[
0
]
||
is_rail_x
[
2
]
||
is_rail_x
[
4
];
is_rail_x_all
[
1
]
=
is_rail_x
[
1
]
||
is_rail_x
[
3
]
||
is_rail_x
[
5
];
is_rail_z_all
[
0
]
=
is_rail_z
[
0
]
||
is_rail_z
[
2
]
||
is_rail_z
[
4
];
is_rail_z_all
[
1
]
=
is_rail_z
[
1
]
||
is_rail_z
[
3
]
||
is_rail_z
[
5
];
// reasonable default, flat straight unrotated rail
bool
is_straight
=
true
;
...
...
@@ -1497,13 +1442,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
u8
tileindex
=
0
;
// check for sloped rail
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
])
{
adjacencies
=
5
;
//5 means sloped
if
(
is_rail_x
[
4
]
||
is_rail_x
[
5
]
||
is_rail_z
[
4
]
||
is_rail_z
[
5
])
{
adjacencies
=
5
;
// 5 means sloped
is_straight
=
true
;
// sloped is always straight
}
else
{
}
else
{
// is really straight, rails on both sides
is_straight
=
(
is_rail_x_all
[
0
]
&&
is_rail_x_all
[
1
])
||
(
is_rail_z_all
[
0
]
&&
is_rail_z_all
[
1
]);
adjacencies
=
is_rail_x_all
[
0
]
+
is_rail_x_all
[
1
]
+
is_rail_z_all
[
0
]
+
is_rail_z_all
[
1
];
...
...
@@ -1511,44 +1453,44 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
switch
(
adjacencies
)
{
case
1
:
if
(
is_rail_x_all
[
0
]
||
is_rail_x_all
[
1
])
if
(
is_rail_x_all
[
0
]
||
is_rail_x_all
[
1
])
angle
=
90
;
break
;
case
2
:
if
(
!
is_straight
)
if
(
!
is_straight
)
tileindex
=
1
;
// curved
if
(
is_rail_x_all
[
0
]
&&
is_rail_x_all
[
1
])
if
(
is_rail_x_all
[
0
]
&&
is_rail_x_all
[
1
])
angle
=
90
;
if
(
is_rail_z_all
[
0
]
&&
is_rail_z_all
[
1
]){
if
(
is_rail_z
_plus_y
[
0
])
if
(
is_rail_z_all
[
0
]
&&
is_rail_z_all
[
1
])
{
if
(
is_rail_z
[
4
])
angle
=
180
;
}
else
if
(
is_rail_x_all
[
0
]
&&
is_rail_z_all
[
0
])
else
if
(
is_rail_x_all
[
0
]
&&
is_rail_z_all
[
0
])
angle
=
270
;
else
if
(
is_rail_x_all
[
0
]
&&
is_rail_z_all
[
1
])
else
if
(
is_rail_x_all
[
0
]
&&
is_rail_z_all
[
1
])
angle
=
180
;
else
if
(
is_rail_x_all
[
1
]
&&
is_rail_z_all
[
1
])
else
if
(
is_rail_x_all
[
1
]
&&
is_rail_z_all
[
1
])
angle
=
90
;
break
;
case
3
:
// here is where the potential to 'switch' a junction is, but not implemented at present
tileindex
=
2
;
// t-junction
if
(
!
is_rail_x_all
[
1
])
angle
=
180
;
angle
=
180
;
if
(
!
is_rail_z_all
[
0
])
angle
=
90
;
angle
=
90
;
if
(
!
is_rail_z_all
[
1
])
angle
=
270
;
angle
=
270
;
break
;
case
4
:
tileindex
=
3
;
// crossing
break
;
case
5
:
//sloped
if
(
is_rail_z
_plus_y
[
0
])
if
(
is_rail_z
[
4
])
angle
=
180
;
if
(
is_rail_x
_plus_y
[
0
])
if
(
is_rail_x
[
4
])
angle
=
90
;
if
(
is_rail_x
_plus_y
[
1
])
if
(
is_rail_x
[
5
])
angle
=
-
90
;
break
;
default
:
...
...
@@ -1566,7 +1508,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
float
s
=
BS
/
2
;
short
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
])
if
(
is_rail_x
[
4
]
||
is_rail_x
[
5
]
||
is_rail_z
[
4
]
||
is_rail_z
[
5
])
g
=
1
;
//Object is at a slope
video
::
S3DVertex
vertices
[
4
]
=
...
...
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