navmesh

package module
v0.0.0-...-3359b19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 3 Imported by: 0

README

navmesh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dijkstra

type Dijkstra struct {
	Matrix map[int32][]WeightedTriangle // all edge for nodes
}

Dijkstra

func (*Dijkstra) CreateMatrixFromMesh

func (d *Dijkstra) CreateMatrixFromMesh(vertices []*V3, triangles [][3]int32)

create neighbour matrix

func (*Dijkstra) Run

func (d *Dijkstra) Run(srcID int32) []int32

type Mesh

type Mesh struct {
	Vertices  []V3       // vertices
	Triangles [][3]int32 // triangles
}
type NavMesh struct {
	Vertices  []*V3      `json:"vertices"`
	Triangles [][3]int32 `json:"triangles"`
	Dijkstra  Dijkstra   `json:"dijkstra"`
	// contains filtered or unexported fields
}
func (nm *NavMesh) FindingPath(src, dest *V3) (*Path, error)

在 X,Y 平面上寻路

func (nm *NavMesh) InitWithVertices(verticesSlice [][]*V3)
func (nm *NavMesh) IsWalkable(v *V3) bool

v 点是否是可行走区域

type Path

type Path struct {
	PathList []*V3
	// contains filtered or unexported fields
}

func (*Path) Move

func (p *Path) Move(moveDistance float64) (*V3, bool)

移动一段距离 返回 当前位置,全部寻路是否完成

type TriangleHeap

type TriangleHeap struct {
	// contains filtered or unexported fields
}

func NewTriangleHeap

func NewTriangleHeap() *TriangleHeap

func (*TriangleHeap) DecreaseKey

func (th *TriangleHeap) DecreaseKey(id int32, weight uint32)

func (*TriangleHeap) Len

func (th *TriangleHeap) Len() int

func (*TriangleHeap) Less

func (th *TriangleHeap) Less(i, j int) bool

func (*TriangleHeap) Pop

func (th *TriangleHeap) Pop() interface{}

func (*TriangleHeap) Push

func (th *TriangleHeap) Push(x interface{})

func (*TriangleHeap) Swap

func (th *TriangleHeap) Swap(i, j int)

type V3

type V3 struct {
	X, Y, Z float64
}

func NewV3

func NewV3(x, y, z float64) *V3

func (*V3) Cross

func (v *V3) Cross(v2 *V3) *V3

func (*V3) Distance

func (v *V3) Distance(target *V3) float64

func (*V3) InRange

func (v *V3) InRange(target *V3, distance float64) bool

目标点是否在半径为 distance 的圆内

func (*V3) Rotate

func (v *V3) Rotate(radian float64) *V3

旋转一个弧度

func (*V3) Sub

func (v *V3) Sub(v2 *V3) *V3

type WeightedTriangle

type WeightedTriangle struct {
	ID     int32  `json:"id"` // triangle ID
	Weight uint32 `json:"w"`
}

Triangle Heap

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL