Compare commits
45 Commits
sqc_xxx_cl
...
SQC_21_Men
Author | SHA1 | Date | |
---|---|---|---|
|
9dd2e1b821 | ||
|
eed8f5f04a | ||
|
e2fa4fea7c | ||
|
fc4a22e844 | ||
|
102153a093 | ||
|
c7271f6217 | ||
|
8ebe7b95fc | ||
|
5e29c9be54 | ||
|
f8680a318a | ||
|
df5b7960b2 | ||
|
f4d4f1eca0 | ||
|
793da52871 | ||
|
18a5d98c57 | ||
|
81240c6f70 | ||
|
f1ddd67655 | ||
|
a054a7bff1 | ||
|
b712c950c6 | ||
|
9cbf20ba21 | ||
|
3f774d7c2e | ||
|
db0a39f64a | ||
|
f2095f6e5b | ||
|
93062e49e2 | ||
|
c85f7df15e | ||
|
6668127f15 | ||
|
54c25e6f78 | ||
|
bf164af23b | ||
|
0d948e3a28 | ||
|
b97890fff3 | ||
|
432b8545a7 | ||
|
54e2f32aba | ||
|
90fdc8ed1b | ||
|
47906776c8 | ||
|
cddc59d6cf | ||
|
965e78309e | ||
|
0452920697 | ||
|
fa9f0a3a8a | ||
|
43f3ce1428 | ||
|
8be8852596 | ||
|
8b3baa9063 | ||
|
bfda5e8948 | ||
|
aacb3b4ceb | ||
|
09dd3d332f | ||
|
ef8a050545 | ||
|
033365c961 | ||
|
2532dfb258 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -373,3 +373,8 @@ FodyWeavers.xsd
|
|||||||
/x64/Release/SQCSim2023.exe
|
/x64/Release/SQCSim2023.exe
|
||||||
/x64/Debug/SQCSim2023.exe
|
/x64/Debug/SQCSim2023.exe
|
||||||
/x64/Debug/SQCSim2021.pdb
|
/x64/Debug/SQCSim2021.pdb
|
||||||
|
/SQCSim-srv/cmake/*
|
||||||
|
!/SQCSim-srv/cmake/CMakeLists.txt
|
||||||
|
/SQCSim2021/cmake/*
|
||||||
|
!/SQCSim2021/cmake/CMakeLists.txt
|
||||||
|
/SQCSim2021/SQCSim-client
|
||||||
|
BIN
Debug/glew32.dll
BIN
Debug/glew32.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -138,6 +138,7 @@
|
|||||||
<ClInclude Include="opensimplex.h" />
|
<ClInclude Include="opensimplex.h" />
|
||||||
<ClInclude Include="player.h" />
|
<ClInclude Include="player.h" />
|
||||||
<ClInclude Include="netprotocol.h" />
|
<ClInclude Include="netprotocol.h" />
|
||||||
|
<ClInclude Include="transformation.h" />
|
||||||
<ClInclude Include="vector3.h" />
|
<ClInclude Include="vector3.h" />
|
||||||
<ClInclude Include="world.h" />
|
<ClInclude Include="world.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -148,6 +149,7 @@
|
|||||||
<ClCompile Include="netprotocol.cpp" />
|
<ClCompile Include="netprotocol.cpp" />
|
||||||
<ClCompile Include="opensimplex.cpp" />
|
<ClCompile Include="opensimplex.cpp" />
|
||||||
<ClCompile Include="player.cpp" />
|
<ClCompile Include="player.cpp" />
|
||||||
|
<ClCompile Include="transformation.cpp" />
|
||||||
<ClCompile Include="world.cpp" />
|
<ClCompile Include="world.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
@@ -51,6 +51,9 @@
|
|||||||
<ClInclude Include="netprotocol.h">
|
<ClInclude Include="netprotocol.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="transformation.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="world.cpp">
|
<ClCompile Include="world.cpp">
|
||||||
@@ -74,5 +77,8 @@
|
|||||||
<ClCompile Include="netprotocol.cpp">
|
<ClCompile Include="netprotocol.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="transformation.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@@ -7,8 +7,9 @@ Bullet::Bullet(Vector3f pos, Vector3f dir, uint64_t tid): m_startpos(pos), m_cur
|
|||||||
|
|
||||||
Bullet::~Bullet() {}
|
Bullet::~Bullet() {}
|
||||||
|
|
||||||
bool Bullet::Update(World* world, float elapsedtime) {
|
bool Bullet::Update(World* world, float elapsedtime, int perframe) {
|
||||||
for (int x = 0; x < 1000; ++x) {
|
int max = 100 / perframe;
|
||||||
|
for (int x = 0; x < max; ++x) {
|
||||||
m_currentpos += m_velocity * elapsedtime;
|
m_currentpos += m_velocity * elapsedtime;
|
||||||
|
|
||||||
if (!world->ChunkAt(m_currentpos))
|
if (!world->ChunkAt(m_currentpos))
|
||||||
@@ -30,10 +31,14 @@ void Bullet::Transpose(int& x, int& z) {
|
|||||||
m_startpos.z -= z * CHUNK_SIZE_Z;
|
m_startpos.z -= z * CHUNK_SIZE_Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f Bullet::getPos() {
|
Vector3f Bullet::getPos() const {
|
||||||
return m_currentpos;
|
return m_currentpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3f Bullet::getVel() const {
|
||||||
|
return m_velocity;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Bullet::getTeamID(){
|
uint64_t Bullet::getTeamID(){
|
||||||
return m_tid;
|
return m_tid;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#ifndef BULLET_H__
|
#ifndef BULLET_H__
|
||||||
#define BULLET_H__
|
#define BULLET_H__
|
||||||
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
|
||||||
@@ -11,9 +12,10 @@ public:
|
|||||||
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
|
Bullet(Vector3f pos, Vector3f dir, uint64_t tid);
|
||||||
~Bullet();
|
~Bullet();
|
||||||
|
|
||||||
bool Update(World* world, float elapsedtime);
|
bool Update(World* world, float elapsedtime, int perframe);
|
||||||
void Transpose(int& x, int& z);
|
void Transpose(int& x, int& z);
|
||||||
Vector3f getPos();
|
Vector3f getPos() const;
|
||||||
|
Vector3f getVel() const;
|
||||||
uint64_t getTeamID();
|
uint64_t getTeamID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
#include "chunk.h"
|
#include "chunk.h"
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
||||||
Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
|
Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y) {
|
||||||
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
|
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
|
||||||
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
|
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
|
||||||
//std::ifstream input(pos.str(), std::fstream::binary);
|
//std::ifstream input(pos.str(), std::fstream::binary);
|
||||||
|
|
||||||
//if (input.fail()) {
|
//if (input.fail()) {
|
||||||
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(SEED);
|
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(seed);
|
||||||
m_blocks.Reset(BTYPE_AIR);
|
m_blocks.Reset(BTYPE_AIR);
|
||||||
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
|
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
|
||||||
@@ -98,14 +98,45 @@ Chunk::~Chunk() {
|
|||||||
|
|
||||||
void Chunk::RemoveBlock(int x, int y, int z, World* world) {
|
void Chunk::RemoveBlock(int x, int y, int z, World* world) {
|
||||||
m_blocks.Set(x, y, z, BTYPE_AIR);
|
m_blocks.Set(x, y, z, BTYPE_AIR);
|
||||||
|
CheckNeighbors(x, y, world);
|
||||||
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
|
void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
|
||||||
m_blocks.Set(x, y, z, type);
|
m_blocks.Set(x, y, z, type);
|
||||||
|
if (world) CheckNeighbors(x, z, world); // Si nullptr, ne pas v<>rifier les chunks voisines.
|
||||||
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockType Chunk::GetBlock(int x, int y, int z) { return m_blocks.Get(x, y, z); }
|
BlockType Chunk::GetBlock(int x, int y, int z) { return m_blocks.Get(x, y, z); }
|
||||||
|
|
||||||
|
void Chunk::CheckNeighbors(unsigned int x, unsigned int z, World* world) {
|
||||||
|
unsigned int cx, cy;
|
||||||
|
|
||||||
|
world->GetScope(cx, cy);
|
||||||
|
|
||||||
|
if (x == 0 && m_posX - cx >= 0 &&
|
||||||
|
world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z))
|
||||||
|
world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)->MakeDirty();
|
||||||
|
else if (x == CHUNK_SIZE_X - 1 && m_posX - cx < WORLD_SIZE_X &&
|
||||||
|
world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z))
|
||||||
|
world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)->MakeDirty();
|
||||||
|
|
||||||
|
if (z == 0 && m_posY - cy >= 0 &&
|
||||||
|
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z))
|
||||||
|
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z)->MakeDirty();
|
||||||
|
else if (z == CHUNK_SIZE_X - 1 && m_posY - cy < WORLD_SIZE_Y &&
|
||||||
|
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z))
|
||||||
|
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z)->MakeDirty();
|
||||||
|
}
|
||||||
|
|
||||||
void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; }
|
void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; }
|
||||||
|
|
||||||
|
bool Chunk::IsDirty() const { return m_isDirty; }
|
||||||
|
|
||||||
|
void Chunk::MakeDirty() { m_isDirty = true; }
|
||||||
|
|
||||||
|
void Chunk::MakeClean() { m_isDirty = false; }
|
||||||
|
|
||||||
void Chunk::MakeModified() { m_isModified = true; }
|
void Chunk::MakeModified() { m_isModified = true; }
|
||||||
|
|
||||||
|
@@ -1,30 +1,36 @@
|
|||||||
#ifndef CHUNK_H__
|
#ifndef CHUNK_H__
|
||||||
#define CHUNK_H__
|
#define CHUNK_H__
|
||||||
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "array3d.h"
|
|
||||||
#include "array2d.h"
|
#include "array2d.h"
|
||||||
|
#include "array3d.h"
|
||||||
#include "blockinfo.h"
|
#include "blockinfo.h"
|
||||||
#include "opensimplex.h"
|
#include "opensimplex.h"
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
class Chunk {
|
class Chunk {
|
||||||
protected:
|
private:
|
||||||
Array3d<BlockType> m_blocks = Array3d<BlockType>(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z);
|
Array3d<BlockType> m_blocks = Array3d<BlockType>(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z);
|
||||||
|
bool m_isDirty = true;
|
||||||
bool m_isModified = false;
|
bool m_isModified = false;
|
||||||
|
|
||||||
unsigned int m_posX; // Position du chunk dans l'array constituant le monde.
|
unsigned int m_posX; // Position du chunk dans l'array constituant le monde.
|
||||||
unsigned int m_posY;
|
unsigned int m_posY;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Chunk(unsigned int x, unsigned int y);
|
Chunk(unsigned int x, unsigned int y, int64_t seed);
|
||||||
~Chunk();
|
~Chunk();
|
||||||
|
|
||||||
void RemoveBlock(int x, int y, int z, World* world);
|
void RemoveBlock(int x, int y, int z, World* world);
|
||||||
void SetBlock(int x, int y, int z, BlockType type, World* world);
|
void SetBlock(int x, int y, int z, BlockType type, World* world);
|
||||||
BlockType GetBlock(int x, int y, int z);
|
BlockType GetBlock(int x, int y, int z);
|
||||||
|
void CheckNeighbors(unsigned int x, unsigned int z, World* world);
|
||||||
void GetPosition(unsigned int& x, unsigned int& y) const;
|
void GetPosition(unsigned int& x, unsigned int& y) const;
|
||||||
|
|
||||||
|
bool IsDirty() const;
|
||||||
|
void MakeDirty();
|
||||||
|
void MakeClean();
|
||||||
void MakeModified();
|
void MakeModified();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -17,7 +17,15 @@
|
|||||||
#define WORLD_SIZE_X 64
|
#define WORLD_SIZE_X 64
|
||||||
#define WORLD_SIZE_Y 64
|
#define WORLD_SIZE_Y 64
|
||||||
|
|
||||||
#define VIEW_DISTANCE 512
|
#define FRAMES_RENDER_CHUNKS 1
|
||||||
|
#define FRAMES_UPDATE_CHUNKS 1
|
||||||
|
#define FRAMES_DELETE_CHUNKS 1
|
||||||
|
|
||||||
|
#define THREADS_GENERATE_CHUNKS 8
|
||||||
|
#define THREADS_UPDATE_CHUNKS 6
|
||||||
|
#define THREADS_DELETE_CHUNKS 3
|
||||||
|
|
||||||
|
#define VIEW_DISTANCE 512 // Si les chunks arr<72>tent de s'afficher pendant une game et qu'il y a un access violation quand tu quitte, il faut augmenter ce chiffre.
|
||||||
#define TEXTURE_SIZE 512
|
#define TEXTURE_SIZE 512
|
||||||
#define MAX_BULLETS 512
|
#define MAX_BULLETS 512
|
||||||
|
|
||||||
@@ -45,6 +53,7 @@ typedef uint64_t Timestamp;
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#define SOCKET int
|
#define SOCKET int
|
||||||
#define INVALID_SOCKET -1
|
#define INVALID_SOCKET -1
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#ifndef NETPROTOCOL_H__
|
#ifndef NETPROTOCOL_H__
|
||||||
#define NETPROTOCOL_H__
|
#define NETPROTOCOL_H__
|
||||||
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) {
|
Player::Player(const Vector3f& position, float rotX, float rotY) : m_position(position), m_rotX(rotX), m_rotY(rotY) {
|
||||||
m_velocity = Vector3f(0, 0, 0);
|
m_velocity = Vector3f(0, 0, 0);
|
||||||
m_airborne = true;
|
m_airborne = true;
|
||||||
|
m_hp = 0.75f; //TODO: Remettre <20> 1.0f
|
||||||
|
m_username = "Zelda Bee-Bop56";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::TurnLeftRight(float value) {
|
void Player::TurnLeftRight(float value) {
|
||||||
@@ -64,7 +66,8 @@ Vector3f Player::GetInput(bool front, bool back, bool left, bool right, bool jum
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
|
Player::Sound Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
|
||||||
|
Player::Sound snd = Player::Sound::NOSOUND;
|
||||||
static float timing = 0.f;
|
static float timing = 0.f;
|
||||||
/* Gestion de collisions */
|
/* Gestion de collisions */
|
||||||
BlockType bt1, bt2, bt3;
|
BlockType bt1, bt2, bt3;
|
||||||
@@ -85,6 +88,7 @@ void Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
|
|||||||
if (bt3 != BTYPE_AIR) {
|
if (bt3 != BTYPE_AIR) {
|
||||||
m_velocity.y = 0;
|
m_velocity.y = 0;
|
||||||
if (timing == 0.f) {
|
if (timing == 0.f) {
|
||||||
|
if (m_airborne) snd = Player::Sound::FALL;
|
||||||
timing = .3f;
|
timing = .3f;
|
||||||
}
|
}
|
||||||
m_airborne = false;
|
m_airborne = false;
|
||||||
@@ -137,10 +141,10 @@ void Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
|
|||||||
m_velocity.x += input.x * 2.f * elapsedTime;
|
m_velocity.x += input.x * 2.f * elapsedTime;
|
||||||
m_velocity.z += input.z * 2.f * elapsedTime;
|
m_velocity.z += input.z * 2.f * elapsedTime;
|
||||||
|
|
||||||
if (input.x == 0.f)
|
if (input.x == 0.f)
|
||||||
m_velocity.x *= .8f;
|
m_velocity.x *= .8f;
|
||||||
|
|
||||||
if (input.z == 0.f)
|
if (input.z == 0.f)
|
||||||
m_velocity.z *= .8f;
|
m_velocity.z *= .8f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -160,6 +164,30 @@ void Player::ApplyPhysics(Vector3f input, World* world, float elapsedTime) {
|
|||||||
m_velocity.y = vy;
|
m_velocity.y = vy;
|
||||||
|
|
||||||
m_position += m_velocity;
|
m_position += m_velocity;
|
||||||
|
|
||||||
|
static float bobbingtime = 0; // Gestion de la cam<61>ra
|
||||||
|
static bool leftright = false;
|
||||||
|
static bool isStep = false;
|
||||||
|
if (bobbingtime <= 360.f)
|
||||||
|
bobbingtime += elapsedTime * 20.f; else bobbingtime = 0;
|
||||||
|
|
||||||
|
if ((sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) < -.2f && !m_airborne) {
|
||||||
|
if (!isStep) {
|
||||||
|
snd = Player::Sound::STEP;
|
||||||
|
}
|
||||||
|
isStep = true;
|
||||||
|
}
|
||||||
|
else isStep = false;
|
||||||
|
m_POV = m_position.y;
|
||||||
|
m_POV += m_airborne ? 0 : (sin(bobbingtime) - 0.5f) * (abs(m_velocity.x) + abs(m_velocity.z)) * .2f;
|
||||||
|
|
||||||
|
return snd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::ApplyTransformation(Transformation& transformation, bool rel) const {
|
||||||
|
transformation.ApplyRotation(-m_rotX, 1, 0, 0);
|
||||||
|
transformation.ApplyRotation(-m_rotY, 0, 1, 0);
|
||||||
|
if (rel) transformation.ApplyTranslation(-GetPOV());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f Player::GetPosition() const { return Vector3f(m_position.x + CHUNK_SIZE_X * WORLD_SIZE_X / 2, m_position.y, m_position.z + CHUNK_SIZE_Z * WORLD_SIZE_Y / 2); }
|
Vector3f Player::GetPosition() const { return Vector3f(m_position.x + CHUNK_SIZE_X * WORLD_SIZE_X / 2, m_position.y, m_position.z + CHUNK_SIZE_Z * WORLD_SIZE_Y / 2); }
|
||||||
@@ -170,6 +198,10 @@ Vector3f Player::GetPOV() const { return Vector3f(GetPosition().x, m_POV, GetPos
|
|||||||
|
|
||||||
Vector3f Player::GetDirection() const { return m_direction; }
|
Vector3f Player::GetDirection() const { return m_direction; }
|
||||||
|
|
||||||
|
std::string Player::GetUsername() const { return m_username; }
|
||||||
|
|
||||||
|
float Player::GetHP() const { return m_hp; }
|
||||||
|
|
||||||
void Player::Teleport(int& x, int& z) {
|
void Player::Teleport(int& x, int& z) {
|
||||||
m_position.x -= x * CHUNK_SIZE_X;
|
m_position.x -= x * CHUNK_SIZE_X;
|
||||||
m_position.z -= z * CHUNK_SIZE_Z;
|
m_position.z -= z * CHUNK_SIZE_Z;
|
||||||
|
@@ -1,33 +1,44 @@
|
|||||||
#ifndef _PLAYER_H__
|
#ifndef PLAYER_H__
|
||||||
#define _PLAYER_H__
|
#define PLAYER_H__
|
||||||
#include "vector3.h"
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
class World;
|
#include <cmath>
|
||||||
|
#include "transformation.h"
|
||||||
|
#include "vector3.h"
|
||||||
|
|
||||||
|
class World;
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
public:
|
public:
|
||||||
|
enum Sound { NOSOUND, STEP, FALL };
|
||||||
|
|
||||||
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
Player(const Vector3f& position, float rotX = 0, float rotY = 0);
|
||||||
void TurnLeftRight(float value);
|
void TurnLeftRight(float value);
|
||||||
void TurnTopBottom(float value);
|
void TurnTopBottom(float value);
|
||||||
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
Vector3f GetInput(bool front, bool back, bool left, bool right, bool jump, bool dash, float elapsedTime);
|
||||||
void ApplyPhysics(Vector3f input, World* world, float elapsedTime);
|
Sound ApplyPhysics(Vector3f input, World* world, float elapsedTime);
|
||||||
|
void ApplyTransformation(Transformation& transformation, bool rel = true) const;
|
||||||
|
|
||||||
Vector3f GetPosition() const;
|
Vector3f GetPosition() const;
|
||||||
Vector3f GetDirection() const;
|
Vector3f GetDirection() const;
|
||||||
Vector3f GetVelocity() const;
|
Vector3f GetVelocity() const;
|
||||||
Vector3f GetPOV() const;
|
Vector3f GetPOV() const;
|
||||||
|
std::string GetUsername() const;
|
||||||
|
float GetHP() const;
|
||||||
void Teleport(int& x, int& z);
|
void Teleport(int& x, int& z);
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
Vector3f m_position;
|
Vector3f m_position;
|
||||||
Vector3f m_velocity;
|
Vector3f m_velocity;
|
||||||
Vector3f m_direction;
|
Vector3f m_direction;
|
||||||
|
|
||||||
|
std::string m_username;
|
||||||
|
|
||||||
float m_rotX = 0;
|
float m_rotX = 0;
|
||||||
float m_rotY = 0;
|
float m_rotY = 0;
|
||||||
float m_POV;
|
float m_POV;
|
||||||
|
|
||||||
|
float m_hp;
|
||||||
|
|
||||||
bool m_airborne;
|
bool m_airborne;
|
||||||
};
|
};
|
||||||
#endif //_PLAYER_H__
|
#endif //_PLAYER_H__
|
||||||
|
@@ -51,10 +51,10 @@ void Transformation::ApplyScale(const Vector3f& v)
|
|||||||
ApplyScale(v.x, v.y, v.z);
|
ApplyScale(v.x, v.y, v.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transformation::Use() const
|
//void Transformation::Use() const
|
||||||
{
|
//{
|
||||||
glLoadMatrixf(m_stack.top().GetInternalValues());
|
// glLoadMatrixf(m_stack.top().GetInternalValues());
|
||||||
}
|
//}
|
||||||
|
|
||||||
const Matrix4f& Transformation::GetMatrix() const
|
const Matrix4f& Transformation::GetMatrix() const
|
||||||
{
|
{
|
@@ -2,9 +2,9 @@
|
|||||||
#define TRANSFORMATION_H__
|
#define TRANSFORMATION_H__
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include "../SQCSim-common/matrix4.h"
|
|
||||||
#include "../SQCSim-common/vector3.h"
|
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
|
#include "matrix4.h"
|
||||||
|
#include "vector3.h"
|
||||||
|
|
||||||
class Transformation
|
class Transformation
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ class Transformation
|
|||||||
void ApplyScale(float x, float y, float z);
|
void ApplyScale(float x, float y, float z);
|
||||||
void ApplyScale(const Vector3f& v);
|
void ApplyScale(const Vector3f& v);
|
||||||
|
|
||||||
void Use() const;
|
//void Use() const;
|
||||||
|
|
||||||
const Matrix4f& GetMatrix() const;
|
const Matrix4f& GetMatrix() const;
|
||||||
|
|
@@ -6,6 +6,10 @@ World::~World() {}
|
|||||||
|
|
||||||
Array2d<Chunk*>& World::GetChunks() { return m_chunks; }
|
Array2d<Chunk*>& World::GetChunks() { return m_chunks; }
|
||||||
|
|
||||||
|
void World::SetSeed(uint64_t seed) {
|
||||||
|
m_seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
Chunk* World::ChunkAt(float x, float y, float z) const {
|
Chunk* World::ChunkAt(float x, float y, float z) const {
|
||||||
int cx = (int)x / CHUNK_SIZE_X;
|
int cx = (int)x / CHUNK_SIZE_X;
|
||||||
int cz = (int)z / CHUNK_SIZE_Z;
|
int cz = (int)z / CHUNK_SIZE_Z;
|
||||||
@@ -38,23 +42,112 @@ BlockType World::BlockAt(const Vector3f& pos, BlockType defaultBlockType) const
|
|||||||
return BlockAt(pos.x, pos.y, pos.z, defaultBlockType);
|
return BlockAt(pos.x, pos.y, pos.z, defaultBlockType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::TransposeWorld(Vector3f& player, Bullet* bullets[MAX_BULLETS]) {
|
||||||
|
int x = 0, y = 0;
|
||||||
|
|
||||||
|
if (player.x > (WORLD_SIZE_X * CHUNK_SIZE_X) * .6f) ++x;
|
||||||
|
else if (player.x < (WORLD_SIZE_X * CHUNK_SIZE_X) * .4f) --x;
|
||||||
|
if (player.z > (WORLD_SIZE_Y * CHUNK_SIZE_Z) * .6f) ++y;
|
||||||
|
else if (player.z < (WORLD_SIZE_Y * CHUNK_SIZE_Z) * .4f) --y;
|
||||||
|
|
||||||
|
if (!x && !y) return;
|
||||||
|
|
||||||
|
if (x > 0) {
|
||||||
|
for (int ax = 0; ax < WORLD_SIZE_X; ++ax)
|
||||||
|
for (int ay = 0; ay < WORLD_SIZE_Y; ++ay)
|
||||||
|
if (ax - x >= 0) {
|
||||||
|
m_chunks.Set(ax - x, ay,
|
||||||
|
m_chunks.Remove(ax, ay));
|
||||||
|
if (ax == WORLD_SIZE_X - 1 && m_chunks.Get(ax - x, ay))
|
||||||
|
m_chunks.Get(ax - x, ay)->MakeDirty();
|
||||||
|
}
|
||||||
|
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
|
||||||
|
}
|
||||||
|
else if (x < 0) {
|
||||||
|
for (int ax = WORLD_SIZE_X - 1; ax >= 0; --ax)
|
||||||
|
for (int ay = WORLD_SIZE_Y - 1; ay >= 0; --ay)
|
||||||
|
if (ax - x < WORLD_SIZE_X) {
|
||||||
|
m_chunks.Set(ax - x, ay,
|
||||||
|
m_chunks.Remove(ax, ay));
|
||||||
|
if (ax == 0 && m_chunks.Get(ax - x, ay))
|
||||||
|
m_chunks.Get(ax - x, ay)->MakeDirty();
|
||||||
|
}
|
||||||
|
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y > 0) {
|
||||||
|
for (int ax = 0; ax < WORLD_SIZE_X; ++ax)
|
||||||
|
for (int ay = 0; ay < WORLD_SIZE_Y; ++ay)
|
||||||
|
if (ay - y >= 0) {
|
||||||
|
m_chunks.Set(ax, ay - y,
|
||||||
|
m_chunks.Remove(ax, ay));
|
||||||
|
if (ay == WORLD_SIZE_Y - 1 && m_chunks.Get(ax, ay - y))
|
||||||
|
m_chunks.Get(ax, ay - y)->MakeDirty();
|
||||||
|
}
|
||||||
|
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
|
||||||
|
}
|
||||||
|
else if (y < 0) {
|
||||||
|
for (int ax = WORLD_SIZE_X - 1; ax >= 0; --ax)
|
||||||
|
for (int ay = WORLD_SIZE_Y - 1; ay >= 0; --ay)
|
||||||
|
if (ay - y < WORLD_SIZE_Y) {
|
||||||
|
m_chunks.Set(ax, ay - y,
|
||||||
|
m_chunks.Remove(ax, ay));
|
||||||
|
if (ay == 0 && m_chunks.Get(ax, ay - y))
|
||||||
|
m_chunks.Get(ax, ay - y)->MakeDirty();
|
||||||
|
}
|
||||||
|
else if (m_chunks.Get(ax, ay)) m_tbDeleted.emplace_back(m_chunks.Remove(ax, ay));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_center[0] += x; m_center[1] += y;
|
||||||
|
player.x -= x * CHUNK_SIZE_X;
|
||||||
|
player.z -= y * CHUNK_SIZE_Z;
|
||||||
|
|
||||||
|
for (int index = 0; index < MAX_BULLETS; ++index)
|
||||||
|
if (bullets[index]) bullets[index]->Transpose(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::CleanUpWorld(int& deleteframes, bool clear = false) {
|
||||||
|
if (clear) {
|
||||||
|
while (m_tbDeleted.size() > 0) {
|
||||||
|
delete m_tbDeleted.back();
|
||||||
|
m_tbDeleted.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!m_tbDeleted.empty() && !deleteframes) {
|
||||||
|
int deleted = 0;
|
||||||
|
while (deleted < THREADS_DELETE_CHUNKS) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
delete m_tbDeleted.back();
|
||||||
|
m_tbDeleted.pop_back();
|
||||||
|
deleteframes = FRAMES_DELETE_CHUNKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void World::GetScope(unsigned int& x, unsigned int& y) {
|
void World::GetScope(unsigned int& x, unsigned int& y) {
|
||||||
x = m_center[0];
|
x = m_center[0];
|
||||||
y = m_center[1];
|
y = m_center[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::ChangeBlockAtPosition(BlockType blockType, Vector3f pos) {
|
void World::Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
int bx = (int)pos.x % CHUNK_SIZE_X;
|
UpdateWorld(player_pos, blockinfo);
|
||||||
int by = (int)pos.y % CHUNK_SIZE_Y;
|
//TransposeWorld(player_pos, bullets);
|
||||||
int bz = (int)pos.z % CHUNK_SIZE_Z;
|
|
||||||
|
|
||||||
ChunkAt(pos)->SetBlock(bx, by, bz, blockType, this);
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
//void World::UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
|
// if (updates == 0 && ChunkAt(chx, 1, chy) &&
|
||||||
|
// ChunkAt(chx, 1, chy)->IsDirty()) {
|
||||||
|
// ChunkAt(chx, 1, chy)->Update(blockinfo, this);
|
||||||
|
// updates = FRAMES_UPDATE_CHUNKS;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block) {
|
void World::ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block) {
|
||||||
Vector3f currentPos = player.GetPosition();
|
Vector3f currentPos = player_pos;
|
||||||
Vector3f currentBlock = currentPos;
|
Vector3f currentBlock = currentPos;
|
||||||
Vector3f ray = player.GetDirection();
|
Vector3f ray = player_dir;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (block) return;
|
if (block) return;
|
||||||
@@ -76,7 +169,7 @@ void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block
|
|||||||
|
|
||||||
BlockType bt = BlockAt(currentBlock);
|
BlockType bt = BlockAt(currentBlock);
|
||||||
|
|
||||||
if (bt == BTYPE_AIR) { // V?rification pour ?tre s?r que le bloc ? changer n'est pas dans le joueur.
|
if (bt == BTYPE_AIR) { // V<EFBFBD>rification pour <EFBFBD>tre s<EFBFBD>r que le bloc <EFBFBD> changer n'est pas dans le joueur.
|
||||||
int Bx = (int)currentBlock.x;
|
int Bx = (int)currentBlock.x;
|
||||||
int By = (int)currentBlock.y;
|
int By = (int)currentBlock.y;
|
||||||
int Bz = (int)currentBlock.z;
|
int Bz = (int)currentBlock.z;
|
||||||
@@ -107,3 +200,211 @@ void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block
|
|||||||
block = true;
|
block = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::ChangeBlockAtPosition(BlockType blockType, Vector3f pos) {
|
||||||
|
int bx = (int)pos.x % CHUNK_SIZE_X;
|
||||||
|
int by = (int)pos.y % CHUNK_SIZE_Y;
|
||||||
|
int bz = (int)pos.z % CHUNK_SIZE_Z;
|
||||||
|
|
||||||
|
ChunkAt(pos)->SetBlock(bx, by, bz, blockType, this);
|
||||||
|
ChunkAt(pos)->MakeModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||||
|
int cx = player.x;
|
||||||
|
int cy = player.z;
|
||||||
|
static int frameGenerate = 1;
|
||||||
|
static int frameUpdate = 2;
|
||||||
|
static int frameDelete = 3;
|
||||||
|
int side = 0;
|
||||||
|
int threads = 0;
|
||||||
|
std::future<Chunk*> genThList[THREADS_GENERATE_CHUNKS];
|
||||||
|
//std::future<void> delThList[THREADS_DELETE_CHUNKS];
|
||||||
|
|
||||||
|
if (frameGenerate > 0) --frameGenerate;
|
||||||
|
if (frameUpdate > 0) --frameUpdate;
|
||||||
|
if (frameDelete > 0) --frameDelete;
|
||||||
|
|
||||||
|
if (!frameGenerate)
|
||||||
|
while (side * CHUNK_SIZE_X <= VIEW_DISTANCE * 2 + CHUNK_SIZE_X) {
|
||||||
|
int tx = -side, ty = -side;
|
||||||
|
int chx = 0;
|
||||||
|
int chy = 0;
|
||||||
|
|
||||||
|
for (; tx <= side; ++tx) {
|
||||||
|
if (frameGenerate)
|
||||||
|
break;
|
||||||
|
chx = cx + tx * CHUNK_SIZE_X;
|
||||||
|
chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
if (chx < WORLD_SIZE_X * CHUNK_SIZE_X && chy < WORLD_SIZE_Y * CHUNK_SIZE_Z &&
|
||||||
|
chx >= 0 && chy >= 0 && !ChunkAt(chx, 1, chy))
|
||||||
|
genThList[threads++] = std::async(std::launch::async,
|
||||||
|
[](unsigned int x, unsigned int y, uint64_t seed) {
|
||||||
|
return new Chunk(x, y, seed); },
|
||||||
|
chx / CHUNK_SIZE_X + m_center[0],
|
||||||
|
chy / CHUNK_SIZE_Z + m_center[1],
|
||||||
|
m_seed);
|
||||||
|
if (threads == THREADS_GENERATE_CHUNKS) frameGenerate = FRAMES_RENDER_CHUNKS;
|
||||||
|
}
|
||||||
|
for (; ty <= side; ++ty) {
|
||||||
|
if (frameGenerate)
|
||||||
|
break;
|
||||||
|
chx = cx + tx * CHUNK_SIZE_X;
|
||||||
|
chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
if (chx < WORLD_SIZE_X * CHUNK_SIZE_X && chy < WORLD_SIZE_Y * CHUNK_SIZE_Z &&
|
||||||
|
chx >= 0 && chy >= 0 && !ChunkAt(chx, 1, chy))
|
||||||
|
genThList[threads++] = std::async(std::launch::async,
|
||||||
|
[](unsigned int x, unsigned int y, uint64_t seed) {
|
||||||
|
return new Chunk(x, y, seed); },
|
||||||
|
chx / CHUNK_SIZE_X + m_center[0],
|
||||||
|
chy / CHUNK_SIZE_Z + m_center[1],
|
||||||
|
m_seed);
|
||||||
|
if (threads == THREADS_GENERATE_CHUNKS) frameGenerate = FRAMES_RENDER_CHUNKS;
|
||||||
|
}
|
||||||
|
for (; tx >= -side; --tx) {
|
||||||
|
if (frameGenerate)
|
||||||
|
break;
|
||||||
|
chx = cx + tx * CHUNK_SIZE_X;
|
||||||
|
chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
if (chx < WORLD_SIZE_X * CHUNK_SIZE_X && chy < WORLD_SIZE_Y * CHUNK_SIZE_Z &&
|
||||||
|
chx >= 0 && chy >= 0 && !ChunkAt(chx, 1, chy))
|
||||||
|
genThList[threads++] = std::async(std::launch::async,
|
||||||
|
[](unsigned int x, unsigned int y, uint64_t seed) {
|
||||||
|
return new Chunk(x, y, seed); },
|
||||||
|
chx / CHUNK_SIZE_X + m_center[0],
|
||||||
|
chy / CHUNK_SIZE_Z + m_center[1],
|
||||||
|
m_seed);
|
||||||
|
if (threads == THREADS_GENERATE_CHUNKS) frameGenerate = FRAMES_RENDER_CHUNKS;
|
||||||
|
}
|
||||||
|
for (; ty >= -side; --ty) {
|
||||||
|
if (frameGenerate)
|
||||||
|
break;
|
||||||
|
chx = cx + tx * CHUNK_SIZE_X;
|
||||||
|
chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
if (chx < WORLD_SIZE_X * CHUNK_SIZE_X && chy < WORLD_SIZE_Y * CHUNK_SIZE_Z &&
|
||||||
|
chx >= 0 && chy >= 0 && !ChunkAt(chx, 1, chy))
|
||||||
|
genThList[threads++] = std::async(std::launch::async,
|
||||||
|
[](unsigned int x, unsigned int y, uint64_t seed) {
|
||||||
|
return new Chunk(x, y, seed); },
|
||||||
|
chx / CHUNK_SIZE_X + m_center[0],
|
||||||
|
chy / CHUNK_SIZE_Z + m_center[1],
|
||||||
|
m_seed);
|
||||||
|
if (threads == THREADS_GENERATE_CHUNKS) frameGenerate = FRAMES_RENDER_CHUNKS;
|
||||||
|
}
|
||||||
|
if (frameGenerate)
|
||||||
|
break;
|
||||||
|
++side;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (threads > 0) {
|
||||||
|
for (int i = 0; i < threads; ++i)
|
||||||
|
genThList[i].wait();
|
||||||
|
|
||||||
|
for (int i = 0; i < threads; ++i) {
|
||||||
|
unsigned int x, y;
|
||||||
|
Chunk* chunk = genThList[i].get();
|
||||||
|
chunk->GetPosition(x, y);
|
||||||
|
m_chunks.Set(x - m_center[0], y - m_center[1], chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
side = 0;
|
||||||
|
threads = 0;
|
||||||
|
|
||||||
|
//if (!frameUpdate)
|
||||||
|
// while (side * CHUNK_SIZE_X <= VIEW_DISTANCE * 2) {
|
||||||
|
// int tx = -side, ty = -side;
|
||||||
|
|
||||||
|
// for (; tx <= side; ++tx) {
|
||||||
|
// if (frameUpdate)
|
||||||
|
// break;
|
||||||
|
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
// if (ChunkAt(chx, 1, chy) &&
|
||||||
|
// ChunkAt(chx, 1, chy)->IsDirty()) {
|
||||||
|
// updateThList[threads++] =
|
||||||
|
// std::async(std::launch::async,
|
||||||
|
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
|
||||||
|
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
|
||||||
|
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for (; ty <= side; ++ty) {
|
||||||
|
// if (frameUpdate)
|
||||||
|
// break;
|
||||||
|
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
// if (ChunkAt(chx, 1, chy) &&
|
||||||
|
// ChunkAt(chx, 1, chy)->IsDirty()) {
|
||||||
|
// updateThList[threads++] =
|
||||||
|
// std::async(std::launch::async,
|
||||||
|
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
|
||||||
|
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
|
||||||
|
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for (; tx >= -side; --tx) {
|
||||||
|
// if (frameUpdate)
|
||||||
|
// break;
|
||||||
|
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
// if (ChunkAt(chx, 1, chy) &&
|
||||||
|
// ChunkAt(chx, 1, chy)->IsDirty()) {
|
||||||
|
// updateThList[threads++] =
|
||||||
|
// std::async(std::launch::async,
|
||||||
|
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
|
||||||
|
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
|
||||||
|
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for (; ty >= -side; --ty) {
|
||||||
|
// if (frameUpdate)
|
||||||
|
// break;
|
||||||
|
// unsigned int chx = cx + tx * CHUNK_SIZE_X, chy = cy + ty * CHUNK_SIZE_Z;
|
||||||
|
// if (ChunkAt(chx, 1, chy) &&
|
||||||
|
// ChunkAt(chx, 1, chy)->IsDirty()) {
|
||||||
|
// updateThList[threads++] =
|
||||||
|
// std::async(std::launch::async,
|
||||||
|
// [](Chunk* chunk, BlockInfo* blockinfo[BTYPE_LAST], World* world) {
|
||||||
|
// chunk->Update(blockinfo, world); return chunk; }, ChunkAt(chx, 1, chy), blockinfo, this);
|
||||||
|
// if (threads == THREADS_UPDATE_CHUNKS) frameUpdate = FRAMES_UPDATE_CHUNKS;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (frameUpdate)
|
||||||
|
// break;
|
||||||
|
// ++side;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//if (threads > 0) {
|
||||||
|
// for (int i = 0; i < threads; ++i) {
|
||||||
|
// updateThList[i].wait();
|
||||||
|
// Chunk* chunk = updateThList[i].get();
|
||||||
|
// chunk->FlushMeshToVBO();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
threads = 0;
|
||||||
|
|
||||||
|
//int del = THREADS_DELETE_CHUNKS;
|
||||||
|
//while (!m_tbDeleted.empty() && del--) { // Moins rapide que le bout en dessous, mais -beaucoup- plus stable.
|
||||||
|
// m_tbDeleted.back()->FlushVBO();
|
||||||
|
// m_tbDeleted.back()->~Chunk();
|
||||||
|
// m_tbDeleted.pop_back();
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*while (!m_tbDeleted.empty() && !frameDelete) {
|
||||||
|
if (m_tbDeleted.back()) {
|
||||||
|
m_tbDeleted.back()->FlushVBO();
|
||||||
|
delThList[threads] =
|
||||||
|
std::async(std::launch::async,
|
||||||
|
[](Chunk* chunk) { delete chunk; }, m_tbDeleted.back());
|
||||||
|
m_tbDeleted.pop_back();
|
||||||
|
if (++threads > THREADS_DELETE_CHUNKS) frameDelete = FRAMES_DELETE_CHUNKS;
|
||||||
|
}
|
||||||
|
else m_tbDeleted.pop_back();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*for (int x = 0; x < threads; ++x) {
|
||||||
|
delThList[x].wait();
|
||||||
|
delThList[x].get();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
int World::GettbDeleted() const { return m_tbDeleted.size(); }
|
||||||
|
@@ -1,19 +1,18 @@
|
|||||||
#ifndef WORLD_H__
|
#ifndef WORLD_H__
|
||||||
#define WORLD_H__
|
#define WORLD_H__
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "chunk.h"
|
|
||||||
#include "array2d.h"
|
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
#include "player.h"
|
#include "array2d.h"
|
||||||
#include "bullet.h"
|
#include "bullet.h"
|
||||||
|
#include "chunk.h"
|
||||||
|
|
||||||
class Chunk;
|
class Chunk;
|
||||||
class Player;
|
|
||||||
class Bullet;
|
class Bullet;
|
||||||
|
|
||||||
class World {
|
class World {
|
||||||
@@ -23,23 +22,33 @@ public:
|
|||||||
|
|
||||||
Array2d<Chunk*>& GetChunks();
|
Array2d<Chunk*>& GetChunks();
|
||||||
|
|
||||||
|
void SetSeed(uint64_t seed);
|
||||||
|
|
||||||
Chunk* ChunkAt(float x, float y, float z) const;
|
Chunk* ChunkAt(float x, float y, float z) const;
|
||||||
Chunk* ChunkAt(const Vector3f& pos) const;
|
Chunk* ChunkAt(const Vector3f& pos) const;
|
||||||
|
|
||||||
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(float x, float y, float z, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
BlockType BlockAt(const Vector3f& pos, BlockType defaultBlockType = BTYPE_AIR) const;
|
||||||
|
|
||||||
|
void Update(Bullet* bullets[MAX_BULLETS], const Vector3f& player_pos, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
|
||||||
void GetScope(unsigned int& x, unsigned int& y);
|
void GetScope(unsigned int& x, unsigned int& y);
|
||||||
|
|
||||||
void ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block);
|
void ChangeBlockAtCursor(BlockType blockType, const Vector3f& player_pos, const Vector3f& player_dir, bool& block);
|
||||||
void ChangeBlockAtPosition(BlockType blockType, Vector3f pos);
|
void ChangeBlockAtPosition(BlockType blockType, Vector3f pos);
|
||||||
|
void CleanUpWorld(int& deleteframes, bool clear);
|
||||||
|
int GettbDeleted() const;
|
||||||
private:
|
private:
|
||||||
Array2d<Chunk*> m_chunks = Array2d<Chunk*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
Array2d<Chunk*> m_chunks = Array2d<Chunk*>(WORLD_SIZE_X, WORLD_SIZE_Y);
|
||||||
std::vector<Chunk*> m_tbDeleted;
|
std::vector<Chunk*> m_tbDeleted;
|
||||||
|
uint64_t m_seed = 0;
|
||||||
|
|
||||||
unsigned int m_center[2] = { UINT16_MAX / 2 - WORLD_SIZE_X, UINT16_MAX / 2 - WORLD_SIZE_Y };
|
unsigned int m_center[2] = { UINT16_MAX / 2 - WORLD_SIZE_X, UINT16_MAX / 2 - WORLD_SIZE_Y };
|
||||||
|
|
||||||
|
void UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
void UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
|
||||||
|
void TransposeWorld(Vector3f& player, Bullet* bullets[MAX_BULLETS]);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // WORLD_H__
|
#endif // WORLD_H__
|
||||||
|
|
||||||
|
30
SQCSim-srv/cmake/CMakeLists.txt
Normal file
30
SQCSim-srv/cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.18.4)
|
||||||
|
|
||||||
|
project(SQCSim-Server VERSION 0.1)
|
||||||
|
|
||||||
|
add_compile_options("-Wno-narrowing")
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../out")
|
||||||
|
|
||||||
|
set(SQCSIM_COMMON_DIR "../../SQCSim-common/")
|
||||||
|
|
||||||
|
add_library(SQCSim-common
|
||||||
|
"${SQCSIM_COMMON_DIR}blockinfo.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}bullet.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}chunk.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}netprotocol.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}opensimplex.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}player.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}transformation.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}world.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(SQCSim-server
|
||||||
|
"../connection.cpp"
|
||||||
|
"../server.cpp"
|
||||||
|
"../main.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(SQCSim-server PUBLIC SQCSim-common)
|
@@ -1,5 +1,6 @@
|
|||||||
#ifndef CONNECTION_H__
|
#ifndef CONNECTION_H__
|
||||||
#define CONNECTION_H__
|
#define CONNECTION_H__
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "../SQCSim-common/player.h"
|
#include "../SQCSim-common/player.h"
|
||||||
|
@@ -14,4 +14,4 @@
|
|||||||
typedef unsigned char LogDest;
|
typedef unsigned char LogDest;
|
||||||
enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST };
|
enum LOG_DEST { CONSOLE, LOGFILE, LOG_LAST };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -85,7 +85,7 @@ int Server::Ready() {
|
|||||||
|
|
||||||
while (!readystart) {
|
while (!readystart) {
|
||||||
sockaddr_in sockad;
|
sockaddr_in sockad;
|
||||||
int addrlen = sizeof(sockad);
|
unsigned int addrlen = sizeof(sockad);
|
||||||
SOCKET sock = accept(m_sock_tcp, (sockaddr*)&sockad, &addrlen);
|
SOCKET sock = accept(m_sock_tcp, (sockaddr*)&sockad, &addrlen);
|
||||||
|
|
||||||
if (sock < 0)
|
if (sock < 0)
|
||||||
@@ -140,7 +140,7 @@ void Server::Run() {
|
|||||||
Log("Partie en cours...", false, false);
|
Log("Partie en cours...", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string Server::Timestamp() {
|
inline std::string Server::LogTimestamp() {
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm timeinfo;
|
struct tm timeinfo;
|
||||||
char buffer[80];
|
char buffer[80];
|
||||||
@@ -162,11 +162,11 @@ inline std::string Server::Timestamp() {
|
|||||||
void Server::Log(std::string str, bool is_error = false, bool is_fatal = false) {
|
void Server::Log(std::string str, bool is_error = false, bool is_fatal = false) {
|
||||||
switch (m_log) {
|
switch (m_log) {
|
||||||
case LOG_DEST::LOGFILE:
|
case LOG_DEST::LOGFILE:
|
||||||
m_logfile << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
m_logfile << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
||||||
break;
|
break;
|
||||||
case LOG_DEST::CONSOLE:
|
case LOG_DEST::CONSOLE:
|
||||||
default:
|
default:
|
||||||
std::cout << Timestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
std::cout << LogTimestamp() << (is_fatal ? "FATAL " : "") << (is_error ? "ERROR " : "") << str << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ private:
|
|||||||
|
|
||||||
World* m_world = nullptr;
|
World* m_world = nullptr;
|
||||||
|
|
||||||
std::string Timestamp();
|
std::string LogTimestamp();
|
||||||
void Log(std::string str, bool is_error, bool is_fatal);
|
void Log(std::string str, bool is_error, bool is_fatal);
|
||||||
void buildIdList(size_t size);
|
void buildIdList(size_t size);
|
||||||
|
|
||||||
|
@@ -20,37 +20,33 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="audio.h" />
|
<ClInclude Include="audio.h" />
|
||||||
<ClInclude Include="chunk.h" />
|
|
||||||
<ClInclude Include="connector.h" />
|
<ClInclude Include="connector.h" />
|
||||||
<ClInclude Include="define.h" />
|
<ClInclude Include="define.h" />
|
||||||
<ClInclude Include="engine.h" />
|
<ClInclude Include="engine.h" />
|
||||||
|
<ClInclude Include="mesh.h" />
|
||||||
<ClInclude Include="openglcontext.h" />
|
<ClInclude Include="openglcontext.h" />
|
||||||
<ClInclude Include="player.h" />
|
|
||||||
<ClInclude Include="shader.h" />
|
<ClInclude Include="shader.h" />
|
||||||
<ClInclude Include="skybox.h" />
|
<ClInclude Include="skybox.h" />
|
||||||
<ClInclude Include="texture.h" />
|
<ClInclude Include="texture.h" />
|
||||||
<ClInclude Include="textureatlas.h" />
|
<ClInclude Include="textureatlas.h" />
|
||||||
<ClInclude Include="tool.h" />
|
<ClInclude Include="tool.h" />
|
||||||
<ClInclude Include="transformation.h" />
|
|
||||||
<ClInclude Include="vertexbuffer.h" />
|
<ClInclude Include="vertexbuffer.h" />
|
||||||
<ClInclude Include="world.h" />
|
<ClInclude Include="worldrenderer.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="audio.cpp" />
|
<ClCompile Include="audio.cpp" />
|
||||||
<ClCompile Include="chunk.cpp" />
|
|
||||||
<ClCompile Include="connector.cpp" />
|
<ClCompile Include="connector.cpp" />
|
||||||
<ClCompile Include="engine.cpp" />
|
<ClCompile Include="engine.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="mesh.cpp" />
|
||||||
<ClCompile Include="openglcontext.cpp" />
|
<ClCompile Include="openglcontext.cpp" />
|
||||||
<ClCompile Include="player.cpp" />
|
|
||||||
<ClCompile Include="shader.cpp" />
|
<ClCompile Include="shader.cpp" />
|
||||||
<ClCompile Include="skybox.cpp" />
|
<ClCompile Include="skybox.cpp" />
|
||||||
<ClCompile Include="texture.cpp" />
|
<ClCompile Include="texture.cpp" />
|
||||||
<ClCompile Include="textureatlas.cpp" />
|
<ClCompile Include="textureatlas.cpp" />
|
||||||
<ClCompile Include="tool.cpp" />
|
<ClCompile Include="tool.cpp" />
|
||||||
<ClCompile Include="transformation.cpp" />
|
|
||||||
<ClCompile Include="vertexbuffer.cpp" />
|
<ClCompile Include="vertexbuffer.cpp" />
|
||||||
<ClCompile Include="world.cpp" />
|
<ClCompile Include="worldrenderer.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
<ProjectReference Include="..\SQCSim-common\SQCSim-common.vcxproj">
|
||||||
@@ -109,8 +105,8 @@
|
|||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>external\irrKlang-1.6.0\include;external\glew210\include;external\devil178\include;external\sfml251\include;$(IncludePath)</IncludePath>
|
<IncludePath>external\irrKlang-1.6.0\include;external\glew210\include;external\devil180\include;external\sfml251-32\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>external\glew210\lib;external\sfml251\lib;external\devil178\lib;external\irrKlang-1.6.0\lib\Win32-visualStudio;$(LibraryPath)</LibraryPath>
|
<LibraryPath>external\glew210\lib\Release\Win32;external\sfml251-32\lib;external\devil180\lib\x86\Release;external\irrKlang-1.6.0\lib\Win32-visualStudio;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
@@ -119,8 +115,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>external\devil180\include;external\irrKlang-1.6.0\include;external\sfml251\include;external\glew210\include;$(IncludePath)</IncludePath>
|
<IncludePath>external\devil180\include;external\irrKlang-1.6.0\include;external\sfml251-32\include;external\glew210\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>external\sfml251\lib;external\devil180\lib\x86\Release;external\glew210\lib\Release\Win32;$(LibraryPath);external\irrKlang-1.6.0\lib\Win32-visualStudio</LibraryPath>
|
<LibraryPath>external\sfml251-32\lib;external\devil180\lib\x86\Release;external\glew210\lib\Release\Win32;$(LibraryPath);external\irrKlang-1.6.0\lib\Win32-visualStudio</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
@@ -172,8 +168,8 @@
|
|||||||
<FloatingPointModel>Fast</FloatingPointModel>
|
<FloatingPointModel>Fast</FloatingPointModel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>irrKlang.lib;sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>irrKlang.lib;sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
@@ -194,8 +190,8 @@
|
|||||||
<FloatingPointModel>Fast</FloatingPointModel>
|
<FloatingPointModel>Fast</FloatingPointModel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>irrKlang.lib;sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>irrKlang.lib;sfml-main.lib;sfml-system.lib;sfml-window.lib;sfml-graphics.lib;GlU32.Lib;OpenGL32.Lib;DevIL.lib;ILU.lib;ILUT.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
@@ -11,9 +11,6 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="chunk.h">
|
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="define.h">
|
<ClInclude Include="define.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -23,12 +20,6 @@
|
|||||||
<ClInclude Include="texture.h">
|
<ClInclude Include="texture.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="transformation.h">
|
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="player.h">
|
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="shader.h">
|
<ClInclude Include="shader.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -44,9 +35,6 @@
|
|||||||
<ClInclude Include="textureatlas.h">
|
<ClInclude Include="textureatlas.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="world.h">
|
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="connector.h">
|
<ClInclude Include="connector.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -56,11 +44,14 @@
|
|||||||
<ClInclude Include="tool.h">
|
<ClInclude Include="tool.h">
|
||||||
<Filter>Fichiers d%27en-tête</Filter>
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="mesh.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="worldrenderer.h">
|
||||||
|
<Filter>Fichiers d%27en-tête</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="chunk.cpp">
|
|
||||||
<Filter>Fichiers sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="engine.cpp">
|
<ClCompile Include="engine.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -73,12 +64,6 @@
|
|||||||
<ClCompile Include="texture.cpp">
|
<ClCompile Include="texture.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="transformation.cpp">
|
|
||||||
<Filter>Fichiers sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="player.cpp">
|
|
||||||
<Filter>Fichiers sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="shader.cpp">
|
<ClCompile Include="shader.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -94,14 +79,17 @@
|
|||||||
<ClCompile Include="textureatlas.cpp">
|
<ClCompile Include="textureatlas.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="world.cpp">
|
|
||||||
<Filter>Fichiers sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="connector.cpp">
|
<ClCompile Include="connector.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="tool.cpp">
|
<ClCompile Include="tool.cpp">
|
||||||
<Filter>Fichiers sources</Filter>
|
<Filter>Fichiers sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="mesh.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="worldrenderer.cpp">
|
||||||
|
<Filter>Fichiers sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
Audio::Audio() {
|
Audio::Audio() {
|
||||||
m_engine = irrklang::createIrrKlangDevice();
|
m_engine = irrklang::createIrrKlangDevice();
|
||||||
m_engine->setDopplerEffectParameters(1);
|
m_engine->setDopplerEffectParameters(10);
|
||||||
m_engine->setRolloffFactor(1);
|
m_engine->setRolloffFactor(2);
|
||||||
m_engine->setDefault3DSoundMinDistance(1);
|
m_engine->setDefault3DSoundMinDistance(.1);
|
||||||
m_engine->setDefault3DSoundMaxDistance(1000);
|
m_engine->setDefault3DSoundMaxDistance(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Audio::Audio(const char * music) {
|
Audio::Audio(const char * music) {
|
||||||
m_engine = irrklang::createIrrKlangDevice();
|
m_engine = irrklang::createIrrKlangDevice();
|
||||||
m_engine->setDopplerEffectParameters(1);
|
m_engine->setDopplerEffectParameters(1);
|
||||||
m_engine->setRolloffFactor(1);
|
m_engine->setRolloffFactor(2);
|
||||||
m_engine->setDefault3DSoundMinDistance(1);
|
m_engine->setDefault3DSoundMinDistance(.1);
|
||||||
m_engine->setDefault3DSoundMaxDistance(1000);
|
m_engine->setDefault3DSoundMaxDistance(1000);
|
||||||
m_music = m_engine->play2D(music, false, true, true, irrklang::ESM_STREAMING);
|
m_music = m_engine->play2D(music, false, true, true, irrklang::ESM_STREAMING);
|
||||||
}
|
}
|
||||||
@@ -28,10 +28,11 @@ void Audio::Update3DAudio(Vector3f pos, Vector3f dir, Vector3f vel) {
|
|||||||
irrklang::vec3df(vel.x, vel.y, vel.z));
|
irrklang::vec3df(vel.x, vel.y, vel.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume = 1) {
|
irrklang::ISound* Audio::Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped = false, float volume = 1) {
|
||||||
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), false, false, true, irrklang::ESM_NO_STREAMING, true);
|
sound = m_engine->play3D(name, irrklang::vec3df(pos.x, pos.y, pos.z), is_looped, false, true, is_looped? irrklang::ESM_STREAMING: irrklang::ESM_NO_STREAMING, true);
|
||||||
sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z));
|
sound->setVelocity(irrklang::vec3df(vel.x, vel.y, vel.z));
|
||||||
sound->setVolume(volume);
|
sound->setVolume(volume);
|
||||||
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume = 1) {
|
void Audio::Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume = 1) {
|
||||||
|
@@ -1,24 +1,30 @@
|
|||||||
#ifndef AUDIO_H__
|
#ifndef AUDIO_H__
|
||||||
#define AUDIO_H__
|
#define AUDIO_H__
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
#include <irrKlang.h>
|
#include <irrKlang.h>
|
||||||
#include <ik_ISoundSource.h>
|
#include <ik_ISoundSource.h>
|
||||||
#include "define.h"
|
#else
|
||||||
|
#include "./external/irrKlang-64bit-1.6.0/include/irrKlang.h"
|
||||||
|
#include "./external/irrKlang-64bit-1.6.0/include/ik_ISoundSource.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../SQCSim-common/vector3.h"
|
#include "../SQCSim-common/vector3.h"
|
||||||
|
#include "define.h"
|
||||||
|
|
||||||
class Audio {
|
class Audio {
|
||||||
private:
|
private:
|
||||||
irrklang::ISoundEngine* m_engine;
|
|
||||||
irrklang::ISound* m_music;
|
irrklang::ISound* m_music;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Audio();
|
Audio();
|
||||||
Audio(const char* music);
|
Audio(const char* music);
|
||||||
~Audio();
|
~Audio();
|
||||||
|
irrklang::ISoundEngine* m_engine;
|
||||||
|
|
||||||
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
|
void Update3DAudio(Vector3f pos, Vector3f dir, Vector3f speed);
|
||||||
|
|
||||||
void Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, float volume);
|
irrklang::ISound* Create3DAudioObj(irrklang::ISound* sound, const char* name, Vector3f pos, Vector3f vel, bool is_looped, float volume);
|
||||||
|
|
||||||
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
void Render3DAudioObj(irrklang::ISound* sound, Vector3f& pos, Vector3f& vel, float volume);
|
||||||
|
|
||||||
@@ -29,4 +35,4 @@ public:
|
|||||||
void PauseEngine();
|
void PauseEngine();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIO_H__
|
#endif // AUDIO_H__
|
||||||
|
@@ -1,234 +0,0 @@
|
|||||||
#include "chunk.h"
|
|
||||||
#include "world.h"
|
|
||||||
|
|
||||||
Chunk::Chunk(unsigned int x, unsigned int y, int64_t seed) : m_posX(x), m_posY(y) {
|
|
||||||
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
|
|
||||||
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
|
|
||||||
//std::ifstream input(pos.str(), std::fstream::binary);
|
|
||||||
|
|
||||||
//if (input.fail()) {
|
|
||||||
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(seed);
|
|
||||||
m_blocks.Reset(BTYPE_AIR);
|
|
||||||
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Montagnes
|
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
|
||||||
float xnoiz, ynoiz;
|
|
||||||
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 4096.;
|
|
||||||
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 4096.;
|
|
||||||
double height = 0;
|
|
||||||
for (int x = 0; x < 39; ++x) {
|
|
||||||
height += simplex.eval(xnoiz, ynoiz);
|
|
||||||
height *= .79;
|
|
||||||
xnoiz *= 1.139;
|
|
||||||
ynoiz *= 1.139;
|
|
||||||
}
|
|
||||||
height = height * 2000. * simplex.eval((double)(ix + x * CHUNK_SIZE_X) / 512., (double)(iz + y * CHUNK_SIZE_Z) / 512.);
|
|
||||||
height /= (CHUNK_SIZE_Y / 1.9);
|
|
||||||
height += 15.;
|
|
||||||
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy)
|
|
||||||
SetBlock(ix, iy, iz, BTYPE_METAL, nullptr);
|
|
||||||
}
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // Collines
|
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
|
||||||
float xnoiz, ynoiz;
|
|
||||||
xnoiz = (double)(ix + x * CHUNK_SIZE_X) / 512.;
|
|
||||||
ynoiz = (double)(iz + y * CHUNK_SIZE_Z) / 512.;
|
|
||||||
float height = simplex.eval(xnoiz, ynoiz) * 50.f;// +1.f;
|
|
||||||
for (int iy = 0; iy <= (int)height % CHUNK_SIZE_Y; ++iy) {
|
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
|
||||||
SetBlock(ix, iy, iz, BTYPE_GRASS, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Lacs"
|
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
|
||||||
for (int iy = 0; iy < 13; ++iy) {
|
|
||||||
if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
|
||||||
SetBlock(ix, iy, iz, BTYPE_ICE, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//for (int ix = 0; ix < CHUNK_SIZE_X; ++ix) // "Arbres"
|
|
||||||
// for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz) {
|
|
||||||
// float xnoiz, ynoiz;
|
|
||||||
// xnoiz = (double)(iz * CHUNK_SIZE_Y + x * CHUNK_SIZE_X) / 256.;
|
|
||||||
// ynoiz = (double)(ix * CHUNK_SIZE_Y + y * CHUNK_SIZE_Z) / 256.;
|
|
||||||
// bool tree = (int)(abs(simplex.eval(xnoiz, ynoiz)) * 17933.f) % CHUNK_SIZE_Y > 126 ? true : false;
|
|
||||||
// for (int iy = 0; iy < CHUNK_SIZE_Y - 10; ++iy)
|
|
||||||
// if (GetBlock(ix, iy, iz) == BTYPE_AIR)
|
|
||||||
// if (GetBlock(ix, iy - 1, iz) == BTYPE_GRASS)
|
|
||||||
// if (tree) {
|
|
||||||
// for (int i = 0; i < (int)(abs(simplex.eval(xnoiz, ynoiz) * 4)) % 42 + 1; ++i)
|
|
||||||
// SetBlock(ix, iy + i, iz, BTYPE_DIRT, nullptr);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/* }
|
|
||||||
else {
|
|
||||||
input.seekg(0, std::ios_base::end);
|
|
||||||
int size = input.tellg();
|
|
||||||
input.seekg(0, std::ios_base::beg);
|
|
||||||
|
|
||||||
char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
|
|
||||||
input.read(data, size);
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
for (int ix = 0; ix < CHUNK_SIZE_X; ++ix)
|
|
||||||
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz)
|
|
||||||
for (int iy = 0; iy < CHUNK_SIZE_Y; ++iy)
|
|
||||||
m_blocks.Set(ix, iy, iz, data[ix + (iz * CHUNK_SIZE_X) + (iy * CHUNK_SIZE_Z * CHUNK_SIZE_X)]);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
Chunk::~Chunk() {
|
|
||||||
/*if (m_isModified) {
|
|
||||||
char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
|
|
||||||
|
|
||||||
for (int x = 0; x < CHUNK_SIZE_X; ++x)
|
|
||||||
for (int z = 0; z < CHUNK_SIZE_Z; ++z)
|
|
||||||
for (int y = 0; y < CHUNK_SIZE_Y; ++y)
|
|
||||||
data[x + (z * CHUNK_SIZE_X) + (y * CHUNK_SIZE_Z * CHUNK_SIZE_X)] = (char)GetBlock(x, y, z);
|
|
||||||
|
|
||||||
std::ostringstream pos;
|
|
||||||
pos << CHUNK_PATH << m_posX << '_' << m_posY << ".chunk";
|
|
||||||
|
|
||||||
std::ofstream output(pos.str(), std::fstream::binary);
|
|
||||||
output.write(data, sizeof(data));
|
|
||||||
output.close();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::RemoveBlock(int x, int y, int z, World* world) {
|
|
||||||
m_blocks.Set(x, y, z, BTYPE_AIR);
|
|
||||||
CheckNeighbors(x, y, world);
|
|
||||||
m_isDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::SetBlock(int x, int y, int z, BlockType type, World* world) {
|
|
||||||
m_blocks.Set(x, y, z, type);
|
|
||||||
if (world) CheckNeighbors(x, z, world); // Si nullptr, ne pas v<>rifier les chunks voisines.
|
|
||||||
m_isDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockType Chunk::GetBlock(int x, int y, int z) { return m_blocks.Get(x, y, z); }
|
|
||||||
|
|
||||||
void Chunk::CheckNeighbors(unsigned int x, unsigned int z, World* world) {
|
|
||||||
unsigned int cx, cy;
|
|
||||||
|
|
||||||
world->GetScope(cx, cy);
|
|
||||||
|
|
||||||
if (x == 0 && m_posX - cx >= 0 &&
|
|
||||||
world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z))
|
|
||||||
world->ChunkAt((m_posX - cx - 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)->MakeDirty();
|
|
||||||
else if (x == CHUNK_SIZE_X - 1 && m_posX - cx < WORLD_SIZE_X &&
|
|
||||||
world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z))
|
|
||||||
world->ChunkAt((m_posX - cx + 1) * CHUNK_SIZE_X, 1, (m_posY - cy) * CHUNK_SIZE_Z)->MakeDirty();
|
|
||||||
|
|
||||||
if (z == 0 && m_posY - cy >= 0 &&
|
|
||||||
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z))
|
|
||||||
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy - 1) * CHUNK_SIZE_Z)->MakeDirty();
|
|
||||||
else if (z == CHUNK_SIZE_X - 1 && m_posY - cy < WORLD_SIZE_Y &&
|
|
||||||
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z))
|
|
||||||
world->ChunkAt((m_posX - cx) * CHUNK_SIZE_X, 1, (m_posY - cy + 1) * CHUNK_SIZE_Z)->MakeDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::GetPosition(unsigned int& x, unsigned int& y) const { x = m_posX; y = m_posY; }
|
|
||||||
|
|
||||||
void Chunk::FlushMeshToVBO() {
|
|
||||||
m_vertexBuffer.SetMeshData(m_vd, m_vcount);
|
|
||||||
m_vcount = 0;
|
|
||||||
delete[] m_vd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::FlushVBO() {
|
|
||||||
m_vertexBuffer.Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::Update(BlockInfo* blockinfo[BTYPE_LAST], World* world) {
|
|
||||||
float u, v, s;
|
|
||||||
// Update mesh
|
|
||||||
if (m_isDirty) {
|
|
||||||
int maxVertexCount = (CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z) * (6 * 4);
|
|
||||||
m_vd = new VertexBuffer::VertexData[maxVertexCount];
|
|
||||||
m_vcount = 0;
|
|
||||||
for (int x = 0; x < CHUNK_SIZE_X; ++x) {
|
|
||||||
for (int z = 0; z < CHUNK_SIZE_Z; ++z) {
|
|
||||||
for (int y = 0; y < CHUNK_SIZE_Y; ++y) {
|
|
||||||
if (m_vcount > USHRT_MAX)
|
|
||||||
break;
|
|
||||||
|
|
||||||
BlockType bt = GetBlock(x, y, z);
|
|
||||||
|
|
||||||
if (bt != BTYPE_AIR) {
|
|
||||||
blockinfo[bt]->GetTexture(u, v, s);
|
|
||||||
AddBlockToMesh(m_vd, m_vcount, bt, x, y, z, u, v, s, world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_vcount > USHRT_MAX) {
|
|
||||||
m_vcount = USHRT_MAX;
|
|
||||||
std::cout << "[ Chunk :: Update ] Chunk data truncaned , too much vertices to have a 16 bit index " << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_isDirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType bt,
|
|
||||||
int x, int y, int z, float u, float v, float s, World* world) {
|
|
||||||
|
|
||||||
unsigned int cex, cey;
|
|
||||||
|
|
||||||
world->GetScope(cex, cey);
|
|
||||||
|
|
||||||
int cx = x + (m_posX - cex) * CHUNK_SIZE_X, cy = z + (m_posY - cey) * CHUNK_SIZE_Z;
|
|
||||||
|
|
||||||
if (y == CHUNK_SIZE_Y - 1 || GetBlock(x, y + 1, z) == BTYPE_AIR) { // y
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z, .8f, .8f, .8f, u, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z + 1.f, .8f, .8f, .8f, u, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z + 1.f, .8f, .8f, .8f, u + s, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z, .8f, .8f, .8f, u + s, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y == 0 || GetBlock(x, y - 1, z) == BTYPE_AIR) { // -y
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y, z + 1.f, .2f, .2f, .2f, u, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y, z, .2f, .2f, .2f, u, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z, .2f, .2f, .2f, u + s, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z + 1.f, .2f, .2f, .2f, u + s, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world->BlockAt(cx + 1, y, cy) == BTYPE_AIR) { // x
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z, .9f, .9f, .9f, u, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z, .9f, .9f, .9f, u, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z + 1.f, .9f, .9f, .9f, u + s, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z + 1.f, .9f, .9f, .9f, u + s, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world->BlockAt(cx - 1, y, cy) == BTYPE_AIR) { // -x
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z + 1.f, .5f, .5f, .5f, u, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z, .5f, .5f, .5f, u + s, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y, z, .5f, .5f, .5f, u + s, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y, z + 1.f, .5f, .5f, .5f, u, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world->BlockAt(cx, y, cy + 1) == BTYPE_AIR) { // z
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y, z + 1.f, .4f, .4f, .4f, u, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z + 1.f, .4f, .4f, .4f, u + s, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z + 1.f, .4f, .4f, .4f, u + s, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z + 1.f, .4f, .4f, .4f, u, v + s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world->BlockAt(cx, y, cy - 1) == BTYPE_AIR) { // -z
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y + 1.f, z, 1.f, 1.f, 1.f, u, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y + 1.f, z, 1.f, 1.f, 1.f, u + s, v + s);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x + 1.f, y, z , 1.f, 1.f, 1.f, u + s, v);
|
|
||||||
vd[count++] = VertexBuffer::VertexData(x, y, z , 1.f, 1.f, 1.f, u, v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::Render() const { m_vertexBuffer.Render(); }
|
|
||||||
|
|
||||||
bool Chunk::IsDirty() const { return m_isDirty; }
|
|
||||||
|
|
||||||
void Chunk::MakeDirty() { m_isDirty = true; }
|
|
||||||
|
|
||||||
void Chunk::MakeModified() { m_isModified = true; }
|
|
||||||
|
|
@@ -1,49 +0,0 @@
|
|||||||
#ifndef CHUNK_H__
|
|
||||||
#define CHUNK_H__
|
|
||||||
#include "define.h"
|
|
||||||
#include "../SQCSim-common/array2d.h"
|
|
||||||
#include "../SQCSim-common/array3d.h"
|
|
||||||
#include "../SQCSim-common/blockinfo.h"
|
|
||||||
#include "../SQCSim-common/opensimplex.h"
|
|
||||||
#include "vertexbuffer.h"
|
|
||||||
|
|
||||||
class World;
|
|
||||||
|
|
||||||
class Chunk {
|
|
||||||
private:
|
|
||||||
Array3d<BlockType> m_blocks = Array3d<BlockType>(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z);
|
|
||||||
VertexBuffer m_vertexBuffer;
|
|
||||||
bool m_isDirty = true;
|
|
||||||
bool m_isModified = false;
|
|
||||||
|
|
||||||
unsigned int m_posX; // Position du chunk dans l'array constituant le monde.
|
|
||||||
unsigned int m_posY;
|
|
||||||
|
|
||||||
VertexBuffer::VertexData* m_vd;
|
|
||||||
int m_vcount;
|
|
||||||
|
|
||||||
void AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s, World* world);
|
|
||||||
|
|
||||||
public:
|
|
||||||
Chunk(unsigned int x, unsigned int y, int64_t seed);
|
|
||||||
~Chunk();
|
|
||||||
|
|
||||||
void RemoveBlock(int x, int y, int z, World* world);
|
|
||||||
void SetBlock(int x, int y, int z, BlockType type, World* world);
|
|
||||||
BlockType GetBlock(int x, int y, int z);
|
|
||||||
void CheckNeighbors(unsigned int x, unsigned int z, World* world);
|
|
||||||
void GetPosition(unsigned int& x, unsigned int& y) const;
|
|
||||||
|
|
||||||
|
|
||||||
void Update(BlockInfo* blockinfo[BTYPE_LAST], World* world);
|
|
||||||
void FlushMeshToVBO();
|
|
||||||
|
|
||||||
void FlushVBO();
|
|
||||||
|
|
||||||
void Render() const;
|
|
||||||
bool IsDirty() const;
|
|
||||||
void MakeDirty();
|
|
||||||
void MakeModified();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CHUNK_H__
|
|
68
SQCSim2021/cmake/CMakeLists.txt
Normal file
68
SQCSim2021/cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.18.4)
|
||||||
|
|
||||||
|
project(SQCSim-Client VERSION 0.8)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
set(CMAKE_BUILD_DIRECTORY "./build")
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "../")
|
||||||
|
|
||||||
|
set(SQCSIM_COMMON_DIR "../../SQCSim-common/")
|
||||||
|
set(SQCSIM_EXTERN_DIR "../external/")
|
||||||
|
|
||||||
|
find_package(SFML COMPONENTS system window graphics REQUIRED)
|
||||||
|
find_package(DevIL REQUIRED)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
find_package(GLEW REQUIRED)
|
||||||
|
|
||||||
|
find_library(IRRKLANG_LIBRARY
|
||||||
|
NAMES libIrrKlang.so
|
||||||
|
PATHS "${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/lib/linux-gcc-64/")
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${SQCSIM_EXTERN_DIR}/irrKlang-64bit-1.6.0/include/
|
||||||
|
${SFML_INCLUDE_DIRS}
|
||||||
|
${IL_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
add_library(SQCSim-common
|
||||||
|
"${SQCSIM_COMMON_DIR}blockinfo.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}bullet.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}chunk.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}netprotocol.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}opensimplex.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}player.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}transformation.cpp"
|
||||||
|
"${SQCSIM_COMMON_DIR}world.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(SQCSim-client
|
||||||
|
"../audio.cpp"
|
||||||
|
"../connector.cpp"
|
||||||
|
"../engine.cpp"
|
||||||
|
"../mesh.cpp"
|
||||||
|
"../openglcontext.cpp"
|
||||||
|
"../shader.cpp"
|
||||||
|
"../skybox.cpp"
|
||||||
|
"../texture.cpp"
|
||||||
|
"../textureatlas.cpp"
|
||||||
|
"../tool.cpp"
|
||||||
|
"../vertexbuffer.cpp"
|
||||||
|
"../worldrenderer.cpp"
|
||||||
|
"../main.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(SQCSim-client PUBLIC SQCSim-common
|
||||||
|
${IRRKLANG_LIBRARY}
|
||||||
|
sfml-system
|
||||||
|
sfml-window
|
||||||
|
sfml-graphics
|
||||||
|
GL
|
||||||
|
GLU
|
||||||
|
GLEW
|
||||||
|
${IL_LIBRARIES}
|
||||||
|
${ILU_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
@@ -1,37 +1,39 @@
|
|||||||
#ifndef CLI_DEFINE_H__
|
#ifndef CLI_DEFINE_H__
|
||||||
#define CLI_DEFINE_H__
|
#define CLI_DEFINE_H__
|
||||||
|
|
||||||
|
//#define SFML_STATIC true
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <GL/glew.h>
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include "../SQCSim-common/define.h"
|
#include "../SQCSim-common/define.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <GL/glew.h>
|
|
||||||
#include <gl/GL.h>
|
#include <gl/GL.h>
|
||||||
#include <gl/GLU.h>
|
#include <gl/GLU.h>
|
||||||
|
#else
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#include <climits>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NETWORK_TEST false
|
#define NETWORK_TEST false
|
||||||
#define SRV_ADDR "127.0.0.1"
|
#define SRV_ADDR "127.0.0.1"
|
||||||
#define COUNTDOWN 300
|
#define COUNTDOWN 300
|
||||||
|
|
||||||
#define FRAMES_RENDER_CHUNKS 1
|
#define BULLET_UPDATES_PER_FRAME 20
|
||||||
#define FRAMES_UPDATE_CHUNKS 1
|
|
||||||
#define FRAMES_DELETE_CHUNKS 1
|
|
||||||
|
|
||||||
#define THREADS_GENERATE_CHUNKS 8
|
|
||||||
#define THREADS_UPDATE_CHUNKS 3
|
|
||||||
#define THREADS_DELETE_CHUNKS 3
|
|
||||||
|
|
||||||
#define BASE_WIDTH 640
|
#define BASE_WIDTH 640
|
||||||
#define BASE_HEIGHT 480
|
#define BASE_HEIGHT 480
|
||||||
|
|
||||||
|
|
||||||
#define TEXTURE_PATH "./media/textures/"
|
#define TEXTURE_PATH "./media/textures/"
|
||||||
#define SHADER_PATH "./media/shaders/"
|
#define SHADER_PATH "./media/shaders/"
|
||||||
#define AUDIO_PATH "./media/audio/"
|
#define AUDIO_PATH "./media/audio/"
|
||||||
#define CHUNK_PATH "./media/chunks/"
|
#define CHUNK_PATH "./media/chunks/"
|
||||||
|
#define MENU_ITEM_PATH "./media/menu_items/"
|
||||||
|
|
||||||
#endif // DEFINE_H__
|
#endif // DEFINE_H__
|
||||||
|
0
SQCSim2021/docs/analyse_preliminaire.md
Normal file
0
SQCSim2021/docs/analyse_preliminaire.md
Normal file
1
SQCSim2021/docs/analyse_serveur.md
Normal file
1
SQCSim2021/docs/analyse_serveur.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
File diff suppressed because it is too large
Load Diff
@@ -6,23 +6,26 @@
|
|||||||
#include "../SQCSim-common/array2d.h"
|
#include "../SQCSim-common/array2d.h"
|
||||||
#include "../SQCSim-common/blockinfo.h"
|
#include "../SQCSim-common/blockinfo.h"
|
||||||
#include "../SQCSim-common/bullet.h"
|
#include "../SQCSim-common/bullet.h"
|
||||||
|
#include "../SQCSim-common/chunk.h"
|
||||||
|
#include "../SQCSim-common/world.h"
|
||||||
|
#include "../SQCSim-common/transformation.h"
|
||||||
|
#include "../SQCSim-common/player.h"
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "openglcontext.h"
|
#include "openglcontext.h"
|
||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "transformation.h"
|
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
#include "player.h"
|
|
||||||
#include "chunk.h"
|
|
||||||
#include "skybox.h"
|
#include "skybox.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "textureatlas.h"
|
#include "textureatlas.h"
|
||||||
#include "world.h"
|
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
|
#include "worldrenderer.h"
|
||||||
|
|
||||||
class Engine : public OpenglContext {
|
class Engine : public OpenglContext {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
virtual ~Engine();
|
virtual ~Engine();
|
||||||
|
virtual void DrawMenu();
|
||||||
|
virtual void DrawSplachScreen();
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void DeInit();
|
virtual void DeInit();
|
||||||
virtual void LoadResource();
|
virtual void LoadResource();
|
||||||
@@ -35,19 +38,23 @@ public:
|
|||||||
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
virtual void MouseReleaseEvent(const MOUSE_BUTTON &button, int x, int y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float GetScale() const;
|
|
||||||
|
|
||||||
int GetFps(float elapsedTime) const;
|
int GetFps(float elapsedTime) const;
|
||||||
int GetCountdown(float elapsedTime);
|
int GetCountdown(float elapsedTime);
|
||||||
|
|
||||||
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
bool LoadTexture(Texture& texture, const std::string& filename, bool useMipmaps = true, bool stopOnError = true);
|
||||||
|
|
||||||
|
void SystemNotification(std::string systemLog);
|
||||||
|
void KillNotification(Player killer, Player killed);
|
||||||
|
void DisplayNotification(std::string message);
|
||||||
|
void ProcessNotificationQueue();
|
||||||
void DisplayCrosshair();
|
void DisplayCrosshair();
|
||||||
|
void DisplayPovGun();
|
||||||
void DisplayCurrentItem();
|
void DisplayCurrentItem();
|
||||||
void DisplayHud(int timer);
|
void DisplayHud(int timer);
|
||||||
void DisplayInfo(float elapsedTime, BlockType bloc);
|
void DisplayInfo(float elapsedTime, BlockType bloc);
|
||||||
|
void DisplaySingleOrMultiplayerMenu();
|
||||||
void DrawHud(float elapsedTime, BlockType bloc);
|
void DrawHud(float elapsedTime, BlockType bloc);
|
||||||
void PrintText(float x, float y, float scale, const std::string& t);
|
void PrintText(float x, float y, const std::string& t, float charSizeMultiplier = 1.0f);
|
||||||
|
|
||||||
Connector m_conn;
|
Connector m_conn;
|
||||||
Shader m_shader01;
|
Shader m_shader01;
|
||||||
@@ -55,24 +62,46 @@ private:
|
|||||||
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
TextureAtlas m_textureAtlas = TextureAtlas(BTYPE_LAST);
|
||||||
|
|
||||||
World m_world = World();
|
World m_world = World();
|
||||||
|
WorldRenderer m_wrenderer = WorldRenderer();
|
||||||
|
|
||||||
Texture m_textureSkybox;
|
|
||||||
Texture m_textureFont;
|
|
||||||
Texture m_textureCrosshair;
|
Texture m_textureCrosshair;
|
||||||
|
Texture m_textureFont;
|
||||||
Texture m_textureGun;
|
Texture m_textureGun;
|
||||||
|
Texture m_texturePovGun;
|
||||||
|
Texture m_textureSkybox;
|
||||||
|
Texture m_textureSoloMultiMenu;
|
||||||
|
Texture m_textureSoloText;
|
||||||
|
Texture m_textureMultiText;
|
||||||
|
Texture m_textureTitle;
|
||||||
|
|
||||||
Skybox m_skybox;
|
Skybox m_skybox;
|
||||||
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
Audio m_audio = Audio(AUDIO_PATH "start.wav");
|
||||||
|
|
||||||
irrklang::ISound* m_powpow;
|
irrklang::ISound* m_powpow,
|
||||||
irrklang::ISound* m_scream;
|
* m_scream;
|
||||||
|
irrklang::ISound *m_whoosh[MAX_BULLETS];
|
||||||
|
|
||||||
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
Player m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f));
|
||||||
|
|
||||||
Bullet* m_bullets[MAX_BULLETS];
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
|
//Menu
|
||||||
|
enum class GameState { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
||||||
|
GameState m_gamestate = GameState::MAIN_MENU;
|
||||||
|
Texture MenuTitleTexture;
|
||||||
|
Texture MenuBGTexture;
|
||||||
|
Texture MenuStartTexture;
|
||||||
|
Texture MenuQuitTexture;
|
||||||
|
Texture MenuOptionsTexture;
|
||||||
|
Texture SplachScreenTexture;
|
||||||
|
|
||||||
float m_scale;
|
float m_scale;
|
||||||
float m_time = 0;
|
float m_time = 0;
|
||||||
|
float m_time_SplashScreen = 0;
|
||||||
|
float m_titleX = 0;
|
||||||
|
float m_titleY = 0;
|
||||||
|
float m_Width = 0;
|
||||||
|
float m_Height = 0;
|
||||||
|
|
||||||
int m_renderCount = 0;
|
int m_renderCount = 0;
|
||||||
int m_countdown = COUNTDOWN;
|
int m_countdown = COUNTDOWN;
|
||||||
@@ -85,8 +114,11 @@ private:
|
|||||||
bool m_displayHud = true;
|
bool m_displayHud = true;
|
||||||
bool m_displayInfo = false;
|
bool m_displayInfo = false;
|
||||||
bool m_resetcountdown = false;
|
bool m_resetcountdown = false;
|
||||||
|
bool m_soloMultiChoiceMade = false;
|
||||||
bool m_stopcountdown = false;
|
bool m_stopcountdown = false;
|
||||||
|
|
||||||
|
bool m_keyK = false;
|
||||||
|
bool m_keyL = false;
|
||||||
bool m_keyW = false;
|
bool m_keyW = false;
|
||||||
bool m_keyA = false;
|
bool m_keyA = false;
|
||||||
bool m_keyS = false;
|
bool m_keyS = false;
|
||||||
@@ -97,6 +129,11 @@ private:
|
|||||||
bool m_mouseC = false;
|
bool m_mouseC = false;
|
||||||
bool m_mouseWU = false;
|
bool m_mouseWU = false;
|
||||||
bool m_mouseWD = false;
|
bool m_mouseWD = false;
|
||||||
|
//Pour trouver ou est la souris
|
||||||
|
float m_mousemx = 0;
|
||||||
|
float m_mousemy = 0;
|
||||||
|
|
||||||
|
std::string m_messageNotification = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENGINE_H__
|
#endif // ENGINE_H__
|
||||||
|
58
SQCSim2021/external/sfml251-32/doc/html/AlResource_8hpp_source.html
vendored
Normal file
58
SQCSim2021/external/sfml251-32/doc/html/AlResource_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Audio_2Export_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Audio_2Export_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Audio_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Audio_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
77
SQCSim2021/external/sfml251-32/doc/html/BlendMode_8hpp_source.html
vendored
Normal file
77
SQCSim2021/external/sfml251-32/doc/html/BlendMode_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/CircleShape_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/CircleShape_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
59
SQCSim2021/external/sfml251-32/doc/html/Clipboard_8hpp_source.html
vendored
Normal file
59
SQCSim2021/external/sfml251-32/doc/html/Clipboard_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
59
SQCSim2021/external/sfml251-32/doc/html/Clock_8hpp_source.html
vendored
Normal file
59
SQCSim2021/external/sfml251-32/doc/html/Clock_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
71
SQCSim2021/external/sfml251-32/doc/html/Color_8hpp_source.html
vendored
Normal file
71
SQCSim2021/external/sfml251-32/doc/html/Color_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
57
SQCSim2021/external/sfml251-32/doc/html/Config_8hpp_source.html
vendored
Normal file
57
SQCSim2021/external/sfml251-32/doc/html/Config_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
70
SQCSim2021/external/sfml251-32/doc/html/ContextSettings_8hpp_source.html
vendored
Normal file
70
SQCSim2021/external/sfml251-32/doc/html/ContextSettings_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
61
SQCSim2021/external/sfml251-32/doc/html/Context_8hpp_source.html
vendored
Normal file
61
SQCSim2021/external/sfml251-32/doc/html/Context_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/ConvexShape_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/ConvexShape_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
74
SQCSim2021/external/sfml251-32/doc/html/Cursor_8hpp_source.html
vendored
Normal file
74
SQCSim2021/external/sfml251-32/doc/html/Cursor_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
61
SQCSim2021/external/sfml251-32/doc/html/Drawable_8hpp_source.html
vendored
Normal file
61
SQCSim2021/external/sfml251-32/doc/html/Drawable_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
58
SQCSim2021/external/sfml251-32/doc/html/Err_8hpp_source.html
vendored
Normal file
58
SQCSim2021/external/sfml251-32/doc/html/Err_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
146
SQCSim2021/external/sfml251-32/doc/html/Event_8hpp_source.html
vendored
Normal file
146
SQCSim2021/external/sfml251-32/doc/html/Event_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/FileInputStream_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/FileInputStream_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
63
SQCSim2021/external/sfml251-32/doc/html/Font_8hpp_source.html
vendored
Normal file
63
SQCSim2021/external/sfml251-32/doc/html/Font_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
70
SQCSim2021/external/sfml251-32/doc/html/Ftp_8hpp_source.html
vendored
Normal file
70
SQCSim2021/external/sfml251-32/doc/html/Ftp_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/GlResource_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/GlResource_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
70
SQCSim2021/external/sfml251-32/doc/html/Glsl_8hpp_source.html
vendored
Normal file
70
SQCSim2021/external/sfml251-32/doc/html/Glsl_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
63
SQCSim2021/external/sfml251-32/doc/html/Glyph_8hpp_source.html
vendored
Normal file
63
SQCSim2021/external/sfml251-32/doc/html/Glyph_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
98
SQCSim2021/external/sfml251-32/doc/html/GpuPreference_8hpp.html
vendored
Normal file
98
SQCSim2021/external/sfml251-32/doc/html/GpuPreference_8hpp.html
vendored
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<title>SFML - Simple and Fast Multimedia Library</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;"/>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
|
||||||
|
<link rel="stylesheet" type="text/css" href="doxygen.css" title="default" media="screen,print" />
|
||||||
|
<script type="text/javascript" src="jquery.js"></script>
|
||||||
|
<script type="text/javascript" src="dynsections.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="banner-container">
|
||||||
|
<div id="banner">
|
||||||
|
<span id="sfml">SFML 2.5.1</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="content">
|
||||||
|
<!-- Generated by Doxygen 1.8.14 -->
|
||||||
|
<div id="navrow1" class="tabs">
|
||||||
|
<ul class="tablist">
|
||||||
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
||||||
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
||||||
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
||||||
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
||||||
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
||||||
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="navrow2" class="tabs2">
|
||||||
|
<ul class="tablist">
|
||||||
|
<li><a href="files.html"><span>File List</span></a></li>
|
||||||
|
<li><a href="globals.html"><span>File Members</span></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="nav-path" class="navpath">
|
||||||
|
<ul>
|
||||||
|
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_c0a853e81d6f1c1f0a3eb7a27dc24256.html">SFML</a></li> </ul>
|
||||||
|
</div>
|
||||||
|
</div><!-- top -->
|
||||||
|
<div class="header">
|
||||||
|
<div class="summary">
|
||||||
|
<a href="#define-members">Macros</a> </div>
|
||||||
|
<div class="headertitle">
|
||||||
|
<div class="title">GpuPreference.hpp File Reference</div> </div>
|
||||||
|
</div><!--header-->
|
||||||
|
<div class="contents">
|
||||||
|
|
||||||
|
<p>Headers.
|
||||||
|
<a href="#details">More...</a></p>
|
||||||
|
<div class="textblock"><code>#include <SFML/Config.hpp></code><br />
|
||||||
|
</div>
|
||||||
|
<p><a href="GpuPreference_8hpp_source.html">Go to the source code of this file.</a></p>
|
||||||
|
<table class="memberdecls">
|
||||||
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
|
||||||
|
Macros</h2></td></tr>
|
||||||
|
<tr class="memitem:ab0233c2d867cbd561036ed2440a4fec0"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="GpuPreference_8hpp.html#ab0233c2d867cbd561036ed2440a4fec0">SFML_DEFINE_DISCRETE_GPU_PREFERENCE</a></td></tr>
|
||||||
|
<tr class="memdesc:ab0233c2d867cbd561036ed2440a4fec0"><td class="mdescLeft"> </td><td class="mdescRight">A macro to encourage usage of the discrete GPU. <a href="#ab0233c2d867cbd561036ed2440a4fec0">More...</a><br /></td></tr>
|
||||||
|
<tr class="separator:ab0233c2d867cbd561036ed2440a4fec0"><td class="memSeparator" colspan="2"> </td></tr>
|
||||||
|
</table>
|
||||||
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||||
|
<div class="textblock"><p>Headers. </p>
|
||||||
|
<p>File containing SFML_DEFINE_DISCRETE_GPU_PREFERENCE </p>
|
||||||
|
|
||||||
|
<p class="definition">Definition in file <a class="el" href="GpuPreference_8hpp_source.html">GpuPreference.hpp</a>.</p>
|
||||||
|
</div><h2 class="groupheader">Macro Definition Documentation</h2>
|
||||||
|
<a id="ab0233c2d867cbd561036ed2440a4fec0"></a>
|
||||||
|
<h2 class="memtitle"><span class="permalink"><a href="#ab0233c2d867cbd561036ed2440a4fec0">◆ </a></span>SFML_DEFINE_DISCRETE_GPU_PREFERENCE</h2>
|
||||||
|
|
||||||
|
<div class="memitem">
|
||||||
|
<div class="memproto">
|
||||||
|
<table class="memname">
|
||||||
|
<tr>
|
||||||
|
<td class="memname">#define SFML_DEFINE_DISCRETE_GPU_PREFERENCE</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div><div class="memdoc">
|
||||||
|
|
||||||
|
<p>A macro to encourage usage of the discrete GPU. </p>
|
||||||
|
<p>In order to inform the Nvidia/AMD driver that an SFML application could benefit from using the more powerful discrete GPU, special symbols have to be publicly exported from the final executable.</p>
|
||||||
|
<p>SFML defines a helper macro to easily do this.</p>
|
||||||
|
<p>Place SFML_DEFINE_DISCRETE_GPU_PREFERENCE in the global scope of a source file that will be linked into the final executable. Typically it is best to place it where the main function is also defined. </p>
|
||||||
|
|
||||||
|
<p class="definition">Definition at line <a class="el" href="GpuPreference_8hpp_source.html#l00069">69</a> of file <a class="el" href="GpuPreference_8hpp_source.html">GpuPreference.hpp</a>.</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!-- contents -->
|
||||||
|
</div>
|
||||||
|
<div id="footer-container">
|
||||||
|
<div id="footer">
|
||||||
|
SFML is licensed under the terms and conditions of the <a href="https://www.sfml-dev.org/license.php">zlib/png license</a>.<br>
|
||||||
|
Copyright © Laurent Gomila ::
|
||||||
|
Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen</a> ::
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
56
SQCSim2021/external/sfml251-32/doc/html/GpuPreference_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/GpuPreference_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Graphics_2Export_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Graphics_2Export_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Graphics_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Graphics_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
71
SQCSim2021/external/sfml251-32/doc/html/Http_8hpp_source.html
vendored
Normal file
71
SQCSim2021/external/sfml251-32/doc/html/Http_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
62
SQCSim2021/external/sfml251-32/doc/html/Image_8hpp_source.html
vendored
Normal file
62
SQCSim2021/external/sfml251-32/doc/html/Image_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
62
SQCSim2021/external/sfml251-32/doc/html/InputSoundFile_8hpp_source.html
vendored
Normal file
62
SQCSim2021/external/sfml251-32/doc/html/InputSoundFile_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
59
SQCSim2021/external/sfml251-32/doc/html/InputStream_8hpp_source.html
vendored
Normal file
59
SQCSim2021/external/sfml251-32/doc/html/InputStream_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
64
SQCSim2021/external/sfml251-32/doc/html/IpAddress_8hpp_source.html
vendored
Normal file
64
SQCSim2021/external/sfml251-32/doc/html/IpAddress_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
71
SQCSim2021/external/sfml251-32/doc/html/Joystick_8hpp_source.html
vendored
Normal file
71
SQCSim2021/external/sfml251-32/doc/html/Joystick_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
160
SQCSim2021/external/sfml251-32/doc/html/Keyboard_8hpp_source.html
vendored
Normal file
160
SQCSim2021/external/sfml251-32/doc/html/Keyboard_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
59
SQCSim2021/external/sfml251-32/doc/html/Listener_8hpp_source.html
vendored
Normal file
59
SQCSim2021/external/sfml251-32/doc/html/Listener_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/Lock_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/Lock_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Main_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Main_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
59
SQCSim2021/external/sfml251-32/doc/html/MemoryInputStream_8hpp_source.html
vendored
Normal file
59
SQCSim2021/external/sfml251-32/doc/html/MemoryInputStream_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
68
SQCSim2021/external/sfml251-32/doc/html/Mouse_8hpp_source.html
vendored
Normal file
68
SQCSim2021/external/sfml251-32/doc/html/Mouse_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
69
SQCSim2021/external/sfml251-32/doc/html/Music_8hpp_source.html
vendored
Normal file
69
SQCSim2021/external/sfml251-32/doc/html/Music_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
59
SQCSim2021/external/sfml251-32/doc/html/Mutex_8hpp_source.html
vendored
Normal file
59
SQCSim2021/external/sfml251-32/doc/html/Mutex_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
58
SQCSim2021/external/sfml251-32/doc/html/NativeActivity_8hpp_source.html
vendored
Normal file
58
SQCSim2021/external/sfml251-32/doc/html/NativeActivity_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Network_2Export_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Network_2Export_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/Network_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/Network_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/NonCopyable_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/NonCopyable_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
56
SQCSim2021/external/sfml251-32/doc/html/OpenGL_8hpp_source.html
vendored
Normal file
56
SQCSim2021/external/sfml251-32/doc/html/OpenGL_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/OutputSoundFile_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/OutputSoundFile_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
61
SQCSim2021/external/sfml251-32/doc/html/Packet_8hpp_source.html
vendored
Normal file
61
SQCSim2021/external/sfml251-32/doc/html/Packet_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
68
SQCSim2021/external/sfml251-32/doc/html/PrimitiveType_8hpp_source.html
vendored
Normal file
68
SQCSim2021/external/sfml251-32/doc/html/PrimitiveType_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
66
SQCSim2021/external/sfml251-32/doc/html/Rect_8hpp_source.html
vendored
Normal file
66
SQCSim2021/external/sfml251-32/doc/html/Rect_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
60
SQCSim2021/external/sfml251-32/doc/html/RectangleShape_8hpp_source.html
vendored
Normal file
60
SQCSim2021/external/sfml251-32/doc/html/RectangleShape_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
67
SQCSim2021/external/sfml251-32/doc/html/RenderStates_8hpp_source.html
vendored
Normal file
67
SQCSim2021/external/sfml251-32/doc/html/RenderStates_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
73
SQCSim2021/external/sfml251-32/doc/html/RenderTarget_8hpp_source.html
vendored
Normal file
73
SQCSim2021/external/sfml251-32/doc/html/RenderTarget_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
62
SQCSim2021/external/sfml251-32/doc/html/RenderTexture_8hpp_source.html
vendored
Normal file
62
SQCSim2021/external/sfml251-32/doc/html/RenderTexture_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
67
SQCSim2021/external/sfml251-32/doc/html/RenderWindow_8hpp_source.html
vendored
Normal file
67
SQCSim2021/external/sfml251-32/doc/html/RenderWindow_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
66
SQCSim2021/external/sfml251-32/doc/html/Sensor_8hpp_source.html
vendored
Normal file
66
SQCSim2021/external/sfml251-32/doc/html/Sensor_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
76
SQCSim2021/external/sfml251-32/doc/html/Shader_8hpp_source.html
vendored
Normal file
76
SQCSim2021/external/sfml251-32/doc/html/Shader_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
67
SQCSim2021/external/sfml251-32/doc/html/Shape_8hpp_source.html
vendored
Normal file
67
SQCSim2021/external/sfml251-32/doc/html/Shape_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
58
SQCSim2021/external/sfml251-32/doc/html/Sleep_8hpp_source.html
vendored
Normal file
58
SQCSim2021/external/sfml251-32/doc/html/Sleep_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
57
SQCSim2021/external/sfml251-32/doc/html/SocketHandle_8hpp_source.html
vendored
Normal file
57
SQCSim2021/external/sfml251-32/doc/html/SocketHandle_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
61
SQCSim2021/external/sfml251-32/doc/html/SocketSelector_8hpp_source.html
vendored
Normal file
61
SQCSim2021/external/sfml251-32/doc/html/SocketSelector_8hpp_source.html
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user