Skip to content

Commit 9357294

Browse files
RealBadAngelkahrl
authored andcommittedFeb 11, 2016
Use single box for halo mesh
1 parent c1044b9 commit 9357294

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed
 

‎src/hud.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
8484

8585
m_selection_mesh = NULL;
8686
m_selection_boxes.clear();
87+
m_halo_boxes.clear();
88+
8789
m_selection_pos = v3f(0.0, 0.0, 0.0);
8890
std::string mode = g_settings->get("node_highlighting");
8991
m_selection_material.Lighting = false;
@@ -574,10 +576,23 @@ void Hud::updateSelectionMesh(const v3s16 &camera_offset)
574576
0,0,1,1
575577
};
576578

577-
m_selection_mesh = convertNodeboxesToMesh(m_selection_boxes, texture_uv);
579+
// Use single halo box instead of multiple overlapping boxes.
580+
// Temporary solution - problem can be solved with multiple
581+
// rendering targets, or some method to remove inner surfaces.
582+
// Thats because of halo transparency.
583+
584+
aabb3f halo_box(100.0, 100.0, 100.0, -100.0, -100.0, -100.0);
585+
m_halo_boxes.clear();
586+
587+
for (std::vector<aabb3f>::iterator
588+
i = m_selection_boxes.begin();
589+
i != m_selection_boxes.end(); ++i) {
590+
halo_box.addInternalBox(*i);
591+
}
578592

579-
// scale final halo mesh
580-
scaleMesh(m_selection_mesh, v3f(1.08, 1.08, 1.08));
593+
m_halo_boxes.push_back(halo_box);
594+
m_selection_mesh = convertNodeboxesToMesh(
595+
m_halo_boxes, texture_uv, 0.5);
581596
}
582597

583598
void Hud::resizeHotbar() {

‎src/hud.h

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class Hud {
162162
video::SColor hbar_colors[4];
163163

164164
std::vector<aabb3f> m_selection_boxes;
165+
std::vector<aabb3f> m_halo_boxes;
165166
v3f m_selection_pos;
166167
v3f m_selection_pos_with_offset;
167168

‎src/mesh.cpp

+10-22
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ scene::IMesh* cloneMesh(scene::IMesh *src_mesh)
406406
}
407407

408408
scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
409-
const f32 *uv_coords)
409+
const f32 *uv_coords, float expand)
410410
{
411411
scene::SMesh* dst_mesh = new scene::SMesh();
412412

@@ -421,31 +421,19 @@ scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
421421

422422
video::SColor c(255,255,255,255);
423423

424-
for(std::vector<aabb3f>::const_iterator
424+
for (std::vector<aabb3f>::const_iterator
425425
i = boxes.begin();
426426
i != boxes.end(); ++i)
427427
{
428428
aabb3f box = *i;
429-
430-
f32 temp;
431-
if (box.MinEdge.X > box.MaxEdge.X)
432-
{
433-
temp=box.MinEdge.X;
434-
box.MinEdge.X=box.MaxEdge.X;
435-
box.MaxEdge.X=temp;
436-
}
437-
if (box.MinEdge.Y > box.MaxEdge.Y)
438-
{
439-
temp=box.MinEdge.Y;
440-
box.MinEdge.Y=box.MaxEdge.Y;
441-
box.MaxEdge.Y=temp;
442-
}
443-
if (box.MinEdge.Z > box.MaxEdge.Z)
444-
{
445-
temp=box.MinEdge.Z;
446-
box.MinEdge.Z=box.MaxEdge.Z;
447-
box.MaxEdge.Z=temp;
448-
}
429+
box.repair();
430+
431+
box.MinEdge.X -= expand;
432+
box.MinEdge.Y -= expand;
433+
box.MinEdge.Z -= expand;
434+
box.MaxEdge.X += expand;
435+
box.MaxEdge.Y += expand;
436+
box.MaxEdge.Z += expand;
449437

450438
// Compute texture UV coords
451439
f32 tx1 = (box.MinEdge.X / BS) + 0.5;

‎src/mesh.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ scene::IMesh* cloneMesh(scene::IMesh *src_mesh);
8686
Convert nodeboxes to mesh.
8787
boxes - set of nodeboxes to be converted into cuboids
8888
uv_coords[24] - table of texture uv coords for each cuboid face
89+
expand - factor by which cuboids will be resized
8990
*/
9091
scene::IMesh* convertNodeboxesToMesh(const std::vector<aabb3f> &boxes,
91-
const f32 *uv_coords = NULL);
92+
const f32 *uv_coords = NULL, float expand = 0);
9293

9394
/*
9495
Update bounding box for a mesh.

0 commit comments

Comments
 (0)
Please sign in to comment.