fix(raycast): 放置位计算(命中格+面法线)
This commit is contained in:
@@ -48,8 +48,8 @@ func Cast(origin, dir [3]float64, maxDist float64, solid Solid) (Hit, bool) {
|
||||
dist := 0.0
|
||||
for dist <= maxDist {
|
||||
if solid(x, y, z) {
|
||||
// 当前格命中:面法线 = 上一步进入方向
|
||||
return Hit{X: x, Y: y, Z: z, Face: face, Prev: [3]int32{x - face[0], y - face[1], z - face[2]}, Dist: dist}, true
|
||||
// 当前格命中:面法线指向射线来向(背离方块),放置位 = 命中格 + 面法线
|
||||
return Hit{X: x, Y: y, Z: z, Face: face, Prev: [3]int32{x + face[0], y + face[1], z + face[2]}, Dist: dist}, true
|
||||
}
|
||||
// 选择 tMax 最小的轴步进
|
||||
switch {
|
||||
|
||||
Reference in New Issue
Block a user