Make fence post selection box smaller and create code to allow node placement to the side of a static box
parent
de51f87e05
commit
e9620d9c8c
|
@ -375,6 +375,9 @@ void content_mapnode_init(ITextureSource *tsrc, IWritableNodeDefManager *nodemgr
|
||||||
f->air_equivalent = true; // grass grows underneath
|
f->air_equivalent = true; // grass grows underneath
|
||||||
f->setInventoryTexture("fence.png", tsrc);
|
f->setInventoryTexture("fence.png", tsrc);
|
||||||
f->used_texturenames.insert("fence.png"); // Add to atlas
|
f->used_texturenames.insert("fence.png"); // Add to atlas
|
||||||
|
f->selection_box.type = NODEBOX_FIXED;
|
||||||
|
f->selection_box.fixed = core::aabbox3d<f32>(
|
||||||
|
-BS/7, -BS/2, -BS/7, BS/7, BS/2, BS/7);
|
||||||
setWoodLikeMaterialProperties(f->material, 0.75);
|
setWoodLikeMaterialProperties(f->material, 0.75);
|
||||||
|
|
||||||
i = CONTENT_RAIL;
|
i = CONTENT_RAIL;
|
||||||
|
|
66
src/game.cpp
66
src/game.cpp
|
@ -348,22 +348,66 @@ void getPointedNode(Client *client, v3f player_position,
|
||||||
|
|
||||||
if(f.selection_box.type == NODEBOX_FIXED)
|
if(f.selection_box.type == NODEBOX_FIXED)
|
||||||
{
|
{
|
||||||
f32 distance = (npf - camera_position).getLength();
|
|
||||||
|
|
||||||
core::aabbox3d<f32> box = f.selection_box.fixed;
|
core::aabbox3d<f32> box = f.selection_box.fixed;
|
||||||
box.MinEdge += npf;
|
box.MinEdge += npf;
|
||||||
box.MaxEdge += npf;
|
box.MaxEdge += npf;
|
||||||
|
|
||||||
if(distance < mindistance)
|
v3s16 facedirs[6] = {
|
||||||
|
v3s16(-1,0,0),
|
||||||
|
v3s16(1,0,0),
|
||||||
|
v3s16(0,-1,0),
|
||||||
|
v3s16(0,1,0),
|
||||||
|
v3s16(0,0,-1),
|
||||||
|
v3s16(0,0,1),
|
||||||
|
};
|
||||||
|
|
||||||
|
core::aabbox3d<f32> faceboxes[6] = {
|
||||||
|
// X-
|
||||||
|
core::aabbox3d<f32>(
|
||||||
|
box.MinEdge.X, box.MinEdge.Y, box.MinEdge.Z,
|
||||||
|
box.MinEdge.X+d, box.MaxEdge.Y, box.MaxEdge.Z
|
||||||
|
),
|
||||||
|
// X+
|
||||||
|
core::aabbox3d<f32>(
|
||||||
|
box.MaxEdge.X-d, box.MinEdge.Y, box.MinEdge.Z,
|
||||||
|
box.MaxEdge.X, box.MaxEdge.Y, box.MaxEdge.Z
|
||||||
|
),
|
||||||
|
// Y-
|
||||||
|
core::aabbox3d<f32>(
|
||||||
|
box.MinEdge.X, box.MinEdge.Y, box.MinEdge.Z,
|
||||||
|
box.MaxEdge.X, box.MinEdge.Y+d, box.MaxEdge.Z
|
||||||
|
),
|
||||||
|
// Y+
|
||||||
|
core::aabbox3d<f32>(
|
||||||
|
box.MinEdge.X, box.MaxEdge.Y-d, box.MinEdge.Z,
|
||||||
|
box.MaxEdge.X, box.MaxEdge.Y, box.MaxEdge.Z
|
||||||
|
),
|
||||||
|
// Z-
|
||||||
|
core::aabbox3d<f32>(
|
||||||
|
box.MinEdge.X, box.MinEdge.Y, box.MinEdge.Z,
|
||||||
|
box.MaxEdge.X, box.MaxEdge.Y, box.MinEdge.Z+d
|
||||||
|
),
|
||||||
|
// Z+
|
||||||
|
core::aabbox3d<f32>(
|
||||||
|
box.MinEdge.X, box.MinEdge.Y, box.MaxEdge.Z-d,
|
||||||
|
box.MaxEdge.X, box.MaxEdge.Y, box.MaxEdge.Z
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
for(u16 i=0; i<6; i++)
|
||||||
{
|
{
|
||||||
if(box.intersectsWithLine(shootline))
|
v3f facedir_f(facedirs[i].X, facedirs[i].Y, facedirs[i].Z);
|
||||||
{
|
v3f centerpoint = npf + facedir_f * BS/2;
|
||||||
nodefound = true;
|
f32 distance = (centerpoint - camera_position).getLength();
|
||||||
nodepos = np;
|
if(distance >= mindistance)
|
||||||
neighbourpos = np;
|
continue;
|
||||||
mindistance = distance;
|
if(!faceboxes[i].intersectsWithLine(shootline))
|
||||||
nodehilightbox = box;
|
continue;
|
||||||
}
|
nodefound = true;
|
||||||
|
nodepos = np;
|
||||||
|
neighbourpos = np+facedirs[i];
|
||||||
|
mindistance = distance;
|
||||||
|
nodehilightbox = box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(f.selection_box.type == NODEBOX_WALLMOUNTED)
|
else if(f.selection_box.type == NODEBOX_WALLMOUNTED)
|
||||||
|
|
Loading…
Reference in New Issue