mirror of https://github.com/axmolengine/axmol.git
setRadius and setGeight implementation
This commit is contained in:
parent
a0adf507c0
commit
5bf09a676e
|
@ -123,24 +123,42 @@ void NavMeshObstacle::syncToNode()
|
|||
{
|
||||
if (_tileCache){
|
||||
auto obstacle = _tileCache->getObstacleByRef(_obstacleID);
|
||||
if (obstacle){
|
||||
Vec3 localPos = Vec3(obstacle->pos[0], obstacle->pos[1], obstacle->pos[2]);
|
||||
if (_owner->getParent())
|
||||
_owner->getParent()->getWorldToNodeTransform().transformPoint(localPos, &localPos);
|
||||
_owner->setPosition3D(localPos);
|
||||
_radius = obstacle->radius;
|
||||
_height = obstacle->height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cocos2d::NavMeshObstacle::setRadius(float radius)
|
||||
{
|
||||
_radius = radius;
|
||||
}
|
||||
|
||||
void cocos2d::NavMeshObstacle::setHeight(float height)
|
||||
{
|
||||
_height = height;
|
||||
}
|
||||
|
||||
void NavMeshObstacle::syncToObstacle()
|
||||
{
|
||||
if (_tileCache){
|
||||
auto obstacle = _tileCache->getObstacleByRef(_obstacleID);
|
||||
if (obstacle){
|
||||
Vec3 worldPos = Vec3(obstacle->pos[0], obstacle->pos[1], obstacle->pos[2]);
|
||||
Mat4 mat = _owner->getNodeToWorldTransform();
|
||||
if (mat.m[12] != obstacle->pos[0] && mat.m[13] != obstacle->pos[1] && mat.m[14] != obstacle->pos[2]){
|
||||
if ((mat.m[12] != obstacle->pos[0] && mat.m[13] != obstacle->pos[1] && mat.m[14] != obstacle->pos[2])
|
||||
|| obstacle->radius != _radius
|
||||
|| obstacle->height != _height){
|
||||
_tileCache->removeObstacle(_obstacleID);
|
||||
_tileCache->addObstacle(&mat.m[12], _radius, _height, &_obstacleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
Loading…
Reference in New Issue