아 화면 렌더링 안 되는건 memset으로 id복사하면서 버텍스 버퍼를 0으로 덮어써버리는게 원인이었음 그리고 현재 있는 버그는 너무 빠른 속도 또는 적당한 이동속도에서 총알을 많이 발사하면 카메라의 위치가 nan이 됨.
This commit is contained in:
@@ -87,6 +87,7 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
|||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
engine.Update();
|
engine.Update();
|
||||||
|
engine.NetUpdate(std::make_shared<Network::Socket>(sock));
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
@@ -142,10 +142,16 @@ int IOCP::send(SOCKET sock, std::vector<IOCPPASSINDATA*>* data) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IOCP::GetRecvedPacketCount(SOCKET sock) {
|
int IOCP::GetRecvedBytes(SOCKET sock) {
|
||||||
std::lock_guard lock(socket_mod_mutex_);
|
std::lock_guard lock(socket_mod_mutex_);
|
||||||
auto queue = GetRecvQueue_(sock);
|
auto queue = GetRecvQueue_(sock);
|
||||||
return queue->size();
|
|
||||||
|
int bytes = 0;
|
||||||
|
for (auto it : *queue) {
|
||||||
|
bytes += it.first.size() - it.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IOCP::iocpWatcher_(utils::ThreadPool* IOCPThread) {
|
void IOCP::iocpWatcher_(utils::ThreadPool* IOCPThread) {
|
||||||
|
|||||||
@@ -13,64 +13,85 @@ Model::~Model() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void Append(std::vector<char>& dst, const T& data) {
|
void Append(std::vector<char>& buffer, const T& value) {
|
||||||
const char* ptr = reinterpret_cast<const char*>(&data);
|
const char* data = reinterpret_cast<const char*>(&value);
|
||||||
dst.insert(dst.end(), ptr, ptr + sizeof(T));
|
buffer.insert(buffer.end(), data, data + sizeof(T));
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<char> Model::Serialize() {
|
|
||||||
std::vector<char> serialized;
|
|
||||||
|
|
||||||
Append(serialized, ID);
|
|
||||||
|
|
||||||
Append(serialized, transform);
|
|
||||||
Append(serialized, position);
|
|
||||||
Append(serialized, linear_velocity);
|
|
||||||
Append(serialized, linear_acceleration);
|
|
||||||
Append(serialized, rotation);
|
|
||||||
Append(serialized, angular_velocity);
|
|
||||||
Append(serialized, angular_acceleration);
|
|
||||||
Append(serialized, scale);
|
|
||||||
Append(serialized, original_offset);
|
|
||||||
|
|
||||||
Append(serialized, radius);
|
|
||||||
|
|
||||||
uint8_t vis = visible ? 1 : 0;
|
|
||||||
uint8_t col = colision ? 1 : 0;
|
|
||||||
Append(serialized, vis);
|
|
||||||
Append(serialized, col);
|
|
||||||
|
|
||||||
return serialized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void Extract(const std::vector<char>& src, size_t& offset, T& out) {
|
void AppendVector(std::vector<char>& buffer, const std::vector<T>& vec) {
|
||||||
std::memcpy(&out, src.data() + offset, sizeof(T));
|
std::uint32_t size = static_cast<std::uint32_t>(vec.size());
|
||||||
|
Append(buffer, size);
|
||||||
|
buffer.insert(buffer.end(), reinterpret_cast<const char*>(vec.data()),
|
||||||
|
reinterpret_cast<const char*>(vec.data() + size));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Read(const std::vector<char>& buffer, size_t& offset, T& out) {
|
||||||
|
std::memcpy(&out, buffer.data() + offset, sizeof(T));
|
||||||
offset += sizeof(T);
|
offset += sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void ReadVector(const std::vector<char>& buffer, size_t& offset,
|
||||||
|
std::vector<T>& out) {
|
||||||
|
std::uint32_t size = 0;
|
||||||
|
Read(buffer, offset, size);
|
||||||
|
out.resize(size);
|
||||||
|
std::memcpy(out.data(), buffer.data() + offset, sizeof(T) * size);
|
||||||
|
offset += sizeof(T) * size;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<char> Model::Serialize() {
|
||||||
|
std::vector<char> buffer;
|
||||||
|
|
||||||
|
AppendVector(buffer, vertices);
|
||||||
|
AppendVector(buffer, indices);
|
||||||
|
|
||||||
|
Append(buffer, position);
|
||||||
|
Append(buffer, linear_velocity);
|
||||||
|
Append(buffer, linear_acceleration);
|
||||||
|
|
||||||
|
Append(buffer, rotation);
|
||||||
|
Append(buffer, angular_velocity);
|
||||||
|
Append(buffer, angular_acceleration);
|
||||||
|
|
||||||
|
Append(buffer, scale);
|
||||||
|
Append(buffer, transform);
|
||||||
|
|
||||||
|
Append(buffer, original_offset);
|
||||||
|
Append(buffer, radius);
|
||||||
|
Append(buffer, lifespan);
|
||||||
|
|
||||||
|
Append(buffer, visible);
|
||||||
|
Append(buffer, colision);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::Deserialize(std::vector<char> data) {
|
void Model::Deserialize(std::vector<char> data) {
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
Extract(data, offset, ID);
|
ReadVector(data, offset, vertices);
|
||||||
|
ReadVector(data, offset, indices);
|
||||||
|
|
||||||
Extract(data, offset, transform);
|
Read(data, offset, position);
|
||||||
Extract(data, offset, position);
|
Read(data, offset, linear_velocity);
|
||||||
Extract(data, offset, linear_velocity);
|
Read(data, offset, linear_acceleration);
|
||||||
Extract(data, offset, linear_acceleration);
|
|
||||||
Extract(data, offset, rotation);
|
|
||||||
Extract(data, offset, angular_velocity);
|
|
||||||
Extract(data, offset, angular_acceleration);
|
|
||||||
Extract(data, offset, scale);
|
|
||||||
Extract(data, offset, original_offset);
|
|
||||||
|
|
||||||
Extract(data, offset, radius);
|
Read(data, offset, rotation);
|
||||||
|
Read(data, offset, angular_velocity);
|
||||||
|
Read(data, offset, angular_acceleration);
|
||||||
|
|
||||||
uint8_t vis = 0, col = 0;
|
Read(data, offset, scale);
|
||||||
Extract(data, offset, vis);
|
Read(data, offset, transform);
|
||||||
Extract(data, offset, col);
|
|
||||||
visible = vis != 0;
|
Read(data, offset, original_offset);
|
||||||
colision = col != 0;
|
Read(data, offset, radius);
|
||||||
|
Read(data, offset, lifespan);
|
||||||
|
|
||||||
|
Read(data, offset, visible);
|
||||||
|
Read(data, offset, colision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void veng::Model::Update(float dt) {
|
void veng::Model::Update(float dt) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "vulkan_engine/vulkan/engine.h"
|
#include "vulkan_engine/vulkan/engine.h"
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
#include "socket/packet.h"
|
||||||
|
|
||||||
namespace veng {
|
namespace veng {
|
||||||
|
|
||||||
@@ -39,23 +40,21 @@ Model* Engine::SpawnModel(std::string asset_name, std::string name) {
|
|||||||
if (asset_name == "") {
|
if (asset_name == "") {
|
||||||
Model model_to_spawn(nullptr);
|
Model model_to_spawn(nullptr);
|
||||||
model_to_spawn.visible = false;
|
model_to_spawn.visible = false;
|
||||||
dynamic_immortal_models_[name] = std::move(model_to_spawn);
|
models_[name] = std::move(model_to_spawn);
|
||||||
return &dynamic_immortal_models_[name];
|
return &models_[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynamic_immortal_models_.find(name) == dynamic_immortal_models_.end()) {
|
if (models_.find(name) == models_.end()) {
|
||||||
Model model_to_spawn(*GetStaticModel(asset_name));
|
Model model_to_spawn(*GetStaticModel(asset_name));
|
||||||
dynamic_immortal_models_[name] = std::move(model_to_spawn);
|
models_[name] = std::move(model_to_spawn);
|
||||||
return &dynamic_immortal_models_[name];
|
return &models_[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t i = 0;
|
std::uint32_t i = 0;
|
||||||
for (i = 0; i < std::numeric_limits<std::uint32_t>::max();) {
|
for (i = 0; i < std::numeric_limits<std::uint32_t>::max();) {
|
||||||
if (dynamic_immortal_models_.find(name + std::to_string(i)) ==
|
if (models_.find(name + std::to_string(i)) == models_.end()) {
|
||||||
dynamic_immortal_models_.end()) {
|
|
||||||
Model model_to_spawn(*GetStaticModel(asset_name));
|
Model model_to_spawn(*GetStaticModel(asset_name));
|
||||||
dynamic_immortal_models_[name + std::to_string(i)] =
|
models_[name + std::to_string(i)] = std::move(model_to_spawn);
|
||||||
std::move(model_to_spawn);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -64,7 +63,7 @@ Model* Engine::SpawnModel(std::string asset_name, std::string name) {
|
|||||||
if (i == std::numeric_limits<std::uint32_t>::max() - 1)
|
if (i == std::numeric_limits<std::uint32_t>::max() - 1)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
else
|
else
|
||||||
return &dynamic_immortal_models_[name + std::to_string(i)];
|
return &models_[name + std::to_string(i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* Engine::SpawnLifedModel(std::string asset_name, std::string name,
|
Model* Engine::SpawnLifedModel(std::string asset_name, std::string name,
|
||||||
@@ -72,22 +71,24 @@ Model* Engine::SpawnLifedModel(std::string asset_name, std::string name,
|
|||||||
if (asset_name == "") {
|
if (asset_name == "") {
|
||||||
Model model_to_spawn(nullptr);
|
Model model_to_spawn(nullptr);
|
||||||
model_to_spawn.visible = false;
|
model_to_spawn.visible = false;
|
||||||
dynamic_models_[name] = std::make_pair(std::move(model_to_spawn), lifespan);
|
model_to_spawn.lifespan = lifespan;
|
||||||
return &dynamic_models_[name].first;
|
models_[name] = std::move(model_to_spawn);
|
||||||
|
return &models_[name];
|
||||||
}
|
}
|
||||||
if (dynamic_models_.find(name) == dynamic_models_.end()) {
|
|
||||||
|
if (models_.find(name) == models_.end()) {
|
||||||
Model model_to_spawn(*GetStaticModel(asset_name));
|
Model model_to_spawn(*GetStaticModel(asset_name));
|
||||||
dynamic_models_[name] = std::make_pair(std::move(model_to_spawn), lifespan);
|
model_to_spawn.lifespan = lifespan;
|
||||||
return &dynamic_models_[name].first;
|
models_[name] = std::move(model_to_spawn);
|
||||||
|
return &models_[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t i = 0;
|
std::uint32_t i = 0;
|
||||||
for (i = 0; i < std::numeric_limits<std::uint32_t>::max();) {
|
for (i = 0; i < std::numeric_limits<std::uint32_t>::max();) {
|
||||||
if (dynamic_models_.find(name + std::to_string(i)) ==
|
if (models_.find(name + std::to_string(i)) == models_.end()) {
|
||||||
dynamic_models_.end()) {
|
|
||||||
Model model_to_spawn(*GetStaticModel(asset_name));
|
Model model_to_spawn(*GetStaticModel(asset_name));
|
||||||
dynamic_models_[name + std::to_string(i)] =
|
model_to_spawn.lifespan = lifespan;
|
||||||
std::make_pair(std::move(model_to_spawn), lifespan);
|
models_[name + std::to_string(i)] = std::move(model_to_spawn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -96,21 +97,15 @@ Model* Engine::SpawnLifedModel(std::string asset_name, std::string name,
|
|||||||
if (i == std::numeric_limits<std::uint32_t>::max() - 1)
|
if (i == std::numeric_limits<std::uint32_t>::max() - 1)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
else
|
else
|
||||||
return &dynamic_models_[name + std::to_string(i)].first;
|
return &models_[name + std::to_string(i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* Engine::GetSpawnedObject(std::string name) {
|
Model* Engine::GetSpawnedObject(std::string name) {
|
||||||
for (auto it = dynamic_immortal_models_.begin();
|
for (auto it = models_.begin(); it != models_.end();) {
|
||||||
it != dynamic_immortal_models_.end();) {
|
|
||||||
if (it->first == name) return &it->second;
|
if (it->first == name) return &it->second;
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = dynamic_models_.begin(); it != dynamic_models_.end();) {
|
|
||||||
if (it->first == name) return &it->second.first;
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,46 +135,74 @@ void Engine::Update() {
|
|||||||
if (Tick != nullptr) Tick(*this, delta_time);
|
if (Tick != nullptr) Tick(*this, delta_time);
|
||||||
|
|
||||||
std::vector<Model*> models;
|
std::vector<Model*> models;
|
||||||
models.reserve(dynamic_immortal_models_.size() +
|
models.reserve(models_.size());
|
||||||
dynamic_models_.size());
|
|
||||||
|
|
||||||
for (auto it = dynamic_immortal_models_.begin();
|
for (auto it = models_.begin(); it != models_.end();) {
|
||||||
it != dynamic_immortal_models_.end();) {
|
auto& model = it->second;
|
||||||
models.push_back(&it->second);
|
|
||||||
|
|
||||||
++it;
|
if (std::abs(model.lifespan + 1.f) <
|
||||||
}
|
std::numeric_limits<float>::epsilon()) {
|
||||||
|
models.push_back(&model);
|
||||||
for (auto it = dynamic_models_.begin(); it != dynamic_models_.end();) {
|
++it;
|
||||||
if (it->second.second < 0.f) {
|
|
||||||
it = dynamic_models_.erase(it);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
it->second.second -= delta_time;
|
|
||||||
}
|
|
||||||
models.push_back(&it->second.first);
|
|
||||||
|
|
||||||
|
if (model.lifespan <= 0.f) {
|
||||||
|
it = models_.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.lifespan -= delta_time;
|
||||||
|
|
||||||
|
models.push_back(&model);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it : models) {
|
for (auto& it : models_) {
|
||||||
it->Update(delta_time);
|
it.second.Update(delta_time);
|
||||||
vulkan_graphics->RenderModel(it);
|
vulkan_graphics->RenderModel(&it.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
physics_controller_.invokeOnColisionEvent(thread_pool_, {models.data(), models.size()});
|
physics_controller_.invokeOnColisionEvent(thread_pool_,
|
||||||
|
{models.data(), models.size()});
|
||||||
|
|
||||||
vulkan_graphics->EndFrame();
|
vulkan_graphics->EndFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Engine::NetUpdate(std::shared_ptr<Network::Socket> sock) {
|
||||||
void Engine::NetworkUpload() {
|
NetworkUpload(sock);
|
||||||
//TODO: 작성하기
|
RefreshFromServer(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::RefreshFromServer() {
|
void Engine::NetworkUpload(std::shared_ptr<Network::Socket> sock) {
|
||||||
// TODO: 작성하기
|
Packet::Header header;
|
||||||
|
header.opcode = Packet::Opcode::UPDATEMODEL;
|
||||||
|
header.body_length = 0;
|
||||||
|
|
||||||
|
std::vector<Network::IOCPPASSINDATA*> data;
|
||||||
|
Network::IOCPPASSINDATA* packet =
|
||||||
|
new Network::IOCPPASSINDATA(sizeof(Packet::Header));
|
||||||
|
packet->event = Network::IOCPEVENT::WRITE;
|
||||||
|
packet->socket = sock;
|
||||||
|
::memcpy(packet->wsabuf.buf, &header, sizeof(Packet::Header));
|
||||||
|
packet->wsabuf.len = sizeof(Packet::Header);
|
||||||
|
data.push_back(packet);
|
||||||
|
for (auto& it : models_) {
|
||||||
|
auto model = it.second.Serialize();
|
||||||
|
Network::IOCPPASSINDATA* packet = new Network::IOCPPASSINDATA(model.size());
|
||||||
|
packet->event = Network::IOCPEVENT::WRITE;
|
||||||
|
packet->socket = sock;
|
||||||
|
::memcpy(packet->wsabuf.buf, model.data(), model.size());
|
||||||
|
packet->wsabuf.len = model.size();
|
||||||
|
data.push_back(packet);
|
||||||
|
}
|
||||||
|
iocp_->send(sock->sock, &data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Engine::RefreshFromServer(std::shared_ptr<Network::Socket> sock) {
|
||||||
|
Network::IOCPPASSINDATA* recv_data = new Network::IOCPPASSINDATA(16 * 1024);
|
||||||
|
recv_data->socket = sock;
|
||||||
|
iocp_->recv(recv_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace veng
|
} // namespace veng
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class IOCP {
|
|||||||
// data는 한 가지 소켓에 보내는 패킷만 담아야 합니다
|
// data는 한 가지 소켓에 보내는 패킷만 담아야 합니다
|
||||||
int send(SOCKET sock, std::vector<IOCPPASSINDATA*>* data);
|
int send(SOCKET sock, std::vector<IOCPPASSINDATA*>* data);
|
||||||
|
|
||||||
int GetRecvedPacketCount(SOCKET sock);
|
int GetRecvedBytes(SOCKET sock);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ struct Model {
|
|||||||
original_offset(other.original_offset),
|
original_offset(other.original_offset),
|
||||||
owner(other.owner),
|
owner(other.owner),
|
||||||
radius(other.radius),
|
radius(other.radius),
|
||||||
|
lifespan(other.lifespan),
|
||||||
OnColision(other.OnColision),
|
OnColision(other.OnColision),
|
||||||
visible(other.visible),
|
visible(other.visible),
|
||||||
colision(other.colision) {
|
colision(other.colision) {
|
||||||
@@ -40,10 +41,10 @@ struct Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Model(Model&& other)
|
Model(Model&& other)
|
||||||
: vertices(other.vertices),
|
: vertices(std::move(other.vertices)),
|
||||||
vertex_buffer(other.vertex_buffer),
|
vertex_buffer(std::move(other.vertex_buffer)),
|
||||||
indices(other.indices),
|
indices(std::move(other.indices)),
|
||||||
index_buffer(other.index_buffer),
|
index_buffer(std::move(other.index_buffer)),
|
||||||
transform(other.transform),
|
transform(other.transform),
|
||||||
position(other.position),
|
position(other.position),
|
||||||
linear_velocity(other.linear_velocity),
|
linear_velocity(other.linear_velocity),
|
||||||
@@ -56,52 +57,25 @@ struct Model {
|
|||||||
original_offset(other.original_offset),
|
original_offset(other.original_offset),
|
||||||
owner(other.owner),
|
owner(other.owner),
|
||||||
radius(other.radius),
|
radius(other.radius),
|
||||||
|
lifespan(other.lifespan),
|
||||||
OnColision(other.OnColision),
|
OnColision(other.OnColision),
|
||||||
visible(other.visible),
|
visible(other.visible),
|
||||||
colision(other.colision) {
|
colision(other.colision) {
|
||||||
ID = other.ID;
|
ID = other.ID;
|
||||||
::memset(&other.ID, 0, 64);
|
::memset(&other.ID, 0, 8);
|
||||||
|
|
||||||
graphics_ = other.graphics_;
|
graphics_ = other.graphics_;
|
||||||
other.graphics_ = nullptr;
|
other.graphics_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model& operator=(const Model& other) {
|
|
||||||
if (this != &other) {
|
|
||||||
ID = utils::GenerateID();
|
|
||||||
vertices = other.vertices;
|
|
||||||
vertex_buffer = other.vertex_buffer;
|
|
||||||
indices = other.indices;
|
|
||||||
index_buffer = other.index_buffer;
|
|
||||||
transform = other.transform;
|
|
||||||
position = other.position;
|
|
||||||
linear_velocity = other.linear_velocity;
|
|
||||||
linear_acceleration = other.linear_acceleration;
|
|
||||||
rotation = other.rotation;
|
|
||||||
angular_velocity = other.angular_velocity;
|
|
||||||
angular_acceleration = other.angular_acceleration;
|
|
||||||
scale = other.scale;
|
|
||||||
material = other.material;
|
|
||||||
original_offset = other.original_offset;
|
|
||||||
owner = other.owner;
|
|
||||||
radius = other.radius;
|
|
||||||
OnColision = other.OnColision;
|
|
||||||
visible = other.visible;
|
|
||||||
colision = other.colision;
|
|
||||||
|
|
||||||
graphics_ = nullptr;
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Model& operator=(Model&& other) noexcept {
|
Model& operator=(Model&& other) noexcept {
|
||||||
if (this != &other) {
|
if (this != &other) {
|
||||||
ID = other.ID;
|
ID = other.ID;
|
||||||
::memset(&other.ID, 0, 64);
|
::memset(&other.ID, 0, 8);
|
||||||
vertices = std::move(other.vertices);
|
vertices = std::move(other.vertices);
|
||||||
vertex_buffer = other.vertex_buffer;
|
vertex_buffer = std::move(other.vertex_buffer);
|
||||||
indices = std::move(other.indices);
|
indices = std::move(other.indices);
|
||||||
index_buffer = other.index_buffer;
|
index_buffer = std::move(other.index_buffer);
|
||||||
transform = other.transform;
|
transform = other.transform;
|
||||||
position = other.position;
|
position = other.position;
|
||||||
linear_velocity = other.linear_velocity;
|
linear_velocity = other.linear_velocity;
|
||||||
@@ -114,6 +88,7 @@ struct Model {
|
|||||||
original_offset = other.original_offset;
|
original_offset = other.original_offset;
|
||||||
owner = other.owner;
|
owner = other.owner;
|
||||||
radius = other.radius;
|
radius = other.radius;
|
||||||
|
lifespan = other.lifespan;
|
||||||
OnColision = other.OnColision;
|
OnColision = other.OnColision;
|
||||||
visible = other.visible;
|
visible = other.visible;
|
||||||
colision = other.colision;
|
colision = other.colision;
|
||||||
@@ -156,6 +131,8 @@ struct Model {
|
|||||||
|
|
||||||
std::float_t radius = 0.f;
|
std::float_t radius = 0.f;
|
||||||
|
|
||||||
|
std::float_t lifespan = -1.f;
|
||||||
|
|
||||||
std::function<void(Model* self, Model* other)> OnColision = nullptr;
|
std::function<void(Model* self, Model* other)> OnColision = nullptr;
|
||||||
|
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
|
|||||||
@@ -25,9 +25,10 @@ class Engine {
|
|||||||
Model* GetSpawnedObject(std::string name);
|
Model* GetSpawnedObject(std::string name);
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
void NetUpdate(std::shared_ptr<Network::Socket> sock);
|
||||||
|
|
||||||
void NetworkUpload();
|
void NetworkUpload(std::shared_ptr<Network::Socket> sock);
|
||||||
void RefreshFromServer();
|
void RefreshFromServer(std::shared_ptr<Network::Socket> sock);
|
||||||
|
|
||||||
std::function<void(Engine&)> BeginPlay = [](Engine& engine) {};
|
std::function<void(Engine&)> BeginPlay = [](Engine& engine) {};
|
||||||
std::function<void(Engine&, std::float_t delta_time)> Tick =
|
std::function<void(Engine&, std::float_t delta_time)> Tick =
|
||||||
@@ -52,9 +53,7 @@ class Engine {
|
|||||||
|
|
||||||
std::unordered_map<std::string, veng::Model> model_assets_;
|
std::unordered_map<std::string, veng::Model> model_assets_;
|
||||||
|
|
||||||
std::unordered_map<std::string, veng::Model> dynamic_immortal_models_;
|
std::unordered_map<std::string, veng::Model> models_;
|
||||||
std::unordered_map<std::string, std::pair<veng::Model, std::float_t>>
|
|
||||||
dynamic_models_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace veng
|
} // namespace veng
|
||||||
|
|||||||
Reference in New Issue
Block a user