mirror of https://github.com/axmolengine/axmol.git
Fix rotation override and node base class calls.
Make sure Node class calls it's base functions and NOT the ones overridden when changing position, and make sure the rotation set for the camera isn't altered when calling applyCustomProperties().
This commit is contained in:
parent
0e7a8a8ae8
commit
730700cf10
|
@ -207,7 +207,6 @@ bool Camera::initDefault()
|
||||||
{
|
{
|
||||||
initOrthographic(size.width, size.height, -1024, 1024);
|
initOrthographic(size.width, size.height, -1024, 1024);
|
||||||
setPosition3D(Vec3(size.width / 2, size.height / 2, 0.f));
|
setPosition3D(Vec3(size.width / 2, size.height / 2, 0.f));
|
||||||
_originalPosition = {size.width / 2, size.height / 2};
|
|
||||||
setRotation3D(Vec3(0.f, 0.f, 0.f));
|
setRotation3D(Vec3(0.f, 0.f, 0.f));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -447,7 +446,6 @@ void Camera::applyCustomProperties()
|
||||||
initOrthographic(size.width, size.height, _nearPlane, _farPlane);
|
initOrthographic(size.width, size.height, _nearPlane, _farPlane);
|
||||||
setPosition3D(Vec3(size.width / 2, size.height / 2, 0.f));
|
setPosition3D(Vec3(size.width / 2, size.height / 2, 0.f));
|
||||||
_originalPosition = {size.width / 2, size.height / 2};
|
_originalPosition = {size.width / 2, size.height / 2};
|
||||||
setRotation3D(Vec3(0.f, 0.f, 0.f));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Director::Projection::_3D:
|
case Director::Projection::_3D:
|
||||||
|
@ -458,7 +456,6 @@ void Camera::applyCustomProperties()
|
||||||
up(0.0f, 1.0f, 0.0f);
|
up(0.0f, 1.0f, 0.0f);
|
||||||
_eyeZdistance = eye.z;
|
_eyeZdistance = eye.z;
|
||||||
setPosition3D(eye);
|
setPosition3D(eye);
|
||||||
lookAt(center, up);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,7 +509,7 @@ const Vec2& Camera::getPosition() const
|
||||||
|
|
||||||
void Camera::setPosition(const Vec2& position)
|
void Camera::setPosition(const Vec2& position)
|
||||||
{
|
{
|
||||||
_originalPosition = position;
|
_originalPosition = {position.x, position.y};
|
||||||
auto& pos = getPositionCenter(position, _projectionType, getZoom(), getRotation());
|
auto& pos = getPositionCenter(position, _projectionType, getZoom(), getRotation());
|
||||||
Node::setPosition(pos.x, pos.y);
|
Node::setPosition(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
@ -525,16 +522,16 @@ void Camera::getPosition(float* x, float* y) const
|
||||||
|
|
||||||
void Camera::setPosition(float x, float y)
|
void Camera::setPosition(float x, float y)
|
||||||
{
|
{
|
||||||
_originalPosition = getPositionCenter({x, y}, _projectionType, getZoom(), getRotation());
|
|
||||||
Node::setPosition(_originalPosition.x, _originalPosition.y);
|
|
||||||
_originalPosition = {x, y};
|
_originalPosition = {x, y};
|
||||||
|
auto& pos = getPositionCenter({x, y}, _projectionType, getZoom(), getRotation());
|
||||||
|
Node::setPosition(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::setPosition3D(const Vec3& position)
|
void Camera::setPosition3D(const Vec3& position)
|
||||||
{
|
{
|
||||||
_originalPosition = getPositionCenter({position.x, position.y}, _projectionType, getZoom(), getRotation());
|
|
||||||
Node::setPosition3D({_originalPosition.x, _originalPosition.y, position.z});
|
|
||||||
_originalPosition = {position.x, position.y};
|
_originalPosition = {position.x, position.y};
|
||||||
|
auto& pos = getPositionCenter({position.x, position.y}, _projectionType, getZoom(), getRotation());
|
||||||
|
Node::setPosition3D({pos.x, pos.y, position.z});
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 Camera::getPosition3D() const
|
Vec3 Camera::getPosition3D() const
|
||||||
|
|
|
@ -502,7 +502,7 @@ const Vec2& Node::getPosition() const
|
||||||
/// position setter
|
/// position setter
|
||||||
void Node::setPosition(const Vec2& position)
|
void Node::setPosition(const Vec2& position)
|
||||||
{
|
{
|
||||||
setPosition(position.x, position.y);
|
Node::setPosition(position.x, position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::getPosition(float* x, float* y) const
|
void Node::getPosition(float* x, float* y) const
|
||||||
|
@ -525,8 +525,8 @@ void Node::setPosition(float x, float y)
|
||||||
|
|
||||||
void Node::setPosition3D(const Vec3& position)
|
void Node::setPosition3D(const Vec3& position)
|
||||||
{
|
{
|
||||||
setPositionZ(position.z);
|
Node::setPositionZ(position.z);
|
||||||
setPosition(position.x, position.y);
|
Node::setPosition(position.x, position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 Node::getPosition3D() const
|
Vec3 Node::getPosition3D() const
|
||||||
|
@ -541,7 +541,7 @@ float Node::getPositionX() const
|
||||||
|
|
||||||
void Node::setPositionX(float x)
|
void Node::setPositionX(float x)
|
||||||
{
|
{
|
||||||
setPosition(x, _position.y);
|
Node::setPosition(x, _position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getPositionY() const
|
float Node::getPositionY() const
|
||||||
|
@ -551,7 +551,7 @@ float Node::getPositionY() const
|
||||||
|
|
||||||
void Node::setPositionY(float y)
|
void Node::setPositionY(float y)
|
||||||
{
|
{
|
||||||
setPosition(_position.x, y);
|
Node::setPosition(_position.x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Node::getPositionZ() const
|
float Node::getPositionZ() const
|
||||||
|
|
Loading…
Reference in New Issue