//
// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
//
package detour
import (
"math"
"unsafe"
)
/// @class dtQueryFilter
///
/// <b>The Default Implementation</b>
///
/// At construction: All area costs default to 1.0. All flags are included
/// and none are excluded.
///
/// If a polygon has both an include and an exclude flag, it will be excluded.
///
/// The way filtering works, a navigation mesh polygon must have at least one flag
/// set to ever be considered by a query. So a polygon with no flags will never
/// be considered.
///
/// Setting the include flags to 0 will result in all polygons being excluded.
///
/// <b>Custom Implementations</b>
///
/// DT_VIRTUAL_QUERYFILTER must be defined in order to extend this class.
///
/// Implement a custom query filter by overriding the virtual passFilter()
/// and getCost() functions. If this is done, both functions should be as
/// fast as possible. Use cached local copies of data rather than accessing
/// your own objects where possible.
///
/// Custom implementations do not need to adhere to the flags or cost logic
/// used by the default implementation.
///
/// In order for A* searches to work properly, the cost should be proportional to
/// the travel distance. Implementing a cost modifier less than 1.0 is likely
/// to lead to problems during pathfinding.
///
/// @see dtNavMeshQuery
func (this *DtQueryFilter) constructor() {
this.m_includeFlags = 0xffff
this.m_excludeFlags = 0
for i := 0; i < DT_MAX_AREAS; i++ {
this.m_areaCost[i] = 1.0
}
}
func (this *DtQueryFilter) destructor() {
}
func (this *DtQueryFilter) PassFilter(_ DtPolyRef, _ *DtMeshTile, poly *DtPoly) bool {
return (poly.Flags&this.m_includeFlags) != 0 && (poly.Flags&this.m_excludeFlags) == 0
}
func (this *DtQueryFilter) GetCost(pa, pb []float32,
_ DtPolyRef, _ *DtMeshTile, _ *DtPoly,
_ DtPolyRef, _ *DtMeshTile, curPoly *DtPoly,
_ DtPolyRef, _ *DtMeshTile, _ *DtPoly) float32 {
return DtVdist(pa, pb) * this.m_areaCost[curPoly.GetArea()]
}
const H_SCALE float32 = 0.999 // Search heuristic scale.
//////////////////////////////////////////////////////////////////////////////////////////
/// @class dtNavMeshQuery
///
/// For methods that support undersized buffers, if the buffer is too small
/// to hold the entire result set the return status of the method will include
/// the #DT_BUFFER_TOO_SMALL flag.
///
/// Constant member functions can be used by multiple clients without side
/// effects. (E.g. No change to the closed list. No impact on an in-progress
/// sliced path query. Etc.)
///
/// Walls and portals: A @e wall is a polygon segment that is
/// considered impassable. A @e portal is a passable segment between polygons.
/// A portal may be treated as a wall based on the dtQueryFilter used for a query.
///
/// @see dtNavMesh, dtQueryFilter, #dtAllocNavMeshQuery(), #dtAllocNavMeshQuery()
/// @name Getters and setters for the default implementation data.
///@{
/// Returns the traversal cost of the area.
/// @param[in] i The id of the area.
/// @returns The traversal cost of the area.
func (this *DtQueryFilter) GetAreaCost(i int) float32 {
return this.m_areaCost[i]
}
/// Sets the traversal cost of the area.
/// @param[in] i The id of the area.
/// @param[in] cost The new cost of traversing the area.
func (this *DtQueryFilter) SetAreaCost(i int, cost float32) {
this.m_areaCost[i] = cost
}
/// Returns the include flags for the filter.
/// Any polygons that include one or more of these flags will be
/// included in the operation.
func (this *DtQueryFilter) GetIncludeFlags() uint16 {
return this.m_includeFlags
}
/// Sets the include flags for the filter.
/// @param[in] flags The new flags.
func (this *DtQueryFilter) SetIncludeFlags(flags uint16) {
this.m_includeFlags = flags
}
/// Returns the exclude flags for the filter.
/// Any polygons that include one ore more of these flags will be
/// excluded from the operation.
func (this *DtQueryFilter) GetExcludeFlags() uint16 {
return this.m_excludeFlags
}
/// Sets the exclude flags for the filter.
/// @param[in] flags The new flags.
func (this *DtQueryFilter) SetExcludeFlags(flags uint16) {
this.m_excludeFlags = flags
}
///@}
/// Gets the node pool.
/// @returns The node pool.
func (this *DtNavMeshQuery) GetNodePool() *DtNodePool {
return this.m_nodePool
}
/// Gets the navigation mesh the query object is using.
/// @return The navigation mesh the query object is using.
func (this *DtNavMeshQuery) GetAttachedNavMesh() *DtNavMesh {
return this.m_nav
}
func (this *DtNavMeshQuery) constructor() {
}
func (this *DtNavMeshQuery) destructor() {
if this.m_tinyNodePool != nil {
DtFreeNodePool(this.m_tinyNodePool)
this.m_tinyNodePool = nil
}
if this.m_nodePool != nil {
DtFreeNodePool(this.m_nodePool)
this.m_nodePool = nil
}
if this.m_openList != nil {
DtFreeNodeQueue(this.m_openList)
this.m_openList = nil
}
}
/// Initializes the query object.
/// @param[in] nav Pointer to the dtNavMesh object to use for all queries.
/// @param[in] maxNodes Maximum number of search nodes. [Limits: 0 < value <= 65535]
/// @returns The status flags for the query.
/// @par
///
/// Must be the first function called after construction, before other
/// functions are used.
///
/// This function can be used multiple times.
func (this *DtNavMeshQuery) Init(nav *DtNavMesh, maxNodes int) DtStatus {
if maxNodes > int(DT_NULL_IDX) || maxNodes > int((1<<DT_NODE_PARENT_BITS)-1) {
return DT_FAILURE | DT_INVALID_PARAM
}
this.m_nav = nav
if this.m_nodePool == nil || this.m_nodePool.GetMaxNodes() < uint32(maxNodes) {
if this.m_nodePool != nil {
DtFreeNodePool(this.m_nodePool)
this.m_nodePool = nil
}
this.m_nodePool = DtAllocNodePool(uint32(maxNodes), DtNextPow2(uint32(maxNodes/4)))
if this.m_nodePool == nil {
return DT_FAILURE | DT_OUT_OF_MEMORY
}
} else {
this.m_nodePool.Clear()
}
if this.m_tinyNodePool == nil {
this.m_tinyNodePool = DtAllocNodePool(64, 32)
if this.m_tinyNodePool == nil {
return DT_FAILURE | DT_OUT_OF_MEMORY
}
} else {
this.m_tinyNodePool.Clear()
}
if this.m_openList == nil || this.m_openList.GetCapacity() < maxNodes {
if this.m_openList != nil {
DtFreeNodeQueue(this.m_openList)
this.m_openList = nil
}
this.m_openList = DtAllocNodeQueue(maxNodes)
if this.m_openList == nil {
return DT_FAILURE | DT_OUT_OF_MEMORY
}
} else {
this.m_openList.Clear()
}
return DT_SUCCESS
}
/// Returns random location on navmesh.
/// Polygons are chosen weighted by area. The search runs in linear related to number of polygon.
/// @param[in] filter The polygon filter to apply to the query.
/// @param[in] frand Function returning a random number [0..1).
/// @param[out] randomRef The reference id of the random location.
/// @param[out] randomPt The random location.
/// @returns The status flags for the query.
func (this *DtNavMeshQuery) FindRandomPoint(filter *DtQueryFilter, frand func() float32,
randomRef *DtPolyRef, randomPt []float32) DtStatus {
DtAssert(this.m_nav != nil)
// Randomly pick one tile. Assume that all tiles cover rou
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
go-server gonet 游戏服务器架构。 框架优势 actor 每个Actor都是一个独立的计算实体,Actor之间不共享数据,各个Actor只能操作自己的数据,所有的交互全部通过传递消息的方式进行,可以有效避免共享数据带来的并发竞争问题。 virtual actor 降低分布式开发的复杂性,Actor总是存在,即不用关心代码在那个进程上运行,比如gm可以运行任一模块org,rank,activity具体模块actor怎么运行参考下面的stub。 微服务 stub模型微服务,解决微服务每个模块是不同的二进制,导致部署麻烦,新加进程会很繁琐,stub更像是插件模式,启用不同模块调用不同的微服务,在rpc通信上也无需区别rpcorg或者rpcrank, 只需要一个rpcgm即可
资源推荐
资源详情
资源评论
收起资源包目录
人工智能-项目实践-go-go分布式服务器,基于内存mmo.zip (235个子文件)
websocket.7z 2KB
protobuf.bat 1KB
批清理.bat 664B
build.bat 213B
proto.bat 173B
protorpc.bat 121B
server.bat 93B
orm.bat 72B
push.bat 61B
kill.bat 55B
link.bat 33B
BanWord.dat 678KB
AI.dat 15KB
AIOP.dat 7KB
Buff.dat 6KB
AICd.dat 6KB
Skill.dat 3KB
Npc.dat 621B
Map.dat 217B
Dockerfile 746B
NavMeshQueryI.go 115KB
NavMeshI.go 52KB
game.pb.go 45KB
client.pb.go 27KB
NavCommon.go 27KB
rpc3.pb.go 26KB
maps_test.go 18KB
NavMesh.go 16KB
cmath.go 14KB
tile.go 13KB
cron.go 13KB
message.pb.go 12KB
database.go 12KB
nav.go 12KB
maps.go 12KB
parseSql.go 11KB
datago.go 10KB
cron_test.go 10KB
vector.go 10KB
box.go 9KB
Cluster.go 9KB
datafile.go 9KB
matrix.go 9KB
db.go 8KB
Sort.go 8KB
common.go 7KB
datalua.go 7KB
Actor.go 7KB
PlayerData.go 7KB
bitStream.go 7KB
Timer.go 6KB
AccountMgr.go 6KB
loadObjSql.go 6KB
config.go 6KB
UserProcess.go 6KB
chat.go 5KB
datapb.go 5KB
Cluster.go 5KB
ClusterServer.go 5KB
datacsv.go 5KB
PacketProcessor.go 5KB
EventProcess.go 5KB
point3f.go 5KB
generate.go 5KB
deque_test.go 5KB
ServerSocket.go 5KB
spec.go 5KB
NavNode.go 4KB
NavNodeI.go 4KB
Ipacket.go 4KB
uuid.go 4KB
hashRing.go 4KB
Isocket.go 4KB
Item.go 4KB
NavMeshQuery.go 4KB
log.go 4KB
point2f.go 4KB
iterator.go 4KB
stubmailbox.go 4KB
ServerSocketClient.go 4KB
WebSocket.go 4KB
stubmailbox.go 3KB
mailbox.go 3KB
heap.go 3KB
PlayerSimpleMgr.go 3KB
PlayerMgr.go 3KB
GameServer.go 3KB
mailbox.go 3KB
mongodb.go 3KB
rpc_benchmark_test.go 3KB
rpc_test.go 3KB
Player.go 3KB
GMServer.go 3KB
ActorMgr.go 3KB
WebSocketClient.go 3KB
channelmgr.go 3KB
ActorPool.go 3KB
deque_test.go 3KB
Login.go 3KB
PlayerData.go 3KB
共 235 条
- 1
- 2
- 3
资源评论
博士僧小星
- 粉丝: 2381
- 资源: 5995
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功