]> git.localhorst.tv Git - sdl-test7.git/blob - src/geometry/FakeLens.cpp
imported current version
[sdl-test7.git] / src / geometry / FakeLens.cpp
1 /*
2  * FakeLens.cpp
3  *
4  *  Created on: Apr 24, 2012
5  *      Author: holy
6  */
7
8 #include "FakeLens.h"
9
10 #include "Circle.h"
11
12
13 #include <iostream>
14 using namespace std;
15
16
17 namespace geometry {
18
19 bool FakeLens::Overlaps(const Shape &other, Vector &normal) const {
20         if (other.Overlaps(*this, normal)) {
21                 normal *= -1;
22                 return true;
23         } else {
24                 return false;
25         }
26 }
27
28 bool FakeLens::Overlaps(const AABB &other, Vector &normal) const {
29         if (AABB::Overlaps(other, normal)) {
30                 MessUpNormal(normal, other);
31                 return true;
32         } else {
33                 return false;
34         }
35 }
36
37 bool FakeLens::Overlaps(const Circle &other, Vector &normal) const {
38         if (AABB::Overlaps(other, normal)) {
39                 MessUpNormal(normal, other);
40                 return true;
41         } else {
42                 return false;
43         }
44 }
45
46 bool FakeLens::Overlaps(const FakeLens &other, Vector &normal) const {
47         if (AABB::Overlaps(static_cast<const AABB &>(other), normal)) {
48                 MessUpNormal(normal, other);
49                 return true;
50         } else {
51                 return false;
52         }
53 }
54
55
56 std::ostream &FakeLens::Write(std::ostream &out) const {
57         return out << "FakeLens(" << Width() << 'x' << Height() << '+' << X() << '+' << Y() << ')';
58 }
59
60
61 void FakeLens::MessUpNormal(Vector &normal, const Shape &other) const {
62         Vector direction((Center() - other.Center()).Unify());
63         normal = ((1 - bendFactor) * normal) + (bendFactor* direction);
64         normal.Unify();
65 }
66
67 }