5 Star 20 Fork 10

NightTC/Gobige

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BridgeGo.go 3.26 KB
一键复制 编辑 原始数据 按行查看 历史
package pathfinder
/*
#cgo windows LDFLAGS: -L${SRCDIR} -lPathLibwin -lm -lstdc++
#cgo linux LDFLAGS: -L${SRCDIR} -lPathLibLinux -lm -lstdc++
#cgo darwin LDFLAGS: -L${SRCDIR} -lPathLibMac -lm -lstdc++
#include "BridgeCpp.h"
#include <stdio.h>
#include <stdlib.h>
*/
import "C"
import (
"unsafe"
"gitee.com/night-tc/gobige/logger"
"gitee.com/night-tc/gobige/msgdef/protomsg"
)
type Cgo_ObsNavMesh C.ObsNavMesh
type Cgo_ObsPathFinder C.ObsPathFinder
//-----------------------------------------------------------------------------
func newObsNavMesh(filename, key string) (navmesh *Cgo_ObsNavMesh) {
defer func() {
logger.Debugf(logger.LogKey_Lib, "newObsNavMesh(%s,%s) %p", filename, key, navmesh)
}()
return (*Cgo_ObsNavMesh)(C.NewObsNavMesh(C.CString(filename), C.CString(key)))
}
func newObsPathFinder(mesh *Cgo_ObsNavMesh) *Cgo_ObsPathFinder {
logger.Debugf(logger.LogKey_Lib, "newObsPathFinder(%p)", mesh)
return (*Cgo_ObsPathFinder)(C.NewObsPathFinder((*C.ObsNavMesh)(mesh)))
}
func (finder *Cgo_ObsPathFinder) FreeObsPath() {
logger.Debugf(logger.LogKey_Lib, "FreeObsPath(%p)", finder)
C.FreeObsPath((*C.ObsPathFinder)(finder))
}
// AddCyinderTO 增加动态阻挡
func (mesh *Cgo_ObsNavMesh) ObsAddCylinder(tag string, spos *protomsg.Vector3, radius float32, height float32) {
C.ObsAddCylinder((*C.ObsNavMesh)(mesh), C.CString(tag), C.float(spos.X), C.float(spos.Y), C.float(spos.Z), C.float(radius), C.float(height))
}
// AddObbBox 增加OBB动态阻挡Box
func (mesh *Cgo_ObsNavMesh) ObsAddObbBox(tag string, centPos, halfPos *protomsg.Vector3, rotaY float32) {
C.ObsAddObbBox((*C.ObsNavMesh)(mesh), C.CString(tag), C.float(centPos.X), C.float(centPos.Y), C.float(centPos.Z),
C.float(halfPos.X), C.float(halfPos.Y), C.float(halfPos.Z), C.float(rotaY))
}
func (mesh *Cgo_ObsNavMesh) ObsAddAabbBox(tag string, minPos, maxPos *protomsg.Vector3) {
C.ObsAddAabbBox((*C.ObsNavMesh)(mesh), C.CString(tag), C.float(minPos.X), C.float(minPos.Y), C.float(minPos.Z),
C.float(maxPos.X), C.float(maxPos.Y), C.float(maxPos.Z))
}
// RemoveTOByTag 删除动态阻挡
func (mesh *Cgo_ObsNavMesh) ObsRemoveTOByTag(tag string) {
C.ObsRemoveTOByTag((*C.ObsNavMesh)(mesh), C.CString(tag))
}
func (mesh *Cgo_ObsNavMesh) ObsRemoveAllTO() {
C.ObsRemoveAllTO((*C.ObsNavMesh)(mesh))
}
// UpdateTO 更新临时阻挡信息
func (mesh *Cgo_ObsNavMesh) ObsUpdateTO() {
C.ObsUpdate((*C.ObsNavMesh)(mesh))
}
// 查找路径
func (finder *Cgo_ObsPathFinder) FindNavPath(spos *protomsg.Vector3, epos *protomsg.Vector3, count *int32) *C.float {
return C.ObsFindPath((*C.ObsPathFinder)(finder), C.float(spos.X), C.float(spos.Y), C.float(spos.Z), C.float(epos.X), C.float(epos.Y), C.float(epos.Z), (*C.int)(unsafe.Pointer(count)))
}
// 获取导航附近的点
func (finder *Cgo_ObsPathFinder) CalcNavNear(spos *protomsg.Vector3, count *int32) *C.float {
return C.ObsCalcNear((*C.ObsPathFinder)(finder), C.float(spos.X), C.float(spos.Y), C.float(spos.Z), (*C.int)(unsafe.Pointer(count)))
}
// CalcRaycast 射线检测
func (finder *Cgo_ObsPathFinder) CalcRaycast(spos *protomsg.Vector3, epos *protomsg.Vector3, count *int32) *C.float {
return C.ObsCalcRaycast((*C.ObsPathFinder)(finder), C.float(spos.X), C.float(spos.Y), C.float(spos.Z), C.float(epos.X), C.float(epos.Y), C.float(epos.Z), (*C.int)(unsafe.Pointer(count)))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/night-tc/gobige.git
git@gitee.com:night-tc/gobige.git
night-tc
gobige
Gobige
840e4d7544b2

搜索帮助