Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

A couple small fixes. #926

Merged
merged 4 commits into from

2 participants

This page is out of date. Refresh to see the latest.
View
14 gameplay/src/Form.cpp
@@ -748,21 +748,19 @@ bool Form::projectPoint(int x, int y, Vector3* point)
{
// Get info about the form's position.
Matrix m = _node->getWorldMatrix();
- Vector3 min(0, 0, 0);
- m.transformPoint(&min);
+ Vector3 pointOnPlane(0, 0, 0);
+ m.transformPoint(&pointOnPlane);
// Unproject point into world space.
Ray ray;
camera->pickRay(Game::getInstance()->getViewport(), x, y, &ray);
// Find the quad's plane. We know its normal is the quad's forward vector.
- Vector3 normal = _node->getForwardVectorWorld();
+ Vector3 normal = _node->getForwardVectorWorld().normalize();
- // To get the plane's distance from the origin, we'll find the distance from the plane defined
- // by the quad's forward vector and one of its points to the plane defined by the same vector and the origin.
- const float& a = normal.x; const float& b = normal.y; const float& c = normal.z;
- const float d = -(a*min.x) - (b*min.y) - (c*min.z);
- const float distance = fabs(d) / sqrt(a*a + b*b + c*c);
+ // To get the plane's distance from the origin, we project a point on the
+ // plane onto the plane's normal vector.
+ const float distance = fabs(Vector3::dot(pointOnPlane, normal));
Plane plane(normal, -distance);
// Check for collision with plane.
View
5 gameplay/src/ImageControl.cpp
@@ -113,6 +113,11 @@ const Rectangle& ImageControl::getRegionDst() const
return _dstRegion;
}
+const char* ImageControl::getType() const
+{
+ return "image";
+}
+
void ImageControl::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
{
spriteBatch->finish();
View
6 gameplay/src/ImageControl.h
@@ -1,7 +1,7 @@
#ifndef IMAGECONTROL_H_
#define IMAGECONTROL_H_
-#include "Control.h"
+#include "Button.h"
#include "Theme.h"
#include "Image.h"
#include "SpriteBatch.h"
@@ -33,7 +33,7 @@ namespace gameplay
}
@endverbatim
*/
-class ImageControl : public Control
+class ImageControl : public Button
{
friend class Container;
@@ -109,6 +109,8 @@ class ImageControl : public Control
*/
const Rectangle& getRegionDst() const;
+ const char* getType() const;
+
protected:
ImageControl();
Something went wrong with that request. Please try again.