mirror of https://github.com/axmolengine/axmol.git
Added getInverseViewMatrix
This commit is contained in:
parent
f5ea9a2219
commit
96e6595e95
|
@ -93,28 +93,19 @@ BillBorad* BillBorad::create()
|
|||
void BillBorad::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
auto camera = Camera::getVisitingCamera();
|
||||
Mat4 viewInverseMat = camera->getViewMatrix().getInversed();
|
||||
Mat4 viewInverseMat = camera->getInverseViewMatrix();
|
||||
viewInverseMat.m[12] = viewInverseMat.m[13] = viewInverseMat.m[14] = 0;
|
||||
|
||||
Mat4 transMat = transform;
|
||||
transMat *= viewInverseMat;
|
||||
// Don't do calculate the culling if the transform was not updated
|
||||
_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transMat, _contentSize) : _insideBounds;
|
||||
//// Don't do calculate the culling if the transform was not updated
|
||||
//_insideBounds = (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transMat, _contentSize) : _insideBounds;
|
||||
|
||||
if(_insideBounds)
|
||||
//if(_insideBounds)
|
||||
{
|
||||
if (_displayedOpacity < 255)
|
||||
{
|
||||
Mat4 modelViewMat = camera->getViewMatrix() * transMat;
|
||||
_quadCommand.init(-modelViewMat.m[14], _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, transMat);
|
||||
renderer->addTransparentCommand(&_quadCommand);
|
||||
}
|
||||
else
|
||||
{
|
||||
_quadCommand.init(-_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, &_quad, 1, transMat);
|
||||
renderer->addTransparentCommand(&_quadCommand);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,18 @@ const Mat4& Camera::getViewMatrix() const
|
|||
}
|
||||
return _view;
|
||||
}
|
||||
const Mat4& Camera::getInverseViewMatrix() const
|
||||
{
|
||||
Mat4 viewInv(getNodeToWorldTransform());
|
||||
static int count = sizeof(float) * 16;
|
||||
if (memcmp(viewInv.m, _viewInv.m, count) != 0)
|
||||
{
|
||||
_viewProjectionDirty = true;
|
||||
_viewInv = viewInv;
|
||||
_view = viewInv.getInversed();
|
||||
}
|
||||
return _viewInv;
|
||||
}
|
||||
void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up)
|
||||
{
|
||||
Vec3 upv = up;
|
||||
|
|
|
@ -120,6 +120,12 @@ public:
|
|||
* @return The camera view matrix.
|
||||
*/
|
||||
const Mat4& getViewMatrix() const;
|
||||
/**
|
||||
* Gets the camera's inverse view matrix.
|
||||
*
|
||||
* @return The camera inverse view matrix.
|
||||
*/
|
||||
const Mat4& getInverseViewMatrix() const;
|
||||
|
||||
/**get view projection matrix*/
|
||||
const Mat4& getViewProjectionMatrix() const;
|
||||
|
|
Loading…
Reference in New Issue