pathfinder

package
v0.0.0-...-0012533 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Err_NavMesh_nil = common.NewError("MapName:%s NavMesh is nil.")
)

Functions

func AddAabbBox

func AddAabbBox(finder *Cgo_TempObstaclesNavMesh, tag string, minPos, maxPos *protomsg.Vector3)

func AddCyinderTO

func AddCyinderTO(finder *Cgo_TempObstaclesNavMesh, tag string, spos *protomsg.Vector3, radius float32, height float32)

AddCyinderTO 增加动态阻挡

func AddObbBoxTO

func AddObbBoxTO(finder *Cgo_TempObstaclesNavMesh, tag string, centPos, halfPos *protomsg.Vector3, rotaY float32)

AddObbBox 增加OBB动态阻挡Box

func CalcNavNear

func CalcNavNear(finder *cgo_dtNavfinder, spos *protomsg.Vector3, count *int32) *C.float

获取导航附近的点

func CalcNavNearTO

func CalcNavNearTO(finder *Cgo_TempObstaclesNavMesh, spos *protomsg.Vector3, count *int32) *C.float

CalcNavNearTO 获取导航附近的点

func CalcRaycast

func CalcRaycast(finder *cgo_dtNavfinder, spos *protomsg.Vector3, epos *protomsg.Vector3, count *int32) *C.float

CalcRaycast 射线检测

func CalcRaycastTO

func CalcRaycastTO(finder *Cgo_TempObstaclesNavMesh, spos *protomsg.Vector3, epos *protomsg.Vector3, count *int32) *C.float

CalcNavNearTO 计算射线检测

func FindNavPath

func FindNavPath(finder *cgo_dtNavfinder, spos *protomsg.Vector3, epos *protomsg.Vector3, count *int32) *C.float

查找路径

func FindNavPathExTO

func FindNavPathExTO(finder *Cgo_TempObstaclesNavMesh, spos *protomsg.Vector3, epos *protomsg.Vector3) bool

func FindNavPathTO

func FindNavPathTO(finder *Cgo_TempObstaclesNavMesh, spos *protomsg.Vector3, epos *protomsg.Vector3, count *int32) *C.float

查找路径

func Free

func Free(ptr unsafe.Pointer)

func GetNavFinder

func GetNavFinder(dtnavmesh *Cgo_dtNavMesh) *cgo_dtNavfinder

生成finder

func GetNavPath

func GetNavPath(finder *Cgo_TempObstaclesNavMesh, count *int32) *C.float

func ReleaseNavFile

func ReleaseNavFile()

释放所有存好的Navmesh

func ReleaseNavFileTO

func ReleaseNavFileTO()

释放所有存好的Navmesh

func RemoveAllTO

func RemoveAllTO(finder *Cgo_TempObstaclesNavMesh)

func RemoveTOByTag

func RemoveTOByTag(finder *Cgo_TempObstaclesNavMesh, tag string)

RemoveTOByTag 删除动态阻挡

func UpdateTO

func UpdateTO(finder *Cgo_TempObstaclesNavMesh)

UpdateTO 更新临时阻挡信息

Types

type Cgo_TempObstaclesNavMesh

type Cgo_TempObstaclesNavMesh C.TempObstaclesNavMesh

func GetNavMeshTO

func GetNavMeshTO(name string) *Cgo_TempObstaclesNavMesh

///////////////////////////////////////////////////////////// 获取Navmesh temp obstacles

type Cgo_dtNavMesh

type Cgo_dtNavMesh C.dtNavMesh

func GetNavMesh

func GetNavMesh(name string) *Cgo_dtNavMesh

获取Navmesh

type GetIfinderF

type GetIfinderF func() (IPathFinder, error)

type IPathFinder

type IPathFinder interface {

	// FindPath 提供外部寻路算法
	//
	// 参数:
	//    params 起点终点
	//
	// 返回值:
	//    path 路点,注意第一个点就是输入的起始点
	//    result 是否寻路成功
	FindPath(navmesh NavmeshParams) (path []protomsg.Vector3, result bool)

	// GetNear 获取某个点附近的合法位置
	// 参数:
	//    params 检查点 *protomsg.Vector3 类型
	// 返回值:
	//    pos 路点,注意第一个点就是输入的起始点
	//    result 是否能成功
	GetNear(srcPos *protomsg.Vector3) (pos *protomsg.Vector3, result bool)

	// CheckWall 按照100单位步长检查墙
	// 墙的定义点位高程超过500单位
	CheckWall(srcPos, dstPos protomsg.Vector3) (path []protomsg.Vector3, bHaveWall bool)

	// Raycast 射线检测,是否撞到墙了
	// 参数:
	//    params 起点终点
	// 返回值:
	//    pos 如果撞到墙了将会返回墙体位置,否则为空
	//    result 是否碰到墙了,true 碰到墙 false 畅通无阻
	Raycast(navmesh NavmeshParams) (*protomsg.Vector3, bool)

	// Raycast 射线检测,是否撞到墙了
	// 参数:
	//    srcPos 起点
	//    dstPos 终点
	// 返回值:
	//    pos 如果撞到墙了将会返回墙体位置,否则为空
	//    result 是否碰到墙了,true 碰到墙 false 没有撞到墙
	RaycastEx(srcPos, dstPos protomsg.Vector3) (*protomsg.Vector3, bool)

	//动态阻挡相关
	// 增加可旋转的Box阻挡
	CreateObstacleOBBBox(doorName string, centPos, halfPos protomsg.Vector3, YawDegree int32)
	// 增加圆柱体阻挡
	CreateObstacleCylinder(doorName string, centPos protomsg.Vector3, radius, height int32)
	// 清理掉某个门
	RemoveObstacle(doorName string)
	// 清理全部的门
	RemoveAllObstacle()
	// 更新阻挡信息
	UpdateObstacle()
	//走直线,找落点;如果我在墙里面,就从墙里出来;
	MeshCheckRushPath(srcPos, stpos protomsg.Vector3) protomsg.Vector3

	Destroy()
}

寻路管理器接口

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

c++没有动态阻挡的寻路

func (this *NavMesh) CheckWall(srcPos, dstPos protomsg.Vector3) (path []protomsg.Vector3, bHaveWall bool)

CheckWall 按照100单位步长检查墙 墙的定义点位高程超过500单位

func (this *NavMesh) CreateObstacleCylinder(doorName string, centPos protomsg.Vector3, radius, height int32)

增加圆柱体阻挡

func (this *NavMesh) CreateObstacleOBBBox(doorName string, centPos, halfPos protomsg.Vector3, YawDegree int32)

动态阻挡相关 增加可旋转的Box阻挡

func (this *NavMesh) Destroy()
func (this *NavMesh) FindPath(navmesh NavmeshParams) (path []protomsg.Vector3, result bool)

FindPath 提供外部寻路算法

参数:

params 起点终点

返回值:

path 路点,注意第一个点就是输入的起始点
result 是否寻路成功
func (this *NavMesh) GetNear(srcPos *protomsg.Vector3) (pos *protomsg.Vector3, result bool)

GetNear 获取某个点附近的合法位置 参数:

params 检查点 *protomsg.Vector3 类型

返回值:

pos 路点,注意第一个点就是输入的起始点
result 是否能成功
func (this *NavMesh) MeshCheckRushPath(srcPos, stpos protomsg.Vector3) protomsg.Vector3

走直线,找落点;如果我在墙里面,就从墙里出来;

func (this *NavMesh) Raycast(navmesh NavmeshParams) (*protomsg.Vector3, bool)

Raycast 射线检测,是否撞到墙了 参数:

params 起点终点

返回值:

pos 如果撞到墙了将会返回墙体位置,否则为空
result 是否碰到墙了,true 碰到墙 false 畅通无阻
func (this *NavMesh) RaycastEx(srcPos, dstPos protomsg.Vector3) (*protomsg.Vector3, bool)

Raycast 射线检测,是否撞到墙了 参数:

srcPos 起点
dstPos 终点

返回值:

pos 如果撞到墙了将会返回墙体位置,否则为空
result 是否碰到墙了,true 碰到墙 false 没有撞到墙
func (this *NavMesh) RemoveAllObstacle()

清理全部的门

func (this *NavMesh) RemoveObstacle(doorName string)

清理掉某个门

func (this *NavMesh) UpdateObstacle()

更新阻挡信息

type NavmeshParams struct {
	Start protomsg.Vector3
	End   protomsg.Vector3
}

func PackageFindParams

func PackageFindParams(srcPos, dstPos protomsg.Vector3) NavmeshParams

type TempObsNavMesh

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

带临时阻挡的寻路

func (*TempObsNavMesh) CheckWall

func (this *TempObsNavMesh) CheckWall(srcPos, dstPos protomsg.Vector3) (path []protomsg.Vector3, bHaveWall bool)

CheckWall 按照100单位步长检查墙 墙的定义点位高程超过500单位

func (*TempObsNavMesh) CreateObstacleCylinder

func (this *TempObsNavMesh) CreateObstacleCylinder(doorName string, centPos protomsg.Vector3, radius, height int32)

增加圆柱体阻挡

func (*TempObsNavMesh) CreateObstacleOBBBox

func (this *TempObsNavMesh) CreateObstacleOBBBox(doorName string, centPos, halfPos protomsg.Vector3, YawDegree int32)

动态阻挡相关 增加可旋转的Box阻挡

func (*TempObsNavMesh) Destroy

func (this *TempObsNavMesh) Destroy()

func (*TempObsNavMesh) FindPath

func (this *TempObsNavMesh) FindPath(navmesh NavmeshParams) (path []protomsg.Vector3, result bool)

FindPath 提供外部寻路算法

参数:

params 起点终点

返回值:

path 路点,注意第一个点就是输入的起始点
result 是否寻路成功

func (*TempObsNavMesh) GetNear

func (this *TempObsNavMesh) GetNear(srcPos *protomsg.Vector3) (pos *protomsg.Vector3, result bool)

GetNear 获取某个点附近的合法位置 参数:

params 检查点 *protomsg.Vector3 类型

返回值:

pos 路点,注意第一个点就是输入的起始点
result 是否能成功

func (*TempObsNavMesh) MeshCheckRushPath

func (this *TempObsNavMesh) MeshCheckRushPath(srcPos, stpos protomsg.Vector3) protomsg.Vector3

走直线,找落点;如果我在墙里面,就从墙里出来;

func (*TempObsNavMesh) Raycast

func (this *TempObsNavMesh) Raycast(navmesh NavmeshParams) (*protomsg.Vector3, bool)

Raycast 射线检测,是否撞到墙了 参数:

params 起点终点

返回值:

pos 如果撞到墙了将会返回墙体位置,否则为空
result 是否碰到墙了,true 碰到墙 false 畅通无阻

func (*TempObsNavMesh) RaycastEx

func (this *TempObsNavMesh) RaycastEx(srcPos, dstPos protomsg.Vector3) (*protomsg.Vector3, bool)

Raycast 射线检测,是否撞到墙了 参数:

srcPos 起点
dstPos 终点

返回值:

pos 如果撞到墙了将会返回墙体位置,否则为空
result 是否碰到墙了,true 碰到墙 false 没有撞到墙

func (*TempObsNavMesh) RemoveAllObstacle

func (this *TempObsNavMesh) RemoveAllObstacle()

清理全部的门

func (*TempObsNavMesh) RemoveObstacle

func (this *TempObsNavMesh) RemoveObstacle(doorName string)

清理掉某个门

func (*TempObsNavMesh) UpdateObstacle

func (this *TempObsNavMesh) UpdateObstacle()

更新阻挡信息

type TypeMgr

type TypeMgr struct {
	//Mesh数据
	MeshMap sync.Map
}

用来管理C++对象 如果是没有动态阻挡的他的Mesh数据是不变的 所以Mesh数据是可以固定的 但还是需要New一个Finder的C++对象进行寻路操作; 因为会有一些临时变量

func GetTypeMgr

func GetTypeMgr() *TypeMgr

获取对象类型管理器

func (*TypeMgr) GetIFinder

func (this *TypeMgr) GetIFinder(mapName string, isObs bool) (IPathFinder, error)

获取NavMesh管理器

Jump to

Keyboard shortcuts

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