@@ -273,6 +273,49 @@ inline bool isPointableNode(const MapNode &n,
273
273
(liquids_pointable && features.isLiquid ());
274
274
}
275
275
276
+ static inline void getNeighborConnectingFace (v3s16 p, INodeDefManager *nodedef,
277
+ ClientMap *map, MapNode n, u8 bitmask, u8 *neighbors)
278
+ {
279
+ MapNode n2 = map->getNodeNoEx (p);
280
+ if (nodedef->nodeboxConnects (n, n2, bitmask))
281
+ *neighbors |= bitmask;
282
+ }
283
+
284
+ static inline u8 getNeighbors (v3s16 p, INodeDefManager *nodedef, ClientMap *map, MapNode n)
285
+ {
286
+ u8 neighbors = 0 ;
287
+ const ContentFeatures &f = nodedef->get (n);
288
+ // locate possible neighboring nodes to connect to
289
+ if (f.drawtype == NDT_NODEBOX && f.node_box .type == NODEBOX_CONNECTED) {
290
+ v3s16 p2 = p;
291
+
292
+ p2.Y ++;
293
+ getNeighborConnectingFace (p2, nodedef, map, n, 1 , &neighbors);
294
+
295
+ p2 = p;
296
+ p2.Y --;
297
+ getNeighborConnectingFace (p2, nodedef, map, n, 2 , &neighbors);
298
+
299
+ p2 = p;
300
+ p2.Z --;
301
+ getNeighborConnectingFace (p2, nodedef, map, n, 4 , &neighbors);
302
+
303
+ p2 = p;
304
+ p2.X --;
305
+ getNeighborConnectingFace (p2, nodedef, map, n, 8 , &neighbors);
306
+
307
+ p2 = p;
308
+ p2.Z ++;
309
+ getNeighborConnectingFace (p2, nodedef, map, n, 16 , &neighbors);
310
+
311
+ p2 = p;
312
+ p2.X ++;
313
+ getNeighborConnectingFace (p2, nodedef, map, n, 32 , &neighbors);
314
+ }
315
+
316
+ return neighbors;
317
+ }
318
+
276
319
/*
277
320
Find what the player is pointing at
278
321
*/
@@ -350,8 +393,9 @@ PointedThing getPointedThing(Client *client, Hud *hud, const v3f &player_positio
350
393
for (s16 x = xstart; x <= xend; x++) {
351
394
MapNode n;
352
395
bool is_valid_position;
396
+ v3s16 p (x, y, z);
353
397
354
- n = map.getNodeNoEx (v3s16 (x, y, z) , &is_valid_position);
398
+ n = map.getNodeNoEx (p , &is_valid_position);
355
399
if (!is_valid_position) {
356
400
continue ;
357
401
}
@@ -360,7 +404,7 @@ PointedThing getPointedThing(Client *client, Hud *hud, const v3f &player_positio
360
404
}
361
405
362
406
std::vector<aabb3f> boxes;
363
- n.getSelectionBoxes (nodedef, &boxes);
407
+ n.getSelectionBoxes (nodedef, &boxes, getNeighbors (p, nodedef, &map, n) );
364
408
365
409
v3s16 np (x, y, z);
366
410
v3f npf = intToFloat (np, BS);
@@ -392,7 +436,7 @@ PointedThing getPointedThing(Client *client, Hud *hud, const v3f &player_positio
392
436
MapNode n = map.getNodeNoEx (pointed_pos);
393
437
v3f npf = intToFloat (pointed_pos, BS);
394
438
std::vector<aabb3f> boxes;
395
- n.getSelectionBoxes (nodedef, &boxes);
439
+ n.getSelectionBoxes (nodedef, &boxes, getNeighbors (pointed_pos, nodedef, &map, n) );
396
440
f32 face_min_distance = 1000 * BS;
397
441
for (std::vector<aabb3f>::const_iterator
398
442
i = boxes.begin ();
0 commit comments