GitHub快速开始

API 参考取自源码中的 Go 文档注释,以英文书写。

package cover3d

import "github.com/nsgo-dev/game/pkg/ai/cover3d"

概述

Package cover3d generates ai.CoverPoint values from the colliders of a physics3d world, projecting the vertical faces of 3D obstacles onto the XZ ground plane.

It lives apart from pkg/ai so that ai does not depend on the 3D physics engine and physics3d does not depend on ai.

索引

函数

func FromBodies(bodies []*physics3d.Body, opts Options) []ai.CoverPoint

FromBodies generates deterministic XZ-plane cover points from the given 3D bodies: axis-aligned or oriented boxes, spheres, vertical capsules, and cylinders standing on an end (their axis within about 25 degrees of vertical). Convex hulls and cylinders lying on their side generate no cover.

func FromWorld(w *physics3d.World, opts Options) []ai.CoverPoint

FromWorld generates deterministic XZ-plane cover points along the vertical faces of matching colliders in w, discarding points that overlap any other matching collider.

类型

type Options struct {
	// Spacing is the horizontal distance between cover samples along each collider face (defaults to 1.0 when <= 0).
	Spacing float32
	// Standoff offsets each cover point outward from the collider face into open space (defaults to 0.5 when <= 0).
	Standoff float32
	// EdgeInset is the margin from face corners (defaults to Spacing * 0.5 when <= 0).
	EdgeInset float32
	// MinEdgeLength skips horizontal faces shorter than this length (<= 0 allows any positive face).
	MinEdgeLength float32
	// HalfCoverMinHeight is the minimum obstacle vertical height for ai.CoverHalf (defaults to 0.7 when <= 0). Shorter obstacles (such as floor slabs) do not generate cover.
	HalfCoverMinHeight float32
	// FullCoverMinHeight is the minimum obstacle vertical height for ai.CoverFull (defaults to 1.6 when <= 0).
	FullCoverMinHeight float32
	// LayerMask filters bodies considered as cover obstacles (0 defaults to physics3d.LayerAll).
	LayerMask physics3d.LayerMask
	// IncludeDynamic includes non-static bodies when true; by default only static level geometry generates cover.
	IncludeDynamic bool
	// StartID is the first ai.CoverPoint.ID assigned (defaults to 1 when 0).
	StartID uint64
}

Options configures 3D collider-edge cover point generation projected onto the XZ ground plane.

Generated ai.CoverPoint values store (X, Z) in Pos, the obstacle's floor Y in Elevation, and the horizontal XZ unit direction into the obstacle in Facing.