made a lot of changes, to get the render pipeline working
This commit is contained in:
@@ -1,9 +1,21 @@
|
|||||||
#include "IdGenerator.hpp"
|
#include "IdGenerator.hpp"
|
||||||
|
|
||||||
std::mt19937 rnd = std::mt19937();
|
bool init = false;
|
||||||
|
std::mt19937 rnd;
|
||||||
auto gen = uuids::uuid_random_generator(rnd);
|
auto gen = uuids::uuid_random_generator(rnd);
|
||||||
|
|
||||||
uuids::uuid TSE::GenerateRandomUUID()
|
uuids::uuid TSE::GenerateRandomUUID()
|
||||||
{
|
{
|
||||||
|
if(!init)
|
||||||
|
{
|
||||||
|
InitRandomIDs();
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
return gen();
|
return gen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TSE::InitRandomIDs()
|
||||||
|
{
|
||||||
|
rnd = std::mt19937();
|
||||||
|
gen = uuids::uuid_random_generator(rnd);
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
namespace TSE
|
namespace TSE
|
||||||
{
|
{
|
||||||
uuids::uuid GenerateRandomUUID();
|
uuids::uuid GenerateRandomUUID();
|
||||||
|
void InitRandomIDs();
|
||||||
} // namespace TSE
|
} // namespace TSE
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Camera.hpp"
|
#include "Camera.hpp"
|
||||||
#include "elements/Transformable.hpp"
|
#include "elements/Transformable.hpp"
|
||||||
#include "interfaces/IRenderer.hpp"
|
#include "interfaces/IRenderer.hpp"
|
||||||
|
#include "uuid.h"
|
||||||
|
|
||||||
TSE::Camera* TSE::Camera::mainCamera = nullptr;
|
TSE::Camera* TSE::Camera::mainCamera = nullptr;
|
||||||
TSE::ICameraHelper* TSE::Camera::helper = nullptr;
|
TSE::ICameraHelper* TSE::Camera::helper = nullptr;
|
||||||
@@ -30,6 +31,11 @@ float TSE::Camera::GetFov() const
|
|||||||
return fov;
|
return fov;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TSE::Vector2 &TSE::Camera::GetRenderTargetSize() const
|
||||||
|
{
|
||||||
|
return lastRtSize;
|
||||||
|
}
|
||||||
|
|
||||||
TSE::Vector3 TSE::Camera::SceenPositionToGamePosition(Vector2 screenPos)
|
TSE::Vector3 TSE::Camera::SceenPositionToGamePosition(Vector2 screenPos)
|
||||||
{
|
{
|
||||||
float x = 2.0f * screenPos.x / lastRtSize.x -1.0f;
|
float x = 2.0f * screenPos.x / lastRtSize.x -1.0f;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
#include "interfaces/IRenderTarget.hpp"
|
#include "interfaces/IRenderTarget.hpp"
|
||||||
#include "elements/BehaviourScript.hpp"
|
#include "elements/BehaviourScript.hpp"
|
||||||
|
#include "uuid.h"
|
||||||
|
|
||||||
namespace TSE
|
namespace TSE
|
||||||
{
|
{
|
||||||
@@ -41,6 +42,7 @@ namespace TSE
|
|||||||
Vector2 lastRtSize = {0, 0};
|
Vector2 lastRtSize = {0, 0};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
std::vector<uuids::uuid> layersNotToRender;
|
||||||
static ICameraHelper* helper;
|
static ICameraHelper* helper;
|
||||||
static Camera* mainCamera;
|
static Camera* mainCamera;
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ namespace TSE
|
|||||||
float GetNearClippingPlane() const;
|
float GetNearClippingPlane() const;
|
||||||
float GetFarClippingPlane() const;
|
float GetFarClippingPlane() const;
|
||||||
float GetFov() const;
|
float GetFov() const;
|
||||||
|
const Vector2& GetRenderTargetSize() const;
|
||||||
|
|
||||||
// Setter
|
// Setter
|
||||||
Vector3 SceenPositionToGamePosition(Vector2 screenPos);
|
Vector3 SceenPositionToGamePosition(Vector2 screenPos);
|
||||||
|
|||||||
@@ -7,9 +7,14 @@ TSE::TileMapChunk::TileMapChunk(int _chunksize, const Vector2 &_pos, SortingOrde
|
|||||||
order = _order;
|
order = _order;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::TileMapChunk::SetTile(const Vector2& p, const Vector2& Spriteindex, TileSet* set)
|
void TSE::TileMapChunk::SetTile(const Vector2& p, const Vector2& Spriteindex, const Vector2& Normalindex, TileSet* set)
|
||||||
{
|
{
|
||||||
sprites[p] = set->GetSpriteIdAt(Spriteindex.x, Spriteindex.y);
|
int normalid = -1;
|
||||||
|
if(Normalindex != Vector2(-1,-1))
|
||||||
|
normalid = set->GetSpriteIdAt(Normalindex.x, Normalindex.y);
|
||||||
|
sprites[p] = {set->GetSpriteIdAt(Spriteindex.x, Spriteindex.y), normalid};
|
||||||
|
dirtyPositions = true;
|
||||||
|
dirtySpriteIds = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::TileMapChunk::RemoveTile(Vector2 p)
|
void TSE::TileMapChunk::RemoveTile(Vector2 p)
|
||||||
@@ -22,8 +27,11 @@ void TSE::TileMapChunk::SetOrdering(SortingOrder _order)
|
|||||||
order = _order;
|
order = _order;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::TileMapChunk::GetOrderedPositions(Vector2 *array)
|
const std::vector<TSE::Vector2>* TSE::TileMapChunk::GetOrderedPositions()
|
||||||
{
|
{
|
||||||
|
if(dirtyPositions)
|
||||||
|
{
|
||||||
|
orderedPositions.clear();
|
||||||
switch (order)
|
switch (order)
|
||||||
{
|
{
|
||||||
case TopLeft:
|
case TopLeft:
|
||||||
@@ -35,7 +43,7 @@ void TSE::TileMapChunk::GetOrderedPositions(Vector2 *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->first - offset;
|
orderedPositions.push_back(v->first - offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -48,7 +56,7 @@ void TSE::TileMapChunk::GetOrderedPositions(Vector2 *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->first - offset;
|
orderedPositions.push_back(v->first - offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -61,7 +69,7 @@ void TSE::TileMapChunk::GetOrderedPositions(Vector2 *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->first - offset;
|
orderedPositions.push_back(v->first - offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -74,15 +82,21 @@ void TSE::TileMapChunk::GetOrderedPositions(Vector2 *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->first - offset;
|
orderedPositions.push_back(v->first - offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
dirtyPositions = false;
|
||||||
|
}
|
||||||
|
return &orderedPositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::TileMapChunk::GetOrderedSpriteIds(int *array)
|
const std::vector<TSE::Vector2i>* TSE::TileMapChunk::GetOrderedSpriteIds()
|
||||||
{
|
{
|
||||||
|
if(dirtySpriteIds)
|
||||||
|
{
|
||||||
|
orderedSpriteIDs.clear();
|
||||||
switch (order)
|
switch (order)
|
||||||
{
|
{
|
||||||
case TopLeft:
|
case TopLeft:
|
||||||
@@ -93,7 +107,7 @@ void TSE::TileMapChunk::GetOrderedSpriteIds(int *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->second;
|
orderedSpriteIDs.push_back(v->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -105,7 +119,7 @@ void TSE::TileMapChunk::GetOrderedSpriteIds(int *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->second;
|
orderedSpriteIDs.push_back(v->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -117,7 +131,7 @@ void TSE::TileMapChunk::GetOrderedSpriteIds(int *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->second;
|
orderedSpriteIDs.push_back(v->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -129,11 +143,14 @@ void TSE::TileMapChunk::GetOrderedSpriteIds(int *array)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = sprites.find(p);
|
auto v = sprites.find(p);
|
||||||
if(v != sprites.end())
|
if(v != sprites.end())
|
||||||
*array++ = v->second;
|
orderedSpriteIDs.push_back(v->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
dirtySpriteIds = false;
|
||||||
|
}
|
||||||
|
return &orderedSpriteIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TSE::TileMapChunk::GetChunksize()
|
int TSE::TileMapChunk::GetChunksize()
|
||||||
@@ -154,17 +171,18 @@ void TSE::TileMap::RemoveTile(Vector2 p)
|
|||||||
chunks[chunkIndex].RemoveTile(chunkInnerPos);
|
chunks[chunkIndex].RemoveTile(chunkInnerPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::TileMap::SetTile(Vector2 p, Vector2 Spriteindex)
|
void TSE::TileMap::SetTile(Vector2 p, Vector2 Spriteindex, Vector2 Normalindex)
|
||||||
{
|
{
|
||||||
Vector2 chunkInnerPos = LocalToChunkPos(p);
|
Vector2 chunkInnerPos = LocalToChunkPos(p);
|
||||||
Vector2 chunkIndex = p - chunkInnerPos;
|
Vector2 chunkIndex = p - chunkInnerPos;
|
||||||
if(!chunks.contains(chunkIndex))
|
if(!chunks.contains(chunkIndex))
|
||||||
{
|
{
|
||||||
|
dirty = true;
|
||||||
chunks[chunkIndex] = TileMapChunk(chunkSize, chunkIndex, order);
|
chunks[chunkIndex] = TileMapChunk(chunkSize, chunkIndex, order);
|
||||||
chunks[chunkIndex].nextLine = nextLine;
|
chunks[chunkIndex].nextLine = nextLine;
|
||||||
CheckBounds(chunkIndex);
|
CheckBounds(chunkIndex);
|
||||||
}
|
}
|
||||||
chunks[chunkIndex].SetTile(chunkInnerPos, Spriteindex, set);
|
chunks[chunkIndex].SetTile(chunkInnerPos, Spriteindex, Normalindex, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
TSE::TileMapChunk* TSE::TileMap::GetChunk(const Vector2 &pos)
|
TSE::TileMapChunk* TSE::TileMap::GetChunk(const Vector2 &pos)
|
||||||
@@ -175,9 +193,11 @@ TSE::TileMapChunk* TSE::TileMap::GetChunk(const Vector2 &pos)
|
|||||||
return &chunks[pos];
|
return &chunks[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSE::TileMap::GetChunkPositionsInOrder(Vector2 *arr)
|
const std::vector<TSE::Vector2>* TSE::TileMap::GetChunkPositionsInOrder()
|
||||||
{
|
{
|
||||||
|
if(dirty)
|
||||||
|
{
|
||||||
|
orderedChunks.clear();
|
||||||
switch (order)
|
switch (order)
|
||||||
{
|
{
|
||||||
case TopLeft:
|
case TopLeft:
|
||||||
@@ -188,7 +208,7 @@ void TSE::TileMap::GetChunkPositionsInOrder(Vector2 *arr)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = chunks.find(p);
|
auto v = chunks.find(p);
|
||||||
if(v != chunks.end())
|
if(v != chunks.end())
|
||||||
*arr++ = v->first;
|
orderedChunks.push_back(v->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -200,7 +220,7 @@ void TSE::TileMap::GetChunkPositionsInOrder(Vector2 *arr)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = chunks.find(p);
|
auto v = chunks.find(p);
|
||||||
if(v != chunks.end())
|
if(v != chunks.end())
|
||||||
*arr++ = v->first;
|
orderedChunks.push_back(v->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -212,7 +232,7 @@ void TSE::TileMap::GetChunkPositionsInOrder(Vector2 *arr)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = chunks.find(p);
|
auto v = chunks.find(p);
|
||||||
if(v != chunks.end())
|
if(v != chunks.end())
|
||||||
*arr++ = v->first;
|
orderedChunks.push_back(v->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -224,11 +244,14 @@ void TSE::TileMap::GetChunkPositionsInOrder(Vector2 *arr)
|
|||||||
Vector2 p(x,y);
|
Vector2 p(x,y);
|
||||||
auto v = chunks.find(p);
|
auto v = chunks.find(p);
|
||||||
if(v != chunks.end())
|
if(v != chunks.end())
|
||||||
*arr++ = v->first;
|
orderedChunks.push_back(v->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
dirty = false;
|
||||||
|
}
|
||||||
|
return &orderedChunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TSE::TileMap::GetChunkCount()
|
int TSE::TileMap::GetChunkCount()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "elements/BehaviourScript.hpp"
|
#include "elements/BehaviourScript.hpp"
|
||||||
#include "Vector2.hpp"
|
#include "Vector2.hpp"
|
||||||
|
#include "Vector2i.hpp"
|
||||||
#include "elements/Sprite.hpp"
|
#include "elements/Sprite.hpp"
|
||||||
#include "elements/TileSet.hpp"
|
#include "elements/TileSet.hpp"
|
||||||
|
|
||||||
@@ -21,19 +22,23 @@ namespace TSE
|
|||||||
struct TileMapChunk
|
struct TileMapChunk
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
bool dirtyPositions = true;
|
||||||
|
bool dirtySpriteIds = true;
|
||||||
|
std::vector<Vector2> orderedPositions;
|
||||||
|
std::vector<Vector2i> orderedSpriteIDs;
|
||||||
SortingOrder order;
|
SortingOrder order;
|
||||||
int chunksize;
|
int chunksize;
|
||||||
std::unordered_map<Vector2, int> sprites;
|
std::unordered_map<Vector2, Vector2i> sprites;
|
||||||
public:
|
public:
|
||||||
Vector2 nextLine;
|
Vector2 nextLine;
|
||||||
Vector2 pos;
|
Vector2 pos;
|
||||||
TileMapChunk(int _chunksize = 16, const Vector2& _pos = {0,0}, SortingOrder _order = TopRight);
|
TileMapChunk(int _chunksize = 16, const Vector2& _pos = {0,0}, SortingOrder _order = TopRight);
|
||||||
|
|
||||||
void SetTile(const Vector2& p, const Vector2& Spriteindex, TileSet* set);
|
void SetTile(const Vector2& p, const Vector2& Spriteindex, const Vector2& Normalindex, TileSet* set);
|
||||||
void RemoveTile(Vector2 p);
|
void RemoveTile(Vector2 p);
|
||||||
void SetOrdering(SortingOrder _order);
|
void SetOrdering(SortingOrder _order);
|
||||||
void GetOrderedPositions(Vector2* array);
|
const std::vector<Vector2>* GetOrderedPositions();
|
||||||
void GetOrderedSpriteIds(int* array);
|
const std::vector<Vector2i>* GetOrderedSpriteIds();
|
||||||
int GetChunksize();
|
int GetChunksize();
|
||||||
int GetSpriteCount();
|
int GetSpriteCount();
|
||||||
|
|
||||||
@@ -42,6 +47,8 @@ namespace TSE
|
|||||||
class TileMap : public BehaviourScript
|
class TileMap : public BehaviourScript
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
bool dirty = true;
|
||||||
|
std::vector<Vector2> orderedChunks;
|
||||||
Rect bounds = Rect(0,0,0,0);
|
Rect bounds = Rect(0,0,0,0);
|
||||||
Vector2 nextLine = Vector2(-0.5f, 1.25f);
|
Vector2 nextLine = Vector2(-0.5f, 1.25f);
|
||||||
public:
|
public:
|
||||||
@@ -52,9 +59,9 @@ namespace TSE
|
|||||||
std::unordered_map<Vector2, TileMapChunk> chunks;
|
std::unordered_map<Vector2, TileMapChunk> chunks;
|
||||||
|
|
||||||
void RemoveTile(Vector2 p);
|
void RemoveTile(Vector2 p);
|
||||||
void SetTile(Vector2 p, Vector2 Spriteindex);
|
void SetTile(Vector2 p, Vector2 Spriteindex, Vector2 Normalindex = {-1,-1});
|
||||||
TileMapChunk* GetChunk(const Vector2& pos);
|
TileMapChunk* GetChunk(const Vector2& pos);
|
||||||
void GetChunkPositionsInOrder(Vector2* arr);
|
const std::vector<Vector2>* GetChunkPositionsInOrder();
|
||||||
int GetChunkCount();
|
int GetChunkCount();
|
||||||
TileSet* GetTileSet();
|
TileSet* GetTileSet();
|
||||||
const Rect& GetBounds() const { return bounds; }
|
const Rect& GetBounds() const { return bounds; }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Layer.hpp"
|
#include "Layer.hpp"
|
||||||
#include "BehaviourScripts/Renderable.hpp"
|
#include "BehaviourScripts/Renderable.hpp"
|
||||||
#include "elements/BehaviourScript.hpp"
|
#include "elements/BehaviourScript.hpp"
|
||||||
|
#include "IdGenerator.hpp"
|
||||||
|
|
||||||
void HandleObject(TSE::Transformable* trans, TSE::TransformationStack& stack, TSE::IRenderer& rnd)
|
void HandleObject(TSE::Transformable* trans, TSE::TransformationStack& stack, TSE::IRenderer& rnd)
|
||||||
{
|
{
|
||||||
@@ -24,6 +25,7 @@ void HandleObject(TSE::Transformable* trans, TSE::TransformationStack& stack, TS
|
|||||||
|
|
||||||
TSE::Layer::Layer(const string &n)
|
TSE::Layer::Layer(const string &n)
|
||||||
{
|
{
|
||||||
|
ID = GenerateRandomUUID();
|
||||||
name = n;
|
name = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,3 +96,13 @@ void TSE::Layer::Update()
|
|||||||
trans->Update();
|
trans->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TSE::Layer::SetNonVisual(bool v)
|
||||||
|
{
|
||||||
|
nonVisual = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TSE::Layer::IsVisual()
|
||||||
|
{
|
||||||
|
return !nonVisual;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,14 +4,16 @@
|
|||||||
#include "Types.hpp"
|
#include "Types.hpp"
|
||||||
#include "interfaces/IRenderer.hpp"
|
#include "interfaces/IRenderer.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "interfaces/IIdentifyable.hpp"
|
||||||
|
|
||||||
namespace TSE
|
namespace TSE
|
||||||
{
|
{
|
||||||
class Layer
|
class Layer : public IIdentifyable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string name;
|
string name;
|
||||||
std::vector<Transformable*> objectsToRender;
|
std::vector<Transformable*> objectsToRender;
|
||||||
|
bool nonVisual = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Layer(const string& name);
|
Layer(const string& name);
|
||||||
@@ -27,5 +29,7 @@ namespace TSE
|
|||||||
void SetName(const string& name);
|
void SetName(const string& name);
|
||||||
std::vector<Transformable*>& GetAllObjects();
|
std::vector<Transformable*>& GetAllObjects();
|
||||||
void Update();
|
void Update();
|
||||||
|
void SetNonVisual(bool v);
|
||||||
|
bool IsVisual();
|
||||||
};
|
};
|
||||||
} // namespace TSE
|
} // namespace TSE
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ namespace TSE
|
|||||||
}
|
}
|
||||||
|
|
||||||
template void Material::SetValue<int>(const string&, const int&);
|
template void Material::SetValue<int>(const string&, const int&);
|
||||||
|
template void Material::SetValue<uint>(const string&, const uint&);
|
||||||
template void Material::SetValue<float>(const string&, const float&);
|
template void Material::SetValue<float>(const string&, const float&);
|
||||||
template void Material::SetValue<Vector2>(const string&, const Vector2&);
|
template void Material::SetValue<Vector2>(const string&, const Vector2&);
|
||||||
template void Material::SetValue<Vector3>(const string&, const Vector3&);
|
template void Material::SetValue<Vector3>(const string&, const Vector3&);
|
||||||
@@ -70,6 +71,7 @@ namespace TSE
|
|||||||
template void Material::SetValue<ITexture>(const string&, const ITexture*);
|
template void Material::SetValue<ITexture>(const string&, const ITexture*);
|
||||||
|
|
||||||
template int Material::GetValue<int>(const string&) const;
|
template int Material::GetValue<int>(const string&) const;
|
||||||
|
template uint Material::GetValue<uint>(const string&) const;
|
||||||
template float Material::GetValue<float>(const string&) const;
|
template float Material::GetValue<float>(const string&) const;
|
||||||
template Vector2 Material::GetValue<Vector2>(const string&) const;
|
template Vector2 Material::GetValue<Vector2>(const string&) const;
|
||||||
template Vector3 Material::GetValue<Vector3>(const string&) const;
|
template Vector3 Material::GetValue<Vector3>(const string&) const;
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
#include "Scene.hpp"
|
#include "Scene.hpp"
|
||||||
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
#include "Debug.hpp"
|
||||||
|
|
||||||
void TSE::Scene::Render(IRenderer &rnd, const IWindow &wnd)
|
void TSE::Scene::Render(IRenderer &rnd, const IWindow &wnd)
|
||||||
{
|
{
|
||||||
|
auto camerasBackup = std::vector<Camera*>(IRenderer::camerasToRenderWith);
|
||||||
int counter = 1;
|
int counter = 1;
|
||||||
for(auto l : layers)
|
for(auto l : layers)
|
||||||
{
|
{
|
||||||
|
IRenderer::camerasToRenderWith.clear();
|
||||||
|
if(!l.second->IsVisual()) continue;
|
||||||
|
for(auto camera : camerasBackup)
|
||||||
|
{
|
||||||
|
auto it = std::find(camera->layersNotToRender.begin(), camera->layersNotToRender.end(), l.second->GetID());
|
||||||
|
if(it == camera->layersNotToRender.end())
|
||||||
|
{
|
||||||
|
IRenderer::camerasToRenderWith.push_back(camera);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
l.second->Render(rnd);
|
l.second->Render(rnd);
|
||||||
if(counter++ != layers.size())
|
if(counter++ != layers.size())
|
||||||
{
|
{
|
||||||
|
|||||||
13
TSE_Core/src/interfaces/IIdentifyable.hpp
Normal file
13
TSE_Core/src/interfaces/IIdentifyable.hpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "uuid.h"
|
||||||
|
|
||||||
|
namespace TSE
|
||||||
|
{
|
||||||
|
class IIdentifyable
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
uuids::uuid ID;
|
||||||
|
public:
|
||||||
|
inline const uuids::uuid& GetID() { return ID;};
|
||||||
|
};
|
||||||
|
} // namespace TSE
|
||||||
35
TSE_Core/src/interfaces/IObservable.hpp
Normal file
35
TSE_Core/src/interfaces/IObservable.hpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "IObserver.hpp"
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace TSE
|
||||||
|
{
|
||||||
|
class IObservable
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::vector<IObserver*> objectsToNotify;
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline void Observe(IObserver* observer)
|
||||||
|
{
|
||||||
|
objectsToNotify.push_back(observer);
|
||||||
|
};
|
||||||
|
inline void StopObserve(IObserver* observer)
|
||||||
|
{
|
||||||
|
auto it = std::find(objectsToNotify.begin(), objectsToNotify.end(), observer);
|
||||||
|
if(it != objectsToNotify.end())
|
||||||
|
objectsToNotify.erase(it);
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline void TriggerObserver(void* data)
|
||||||
|
{
|
||||||
|
for (auto &&observer : objectsToNotify)
|
||||||
|
{
|
||||||
|
observer->OnObserved(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} // namespace TSE
|
||||||
10
TSE_Core/src/interfaces/IObserver.hpp
Normal file
10
TSE_Core/src/interfaces/IObserver.hpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace TSE
|
||||||
|
{
|
||||||
|
class IObserver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void OnObserved(void* data) = 0;
|
||||||
|
};
|
||||||
|
} // namespace TSE
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "IInputManager.hpp"
|
#include "IInputManager.hpp"
|
||||||
#include "elements/AudioEngine.hpp"
|
#include "elements/AudioEngine.hpp"
|
||||||
|
#include "IdGenerator.hpp"
|
||||||
|
|
||||||
#define FREEIMAGE_LIB
|
#define FREEIMAGE_LIB
|
||||||
#include "FI/FreeImage.h"
|
#include "FI/FreeImage.h"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace TSE
|
|||||||
virtual void Clear() const = 0;
|
virtual void Clear() const = 0;
|
||||||
virtual void ClearDepthBuffer() const = 0;
|
virtual void ClearDepthBuffer() const = 0;
|
||||||
virtual bool ShouldClose() const = 0;
|
virtual bool ShouldClose() const = 0;
|
||||||
|
virtual void DoneSetup() = 0;
|
||||||
|
|
||||||
bool BaseInit() const;
|
bool BaseInit() const;
|
||||||
void BaseUpdate() const;
|
void BaseUpdate() const;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ TSE::EDITOR::EditorSubsystem::EditorSubsystem() : sv(nullptr), editorLayer("")
|
|||||||
|
|
||||||
editorLayer = Layer(".editor");
|
editorLayer = Layer(".editor");
|
||||||
editorLayer.AddTransformable(editorCamera);
|
editorLayer.AddTransformable(editorCamera);
|
||||||
|
editorLayer.SetNonVisual(true);
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
}
|
}
|
||||||
@@ -439,6 +439,14 @@ namespace TSE::EDITOR
|
|||||||
Texture* value = element->GetValue<Texture*>(name);
|
Texture* value = element->GetValue<Texture*>(name);
|
||||||
Draw(value, debug, name , true);
|
Draw(value, debug, name , true);
|
||||||
}
|
}
|
||||||
|
if (type == typeid(uint).name())
|
||||||
|
{
|
||||||
|
int value = element->GetValue<uint>(name);
|
||||||
|
if(ImGui::InputInt(name.c_str(), &value))
|
||||||
|
{
|
||||||
|
element->SetValue(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled(("Not Implemented: " + type).c_str());
|
ImGui::TextDisabled(("Not Implemented: " + type).c_str());
|
||||||
|
|||||||
@@ -149,3 +149,13 @@ bool TSE::GLFW::WindowGlfw::ShouldClose() const
|
|||||||
{
|
{
|
||||||
return glfwWindowShouldClose(window);
|
return glfwWindowShouldClose(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TSE::GLFW::WindowGlfw::DoneSetup()
|
||||||
|
{
|
||||||
|
renderingBackend->onResize(width, height);
|
||||||
|
|
||||||
|
for (auto const& i : objectsToResize)
|
||||||
|
{
|
||||||
|
i->OnResize(width, height, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,5 +36,6 @@ namespace TSE::GLFW
|
|||||||
bool ShouldClose() const override;
|
bool ShouldClose() const override;
|
||||||
inline void Bind() override { };
|
inline void Bind() override { };
|
||||||
inline void Unbind() override { };
|
inline void Unbind() override { };
|
||||||
|
void DoneSetup() override;
|
||||||
};
|
};
|
||||||
} // namespace TSE::GLFW
|
} // namespace TSE::GLFW
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "DefaultRendererOpenGL.hpp"
|
#include "DefaultRendererOpenGL.hpp"
|
||||||
#include "BehaviourScripts/Camera.hpp"
|
#include "BehaviourScripts/Camera.hpp"
|
||||||
#include "BehaviourScripts/Renderable.hpp"
|
#include "BehaviourScripts/Renderable.hpp"
|
||||||
|
#include "Debug.hpp"
|
||||||
|
|
||||||
#define RENDERER_MAX_SPRITES 20000
|
#define RENDERER_MAX_SPRITES 20000
|
||||||
#define RENDERER_MAX_INDECIES 60000
|
#define RENDERER_MAX_INDECIES 60000
|
||||||
@@ -78,6 +79,8 @@ void TSE::GLFW::DefaultRendererOpenGL::Flush()
|
|||||||
camerasToRenderWith[i]->PostDraw();
|
camerasToRenderWith[i]->PostDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastShader->PostDraw();
|
||||||
|
|
||||||
if(ibobound)
|
if(ibobound)
|
||||||
{
|
{
|
||||||
ibo->Unbind();
|
ibo->Unbind();
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ void TSE::GLFW::FrameBuffer::LoadFBTexture()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, depthRboID);
|
glBindRenderbuffer(GL_RENDERBUFFER, depthRboID);
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ void TSE::GLFW::Shader::DrawCall(int indexCount)
|
|||||||
OnDrawCall(indexCount);
|
OnDrawCall(indexCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TSE::GLFW::Shader::PostDraw()
|
||||||
|
{
|
||||||
|
OnPostDraw();
|
||||||
|
}
|
||||||
|
|
||||||
void TSE::GLFW::Shader::Submit(const Transformable &t, float *&target, TransformationStack &stack, void (*restartDrawcall)(IRenderer &), IRenderer &rnd)
|
void TSE::GLFW::Shader::Submit(const Transformable &t, float *&target, TransformationStack &stack, void (*restartDrawcall)(IRenderer &), IRenderer &rnd)
|
||||||
{
|
{
|
||||||
OnSubmit(t, target, stack, restartDrawcall, rnd);
|
OnSubmit(t, target, stack, restartDrawcall, rnd);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace TSE::GLFW
|
|||||||
virtual void OnDisable() const {};
|
virtual void OnDisable() const {};
|
||||||
virtual void OnFlush() {};
|
virtual void OnFlush() {};
|
||||||
virtual void OnDrawCall(int indexCount) {};
|
virtual void OnDrawCall(int indexCount) {};
|
||||||
|
virtual void OnPostDraw() {};
|
||||||
virtual void OnSubmit(const Transformable& t, float*& target, TransformationStack& stack, void (*restartDrawcall)(IRenderer&), IRenderer& rnd) {};
|
virtual void OnSubmit(const Transformable& t, float*& target, TransformationStack& stack, void (*restartDrawcall)(IRenderer&), IRenderer& rnd) {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -33,6 +34,7 @@ namespace TSE::GLFW
|
|||||||
void Disable(bool notify = false) const;
|
void Disable(bool notify = false) const;
|
||||||
void Flush();
|
void Flush();
|
||||||
void DrawCall(int indexCount);
|
void DrawCall(int indexCount);
|
||||||
|
void PostDraw();
|
||||||
void Submit(const Transformable& t, float*& target, TransformationStack& stack, void (*restartDrawcall)(IRenderer&), IRenderer& rnd);
|
void Submit(const Transformable& t, float*& target, TransformationStack& stack, void (*restartDrawcall)(IRenderer&), IRenderer& rnd);
|
||||||
bool IsEnabled() const;
|
bool IsEnabled() const;
|
||||||
int packageSize();
|
int packageSize();
|
||||||
|
|||||||
@@ -171,9 +171,7 @@ void TSE::GLFW::BasicTileMapShader::OnSubmit(const Transformable &t, float *&tar
|
|||||||
SpriteCount = tileSet->GetCount();
|
SpriteCount = tileSet->GetCount();
|
||||||
SpriteScale = tm->SpriteScale;
|
SpriteScale = tm->SpriteScale;
|
||||||
|
|
||||||
const int chunkcount = tm->GetChunkCount();
|
const std::vector<Vector2> orderedChunks = *tm->GetChunkPositionsInOrder();
|
||||||
Vector2 orderedChunks[chunkcount];
|
|
||||||
tm->GetChunkPositionsInOrder(orderedChunks);
|
|
||||||
|
|
||||||
Matrix4x4 matr = t.GetLocalMatrix();
|
Matrix4x4 matr = t.GetLocalMatrix();
|
||||||
|
|
||||||
@@ -183,10 +181,8 @@ void TSE::GLFW::BasicTileMapShader::OnSubmit(const Transformable &t, float *&tar
|
|||||||
{
|
{
|
||||||
auto chunk = tm->GetChunk(chunkPos);
|
auto chunk = tm->GetChunk(chunkPos);
|
||||||
const int spriteCount = chunk->GetSpriteCount();
|
const int spriteCount = chunk->GetSpriteCount();
|
||||||
Vector2 spritePositions[spriteCount];
|
const std::vector<Vector2> spritePositions = *chunk->GetOrderedPositions();
|
||||||
int spriteIds[spriteCount];
|
const std::vector<Vector2i> spriteIds = *chunk->GetOrderedSpriteIds();
|
||||||
chunk->GetOrderedPositions(spritePositions);
|
|
||||||
chunk->GetOrderedSpriteIds(spriteIds);
|
|
||||||
int chunkSize = chunk->GetChunksize();
|
int chunkSize = chunk->GetChunksize();
|
||||||
|
|
||||||
for (int i = 0; i < spriteCount; i++)
|
for (int i = 0; i < spriteCount; i++)
|
||||||
@@ -198,7 +194,7 @@ void TSE::GLFW::BasicTileMapShader::OnSubmit(const Transformable &t, float *&tar
|
|||||||
*target++ = pos.x;
|
*target++ = pos.x;
|
||||||
*target++ = pos.y;
|
*target++ = pos.y;
|
||||||
*target++ = pos.z;
|
*target++ = pos.z;
|
||||||
*target++ = spriteIds[i];
|
*target++ = spriteIds[i].x;
|
||||||
|
|
||||||
++instanceCount;
|
++instanceCount;
|
||||||
stack.Pop();
|
stack.Pop();
|
||||||
|
|||||||
138
TSE_Math/src/Vector2i.cpp
Normal file
138
TSE_Math/src/Vector2i.cpp
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
#include "Vector2i.hpp"
|
||||||
|
#include "Vector2.hpp"
|
||||||
|
#include "Vector3.hpp"
|
||||||
|
#include "Vector4.hpp"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
TSE::Vector2i::Vector2i() { }
|
||||||
|
|
||||||
|
TSE::Vector2i::Vector2i(int _x, int _y)
|
||||||
|
{
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i::Vector2i(const Vector2i &other)
|
||||||
|
{
|
||||||
|
x = other.x;
|
||||||
|
y = other.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i::Vector2i(const Vector2 &other)
|
||||||
|
{
|
||||||
|
x = other.x;
|
||||||
|
y = other.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i::Vector2i(const Vector3 &other)
|
||||||
|
{
|
||||||
|
x = other.x;
|
||||||
|
y = other.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i::Vector2i(const Vector4 &other)
|
||||||
|
{
|
||||||
|
x = other.x;
|
||||||
|
y = other.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TSE::Vector2i::IsValid() const
|
||||||
|
{
|
||||||
|
return !std::isnan(x) && !std::isnan(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::string TSE::Vector2i::ToString() const
|
||||||
|
{
|
||||||
|
return "(" + std::to_string(x) + "|" + std::to_string(y) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2 TSE::Vector2i::ToVector2() const
|
||||||
|
{
|
||||||
|
return Vector2();
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector3 TSE::Vector2i::ToVector3() const
|
||||||
|
{
|
||||||
|
return Vector3(x,y,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector4 TSE::Vector2i::ToVector4() const
|
||||||
|
{
|
||||||
|
return Vector4(x,y,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator+(const Vector2i &other) const
|
||||||
|
{
|
||||||
|
return Vector2i(x + other.x, y + other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator+=(const Vector2i &other)
|
||||||
|
{
|
||||||
|
*this = *this + other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator-(const Vector2i &other) const
|
||||||
|
{
|
||||||
|
return Vector2i(x - other.x, y - other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator-=(const Vector2i &other)
|
||||||
|
{
|
||||||
|
*this = *this - other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator*(const Vector2i &other) const
|
||||||
|
{
|
||||||
|
return Vector2i(x * other.x, y * other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator*=(const Vector2i &other)
|
||||||
|
{
|
||||||
|
*this = *this * other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator/(const Vector2i &other) const
|
||||||
|
{
|
||||||
|
return Vector2i(x / other.x, y / other.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator/=(const Vector2i &other)
|
||||||
|
{
|
||||||
|
*this = *this / other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator*(const float other) const
|
||||||
|
{
|
||||||
|
return Vector2i(x * other, y * other);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator*=(const float other)
|
||||||
|
{
|
||||||
|
*this = *this * other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator/(const float other) const
|
||||||
|
{
|
||||||
|
return Vector2i(x / other, y / other);
|
||||||
|
}
|
||||||
|
|
||||||
|
TSE::Vector2i TSE::Vector2i::operator/=(const float other)
|
||||||
|
{
|
||||||
|
*this = *this / other;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TSE::Vector2i::operator==(const Vector2i &other) const
|
||||||
|
{
|
||||||
|
return x == other.x && y == other.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TSE::Vector2i::operator!=(const Vector2i &other) const
|
||||||
|
{
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
85
TSE_Math/src/Vector2i.hpp
Normal file
85
TSE_Math/src/Vector2i.hpp
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Types.hpp"
|
||||||
|
#include "MathF.hpp"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
namespace TSE
|
||||||
|
{
|
||||||
|
class Vector2;
|
||||||
|
class Vector3;
|
||||||
|
class Vector4;
|
||||||
|
|
||||||
|
class Vector2i
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#pragma region members
|
||||||
|
int x = 0, y = 0;
|
||||||
|
#pragma endregion members
|
||||||
|
|
||||||
|
#pragma region consts
|
||||||
|
static const Vector2i left;
|
||||||
|
static const Vector2i right;
|
||||||
|
static const Vector2i up;
|
||||||
|
static const Vector2i down;
|
||||||
|
static const Vector2i one;
|
||||||
|
static const Vector2i zero;
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region ctor
|
||||||
|
/// @brief enpty constructor defined as (0,0)
|
||||||
|
Vector2i();
|
||||||
|
/// @brief constructs a Vector2i with custom values
|
||||||
|
/// @param _x the x component
|
||||||
|
/// @param _y the y component
|
||||||
|
Vector2i(int _x, int _y);
|
||||||
|
/// @brief copy constructor
|
||||||
|
/// @param other the Vector2i to be copied from
|
||||||
|
Vector2i(const Vector2i& other);
|
||||||
|
/// @brief copy constructor
|
||||||
|
/// @param other the Vector2i to be copied from
|
||||||
|
Vector2i(const Vector2& other);
|
||||||
|
/// @brief converter constructor. it converts a Vector3 to a Vector2i without encointing for the z component
|
||||||
|
/// @param other the Vector3 to convert
|
||||||
|
Vector2i(const Vector3& other);
|
||||||
|
/// @brief converter constructor. it converts a Vector4 to a Vector2i without encointing for the z, and w component
|
||||||
|
/// @param other the Vector4 to convert
|
||||||
|
Vector2i(const Vector4& other);
|
||||||
|
#pragma endregion ctor
|
||||||
|
|
||||||
|
#pragma region methods
|
||||||
|
/// @brief checks if the individual components have valid values aka are not nan
|
||||||
|
/// @return are the values valid
|
||||||
|
bool IsValid() const;
|
||||||
|
/// @brief gives you the Vector2i as a string representation. mostly for debugging
|
||||||
|
/// @return the Vector2i in a format like (x|y)
|
||||||
|
string ToString() const;
|
||||||
|
/// @brief creates a Vector3 with the same values as the Vector2i, the y component gets the value 0
|
||||||
|
/// @return the Vector2i as a Vector3
|
||||||
|
Vector2 ToVector2() const;
|
||||||
|
/// @brief creates a Vector3 with the same values as the Vector2i, the y component gets the value 0
|
||||||
|
/// @return the Vector2i as a Vector3
|
||||||
|
Vector3 ToVector3() const;
|
||||||
|
/// @brief creates a Vector4 with the same values as the Vector2i, the y and w components get the value 0
|
||||||
|
/// @return the Vector2i as a Vector4
|
||||||
|
Vector4 ToVector4() const;
|
||||||
|
|
||||||
|
#pragma region operators
|
||||||
|
Vector2i operator+(const Vector2i& other) const;
|
||||||
|
Vector2i operator+=(const Vector2i& other);
|
||||||
|
Vector2i operator-(const Vector2i& other) const;
|
||||||
|
Vector2i operator-=(const Vector2i& other);
|
||||||
|
Vector2i operator*(const Vector2i& other) const;
|
||||||
|
Vector2i operator*=(const Vector2i& other);
|
||||||
|
Vector2i operator/(const Vector2i& other) const;
|
||||||
|
Vector2i operator/=(const Vector2i& other);
|
||||||
|
Vector2i operator*(const float other) const;
|
||||||
|
Vector2i operator*=(const float other);
|
||||||
|
Vector2i operator/(const float other) const;
|
||||||
|
Vector2i operator/=(const float other);
|
||||||
|
bool operator==(const Vector2i& other) const;
|
||||||
|
bool operator!=(const Vector2i& other) const;
|
||||||
|
#pragma endregion operators
|
||||||
|
#pragma endregion methods
|
||||||
|
};
|
||||||
|
} // namespace TSE
|
||||||
Reference in New Issue
Block a user