small refactoring

master
Vectozavr 2022-02-24 11:11:04 +07:00
parent b4d7373461
commit 874df60941
4 changed files with 9 additions and 7 deletions

View File

@ -15,7 +15,7 @@ int main() {
//game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
// Optimal for MacBook Pro 16 display:
game.create(2048, 1152, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR);
game.create(2048, 1152, ShooterConsts::PROJECT_NAME, false, Consts::BACKGROUND_COLOR);
//game.create(3072, 1920, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR);
return 0;

View File

@ -58,7 +58,7 @@ void Engine::create(int screenWidth, int screenHeight, const std::string &name,
Time::startTimer("d projections");
if (_useOpenGL) {
GLfloat *view = camera->glInvModel();
screen->pushGLStates();
screen->popGLStates();
screen->prepareToGlDrawMesh();
for (auto &it : *world) {
if (it.second->isVisible()) {
@ -68,7 +68,7 @@ void Engine::create(int screenWidth, int screenHeight, const std::string &name,
delete[] model;
}
}
screen->popGLStates();
screen->pushGLStates();
delete[] view;
} else {
// clear triangles from previous frame

View File

@ -12,16 +12,18 @@
using namespace std;
void World::addBody(std::shared_ptr<RigidBody> body) {
std::shared_ptr<RigidBody> World::addBody(std::shared_ptr<RigidBody> body) {
_objects.emplace(body->name(), body);
Log::log("World::addBody(): inserted body '" + body->name().str() + "' with " +
std::to_string(_objects[body->name()]->triangles().size()) + " tris.");
return _objects[body->name()];
}
void World::loadBody(const ObjectNameTag &tag, const string &filename, const Vec3D &scale) {
std::shared_ptr<RigidBody> World::loadBody(const ObjectNameTag &tag, const string &filename, const Vec3D &scale) {
_objects.emplace(tag, std::make_shared<RigidBody>(tag, filename, scale));
Log::log("World::loadBody(): inserted body from " + filename + " with title '" + tag.str() + "' with " +
std::to_string(_objects[tag]->triangles().size()) + " tris.");
return _objects[tag];
}
IntersectionInformation World::rayCast(const Vec3D &from, const Vec3D &to, const std::string &skipTags) {

View File

@ -30,10 +30,10 @@ public:
void update();
void addBody(std::shared_ptr<RigidBody> mesh);
std::shared_ptr<RigidBody> addBody(std::shared_ptr<RigidBody> mesh);
std::shared_ptr<RigidBody> body(const ObjectNameTag &tag);
void removeBody(const ObjectNameTag &tag);
void loadBody(const ObjectNameTag &tag, const std::string &filename, const Vec3D &scale = Vec3D{1, 1, 1});
std::shared_ptr<RigidBody> loadBody(const ObjectNameTag &tag, const std::string &filename, const Vec3D &scale = Vec3D{1, 1, 1});
void loadMap(const std::string &filename, const Vec3D &scale = Vec3D{1, 1, 1});
// std::string skipTags is a string that consist of all objects we want to skip in ray casting