mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Cleanup selection mesh code, add shaders for halo and selection boxes
This commit is contained in:
parent
430195381d
commit
b44da4916a
21 changed files with 336 additions and 304 deletions
42
src/mesh.cpp
42
src/mesh.cpp
|
@ -405,9 +405,11 @@ scene::IMesh* cloneMesh(scene::IMesh *src_mesh)
|
|||
return dst_mesh;
|
||||
}
|
||||
|
||||
scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
|
||||
scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
|
||||
const f32 *uv_coords)
|
||||
{
|
||||
scene::SMesh* dst_mesh = new scene::SMesh();
|
||||
|
||||
for (u16 j = 0; j < 6; j++)
|
||||
{
|
||||
scene::IMeshBuffer *buf = new scene::SMeshBuffer();
|
||||
|
@ -416,12 +418,10 @@ scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
|
|||
dst_mesh->addMeshBuffer(buf);
|
||||
buf->drop();
|
||||
}
|
||||
|
||||
|
||||
video::SColor c(255,255,255,255);
|
||||
|
||||
std::vector<aabb3f> boxes = f->node_box.fixed;
|
||||
|
||||
for(std::vector<aabb3f>::iterator
|
||||
for(std::vector<aabb3f>::const_iterator
|
||||
i = boxes.begin();
|
||||
i != boxes.end(); ++i)
|
||||
{
|
||||
|
@ -446,27 +446,33 @@ scene::IMesh* convertNodeboxNodeToMesh(ContentFeatures *f)
|
|||
box.MinEdge.Z=box.MaxEdge.Z;
|
||||
box.MaxEdge.Z=temp;
|
||||
}
|
||||
// Compute texture coords
|
||||
f32 tx1 = (box.MinEdge.X/BS)+0.5;
|
||||
f32 ty1 = (box.MinEdge.Y/BS)+0.5;
|
||||
f32 tz1 = (box.MinEdge.Z/BS)+0.5;
|
||||
f32 tx2 = (box.MaxEdge.X/BS)+0.5;
|
||||
f32 ty2 = (box.MaxEdge.Y/BS)+0.5;
|
||||
f32 tz2 = (box.MaxEdge.Z/BS)+0.5;
|
||||
f32 txc[24] = {
|
||||
|
||||
// Compute texture UV coords
|
||||
f32 tx1 = (box.MinEdge.X / BS) + 0.5;
|
||||
f32 ty1 = (box.MinEdge.Y / BS) + 0.5;
|
||||
f32 tz1 = (box.MinEdge.Z / BS) + 0.5;
|
||||
f32 tx2 = (box.MaxEdge.X / BS) + 0.5;
|
||||
f32 ty2 = (box.MaxEdge.Y / BS) + 0.5;
|
||||
f32 tz2 = (box.MaxEdge.Z / BS) + 0.5;
|
||||
|
||||
f32 txc_default[24] = {
|
||||
// up
|
||||
tx1, 1-tz2, tx2, 1-tz1,
|
||||
tx1, 1 - tz2, tx2, 1 - tz1,
|
||||
// down
|
||||
tx1, tz1, tx2, tz2,
|
||||
// right
|
||||
tz1, 1-ty2, tz2, 1-ty1,
|
||||
tz1, 1 - ty2, tz2, 1 - ty1,
|
||||
// left
|
||||
1-tz2, 1-ty2, 1-tz1, 1-ty1,
|
||||
1 - tz2, 1 - ty2, 1 - tz1, 1 - ty1,
|
||||
// back
|
||||
1-tx2, 1-ty2, 1-tx1, 1-ty1,
|
||||
1 - tx2, 1 - ty2, 1 - tx1, 1 - ty1,
|
||||
// front
|
||||
tx1, 1-ty2, tx2, 1-ty1,
|
||||
tx1, 1 - ty2, tx2, 1 - ty1,
|
||||
};
|
||||
|
||||
// use default texture UV mapping if not provided
|
||||
const f32 *txc = uv_coords ? uv_coords : txc_default;
|
||||
|
||||
v3f min = box.MinEdge;
|
||||
v3f max = box.MaxEdge;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue