mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2025-09-08 17:10:16 +02:00
vector_type is 3 x float, TCollisionComponent v1.
This commit is contained in:
parent
0258363287
commit
a1678120f8
15 changed files with 270 additions and 60 deletions
|
@ -5,19 +5,21 @@
|
|||
TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, float x0, float y0, float x1,
|
||||
float y1): TEdgeSegment(collCmp, flagPtr, visualFlag)
|
||||
{
|
||||
Start.X = x0;
|
||||
Start.Y = y0;
|
||||
End.X = x1;
|
||||
End.Y = y1;
|
||||
this->X0 = x0;
|
||||
this->Y0 = y0;
|
||||
this->X1 = x1;
|
||||
this->Y1 = y1;
|
||||
maths::line_init(&Line, x0, y0, x1, y1);
|
||||
}
|
||||
|
||||
TLine::TLine(TCollisionComponent* collCmp, char* flagPtr, unsigned int visualFlag, struct vector_type* start,
|
||||
struct vector_type* end) : TEdgeSegment(collCmp, flagPtr, visualFlag)
|
||||
{
|
||||
Start = *start;
|
||||
End = *end;
|
||||
maths::line_init(&Line, Start.X, Start.Y, End.X, End.Y);
|
||||
this->X0 = start->X;
|
||||
this->Y0 = start->Y;
|
||||
this->X1 = end->X;
|
||||
this->Y1 = end->Y;
|
||||
maths::line_init(&Line, X0, Y0, X1, Y1);
|
||||
}
|
||||
|
||||
void TLine::Offset(float offset)
|
||||
|
@ -25,14 +27,14 @@ void TLine::Offset(float offset)
|
|||
float offX = offset * Line.PerpendicularL.X;
|
||||
float offY = offset * Line.PerpendicularL.Y;
|
||||
|
||||
Start.X += offX;
|
||||
Start.Y += offY;
|
||||
End.X += offX;
|
||||
End.Y += offY;
|
||||
maths::line_init(&Line, Start.X, Start.Y, End.X, End.Y);
|
||||
X0 += offX;
|
||||
Y0 += offY;
|
||||
X1 += offX;
|
||||
Y1 += offY;
|
||||
maths::line_init(&Line, X0, Y0, X1, Y1);
|
||||
}
|
||||
|
||||
double TLine::FindCollisionDistance(ray_type* ray)
|
||||
{
|
||||
return maths::ray_intersect_line(ray, &Line);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue