#include <C4FoWBeam.h>
Public Member Functions | |
C4FoWBeam (int32_t iLeftX, int32_t iLeftY, int32_t iRightX, int32_t iRightY) | |
bool | isDirty () const |
bool | isClean () const |
C4FoWBeam * | getNext () const |
void | setNext (C4FoWBeam *next) |
int32_t | getLeftX (int32_t y) const |
int32_t | getRightX (int32_t y) const |
float | getLeftXf (int32_t y) const |
float | getRightXf (int32_t y) const |
int32_t | getLeftEndY () const |
int32_t | getLeftEndX () const |
float | getLeftEndXf () const |
int32_t | getRightEndY () const |
int32_t | getRightEndX () const |
float | getRightEndXf () const |
StdStrBuf | getDesc () const |
bool | isLeft (int32_t x, int32_t y) const |
bool | isRight (int32_t x, int32_t y) const |
bool | isInside (int32_t x, int32_t y) const |
void | SetLeft (int32_t x, int32_t y) |
void | SetRight (int32_t x, int32_t y) |
bool | MergeRight (int32_t x, int32_t y) |
bool | MergeLeft (int32_t x, int32_t y) |
C4FoWBeam * | Split (int32_t x, int32_t y) |
bool | EliminateRight (int32_t x, int32_t y) |
void | MergeDirty () |
void | Clean (int32_t y) |
void | Dirty (int32_t y) |
void | Prune (int32_t y) |
void | CompileFunc (StdCompiler *pComp) |
This class represents one beam. A beam is a triangle spanned by two rays: one going from the origin to the left delimiter point, one going from the origin to the right delimiter point.
LeftEndX/Y and RightEndX/Y are the positions where this beam hit a solid material pixel while LeftX/Y and RightX/Y are the positions at which this beam did not hit but merely streaked a solid pixel (= the neighboring beam hits it) and thus continues until *EndX/Y.
It is assumed that the beam always goes down in display coordinate system, thus the Y-position of the delimiting points is always > 0. C4FoWLightSection transforms the coordinate system after calculation to implement the beams that go into other directions. This class here always assumes one direction.
A beam is initially marked as "dirty", meaning that the end points of the beam haven't been found yet (by the ray trace algorithm) and the beam will extend further. When all beams are "clean", the algorithm is done.
Definition at line 37 of file C4FoWBeam.h.
|
inline |
Definition at line 40 of file C4FoWBeam.h.
Referenced by Split().
void C4FoWBeam::Clean | ( | int32_t | y | ) |
Set a new end point, making the beam "clean".
Definition at line 157 of file C4FoWBeam.cpp.
Referenced by Prune(), and C4FoWLightSection::Update().
void C4FoWBeam::CompileFunc | ( | StdCompiler * | pComp | ) |
Definition at line 188 of file C4FoWBeam.cpp.
References mkNamingAdapt(), and StdCompiler::Value().
void C4FoWBeam::Dirty | ( | int32_t | y | ) |
Extend this beam to the new maximum length, making it "dirty" because now the end points haven't been found anymore Called when the size of the light has been increased to the given value.
Definition at line 165 of file C4FoWBeam.cpp.
Referenced by C4FoWLightSection::Invalidate(), MergeDirty(), Split(), and C4FoWLightSection::Update().
bool C4FoWBeam::EliminateRight | ( | int32_t | x, |
int32_t | y | ||
) |
Makes this beam span from its left delimiter point to the right delimiter point of the next but one beam, removing the two beams in between in the process. In other words, removes the next beam and merges this beam with the next but one beam. Returns false and does not do the action in case the error threshold would be reached.
Definition at line 90 of file C4FoWBeam.cpp.
References isDirty().
Referenced by C4FoWLightSection::Update().
StdStrBuf C4FoWBeam::getDesc | ( | ) | const |
Definition at line 36 of file C4FoWBeam.cpp.
References FormatString(), getLeftEndY(), getLeftX(), getRightEndY(), and getRightX().
Referenced by C4FoWLightSection::Update().
|
inline |
Definition at line 69 of file C4FoWBeam.h.
References getLeftX().
|
inline |
Definition at line 70 of file C4FoWBeam.h.
References getLeftXf().
Referenced by C4FoWLightSection::CalculateTriangles().
|
inline |
Definition at line 68 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::CalculateTriangles(), getDesc(), C4FoWLightSection::Invalidate(), MergeDirty(), and C4FoWLightSection::Update().
|
inline |
Definition at line 63 of file C4FoWBeam.h.
Referenced by getDesc(), getLeftEndX(), and C4FoWLightSection::Update().
|
inline |
Definition at line 65 of file C4FoWBeam.h.
Referenced by getLeftEndXf().
|
inline |
Definition at line 59 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::CalculateTriangles(), C4FoWLightSection::CompileFunc(), C4FoWLightSection::Dirty(), C4FoWLightSection::Invalidate(), MergeDirty(), C4FoWLightSection::Prune(), and C4FoWLightSection::Update().
|
inline |
Definition at line 72 of file C4FoWBeam.h.
References getRightX().
Referenced by C4FoWLightSection::Update().
|
inline |
Definition at line 73 of file C4FoWBeam.h.
References getRightXf().
Referenced by C4FoWLightSection::CalculateTriangles().
|
inline |
Definition at line 71 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::CalculateTriangles(), getDesc(), C4FoWLightSection::Invalidate(), and C4FoWLightSection::Update().
|
inline |
Definition at line 64 of file C4FoWBeam.h.
Referenced by getDesc(), getRightEndX(), and C4FoWLightSection::Update().
|
inline |
Definition at line 66 of file C4FoWBeam.h.
Referenced by getRightEndXf().
|
inline |
Definition at line 58 of file C4FoWBeam.h.
|
inline |
Definition at line 57 of file C4FoWBeam.h.
Referenced by EliminateRight(), C4FoWLightSection::Invalidate(), MergeDirty(), MergeLeft(), MergeRight(), Split(), and C4FoWLightSection::Update().
|
inline |
returns whether the given point is inside the triangle that is defined by this beam
Definition at line 88 of file C4FoWBeam.h.
References isLeft(), and isRight().
Referenced by Split().
|
inline |
returns whether the given point is left of an imaginery line drawn from the origin to the left delimiter point (point is left of beam)
Definition at line 78 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::Invalidate(), isInside(), MergeLeft(), and C4FoWLightSection::Update().
|
inline |
returns whether the given point is right of an imaginery line drawn from the origin to the right delimiter point (point is right of beam)
Definition at line 83 of file C4FoWBeam.h.
Referenced by isInside(), MergeRight(), and C4FoWLightSection::Update().
void C4FoWBeam::MergeDirty | ( | ) |
Definition at line 136 of file C4FoWBeam.cpp.
References Dirty(), getLeftEndY(), getNext(), and isDirty().
Referenced by C4FoWLightSection::Invalidate().
bool C4FoWBeam::MergeLeft | ( | int32_t | x, |
int32_t | y | ||
) |
Set the new left delimiter point to the given point if the resulting difference in size is less than the error threshold. If successfull, adds the introduced error to iError.
Asserts that the given point is really left of the right delimiter point
Definition at line 70 of file C4FoWBeam.cpp.
References isDirty(), and isLeft().
Referenced by C4FoWLightSection::Update().
bool C4FoWBeam::MergeRight | ( | int32_t | x, |
int32_t | y | ||
) |
Set the new right delimiter point to the given point if the resulting difference in size is less than the error threshold. If successfull, adds the introduced error to iError.
Asserts that the given point is really right of the right delimiter point
Definition at line 45 of file C4FoWBeam.cpp.
References isDirty(), and isRight().
Referenced by C4FoWLightSection::Update().
void C4FoWBeam::Prune | ( | int32_t | y | ) |
Prune this beam to a new maximum length. Called when the size of the light has been decreased to the given value.
Definition at line 173 of file C4FoWBeam.cpp.
References Clean().
|
inline |
Definition at line 92 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::Update().
|
inline |
Definition at line 60 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::CompileFunc().
|
inline |
Definition at line 93 of file C4FoWBeam.h.
Referenced by C4FoWLightSection::Update().
C4FoWBeam * C4FoWBeam::Split | ( | int32_t | x, |
int32_t | y | ||
) |
Split this beam into two: this beam and the returned one. The given point x,y is the position at which the two resulting beams are connected with their left/right endpoints. It is asserted that the given point is inside the previous beam. (So the beam can only made smaller)
Definition at line 117 of file C4FoWBeam.cpp.
References C4FoWBeam(), Dirty(), isDirty(), and isInside().
Referenced by C4FoWLightSection::Update().