Objects constructor infinite allocation fix
This commit is contained in:
parent
98cac71b2a
commit
f9935d6b77
@ -128,11 +128,11 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
|
||||
|
||||
void Graphic3DRenderer::UpdateInternalTestObjects() {
|
||||
static float thetaAngle = 0.31f;
|
||||
thetaAngle = thetaAngle >= 6.283185f ? -6.283185f : thetaAngle + 0.004f;
|
||||
thetaAngle = thetaAngle >= M3D_2PI ? -M3D_2PI : thetaAngle + 0.004f;
|
||||
static float thetaAngle2 = 2.12f;
|
||||
thetaAngle2 = thetaAngle2 >= 6.283185f ? -6.283185f : thetaAngle2 + 0.005f;
|
||||
thetaAngle2 = thetaAngle2 >= M3D_2PI ? -M3D_2PI : thetaAngle2 + 0.005f;
|
||||
static float thetaAngle3 = -4.78f;
|
||||
thetaAngle3 = thetaAngle3 >= 6.283185f ? -6.283185f : thetaAngle3 + 0.008f;
|
||||
thetaAngle3 = thetaAngle3 >= M3D_2PI ? -M3D_2PI : thetaAngle3 + 0.008f;
|
||||
mWorldObjsList[0]->SetRotation(thetaAngle, 0.f, thetaAngle * 0.5f);
|
||||
mWorldObjsList[1]->SetRotation(thetaAngle2, 0.f, thetaAngle2 * 0.5f);
|
||||
mWorldObjsList[2]->SetRotation(thetaAngle3, 0.f, thetaAngle3 * 0.5f);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
Camera::Camera() {
|
||||
SetFrustrum(90.f, (1280.f/1024.f), 1.0f, 1000.f);
|
||||
SetFrustrum(90.f, (1280.f/1024.f), 1.0f, 100.f);
|
||||
}
|
||||
|
||||
void Camera::SetFrustrum(float fov, float r, float zn, float zf) {
|
||||
|
@ -56,23 +56,23 @@ void CockpitUI::Update() {
|
||||
}
|
||||
|
||||
void CockpitUI::Draw(std::shared_ptr<sf::RenderWindow>& context) {
|
||||
sf::BlendMode sBM = sf::BlendNone;
|
||||
sf::BlendMode sBM = sf::BlendAlpha;
|
||||
sf::RenderStates sRS(sBM);
|
||||
|
||||
// Clear the UI screen
|
||||
mUIRender.clear(sf::Color::Transparent);
|
||||
|
||||
// Draw the static board
|
||||
sf::Sprite staticBoardSprite(mStaticCockpitTexture);
|
||||
mUIRender.draw(staticBoardSprite, sRS);
|
||||
|
||||
// Draw the radar display
|
||||
sf::CircleShape radar(95, 8);
|
||||
radar.setRotation(22.5f);
|
||||
radar.setPosition(sf::Vector2f(838,378));
|
||||
radar.setFillColor(sf::Color::Yellow);
|
||||
radar.setFillColor(SF_COLOR_4CHEX(0x666666FF));
|
||||
mUIRender.draw(radar, sRS);
|
||||
|
||||
// Draw the static board
|
||||
sf::Sprite staticBoardSprite(mStaticCockpitTexture);
|
||||
mUIRender.draw(staticBoardSprite, sRS);
|
||||
|
||||
// Do the final texture render
|
||||
mUIRender.display();
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
ObjectDbgCube::ObjectDbgCube() {
|
||||
if (!isMeshLoaded) {
|
||||
try {
|
||||
mMesh.vertices.resize(8);
|
||||
} catch (const std::length_error& ex) {
|
||||
@ -33,4 +34,5 @@ ObjectDbgCube::ObjectDbgCube() {
|
||||
mMesh.parts.push_back(basePart);
|
||||
|
||||
UpdateAABBFromMesh();
|
||||
}
|
||||
}
|
@ -2,5 +2,8 @@
|
||||
|
||||
|
||||
Tank::Tank() {
|
||||
if (!isMeshLoaded) {
|
||||
LoadMeshFromObjFile("tank_sample.obj");
|
||||
isMeshLoaded = true;
|
||||
}
|
||||
}
|
@ -57,6 +57,7 @@ public:
|
||||
|
||||
protected:
|
||||
inline static Mesh mMesh;
|
||||
inline static bool isMeshLoaded = false;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user