mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-22 17:00:18 +01:00
Compare commits
2 commits
3f7526ba12
...
2d0da712e3
Author | SHA1 | Date | |
---|---|---|---|
|
2d0da712e3 | ||
|
d23444b983 |
60 changed files with 171 additions and 181 deletions
|
@ -49,7 +49,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
|
||||||
loader::query_visual(groupIndex, index, &visual);
|
loader::query_visual(groupIndex, index, &visual);
|
||||||
if (ListBitmap)
|
if (ListBitmap)
|
||||||
ListBitmap->push_back(visual.Bitmap);
|
ListBitmap->push_back(visual.Bitmap);
|
||||||
auto visVec = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, index, 501));
|
auto visVec = reinterpret_cast<vector3*>(loader::query_float_attribute(groupIndex, index, 501));
|
||||||
auto zDepth = proj::z_distance(visVec);
|
auto zDepth = proj::z_distance(visVec);
|
||||||
VisualZArray[index] = zDepth;
|
VisualZArray[index] = zDepth;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ int TBall::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBall::throw_ball(TBall* ball, vector_type* acceleration, float angleMult, float speedMult1, float speedMult2)
|
void TBall::throw_ball(TBall* ball, vector3* acceleration, float angleMult, float speedMult1, float speedMult2)
|
||||||
{
|
{
|
||||||
ball->CollisionComp = nullptr;
|
ball->CollisionComp = nullptr;
|
||||||
ball->Acceleration = *acceleration;
|
ball->Acceleration = *acceleration;
|
||||||
|
|
|
@ -14,22 +14,22 @@ public :
|
||||||
bool already_hit(TEdgeSegment* edge);
|
bool already_hit(TEdgeSegment* edge);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
|
|
||||||
static void throw_ball(TBall* ball, struct vector_type* acceleration, float angleMult, float speedMult1,
|
static void throw_ball(TBall* ball, vector3* acceleration, float angleMult, float speedMult1,
|
||||||
float speedMult2);
|
float speedMult2);
|
||||||
|
|
||||||
vector_type Position{};
|
vector3 Position{};
|
||||||
vector_type Acceleration{};
|
vector3 Acceleration{};
|
||||||
float Speed;
|
float Speed;
|
||||||
float RayMaxDistance;
|
float RayMaxDistance;
|
||||||
float TimeDelta;
|
float TimeDelta;
|
||||||
float TimeNow;
|
float TimeNow;
|
||||||
vector_type InvAcceleration{};
|
vector2 InvAcceleration{};
|
||||||
vector_type RampFieldForce{};
|
vector2 RampFieldForce{};
|
||||||
TCollisionComponent* CollisionComp;
|
TCollisionComponent* CollisionComp;
|
||||||
int FieldFlag;
|
int FieldFlag;
|
||||||
TEdgeSegment* Collisions[5]{};
|
TEdgeSegment* Collisions[5]{};
|
||||||
int EdgeCollisionCount;
|
int EdgeCollisionCount;
|
||||||
vector_type CollisionOffset{};
|
vector3 CollisionOffset{};
|
||||||
int CollisionFlag;
|
int CollisionFlag;
|
||||||
float Offset;
|
float Offset;
|
||||||
float VisualZArray[50]{};
|
float VisualZArray[50]{};
|
||||||
|
|
|
@ -100,7 +100,7 @@ int TBumper::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBumper::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TBumper::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (DefaultCollision(ball, nextPosition, direction))
|
if (DefaultCollision(ball, nextPosition, direction))
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
TBumper(TPinballTable* table, int groupIndex);
|
TBumper(TPinballTable* table, int groupIndex);
|
||||||
~TBumper() override = default;
|
~TBumper() override = default;
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "TCollisionComponent.h"
|
#include "TCollisionComponent.h"
|
||||||
#include "TTableLayer.h"
|
#include "TTableLayer.h"
|
||||||
|
|
||||||
TCircle::TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned collisionGroup, vector_type* center,
|
TCircle::TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned collisionGroup, vector2* center,
|
||||||
float radius): TEdgeSegment(collComp, activeFlag, collisionGroup)
|
float radius): TEdgeSegment(collComp, activeFlag, collisionGroup)
|
||||||
{
|
{
|
||||||
Circle.RadiusSq = radius * radius;
|
Circle.RadiusSq = radius * radius;
|
||||||
|
@ -19,7 +19,7 @@ float TCircle::FindCollisionDistance(ray_type* ray)
|
||||||
|
|
||||||
void TCircle::EdgeCollision(TBall* ball, float coef)
|
void TCircle::EdgeCollision(TBall* ball, float coef)
|
||||||
{
|
{
|
||||||
vector_type direction{}, nextPosition{};
|
vector2 direction{}, nextPosition{};
|
||||||
|
|
||||||
nextPosition.X = coef * ball->Acceleration.X + ball->Position.X;
|
nextPosition.X = coef * ball->Acceleration.X + ball->Position.X;
|
||||||
nextPosition.Y = coef * ball->Acceleration.Y + ball->Position.Y;
|
nextPosition.Y = coef * ball->Acceleration.Y + ball->Position.Y;
|
||||||
|
|
|
@ -8,7 +8,7 @@ class TCircle :
|
||||||
public:
|
public:
|
||||||
circle_type Circle{};
|
circle_type Circle{};
|
||||||
|
|
||||||
TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, vector_type* center,
|
TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, vector2* center,
|
||||||
float radius);
|
float radius);
|
||||||
float FindCollisionDistance(ray_type* ray) override;
|
float FindCollisionDistance(ray_type* ray) override;
|
||||||
void EdgeCollision(TBall* ball, float coef) override;
|
void EdgeCollision(TBall* ball, float coef) override;
|
||||||
|
|
|
@ -51,7 +51,7 @@ void TCollisionComponent::port_draw()
|
||||||
edge->port_draw();
|
edge->port_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TCollisionComponent::DefaultCollision(TBall* ball, vector_type* nextPosition, vector_type* direction)
|
int TCollisionComponent::DefaultCollision(TBall* ball, vector2* nextPosition, vector2* direction)
|
||||||
{
|
{
|
||||||
if (PinballTable->TiltLockFlag)
|
if (PinballTable->TiltLockFlag)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ int TCollisionComponent::DefaultCollision(TBall* ball, vector_type* nextPosition
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCollisionComponent::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction,
|
void TCollisionComponent::Collision(TBall* ball, vector2* nextPosition, vector2* direction,
|
||||||
float coef, TEdgeSegment* edge)
|
float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
int soundIndex;
|
int soundIndex;
|
||||||
|
@ -105,7 +105,7 @@ void TCollisionComponent::Collision(TBall* ball, vector_type* nextPosition, vect
|
||||||
loader::play_sound(soundIndex);
|
loader::play_sound(soundIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TCollisionComponent::FieldEffect(TBall* ball, vector_type* vecDst)
|
int TCollisionComponent::FieldEffect(TBall* ball, vector2* vecDst)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "TPinballComponent.h"
|
#include "TPinballComponent.h"
|
||||||
|
|
||||||
struct vector_type;
|
struct vector2;
|
||||||
class TEdgeSegment;
|
class TEdgeSegment;
|
||||||
class TBall;
|
class TBall;
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ public:
|
||||||
TCollisionComponent(TPinballTable* table, int groupIndex, bool createWall);
|
TCollisionComponent(TPinballTable* table, int groupIndex, bool createWall);
|
||||||
~TCollisionComponent() override;
|
~TCollisionComponent() override;
|
||||||
void port_draw() override;
|
void port_draw() override;
|
||||||
virtual void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
virtual void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge);
|
TEdgeSegment* edge);
|
||||||
virtual int FieldEffect(TBall* ball, vector_type* vecDst);
|
virtual int FieldEffect(TBall* ball, vector2* vecDst);
|
||||||
int DefaultCollision(TBall* ball, vector_type* nextPosition, vector_type* direction);
|
int DefaultCollision(TBall* ball, vector2* nextPosition, vector2* direction);
|
||||||
};
|
};
|
||||||
|
|
|
@ -93,7 +93,7 @@ int TDemo::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDemo::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TDemo::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->not_again(edge);
|
ball->not_again(edge);
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TDemo :
|
||||||
public:
|
public:
|
||||||
TDemo(TPinballTable* table, int groupIndex);
|
TDemo(TPinballTable* table, int groupIndex);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void PlungerRelease(int timerId, void* caller);
|
static void PlungerRelease(int timerId, void* caller);
|
||||||
|
|
|
@ -28,7 +28,7 @@ int TDrain::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDrain::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TDrain::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->Message(1024, 0.0);
|
ball->Message(1024, 0.0);
|
||||||
PinballTable->BallInSink = 1;
|
PinballTable->BallInSink = 1;
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TDrain :
|
||||||
public:
|
public:
|
||||||
TDrain(TPinballTable* table, int groupIndex);
|
TDrain(TPinballTable* table, int groupIndex);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void TimerCallback(int timerId, void* caller);
|
static void TimerCallback(int timerId, void* caller);
|
||||||
|
|
|
@ -87,9 +87,9 @@ int TEdgeManager::TestGridBox(int x, int y, float* distPtr, TEdgeSegment** edgeD
|
||||||
return edgeIndex;
|
return edgeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEdgeManager::FieldEffects(TBall* ball, vector_type* dstVec)
|
void TEdgeManager::FieldEffects(TBall* ball, vector2* dstVec)
|
||||||
{
|
{
|
||||||
vector_type vec{};
|
vector2 vec{};
|
||||||
TEdgeBox* edgeBox = &BoxArray[box_x(ball->Position.X) + box_y(ball->Position.Y) *
|
TEdgeBox* edgeBox = &BoxArray[box_x(ball->Position.X) + box_y(ball->Position.Y) *
|
||||||
MaxBoxX];
|
MaxBoxX];
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TEdgeManager
|
||||||
public:
|
public:
|
||||||
TEdgeManager(float posX, float posY, float width, float height);
|
TEdgeManager(float posX, float posY, float width, float height);
|
||||||
~TEdgeManager();
|
~TEdgeManager();
|
||||||
void FieldEffects(TBall* ball, struct vector_type* dstVec);
|
void FieldEffects(TBall* ball, struct vector2* dstVec);
|
||||||
int box_x(float x);
|
int box_x(float x);
|
||||||
int box_y(float y);
|
int box_y(float y);
|
||||||
int increment_box_x(int x);
|
int increment_box_x(int x);
|
||||||
|
|
|
@ -20,7 +20,8 @@ void TEdgeSegment::port_draw()
|
||||||
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
|
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
|
||||||
unsigned int collisionGroup, float offset, size_t wallValue)
|
unsigned int collisionGroup, float offset, size_t wallValue)
|
||||||
{
|
{
|
||||||
vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{};
|
vector2 center{}, start{}, end{}, prevCenter{};
|
||||||
|
vector3 vec1{}, vec2{}, dstVec{};
|
||||||
TEdgeSegment* edge = nullptr;
|
TEdgeSegment* edge = nullptr;
|
||||||
|
|
||||||
wall_type wallType = static_cast<wall_type>(static_cast<int>(floor(*floatArr) - 1.0f));
|
wall_type wallType = static_cast<wall_type>(static_cast<int>(floor(*floatArr) - 1.0f));
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
||||||
{
|
{
|
||||||
visualStruct visual{};
|
visualStruct visual{};
|
||||||
vector_type end{}, start{};
|
vector2 end{}, start{};
|
||||||
|
|
||||||
Timer = 0;
|
Timer = 0;
|
||||||
loader::query_visual(groupIndex, 0, &visual);
|
loader::query_visual(groupIndex, 0, &visual);
|
||||||
|
@ -72,7 +72,7 @@ int TFlagSpinner::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFlagSpinner::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TFlagSpinner::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TFlagSpinner :
|
||||||
public:
|
public:
|
||||||
TFlagSpinner(TPinballTable* table, int groupIndex);
|
TFlagSpinner(TPinballTable* table, int groupIndex);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
|
|
|
@ -31,9 +31,9 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
|
||||||
retractTime = 0.08f;
|
retractTime = 0.08f;
|
||||||
extendTime = 0.04f;
|
extendTime = 0.04f;
|
||||||
}
|
}
|
||||||
auto vecT2 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 802));
|
auto vecT2 = reinterpret_cast<vector3*>(loader::query_float_attribute(groupIndex, 0, 802));
|
||||||
auto vecT1 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 801));
|
auto vecT1 = reinterpret_cast<vector3*>(loader::query_float_attribute(groupIndex, 0, 801));
|
||||||
auto origin = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 800));
|
auto origin = reinterpret_cast<vector3*>(loader::query_float_attribute(groupIndex, 0, 800));
|
||||||
auto flipperEdge = new TFlipperEdge(
|
auto flipperEdge = new TFlipperEdge(
|
||||||
this,
|
this,
|
||||||
&ActiveFlag,
|
&ActiveFlag,
|
||||||
|
@ -128,7 +128,7 @@ void TFlipper::port_draw()
|
||||||
FlipperEdge->port_draw();
|
FlipperEdge->port_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFlipper::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TFlipper::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ public:
|
||||||
~TFlipper() override;
|
~TFlipper() override;
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void port_draw() override;
|
void port_draw() override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
|
|
|
@ -7,15 +7,15 @@
|
||||||
#include "TTableLayer.h"
|
#include "TTableLayer.h"
|
||||||
|
|
||||||
float TFlipperEdge::flipper_sin_angle, TFlipperEdge::flipper_cos_angle;
|
float TFlipperEdge::flipper_sin_angle, TFlipperEdge::flipper_cos_angle;
|
||||||
vector_type TFlipperEdge::A1, TFlipperEdge::A2, TFlipperEdge::B1, TFlipperEdge::B2, TFlipperEdge::T1;
|
vector2 TFlipperEdge::A1, TFlipperEdge::A2, TFlipperEdge::B1, TFlipperEdge::B2, TFlipperEdge::T1;
|
||||||
line_type TFlipperEdge::lineA, TFlipperEdge::lineB;
|
line_type TFlipperEdge::lineA, TFlipperEdge::lineB;
|
||||||
circle_type TFlipperEdge::circlebase, TFlipperEdge::circleT1;
|
circle_type TFlipperEdge::circlebase, TFlipperEdge::circleT1;
|
||||||
|
|
||||||
TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, TPinballTable* table,
|
TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, TPinballTable* table,
|
||||||
vector_type* origin, vector_type* vecT1, vector_type* vecT2, float extendTime, float retractTime,
|
vector3* origin, vector3* vecT1, vector3* vecT2, float extendTime, float retractTime,
|
||||||
float collMult, float elasticity, float smoothness): TEdgeSegment(collComp, activeFlag, collisionGroup)
|
float collMult, float elasticity, float smoothness): TEdgeSegment(collComp, activeFlag, collisionGroup)
|
||||||
{
|
{
|
||||||
vector_type crossProd{}, vecDir1{}, vecDir2{};
|
vector3 crossProd{}, vecDir1{}, vecDir2{};
|
||||||
|
|
||||||
Elasticity = elasticity;
|
Elasticity = elasticity;
|
||||||
Smoothness = smoothness;
|
Smoothness = smoothness;
|
||||||
|
@ -200,7 +200,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
|
||||||
auto ballInside = is_ball_inside(posX, posY);
|
auto ballInside = is_ball_inside(posX, posY);
|
||||||
if (ballInside != 0)
|
if (ballInside != 0)
|
||||||
{
|
{
|
||||||
vector_type* linePtr;
|
vector2* linePtr;
|
||||||
if (FlipperFlag == 1 && ballInside != 5)
|
if (FlipperFlag == 1 && ballInside != 5)
|
||||||
{
|
{
|
||||||
linePtr = &lineA.PerpendicularL;
|
linePtr = &lineA.PerpendicularL;
|
||||||
|
@ -271,7 +271,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
|
||||||
NextBallPosition = dstRay.Origin;
|
NextBallPosition = dstRay.Origin;
|
||||||
NextBallPosition.X -= srcRay.Direction.X * 1e-05f;
|
NextBallPosition.X -= srcRay.Direction.X * 1e-05f;
|
||||||
NextBallPosition.Y -= srcRay.Direction.Y * 1e-05f;
|
NextBallPosition.Y -= srcRay.Direction.Y * 1e-05f;
|
||||||
vector_type* linePtr;
|
vector2* linePtr;
|
||||||
if (FlipperFlag == 2)
|
if (FlipperFlag == 2)
|
||||||
{
|
{
|
||||||
linePtr = &lineB.PerpendicularL;
|
linePtr = &lineB.PerpendicularL;
|
||||||
|
@ -435,7 +435,7 @@ float TFlipperEdge::flipper_angle(float timeNow)
|
||||||
|
|
||||||
int TFlipperEdge::is_ball_inside(float x, float y)
|
int TFlipperEdge::is_ball_inside(float x, float y)
|
||||||
{
|
{
|
||||||
vector_type testPoint{};
|
vector2 testPoint{};
|
||||||
float dx = RotOrigin.X - x;
|
float dx = RotOrigin.X - x;
|
||||||
float dy = RotOrigin.Y - y;
|
float dy = RotOrigin.Y - y;
|
||||||
if (((A2.X - A1.X) * (y - A1.Y) - (A2.Y - A1.Y) * (x - A1.X) >= 0.0f &&
|
if (((A2.X - A1.X) * (y - A1.Y) - (A2.Y - A1.Y) * (x - A1.X) >= 0.0f &&
|
||||||
|
|
|
@ -8,7 +8,7 @@ class TFlipperEdge : public TEdgeSegment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, TPinballTable* table,
|
TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, TPinballTable* table,
|
||||||
vector_type* origin, vector_type* vecT1, vector_type* vecT2, float extendTime, float retractTime, float collMult,
|
vector3* origin, vector3* vecT1, vector3* vecT2, float extendTime, float retractTime, float collMult,
|
||||||
float elasticity, float smoothness);
|
float elasticity, float smoothness);
|
||||||
void port_draw() override;
|
void port_draw() override;
|
||||||
float FindCollisionDistance(ray_type* ray) override;
|
float FindCollisionDistance(ray_type* ray) override;
|
||||||
|
@ -23,7 +23,7 @@ public:
|
||||||
int FlipperFlag;
|
int FlipperFlag;
|
||||||
float Elasticity;
|
float Elasticity;
|
||||||
float Smoothness;
|
float Smoothness;
|
||||||
vector_type RotOrigin{};
|
vector2 RotOrigin{};
|
||||||
float CirclebaseRadius;
|
float CirclebaseRadius;
|
||||||
float CircleT1Radius;
|
float CircleT1Radius;
|
||||||
float CirclebaseRadiusSq;
|
float CirclebaseRadiusSq;
|
||||||
|
@ -35,27 +35,27 @@ public:
|
||||||
float Angle1;
|
float Angle1;
|
||||||
int CollisionFlag1;
|
int CollisionFlag1;
|
||||||
int CollisionFlag2{};
|
int CollisionFlag2{};
|
||||||
vector_type CollisionLinePerp{};
|
vector2 CollisionLinePerp{};
|
||||||
vector_type A1Src{};
|
vector2 A1Src{};
|
||||||
vector_type A2Src{};
|
vector2 A2Src{};
|
||||||
vector_type B1Src{};
|
vector2 B1Src{};
|
||||||
vector_type B2Src{};
|
vector2 B2Src{};
|
||||||
float CollisionMult;
|
float CollisionMult;
|
||||||
vector_type T1Src{};
|
vector2 T1Src{};
|
||||||
vector_type T2Src{};
|
vector2 T2Src{};
|
||||||
float DistanceDivSq;
|
float DistanceDivSq;
|
||||||
float CollisionTimeAdvance;
|
float CollisionTimeAdvance;
|
||||||
vector_type CollisionDirection{};
|
vector2 CollisionDirection{};
|
||||||
int EdgeCollisionFlag;
|
int EdgeCollisionFlag;
|
||||||
float InputTime;
|
float InputTime;
|
||||||
float AngleStopTime;
|
float AngleStopTime;
|
||||||
float AngleMult;
|
float AngleMult;
|
||||||
float ExtendTime;
|
float ExtendTime;
|
||||||
float RetractTime;
|
float RetractTime;
|
||||||
vector_type NextBallPosition{};
|
vector2 NextBallPosition{};
|
||||||
|
|
||||||
static float flipper_sin_angle, flipper_cos_angle;
|
static float flipper_sin_angle, flipper_cos_angle;
|
||||||
static vector_type A1, A2, B1, B2, T1;
|
static vector2 A1, A2, B1, B2, T1;
|
||||||
static line_type lineA, lineB;
|
static line_type lineA, lineB;
|
||||||
static circle_type circlebase, circleT1;
|
static circle_type circlebase, circleT1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,7 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||||
Circle.RadiusSq = 0.001f;
|
Circle.RadiusSq = 0.001f;
|
||||||
|
|
||||||
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
||||||
reinterpret_cast<vector_type*>(visual.FloatArr),
|
reinterpret_cast<vector3*>(visual.FloatArr),
|
||||||
Circle.RadiusSq);
|
Circle.RadiusSq);
|
||||||
if (tCircle)
|
if (tCircle)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,6 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||||
circle.RadiusSq = Circle.RadiusSq;
|
circle.RadiusSq = Circle.RadiusSq;
|
||||||
circle.Center.X = Circle.Center.X;
|
circle.Center.X = Circle.Center.X;
|
||||||
circle.Center.Y = Circle.Center.Y;
|
circle.Center.Y = Circle.Center.Y;
|
||||||
circle.Center.Z = Circle.Center.Z;
|
|
||||||
|
|
||||||
Field.Flag2Ptr = &ActiveFlag;
|
Field.Flag2Ptr = &ActiveFlag;
|
||||||
Field.CollisionComp = this;
|
Field.CollisionComp = this;
|
||||||
|
@ -70,7 +69,7 @@ int THole::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void THole::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void THole::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (!BallCapturedFlag)
|
if (!BallCapturedFlag)
|
||||||
{
|
{
|
||||||
|
@ -94,10 +93,10 @@ void THole::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int THole::FieldEffect(TBall* ball, vector_type* vecDst)
|
int THole::FieldEffect(TBall* ball, vector2* vecDst)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
vector_type direction{};
|
vector2 direction{};
|
||||||
|
|
||||||
if (BallCapturedFlag)
|
if (BallCapturedFlag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,9 +9,9 @@ class THole :
|
||||||
public:
|
public:
|
||||||
THole(TPinballTable* table, int groupIndex);
|
THole(TPinballTable* table, int groupIndex);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
int FieldEffect(TBall* ball, vector_type* vecDst) override;
|
int FieldEffect(TBall* ball, vector2* vecDst) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ int TKickback::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TKickback::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TKickback::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (PinballTable->TiltLockFlag)
|
if (PinballTable->TiltLockFlag)
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TKickback :
|
||||||
public:
|
public:
|
||||||
TKickback(TPinballTable* table, int groupIndex);
|
TKickback(TPinballTable* table, int groupIndex);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
|
|
|
@ -36,7 +36,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
|
||||||
if (Circle.RadiusSq == 0.0f)
|
if (Circle.RadiusSq == 0.0f)
|
||||||
Circle.RadiusSq = 0.001f;
|
Circle.RadiusSq = 0.001f;
|
||||||
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
||||||
reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq);
|
reinterpret_cast<vector3*>(visual.FloatArr), Circle.RadiusSq);
|
||||||
if (tCircle)
|
if (tCircle)
|
||||||
{
|
{
|
||||||
tCircle->place_in_grid();
|
tCircle->place_in_grid();
|
||||||
|
@ -54,7 +54,6 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
|
||||||
circle.RadiusSq = Circle.RadiusSq;
|
circle.RadiusSq = Circle.RadiusSq;
|
||||||
circle.Center.X = Circle.Center.X;
|
circle.Center.X = Circle.Center.X;
|
||||||
circle.Center.Y = Circle.Center.Y;
|
circle.Center.Y = Circle.Center.Y;
|
||||||
circle.Center.Z = Circle.Center.Z;
|
|
||||||
Field.Flag2Ptr = &ActiveFlag;
|
Field.Flag2Ptr = &ActiveFlag;
|
||||||
Field.CollisionComp = this;
|
Field.CollisionComp = this;
|
||||||
Field.Mask = visual.CollisionGroup;
|
Field.Mask = visual.CollisionGroup;
|
||||||
|
@ -105,7 +104,7 @@ int TKickout::get_scoring(int index)
|
||||||
return index < 5 ? Scores[index] : 0;
|
return index < 5 ? Scores[index] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TKickout::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TKickout::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (!KickFlag1)
|
if (!KickFlag1)
|
||||||
{
|
{
|
||||||
|
@ -129,9 +128,9 @@ void TKickout::Collision(TBall* ball, vector_type* nextPosition, vector_type* di
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TKickout::FieldEffect(TBall* ball, vector_type* dstVec)
|
int TKickout::FieldEffect(TBall* ball, vector2* dstVec)
|
||||||
{
|
{
|
||||||
vector_type direction{};
|
vector2 direction{};
|
||||||
|
|
||||||
if (KickFlag1)
|
if (KickFlag1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,9 +11,9 @@ public:
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
int FieldEffect(TBall* ball, vector_type* vecDst) override;
|
int FieldEffect(TBall* ball, vector2* vecDst) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
static void ResetTimerExpired(int timerId, void* caller);
|
static void ResetTimerExpired(int timerId, void* caller);
|
||||||
|
@ -28,7 +28,7 @@ public:
|
||||||
float FieldMult;
|
float FieldMult;
|
||||||
circle_type Circle{};
|
circle_type Circle{};
|
||||||
float OriginalBallZ{};
|
float OriginalBallZ{};
|
||||||
vector_type BallAcceleration{};
|
vector3 BallAcceleration{};
|
||||||
float ThrowAngleMult;
|
float ThrowAngleMult;
|
||||||
float ThrowSpeedMult1;
|
float ThrowSpeedMult1;
|
||||||
float ThrowSpeedMult2;
|
float ThrowSpeedMult2;
|
||||||
|
|
|
@ -34,7 +34,7 @@ int TLightRollover::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLightRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TLightRollover::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
|
|
@ -8,7 +8,7 @@ public:
|
||||||
TLightRollover(TPinballTable* table, int groupIndex);
|
TLightRollover(TPinballTable* table, int groupIndex);
|
||||||
~TLightRollover() override = default;
|
~TLightRollover() override = default;
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void delay_expired(int timerId, void* caller);
|
static void delay_expired(int timerId, void* caller);
|
||||||
|
|
|
@ -14,8 +14,8 @@ TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collis
|
||||||
maths::line_init(&Line, x0, y0, x1, y1);
|
maths::line_init(&Line, x0, y0, x1, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, struct vector_type* start,
|
TLine::TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, struct vector2* start,
|
||||||
struct vector_type* end) : TEdgeSegment(collCmp, activeFlag, collisionGroup)
|
struct vector2* end) : TEdgeSegment(collCmp, activeFlag, collisionGroup)
|
||||||
{
|
{
|
||||||
X0 = start->X;
|
X0 = start->X;
|
||||||
Y0 = start->Y;
|
Y0 = start->Y;
|
||||||
|
|
|
@ -9,7 +9,7 @@ public:
|
||||||
line_type Line{};
|
line_type Line{};
|
||||||
float X0, Y0, X1, Y1;
|
float X0, Y0, X1, Y1;
|
||||||
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1, float y1);
|
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1, float y1);
|
||||||
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, vector_type* start, vector_type* end);
|
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, vector2* start, vector2* end);
|
||||||
void Offset(float offset);
|
void Offset(float offset);
|
||||||
float FindCollisionDistance(ray_type* ray) override;
|
float FindCollisionDistance(ray_type* ray) override;
|
||||||
void EdgeCollision(TBall* ball, float coef) override;
|
void EdgeCollision(TBall* ball, float coef) override;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
||||||
{
|
{
|
||||||
visualStruct visual{};
|
visualStruct visual{};
|
||||||
vector_type linePt1{}, linePt2{};
|
vector2 linePt1{}, linePt2{};
|
||||||
|
|
||||||
loader::query_visual(groupIndex, 0, &visual);
|
loader::query_visual(groupIndex, 0, &visual);
|
||||||
if (visual.FloatArrCount == 2)
|
if (visual.FloatArrCount == 2)
|
||||||
|
@ -40,7 +40,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TOneway::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TOneway::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (edge == Line)
|
if (edge == Line)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ class TOneway : public TCollisionComponent
|
||||||
public:
|
public:
|
||||||
TOneway(TPinballTable* table, int groupIndex);
|
TOneway(TPinballTable* table, int groupIndex);
|
||||||
~TOneway() override = default;
|
~TOneway() override = default;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
|
|
|
@ -617,7 +617,7 @@ void TPinballTable::replay_timer_callback(int timerId, void* caller)
|
||||||
void TPinballTable::tilt_timeout(int timerId, void* caller)
|
void TPinballTable::tilt_timeout(int timerId, void* caller)
|
||||||
{
|
{
|
||||||
auto table = static_cast<TPinballTable*>(caller);
|
auto table = static_cast<TPinballTable*>(caller);
|
||||||
vector_type vec{};
|
vector2 vec{};
|
||||||
|
|
||||||
table->TiltTimeoutTimer = 0;
|
table->TiltTimeoutTimer = 0;
|
||||||
if (table->TiltLockFlag)
|
if (table->TiltLockFlag)
|
||||||
|
|
|
@ -33,7 +33,7 @@ TPlunger::TPlunger(TPinballTable* table, int groupIndex) : TCollisionComponent(t
|
||||||
table->PlungerPositionY = floatArr[1];
|
table->PlungerPositionY = floatArr[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPlunger::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TPlunger::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (PinballTable->TiltLockFlag)
|
if (PinballTable->TiltLockFlag)
|
||||||
Message(1017, 0.0);
|
Message(1017, 0.0);
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TPlunger :
|
||||||
public:
|
public:
|
||||||
TPlunger(TPinballTable* table, int groupIndex);
|
TPlunger(TPinballTable* table, int groupIndex);
|
||||||
~TPlunger() override = default;
|
~TPlunger() override = default;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ int TPopupTarget::get_scoring(int index)
|
||||||
return index < 3 ? Scores[index] : 0;
|
return index < 3 ? Scores[index] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPopupTarget::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TPopupTarget::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (this->PinballTable->TiltLockFlag)
|
if (this->PinballTable->TiltLockFlag)
|
||||||
|
|
|
@ -9,7 +9,7 @@ public:
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
||||||
{
|
{
|
||||||
visualStruct visual{};
|
visualStruct visual{};
|
||||||
vector_type end{}, start{}, *end2, *start2, *start3, *end3;
|
vector2 end{}, start{}, *end2, *start2, *start3, *end3;
|
||||||
|
|
||||||
MessageField = 0;
|
MessageField = 0;
|
||||||
UnusedBaseFlag = 1;
|
UnusedBaseFlag = 1;
|
||||||
|
@ -85,16 +85,16 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
||||||
for (auto index = 0; index < RampPlaneCount; index++)
|
for (auto index = 0; index < RampPlaneCount; index++)
|
||||||
{
|
{
|
||||||
auto plane = &RampPlane[index];
|
auto plane = &RampPlane[index];
|
||||||
auto pVec1 = reinterpret_cast<vector_type*>(&plane->V1);
|
auto pVec1 = &plane->V1;
|
||||||
auto pVec2 = reinterpret_cast<vector_type*>(&plane->V2);
|
auto pVec2 = &plane->V2;
|
||||||
auto pVec3 = reinterpret_cast<vector_type*>(&plane->V3);
|
auto pVec3 = &plane->V3;
|
||||||
|
|
||||||
xMin = std::min(std::min(std::min(plane->V3.X, plane->V1.X), plane->V2.X), xMin);
|
xMin = std::min(std::min(std::min(plane->V3.X, plane->V1.X), plane->V2.X), xMin);
|
||||||
yMin = std::min(std::min(std::min(plane->V3.Y, plane->V1.Y), plane->V2.Y), xMin); // Sic
|
yMin = std::min(std::min(std::min(plane->V3.Y, plane->V1.Y), plane->V2.Y), xMin); // Sic
|
||||||
xMax = std::max(std::max(std::max(plane->V3.X, plane->V1.X), plane->V2.X), xMin);
|
xMax = std::max(std::max(std::max(plane->V3.X, plane->V1.X), plane->V2.X), xMin);
|
||||||
yMax = std::max(std::max(std::max(plane->V3.Y, plane->V1.Y), plane->V2.Y), xMin);
|
yMax = std::max(std::max(std::max(plane->V3.Y, plane->V1.Y), plane->V2.Y), xMin);
|
||||||
|
|
||||||
vector_type* pointOrder[4] = {pVec1, pVec2, pVec3, pVec1};
|
vector2* pointOrder[4] = {pVec1, pVec2, pVec3, pVec1};
|
||||||
for (auto pt = 0; pt < 3; pt++)
|
for (auto pt = 0; pt < 3; pt++)
|
||||||
{
|
{
|
||||||
auto point1 = pointOrder[pt], point2 = pointOrder[pt + 1];
|
auto point1 = pointOrder[pt], point2 = pointOrder[pt + 1];
|
||||||
|
@ -154,7 +154,7 @@ int TRamp::get_scoring(int index)
|
||||||
return index < 4 ? Scores[index] : 0;
|
return index < 4 ? Scores[index] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRamp::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TRamp::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->not_again(edge);
|
ball->not_again(edge);
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
@ -204,7 +204,7 @@ void TRamp::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TRamp::FieldEffect(TBall* ball, vector_type* vecDst)
|
int TRamp::FieldEffect(TBall* ball, vector2* vecDst)
|
||||||
{
|
{
|
||||||
vecDst->X = ball->RampFieldForce.X - ball->Acceleration.X * ball->Speed * BallFieldMult;
|
vecDst->X = ball->RampFieldForce.X - ball->Acceleration.X * ball->Speed * BallFieldMult;
|
||||||
vecDst->Y = ball->RampFieldForce.Y - ball->Acceleration.Y * ball->Speed * BallFieldMult;
|
vecDst->Y = ball->RampFieldForce.Y - ball->Acceleration.Y * ball->Speed * BallFieldMult;
|
||||||
|
|
|
@ -12,9 +12,9 @@ public:
|
||||||
TRamp(TPinballTable* table, int groupIndex);
|
TRamp(TPinballTable* table, int groupIndex);
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
int FieldEffect(TBall* ball, vector_type* vecDst) override;
|
int FieldEffect(TBall* ball, vector2* vecDst) override;
|
||||||
void port_draw() override;
|
void port_draw() override;
|
||||||
|
|
||||||
int Scores[4]{};
|
int Scores[4]{};
|
||||||
|
|
|
@ -37,7 +37,7 @@ int TRollover::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TRollover::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
|
|
@ -10,7 +10,7 @@ public:
|
||||||
TRollover(TPinballTable* table, int groupIndex);
|
TRollover(TPinballTable* table, int groupIndex);
|
||||||
~TRollover() override = default;
|
~TRollover() override = default;
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
|
|
|
@ -75,7 +75,7 @@ int TSink::get_scoring(int index)
|
||||||
return index < 3 ? Scores[index] : 0;
|
return index < 3 ? Scores[index] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSink::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TSink::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
Timer = 0;
|
Timer = 0;
|
||||||
if (PinballTable->TiltLockFlag)
|
if (PinballTable->TiltLockFlag)
|
||||||
|
|
|
@ -10,15 +10,15 @@ public:
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
|
|
||||||
int Timer;
|
int Timer;
|
||||||
float TimerTime;
|
float TimerTime;
|
||||||
vector_type BallPosition{};
|
vector2 BallPosition{};
|
||||||
vector_type BallAcceleration{};
|
vector3 BallAcceleration{};
|
||||||
float ThrowAngleMult;
|
float ThrowAngleMult;
|
||||||
float ThrowSpeedMult1;
|
float ThrowSpeedMult1;
|
||||||
float ThrowSpeedMult2;
|
float ThrowSpeedMult2;
|
||||||
|
|
|
@ -64,7 +64,7 @@ int TSoloTarget::get_scoring(int index)
|
||||||
return index < 1 ? Scores[index] : 0;
|
return index < 1 ? Scores[index] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSoloTarget::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TSoloTarget::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (DefaultCollision(ball, nextPosition, direction))
|
if (DefaultCollision(ball, nextPosition, direction))
|
||||||
|
|
|
@ -9,7 +9,7 @@ public:
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
|
|
|
@ -111,7 +111,7 @@ TTableLayer::~TTableLayer()
|
||||||
delete edge_manager;
|
delete edge_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TTableLayer::FieldEffect(TBall* ball, vector_type* vecDst)
|
int TTableLayer::FieldEffect(TBall* ball, vector2* vecDst)
|
||||||
{
|
{
|
||||||
vecDst->X = GraityDirX - (0.5f - RandFloat() + ball->Acceleration.X) *
|
vecDst->X = GraityDirX - (0.5f - RandFloat() + ball->Acceleration.X) *
|
||||||
ball->Speed * GraityMult;
|
ball->Speed * GraityMult;
|
||||||
|
@ -161,7 +161,7 @@ void TTableLayer::edges_insert_square(float y0, float x0, float y1, float x1, TE
|
||||||
void TTableLayer::edges_insert_circle(circle_type* circle, TEdgeSegment* edge, field_effect_type* field)
|
void TTableLayer::edges_insert_circle(circle_type* circle, TEdgeSegment* edge, field_effect_type* field)
|
||||||
{
|
{
|
||||||
ray_type ray{};
|
ray_type ray{};
|
||||||
vector_type vec1{};
|
vector2 vec1{};
|
||||||
|
|
||||||
auto radiusM = sqrt(circle->RadiusSq) + edge_manager->AdvanceX * 0.001f;
|
auto radiusM = sqrt(circle->RadiusSq) + edge_manager->AdvanceX * 0.001f;
|
||||||
auto radiusMSq = radiusM * radiusM;
|
auto radiusMSq = radiusM * radiusM;
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TTableLayer :
|
||||||
public:
|
public:
|
||||||
TTableLayer(TPinballTable* table);
|
TTableLayer(TPinballTable* table);
|
||||||
~TTableLayer() override;
|
~TTableLayer() override;
|
||||||
int FieldEffect(TBall* ball, vector_type* vecDst) override;
|
int FieldEffect(TBall* ball, vector2* vecDst) override;
|
||||||
|
|
||||||
static void edges_insert_square(float y0, float x0, float y1, float x1, TEdgeSegment* edge,
|
static void edges_insert_square(float y0, float x0, float y1, float x1, TEdgeSegment* edge,
|
||||||
field_effect_type* field);
|
field_effect_type* field);
|
||||||
|
|
|
@ -10,7 +10,7 @@ TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, gr
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTripwire::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void TTripwire::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge)
|
TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
|
|
@ -7,6 +7,6 @@ class TTripwire :
|
||||||
public:
|
public:
|
||||||
TTripwire(TPinballTable* table, int groupIndex);
|
TTripwire(TPinballTable* table, int groupIndex);
|
||||||
~TTripwire() override = default;
|
~TTripwire() override = default;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ int TWall::Message(int code, float value)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TWall::Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef, TEdgeSegment* edge)
|
void TWall::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef, TEdgeSegment* edge)
|
||||||
{
|
{
|
||||||
if (DefaultCollision(ball, nextPosition, direction))
|
if (DefaultCollision(ball, nextPosition, direction))
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ class TWall :
|
||||||
public:
|
public:
|
||||||
TWall(TPinballTable* table, int groupIndex);
|
TWall(TPinballTable* table, int groupIndex);
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float coef,
|
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float coef,
|
||||||
TEdgeSegment* edge) override;
|
TEdgeSegment* edge) override;
|
||||||
void put_scoring(int index, int score) override;
|
void put_scoring(int index, int score) override;
|
||||||
int get_scoring(int index) override;
|
int get_scoring(int index) override;
|
||||||
|
|
|
@ -390,7 +390,7 @@ int loader::kicker(int groupIndex, visualKickerStruct* kicker)
|
||||||
kicker->ThrowBallMult = *floatArr;
|
kicker->ThrowBallMult = *floatArr;
|
||||||
break;
|
break;
|
||||||
case 404:
|
case 404:
|
||||||
kicker->ThrowBallAcceleration = *reinterpret_cast<vector_type*>(floatArr);
|
kicker->ThrowBallAcceleration = *reinterpret_cast<vector3*>(floatArr);
|
||||||
floatArr += 3;
|
floatArr += 3;
|
||||||
index += 4;
|
index += 4;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct visualKickerStruct
|
||||||
float Threshold;
|
float Threshold;
|
||||||
float Boost;
|
float Boost;
|
||||||
float ThrowBallMult;
|
float ThrowBallMult;
|
||||||
vector_type ThrowBallAcceleration;
|
vector3 ThrowBallAcceleration;
|
||||||
float ThrowBallAngleMult;
|
float ThrowBallAngleMult;
|
||||||
int HardHitSoundId;
|
int HardHitSoundId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -155,7 +155,7 @@ float maths::ray_intersect_circle(ray_type* ray, circle_type* circle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float maths::normalize_2d(vector_type* vec)
|
float maths::normalize_2d(vector2* vec)
|
||||||
{
|
{
|
||||||
float mag = sqrt(vec->X * vec->X + vec->Y * vec->Y);
|
float mag = sqrt(vec->X * vec->X + vec->Y * vec->Y);
|
||||||
if (mag != 0.0f)
|
if (mag != 0.0f)
|
||||||
|
@ -245,14 +245,14 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
|
||||||
return 1000000000.0;
|
return 1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void maths::cross(vector_type* vec1, vector_type* vec2, vector_type* dstVec)
|
void maths::cross(vector3* vec1, vector3* vec2, vector3* dstVec)
|
||||||
{
|
{
|
||||||
dstVec->X = vec2->Z * vec1->Y - vec2->Y * vec1->Z;
|
dstVec->X = vec2->Z * vec1->Y - vec2->Y * vec1->Z;
|
||||||
dstVec->Y = vec2->X * vec1->Z - vec1->X * vec2->Z;
|
dstVec->Y = vec2->X * vec1->Z - vec1->X * vec2->Z;
|
||||||
dstVec->Z = vec1->X * vec2->Y - vec2->X * vec1->Y;
|
dstVec->Z = vec1->X * vec2->Y - vec2->X * vec1->Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float maths::magnitude(vector_type* vec)
|
float maths::magnitude(vector3* vec)
|
||||||
{
|
{
|
||||||
float result;
|
float result;
|
||||||
auto magSq = vec->X * vec->X + vec->Y * vec->Y + vec->Z * vec->Z;
|
auto magSq = vec->X * vec->X + vec->Y * vec->Y + vec->Z * vec->Z;
|
||||||
|
@ -263,13 +263,13 @@ float maths::magnitude(vector_type* vec)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void maths::vector_add(vector_type* vec1Dst, vector_type* vec2)
|
void maths::vector_add(vector2* vec1Dst, vector2* vec2)
|
||||||
{
|
{
|
||||||
vec1Dst->X += vec2->X;
|
vec1Dst->X += vec2->X;
|
||||||
vec1Dst->Y += vec2->Y;
|
vec1Dst->Y += vec2->Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float maths::basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity, float smoothness,
|
float maths::basic_collision(TBall* ball, vector2* nextPosition, vector2* direction, float elasticity, float smoothness,
|
||||||
float threshold, float boost)
|
float threshold, float boost)
|
||||||
{
|
{
|
||||||
ball->Position.X = nextPosition->X;
|
ball->Position.X = nextPosition->X;
|
||||||
|
@ -299,24 +299,24 @@ float maths::basic_collision(TBall* ball, vector_type* nextPosition, vector_type
|
||||||
return projSpeed;
|
return projSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
float maths::Distance_Squared(vector_type& vec1, vector_type& vec2)
|
float maths::Distance_Squared(vector2& vec1, vector2& vec2)
|
||||||
{
|
{
|
||||||
return (vec1.Y - vec2.Y) * (vec1.Y - vec2.Y) + (vec1.X - vec2.X) * (vec1.X - vec2.X);
|
return (vec1.Y - vec2.Y) * (vec1.Y - vec2.Y) + (vec1.X - vec2.X) * (vec1.X - vec2.X);
|
||||||
}
|
}
|
||||||
|
|
||||||
float maths::DotProduct(vector_type* vec1, vector_type* vec2)
|
float maths::DotProduct(vector2* vec1, vector2* vec2)
|
||||||
{
|
{
|
||||||
return vec1->Y * vec2->Y + vec1->X * vec2->X;
|
return vec1->Y * vec2->Y + vec1->X * vec2->X;
|
||||||
}
|
}
|
||||||
|
|
||||||
void maths::vswap(vector_type* vec1, vector_type* vec2)
|
void maths::vswap(vector2* vec1, vector2* vec2)
|
||||||
{
|
{
|
||||||
vector_type tmp = *vec1;
|
vector2 tmp = *vec1;
|
||||||
*vec1 = *vec2;
|
*vec1 = *vec2;
|
||||||
*vec2 = tmp;
|
*vec2 = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
float maths::Distance(vector_type* vec1, vector_type* vec2)
|
float maths::Distance(vector2* vec1, vector2* vec2)
|
||||||
{
|
{
|
||||||
auto dx = vec1->X - vec2->X;
|
auto dx = vec1->X - vec2->X;
|
||||||
auto dy = vec1->Y - vec2->Y;
|
auto dy = vec1->Y - vec2->Y;
|
||||||
|
@ -329,7 +329,7 @@ void maths::SinCos(float angle, float* sinOut, float* cosOut)
|
||||||
*cosOut = cos(angle);
|
*cosOut = cos(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void maths::RotatePt(vector_type* point, float sin, float cos, vector_type* origin)
|
void maths::RotatePt(vector2* point, float sin, float cos, vector2* origin)
|
||||||
{
|
{
|
||||||
auto dirX = point->X - origin->X;
|
auto dirX = point->X - origin->X;
|
||||||
auto dirY = point->Y - origin->Y;
|
auto dirY = point->Y - origin->Y;
|
||||||
|
@ -370,7 +370,7 @@ float maths::distance_to_flipper(ray_type* ray1, ray_type* ray2)
|
||||||
|
|
||||||
if (distanceType != -1)
|
if (distanceType != -1)
|
||||||
{
|
{
|
||||||
vector_type* nextOrigin;
|
vector2* nextOrigin;
|
||||||
if (distanceType)
|
if (distanceType)
|
||||||
{
|
{
|
||||||
if (distanceType != 1)
|
if (distanceType != 1)
|
||||||
|
@ -406,7 +406,7 @@ float maths::distance_to_flipper(ray_type* ray1, ray_type* ray2)
|
||||||
return 1000000000.0;
|
return 1000000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void maths::RotateVector(vector_type* vec, float angle)
|
void maths::RotateVector(vector2* vec, float angle)
|
||||||
{
|
{
|
||||||
float s = sin(angle), c = cos(angle);
|
float s = sin(angle), c = cos(angle);
|
||||||
vec->X = c * vec->X - s * vec->Y;
|
vec->X = c * vec->X - s * vec->Y;
|
||||||
|
@ -418,10 +418,10 @@ void maths::RotateVector(vector_type* vec, float angle)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void maths::find_closest_edge(ramp_plane_type* plane, int planeCount, wall_point_type* wall, vector_type** lineEnd,
|
void maths::find_closest_edge(ramp_plane_type* plane, int planeCount, wall_point_type* wall, vector2** lineEnd,
|
||||||
vector_type** lineStart)
|
vector2** lineStart)
|
||||||
{
|
{
|
||||||
vector_type wallEnd{}, wallStart{};
|
vector2 wallEnd{}, wallStart{};
|
||||||
|
|
||||||
wallStart.X = wall->X0;
|
wallStart.X = wall->X0;
|
||||||
wallStart.Y = wall->Y0;
|
wallStart.Y = wall->Y0;
|
||||||
|
@ -432,9 +432,9 @@ void maths::find_closest_edge(ramp_plane_type* plane, int planeCount, wall_point
|
||||||
ramp_plane_type* planePtr = plane;
|
ramp_plane_type* planePtr = plane;
|
||||||
for (auto index = 0; index < planeCount; index++)
|
for (auto index = 0; index < planeCount; index++)
|
||||||
{
|
{
|
||||||
auto vec1 = reinterpret_cast<vector_type*>(&planePtr->V1),
|
auto vec1 = &planePtr->V1,
|
||||||
vec2 = reinterpret_cast<vector_type*>(&planePtr->V2),
|
vec2 = &planePtr->V2,
|
||||||
vec3 = reinterpret_cast<vector_type*>(&planePtr->V3);
|
vec3 = &planePtr->V3;
|
||||||
auto distance = Distance(&wallStart, vec1) + Distance(&wallEnd, vec2);
|
auto distance = Distance(&wallStart, vec1) + Distance(&wallEnd, vec2);
|
||||||
if (distance < maxDistance)
|
if (distance < maxDistance)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
|
|
||||||
class TBall;
|
class TBall;
|
||||||
|
|
||||||
struct vector_type
|
struct vector2
|
||||||
{
|
{
|
||||||
float X;
|
float X;
|
||||||
float Y;
|
float Y;
|
||||||
float Z;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct vector3 :vector2
|
||||||
|
{
|
||||||
|
float Z;
|
||||||
|
};
|
||||||
|
|
||||||
struct rectangle_type
|
struct rectangle_type
|
||||||
{
|
{
|
||||||
|
@ -20,14 +23,14 @@ struct rectangle_type
|
||||||
|
|
||||||
struct circle_type
|
struct circle_type
|
||||||
{
|
{
|
||||||
vector_type Center;
|
vector2 Center;
|
||||||
float RadiusSq;
|
float RadiusSq;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ray_type
|
struct ray_type
|
||||||
{
|
{
|
||||||
vector_type Origin;
|
vector2 Origin;
|
||||||
vector_type Direction;
|
vector2 Direction;
|
||||||
float MaxDistance;
|
float MaxDistance;
|
||||||
float MinDistance;
|
float MinDistance;
|
||||||
float TimeNow;
|
float TimeNow;
|
||||||
|
@ -37,18 +40,12 @@ struct ray_type
|
||||||
|
|
||||||
struct line_type
|
struct line_type
|
||||||
{
|
{
|
||||||
vector_type PerpendicularL;
|
vector2 PerpendicularL;
|
||||||
vector_type Direction;
|
vector2 Direction;
|
||||||
float PreComp1;
|
float PreComp1;
|
||||||
float OriginX;
|
float OriginX;
|
||||||
float OriginY;
|
float OriginY;
|
||||||
vector_type RayIntersect;
|
vector2 RayIntersect;
|
||||||
};
|
|
||||||
|
|
||||||
struct vector_type2
|
|
||||||
{
|
|
||||||
float X;
|
|
||||||
float Y;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wall_point_type
|
struct wall_point_type
|
||||||
|
@ -61,13 +58,13 @@ struct wall_point_type
|
||||||
|
|
||||||
struct ramp_plane_type
|
struct ramp_plane_type
|
||||||
{
|
{
|
||||||
vector_type BallCollisionOffset;
|
vector3 BallCollisionOffset;
|
||||||
vector_type2 V1;
|
vector2 V1;
|
||||||
vector_type2 V2;
|
vector2 V2;
|
||||||
vector_type2 V3;
|
vector2 V3;
|
||||||
float GravityAngle1;
|
float GravityAngle1;
|
||||||
float GravityAngle2;
|
float GravityAngle2;
|
||||||
vector_type2 FieldForce;
|
vector2 FieldForce;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,23 +75,23 @@ public:
|
||||||
static int rectangle_clip(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
static int rectangle_clip(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
||||||
static int overlapping_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
static int overlapping_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
||||||
static float ray_intersect_circle(ray_type* ray, circle_type* circle);
|
static float ray_intersect_circle(ray_type* ray, circle_type* circle);
|
||||||
static float normalize_2d(vector_type* vec);
|
static float normalize_2d(vector2* vec);
|
||||||
static void line_init(line_type* line, float x0, float y0, float x1, float y1);
|
static void line_init(line_type* line, float x0, float y0, float x1, float y1);
|
||||||
static float ray_intersect_line(ray_type* ray, line_type* line);
|
static float ray_intersect_line(ray_type* ray, line_type* line);
|
||||||
static void cross(vector_type* vec1, vector_type* vec2, vector_type* dstVec);
|
static void cross(vector3* vec1, vector3* vec2, vector3* dstVec);
|
||||||
static float magnitude(vector_type* vec);
|
static float magnitude(vector3* vec);
|
||||||
static void vector_add(vector_type* vec1Dst, vector_type* vec2);
|
static void vector_add(vector2* vec1Dst, vector2* vec2);
|
||||||
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity,
|
static float basic_collision(TBall* ball, vector2* nextPosition, vector2* direction, float elasticity,
|
||||||
float smoothness,
|
float smoothness,
|
||||||
float threshold, float boost);
|
float threshold, float boost);
|
||||||
static float Distance_Squared(vector_type& vec1, vector_type& vec2);
|
static float Distance_Squared(vector2& vec1, vector2& vec2);
|
||||||
static float DotProduct(vector_type* vec1, vector_type* vec2);
|
static float DotProduct(vector2* vec1, vector2* vec2);
|
||||||
static void vswap(vector_type* vec1, vector_type* vec2);
|
static void vswap(vector2* vec1, vector2* vec2);
|
||||||
static float Distance(vector_type* vec1, vector_type* vec2);
|
static float Distance(vector2* vec1, vector2* vec2);
|
||||||
static void SinCos(float angle, float* sinOut, float* cosOut);
|
static void SinCos(float angle, float* sinOut, float* cosOut);
|
||||||
static void RotatePt(vector_type* point, float sin, float cos, vector_type* origin);
|
static void RotatePt(vector2* point, float sin, float cos, vector2* origin);
|
||||||
static float distance_to_flipper(ray_type* ray1, ray_type* ray2);
|
static float distance_to_flipper(ray_type* ray1, ray_type* ray2);
|
||||||
static void RotateVector(vector_type* vec, float angle);
|
static void RotateVector(vector2* vec, float angle);
|
||||||
static void find_closest_edge(ramp_plane_type* plane, int planeCount, wall_point_type* wall, vector_type** lineEnd,
|
static void find_closest_edge(ramp_plane_type* plane, int planeCount, wall_point_type* wall, vector2** lineEnd,
|
||||||
vector_type** lineStart);
|
vector2** lineStart);
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,7 +64,7 @@ void nudge::nudge_up()
|
||||||
|
|
||||||
void nudge::_nudge(float xDiff, float yDiff)
|
void nudge::_nudge(float xDiff, float yDiff)
|
||||||
{
|
{
|
||||||
vector_type accelMod;
|
vector2 accelMod;
|
||||||
float invAccelX, invAccelY;
|
float invAccelX, invAccelY;
|
||||||
|
|
||||||
accelMod.X = xDiff * 0.5f;
|
accelMod.X = xDiff * 0.5f;
|
||||||
|
|
|
@ -290,7 +290,7 @@ void pb::frame(float dtMilliSec)
|
||||||
|
|
||||||
void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
||||||
{
|
{
|
||||||
vector_type vec1{}, vec2{};
|
vector2 vec1{}, vec2{};
|
||||||
|
|
||||||
for (auto ball : MainTable->BallList)
|
for (auto ball : MainTable->BallList)
|
||||||
{
|
{
|
||||||
|
@ -308,7 +308,6 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
|
||||||
{
|
{
|
||||||
vec2.X = 0.0;
|
vec2.X = 0.0;
|
||||||
vec2.Y = 0.0;
|
vec2.Y = 0.0;
|
||||||
vec2.Z = 0.0;
|
|
||||||
TTableLayer::edge_manager->FieldEffects(ball, &vec2);
|
TTableLayer::edge_manager->FieldEffects(ball, &vec2);
|
||||||
vec2.X = vec2.X * timeDelta;
|
vec2.X = vec2.X * timeDelta;
|
||||||
vec2.Y = vec2.Y * timeDelta;
|
vec2.Y = vec2.Y * timeDelta;
|
||||||
|
@ -486,8 +485,8 @@ void pb::InputDown(GameInput input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ball->Position.X = 1.0;
|
|
||||||
ball->ActiveFlag = 1;
|
ball->ActiveFlag = 1;
|
||||||
|
ball->Position.X = 1.0;
|
||||||
ball->Position.Z = ball->Offset;
|
ball->Position.Z = ball->Offset;
|
||||||
ball->Position.Y = 1.0;
|
ball->Position.Y = 1.0;
|
||||||
ball->Acceleration.Z = 0.0;
|
ball->Acceleration.Z = 0.0;
|
||||||
|
@ -595,7 +594,7 @@ bool pb::chk_highscore()
|
||||||
float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
||||||
{
|
{
|
||||||
ray_type ray{};
|
ray_type ray{};
|
||||||
vector_type positionMod{};
|
vector2 positionMod{};
|
||||||
|
|
||||||
if (ball->ActiveFlag && !ball->CollisionComp)
|
if (ball->ActiveFlag && !ball->CollisionComp)
|
||||||
{
|
{
|
||||||
|
@ -607,12 +606,8 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
||||||
ball->RayMaxDistance = maxDistance;
|
ball->RayMaxDistance = maxDistance;
|
||||||
ball->TimeNow = timeNow;
|
ball->TimeNow = timeNow;
|
||||||
|
|
||||||
ray.Origin.X = ball->Position.X;
|
ray.Origin = ball->Position;
|
||||||
ray.Origin.Y = ball->Position.Y;
|
ray.Direction = ball->Acceleration;
|
||||||
ray.Origin.Z = ball->Position.Z;
|
|
||||||
ray.Direction.X = ball->Acceleration.X;
|
|
||||||
ray.Direction.Y = ball->Acceleration.Y;
|
|
||||||
ray.Direction.Z = ball->Acceleration.Z;
|
|
||||||
ray.MaxDistance = maxDistance;
|
ray.MaxDistance = maxDistance;
|
||||||
ray.FieldFlag = ball->FieldFlag;
|
ray.FieldFlag = ball->FieldFlag;
|
||||||
ray.TimeNow = timeNow;
|
ray.TimeNow = timeNow;
|
||||||
|
@ -628,7 +623,6 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
||||||
ball->RayMaxDistance = maxDistance;
|
ball->RayMaxDistance = maxDistance;
|
||||||
positionMod.X = maxDistance * ball->Acceleration.X;
|
positionMod.X = maxDistance * ball->Acceleration.X;
|
||||||
positionMod.Y = maxDistance * ball->Acceleration.Y;
|
positionMod.Y = maxDistance * ball->Acceleration.Y;
|
||||||
positionMod.Z = 0.0;
|
|
||||||
maths::vector_add(&ball->Position, &positionMod);
|
maths::vector_add(&ball->Position, &positionMod);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -26,7 +26,7 @@ void proj::init(float* mat4x3, float d, float centerX, float centerY)
|
||||||
centery = centerY;
|
centery = centerY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void proj::matrix_vector_multiply(mat4_row_major* mat, vector_type* vec, vector_type* dstVec)
|
void proj::matrix_vector_multiply(mat4_row_major* mat, vector3* vec, vector3* dstVec)
|
||||||
{
|
{
|
||||||
const float x = vec->X, y = vec->Y, z = vec->Z;
|
const float x = vec->X, y = vec->Y, z = vec->Z;
|
||||||
dstVec->X = z * mat->Row0.Z + y * mat->Row0.Y + x * mat->Row0.X + mat->Row0.W;
|
dstVec->X = z * mat->Row0.Z + y * mat->Row0.Y + x * mat->Row0.X + mat->Row0.W;
|
||||||
|
@ -34,17 +34,17 @@ void proj::matrix_vector_multiply(mat4_row_major* mat, vector_type* vec, vector_
|
||||||
dstVec->Z = z * mat->Row2.Z + y * mat->Row2.Y + x * mat->Row2.X + mat->Row2.W;
|
dstVec->Z = z * mat->Row2.Z + y * mat->Row2.Y + x * mat->Row2.X + mat->Row2.W;
|
||||||
}
|
}
|
||||||
|
|
||||||
float proj::z_distance(vector_type* vec)
|
float proj::z_distance(vector3* vec)
|
||||||
{
|
{
|
||||||
vector_type dstVec{};
|
vector3 dstVec{};
|
||||||
matrix_vector_multiply(&matrix, vec, &dstVec);
|
matrix_vector_multiply(&matrix, vec, &dstVec);
|
||||||
return maths::magnitude(&dstVec);
|
return maths::magnitude(&dstVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void proj::xform_to_2d(vector_type* vec, int* dst)
|
void proj::xform_to_2d(vector3* vec, int* dst)
|
||||||
{
|
{
|
||||||
float projCoef;
|
float projCoef;
|
||||||
vector_type dstVec2{};
|
vector3 dstVec2{};
|
||||||
|
|
||||||
matrix_vector_multiply(&matrix, vec, &dstVec2);
|
matrix_vector_multiply(&matrix, vec, &dstVec2);
|
||||||
if (dstVec2.Z == 0.0f)
|
if (dstVec2.Z == 0.0f)
|
||||||
|
|
|
@ -22,9 +22,9 @@ class proj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void init(float* mat4x3, float d, float centerX, float centerY);
|
static void init(float* mat4x3, float d, float centerX, float centerY);
|
||||||
static void matrix_vector_multiply(mat4_row_major* mat, vector_type* vec, vector_type* dstVec);
|
static void matrix_vector_multiply(mat4_row_major* mat, vector3* vec, vector3* dstVec);
|
||||||
static float z_distance(vector_type* vec);
|
static float z_distance(vector3* vec);
|
||||||
static void xform_to_2d(vector_type* vec, int* dst);
|
static void xform_to_2d(vector3* vec, int* dst);
|
||||||
static void recenter(float centerX, float centerY);
|
static void recenter(float centerX, float centerY);
|
||||||
private:
|
private:
|
||||||
static mat4_row_major matrix;
|
static mat4_row_major matrix;
|
||||||
|
|
Loading…
Reference in a new issue