diff --git a/examples/01-cubes/cubes.cpp b/examples/01-cubes/cubes.cpp index ea8f8ec6c..faa098ecb 100644 --- a/examples/01-cubes/cubes.cpp +++ b/examples/01-cubes/cubes.cpp @@ -273,8 +273,8 @@ public: float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) ); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index 25198be8f..f5256d828 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/examples/02-metaballs/metaballs.cpp @@ -579,8 +579,8 @@ public: const double toMs = 1000.0/freq; float time = (float)( (now - m_timeOffset)/double(bx::getHPFrequency() ) ); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -50.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -50.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/03-raymarch/raymarch.cpp b/examples/03-raymarch/raymarch.cpp index fcb42991c..a07e01848 100644 --- a/examples/03-raymarch/raymarch.cpp +++ b/examples/03-raymarch/raymarch.cpp @@ -192,8 +192,8 @@ public: // if no other draw calls are submitted to viewZ 0. bgfx::touch(0); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -15.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -15.0f }; float view[16]; float proj[16]; diff --git a/examples/04-mesh/mesh.cpp b/examples/04-mesh/mesh.cpp index 48d0d5cf3..06896ef02 100644 --- a/examples/04-mesh/mesh.cpp +++ b/examples/04-mesh/mesh.cpp @@ -103,8 +103,8 @@ public: float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) ); bgfx::setUniform(u_time, &time); - float at[3] = { 0.0f, 1.0f, 0.0f }; - float eye[3] = { 0.0f, 1.0f, -2.5f }; + const bx::Vec3 at = { 0.0f, 1.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 1.0f, -2.5f }; // Set view and projection matrix for view 0. { diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index e9d489507..d471efb87 100644 --- a/examples/05-instancing/instancing.cpp +++ b/examples/05-instancing/instancing.cpp @@ -172,8 +172,8 @@ public: } else { - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/06-bump/bump.cpp b/examples/06-bump/bump.cpp index 9cff80eee..2f2991619 100644 --- a/examples/06-bump/bump.cpp +++ b/examples/06-bump/bump.cpp @@ -211,8 +211,8 @@ public: float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() )); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -7.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -7.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index e28acb437..987c51761 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -423,8 +423,8 @@ public: // if no other draw calls are submitted to view 0. bgfx::touch(0); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; float view[16]; float proj[16]; diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index 0ce62ad50..0eb0c53ca 100644 --- a/examples/08-update/update.cpp +++ b/examples/08-update/update.cpp @@ -484,8 +484,8 @@ public: } } - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -5.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -5.0f }; float view[16]; bx::mtxLookAt(view, eye, at); diff --git a/examples/09-hdr/hdr.cpp b/examples/09-hdr/hdr.cpp index 5ceadd5a6..fb3a266da 100644 --- a/examples/09-hdr/hdr.cpp +++ b/examples/09-hdr/hdr.cpp @@ -469,8 +469,8 @@ public: bgfx::setViewTransform(ii, NULL, proj); } - float at[3] = { 0.0f, 1.0f, 0.0f }; - float eye[3] = { 0.0f, 1.0f, -2.5f }; + const bx::Vec3 at = { 0.0f, 1.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 1.0f, -2.5f }; float mtx[16]; bx::mtxRotateXY(mtx @@ -478,11 +478,10 @@ public: , m_time ); - float temp[4]; - bx::vec3MulMtx(temp, eye, mtx); + const bx::Vec3 tmp = bx::mul(eye, mtx); float view[16]; - bx::mtxLookAt(view, temp, at); + bx::mtxLookAt(view, tmp, at); bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, caps->homogeneousDepth); // Set view and projection matrix for view hdrMesh. diff --git a/examples/10-font/font.cpp b/examples/10-font/font.cpp index ca5e4c83e..26dbfc76e 100644 --- a/examples/10-font/font.cpp +++ b/examples/10-font/font.cpp @@ -258,8 +258,8 @@ public: m_textBufferManager->appendText(m_transientText, m_visitor10, "text buffer\n"); m_textBufferManager->appendText(m_transientText, m_visitor10, fpsText); - float at[3] = { 0, 0, 0.0f }; - float eye[3] = { 0, 0, -1.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -1.0f }; float view[16]; bx::mtxLookAt(view, eye, at); diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index 6f59674c6..43634abba 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/examples/11-fontsdf/fontsdf.cpp @@ -191,8 +191,8 @@ public: // if no other draw calls are submitted to view 0. bgfx::touch(0); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -1.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -1.0f }; float view[16]; bx::mtxLookAt(view, eye, at); diff --git a/examples/12-lod/lod.cpp b/examples/12-lod/lod.cpp index 2b574d290..130826c74 100644 --- a/examples/12-lod/lod.cpp +++ b/examples/12-lod/lod.cpp @@ -176,8 +176,8 @@ public: // if no other draw calls are submitted to view 0. bgfx::touch(0); - float at[3] = { 0.0f, 1.0f, 0.0f }; - float eye[3] = { 0.0f, 2.0f, -distance }; + const bx::Vec3 at = { 0.0f, 1.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 2.0f, -distance }; // Set view and projection matrix for view 0. { @@ -245,12 +245,12 @@ public: } int lod = 0; - if (eye[2] < -2.5f) + if (eye.z < -2.5f) { lod = 1; } - if (eye[2] < -5.0f) + if (eye.z < -5.0f) { lod = 2; } diff --git a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp index cbf85aa46..b42b4a6f8 100644 --- a/examples/15-shadowmaps-simple/shadowmaps_simple.cpp +++ b/examples/15-shadowmaps-simple/shadowmaps_simple.cpp @@ -213,8 +213,8 @@ public: // Set view and projection matrices. - float eye[3] = { 0.0f, 30.0f, -60.0f }; - float at[3] = { 0.0f, 5.0f, 0.0f }; + const bx::Vec3 at = { 0.0f, 5.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 30.0f, -60.0f }; bx::mtxLookAt(m_view, eye, at); const float aspect = float(int32_t(m_width) ) / float(int32_t(m_height) ); @@ -319,9 +319,8 @@ public: float lightView[16]; float lightProj[16]; - float eye[3] = { -lightPos[0], -lightPos[1], -lightPos[2] }; - float at[3] = { 0.0f, 0.0f, 0.0f }; - + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { -lightPos[0], -lightPos[1], -lightPos[2] }; bx::mtxLookAt(lightView, eye, at); const bgfx::Caps* caps = bgfx::getCaps(); diff --git a/examples/16-shadowmaps/shadowmaps.cpp b/examples/16-shadowmaps/shadowmaps.cpp index 7311722f2..4c9a02060 100644 --- a/examples/16-shadowmaps/shadowmaps.cpp +++ b/examples/16-shadowmaps/shadowmaps.cpp @@ -2335,7 +2335,7 @@ public: float at[3]; bx::vec3Add(at, m_pointLight.m_position.m_v, m_pointLight.m_spotDirectionInner.m_v); - bx::mtxLookAt(lightView[TetrahedronFaces::Green], m_pointLight.m_position.m_v, at); + bx::mtxLookAt(lightView[TetrahedronFaces::Green], bx::load(m_pointLight.m_position.m_v), bx::load(at) ); } else if (LightType::PointLight == m_settings.m_lightType) { @@ -2421,13 +2421,13 @@ public: else // LightType::DirectionalLight == settings.m_lightType { // Setup light view mtx. - float eye[3] = + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { - -m_directionalLight.m_position.m_x - , -m_directionalLight.m_position.m_y - , -m_directionalLight.m_position.m_z + -m_directionalLight.m_position.m_x, + -m_directionalLight.m_position.m_y, + -m_directionalLight.m_position.m_z, }; - float at[3] = { 0.0f, 0.0f, 0.0f }; bx::mtxLookAt(lightView[0], eye, at); // Compute camera inverse view mtx. diff --git a/examples/17-drawstress/drawstress.cpp b/examples/17-drawstress/drawstress.cpp index 3cebdd502..9e88829df 100644 --- a/examples/17-drawstress/drawstress.cpp +++ b/examples/17-drawstress/drawstress.cpp @@ -375,8 +375,8 @@ public: imguiEndFrame(); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; float view[16]; bx::mtxLookAt(view, eye, at); diff --git a/examples/18-ibl/ibl.cpp b/examples/18-ibl/ibl.cpp index cfa40a320..7f43232d3 100644 --- a/examples/18-ibl/ibl.cpp +++ b/examples/18-ibl/ibl.cpp @@ -205,7 +205,7 @@ struct Camera void mtxLookAt(float* _outViewMtx) { - bx::mtxLookAt(_outViewMtx, m_pos.curr, m_target.curr); + bx::mtxLookAt(_outViewMtx, bx::load(m_pos.curr), bx::load(m_target.curr) ); } void orbit(float _dx, float _dy) diff --git a/examples/19-oit/oit.cpp b/examples/19-oit/oit.cpp index d898024ca..d12965b73 100644 --- a/examples/19-oit/oit.cpp +++ b/examples/19-oit/oit.cpp @@ -351,8 +351,8 @@ public: // http://jcgt.org/published/0002/02/09/ // http://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -7.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -7.0f }; float view[16]; float proj[16]; diff --git a/examples/22-windows/windows.cpp b/examples/22-windows/windows.cpp index fffd1f950..cd2be0885 100644 --- a/examples/22-windows/windows.cpp +++ b/examples/22-windows/windows.cpp @@ -230,8 +230,8 @@ public: } } - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; float view[16]; bx::mtxLookAt(view, eye, at); diff --git a/examples/23-vectordisplay/main.cpp b/examples/23-vectordisplay/main.cpp index 13114d7f9..badeeccff 100644 --- a/examples/23-vectordisplay/main.cpp +++ b/examples/23-vectordisplay/main.cpp @@ -119,8 +119,8 @@ public: m_vd.resize(uint16_t(m_width), uint16_t(m_height) ); } - const float at[3] = { 0.0f, 0.0f, 0.0f }; - const float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; float view[16]; float proj[16]; diff --git a/examples/26-occlusion/occlusion.cpp b/examples/26-occlusion/occlusion.cpp index e37e2feee..55970a401 100644 --- a/examples/26-occlusion/occlusion.cpp +++ b/examples/26-occlusion/occlusion.cpp @@ -219,8 +219,8 @@ public: bgfx::setViewTransform(1, view, proj); bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) ); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 17.5f, 10.0f, -17.5f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 17.5f, 10.0f, -17.5f }; bx::mtxLookAt(view, eye, at); bgfx::setViewTransform(2, view, proj); diff --git a/examples/28-wireframe/wireframe.cpp b/examples/28-wireframe/wireframe.cpp index 2e49075b9..d19ee8b8c 100644 --- a/examples/28-wireframe/wireframe.cpp +++ b/examples/28-wireframe/wireframe.cpp @@ -49,7 +49,7 @@ struct Camera void mtxLookAt(float* _outViewMtx) { - bx::mtxLookAt(_outViewMtx, m_pos.curr, m_target.curr); + bx::mtxLookAt(_outViewMtx, bx::load(m_pos.curr), bx::load(m_target.curr) ); } void orbit(float _dx, float _dy) diff --git a/examples/29-debugdraw/debugdraw.cpp b/examples/29-debugdraw/debugdraw.cpp index 43646e866..f2e2cfddd 100644 --- a/examples/29-debugdraw/debugdraw.cpp +++ b/examples/29-debugdraw/debugdraw.cpp @@ -627,9 +627,9 @@ public: float mtxInvVp[16]; bx::mtxInverse(mtxInvVp, mtxVp); - float zero[3] = {}; - float eye[] = { 5.0f, 10.0f, 5.0f }; - bx::mtxLookAt(view, eye, zero); + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 5.0f, 10.0f, 5.0f }; + bx::mtxLookAt(view, eye, at); bx::mtxProj(proj, 45.0f, float(m_width)/float(m_height), 1.0f, 15.0f, bgfx::getCaps()->homogeneousDepth); bx::mtxMul(mtxVp, view, proj); diff --git a/examples/30-picking/picking.cpp b/examples/30-picking/picking.cpp index 5fbcfecfe..7847e1ba4 100644 --- a/examples/30-picking/picking.cpp +++ b/examples/30-picking/picking.cpp @@ -238,13 +238,14 @@ public: const float camSpeed = 0.25; float cameraSpin = (float)m_cameraSpin; float eyeDist = 2.5f; - float eye[3] = + + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { -eyeDist * bx::sin(time*cameraSpin*camSpeed), 0.0f, -eyeDist * bx::cos(time*cameraSpin*camSpeed), }; - float at[3] = { 0.0f, 0.0f, 0.0f }; float view[16]; bx::mtxLookAt(view, eye, at); @@ -277,7 +278,7 @@ public: // Look at our unprojected point float pickView[16]; - bx::mtxLookAt(pickView, pickEye, pickAt); + bx::mtxLookAt(pickView, bx::load(pickEye), bx::load(pickAt) ); // Tight FOV is best for picking float pickProj[16]; diff --git a/examples/31-rsm/reflectiveshadowmap.cpp b/examples/31-rsm/reflectiveshadowmap.cpp index d57bf2426..8a0ca30a2 100644 --- a/examples/31-rsm/reflectiveshadowmap.cpp +++ b/examples/31-rsm/reflectiveshadowmap.cpp @@ -476,7 +476,7 @@ public: lightAt[1] = 0.0f; lightAt[2] = 0.0f; - bx::mtxLookAt(smView, lightEye, lightAt); + bx::mtxLookAt(smView, bx::load(lightEye), bx::load(lightAt) ); const float area = 10.0f; const bgfx::Caps* caps = bgfx::getCaps(); bx::mtxOrtho(smProj, -area, area, -area, area, -100.0f, 100.0f, 0.0f, caps->homogeneousDepth); diff --git a/examples/33-pom/pom.cpp b/examples/33-pom/pom.cpp index 745a6ae6f..4148c3212 100644 --- a/examples/33-pom/pom.cpp +++ b/examples/33-pom/pom.cpp @@ -225,8 +225,8 @@ public: float time = (float)( (now-m_timeOffset)/freq); - float at[3] = { 0.0f, 0.0f, 1.0f }; - float eye[3] = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 1.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, 0.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/34-mvs/mvs.cpp b/examples/34-mvs/mvs.cpp index 0da9e8ceb..87144356f 100644 --- a/examples/34-mvs/mvs.cpp +++ b/examples/34-mvs/mvs.cpp @@ -207,8 +207,8 @@ public: float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) ); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/35-dynamic/dynamic.cpp b/examples/35-dynamic/dynamic.cpp index c9599fb2d..0bcbf1102 100644 --- a/examples/35-dynamic/dynamic.cpp +++ b/examples/35-dynamic/dynamic.cpp @@ -190,8 +190,8 @@ public: float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) ); - float at[3] = { 0.0f, 0.0f, 0.0f }; - float eye[3] = { 0.0f, 0.0f, -35.0f }; + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; + const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; // Set view and projection matrix for view 0. { diff --git a/examples/37-gpudrivenrendering/gpudrivenrendering.cpp b/examples/37-gpudrivenrendering/gpudrivenrendering.cpp index aa7f5e115..d65200cf1 100644 --- a/examples/37-gpudrivenrendering/gpudrivenrendering.cpp +++ b/examples/37-gpudrivenrendering/gpudrivenrendering.cpp @@ -55,7 +55,7 @@ struct Camera void mtxLookAt(float* _outViewMtx) { - bx::mtxLookAt(_outViewMtx, m_pos.curr, m_target.curr); + bx::mtxLookAt(_outViewMtx, bx::load(m_pos.curr), bx::load(m_target.curr) ); } void orbit(float _dx, float _dy) diff --git a/examples/common/camera.cpp b/examples/common/camera.cpp index 9e56c26dc..3e48e57d4 100644 --- a/examples/common/camera.cpp +++ b/examples/common/camera.cpp @@ -240,7 +240,7 @@ struct Camera void getViewMtx(float* _viewMtx) { - bx::mtxLookAt(_viewMtx, &m_eye.x, &m_at.x, &m_up.x); + bx::mtxLookAt(_viewMtx, bx::load(&m_eye.x), bx::load(&m_at.x), bx::load(&m_up.x) ); } void setPosition(const float* _pos)