From 614c1556effbaebe4e4ab1325033d54b974e26aa Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 7 Sep 2016 13:04:58 +0200 Subject: [PATCH 1/6] Graphics/Sprite: Allows to set sprite corner color Former-commit-id: 66ca16acbb25da23a8a85b77d1bd4c4ca412e82f [formerly d4f67e512d1e7edd31c049045cc9069a8926d794] [formerly 7b9ca802280f114492d4e1aaa068c241802f3c25 [formerly 068f737047936c99b79057674bd453a54fe44960]] Former-commit-id: e92d6bb1bd4668a2f94f0311f887f38c00544277 [formerly da0e5d605a0b9197a767e48d8a5dbd94dd83872b] Former-commit-id: a4ce87c4974513dbe3890ac3f316ed14b74919eb --- include/Nazara/Graphics/Sprite.hpp | 3 ++ include/Nazara/Graphics/Sprite.inl | 59 +++++++++++++++++++++++++++--- src/Nazara/Graphics/Sprite.cpp | 9 ++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index 3aa261d89..13bcc289b 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -37,12 +37,14 @@ namespace Nz void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData) const override; inline const Color& GetColor() const; + inline const Color& GetCornerColor(RectCorner corner) const; inline const MaterialRef& GetMaterial() const; inline const Vector3f& GetOrigin() const; inline const Vector2f& GetSize() const; inline const Rectf& GetTextureCoords() const; inline void SetColor(const Color& color); + inline void SetCornerColor(RectCorner corner, const Color& color); inline void SetDefaultMaterial(); inline void SetMaterial(MaterialRef material, bool resizeSprite = true); inline void SetOrigin(const Vector3f& origin); @@ -65,6 +67,7 @@ namespace Nz static bool Initialize(); static void Uninitialize(); + std::array m_cornerColor; Color m_color; MaterialRef m_material; Rectf m_textureCoords; diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index 410b42478..bc27bf67c 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -18,6 +18,9 @@ namespace Nz m_size(64.f, 64.f), m_origin(Nz::Vector3f::Zero()) { + for (Color& color : m_cornerColor) + color = Color::White; + SetDefaultMaterial(); } @@ -62,14 +65,35 @@ namespace Nz /*! * \brief Gets the color of the sprite + * + * This is the global color of the sprite, independent from corner colors + * * \return Current color + * + * \see GetCornerColor + * \see SetColor */ - inline const Color& Sprite::GetColor() const { return m_color; } + /*! + * \brief Gets the color setup on a corner of the sprite + * + * \return Current color + * + * \param corner Corner of the sprite to query + * + * \see SetCornerColor + */ + inline const Color& Sprite::GetCornerColor(RectCorner corner) const + { + NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + + return m_cornerColor[corner]; + } + /*! * \brief Gets the material of the sprite * \return Current material @@ -86,7 +110,7 @@ namespace Nz * * \see SetOrigin */ - inline const Vector3f & Sprite::GetOrigin() const + inline const Vector3f& Sprite::GetOrigin() const { return m_origin; } @@ -105,18 +129,21 @@ namespace Nz * \brief Gets the texture coordinates of the sprite * \return Current texture coordinates */ - inline const Rectf& Sprite::GetTextureCoords() const { return m_textureCoords; } /*! - * \brief Sets the color of the billboard + * \brief Sets the global color of the sprite * - * \param color Color for the billboard + * This is independent from the corner color of the sprite + * + * \param color Color for the sprite + * + * \see GetColor + * \see SetCornerColor */ - inline void Sprite::SetColor(const Color& color) { m_color = color; @@ -124,6 +151,26 @@ namespace Nz InvalidateVertices(); } + /*! + * \brief Sets a color for a corner of the sprite + * + * This is independent from the sprite global color, which gets multiplied by the corner color when rendering the sprite. + * + * \param corner Corner of the sprite to set + * \param color Color for the sprite + * + * \see GetCornerColor + * \see SetColor + */ + inline void Sprite::SetCornerColor(RectCorner corner, const Color& color) + { + NazaraAssert(corner < m_cornerColor.size(), "Invalid corner"); + + m_cornerColor[corner] = color; + + InvalidateVertices(); + } + /*! * \brief Sets the default material of the sprite (just default material) */ diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 8b950bf2a..1b14ab6de 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -49,7 +49,6 @@ namespace Nz * * \param instanceData Data of the instance */ - void Sprite::UpdateData(InstanceData* instanceData) const { instanceData->data.resize(4 * sizeof(VertexStruct_XYZ_Color_UV)); @@ -61,19 +60,19 @@ namespace Nz Vector3f origin(m_origin.x, -m_origin.y, m_origin.z); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftTop]; *posPtr++ = instanceData->transformMatrix.Transform(Vector3f(-origin)); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftTop); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_RightTop]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightTop); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_LeftBottom]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_LeftBottom); - *colorPtr++ = m_color; + *colorPtr++ = m_color * m_cornerColor[RectCorner_RightBottom]; *posPtr++ = instanceData->transformMatrix.Transform(m_size.x*Vector3f::Right() + m_size.y*Vector3f::Down() - origin); *texCoordPtr++ = m_textureCoords.GetCorner(RectCorner_RightBottom); } From 4c68121a8b80d82e4a6cd12a104578bb83c763b6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 9 Sep 2016 23:17:36 +0200 Subject: [PATCH 2/6] Sdk/Entity: Fix component cleaning on destruction Former-commit-id: b074d35399413268e81643e49d75a669277e0668 [formerly da1d3881dcdcdf935530351875acb02069e10abb] [formerly 72680c76ca01af0b2b86012654f44cbc9fd62932 [formerly 0c56ea07f4641c92d983bb635b01ae25349024ed]] Former-commit-id: 08ce8b3cd0e089fabc182b20ad9e6a779adebde3 [formerly 59f13e00812fe2ae6000673f494e6dc2f8d29d06] Former-commit-id: 56471a336c769d464f54473e3f154da39b1d18df --- SDK/src/NDK/Entity.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SDK/src/NDK/Entity.cpp b/SDK/src/NDK/Entity.cpp index 815d0dc1b..a49a8f6aa 100644 --- a/SDK/src/NDK/Entity.cpp +++ b/SDK/src/NDK/Entity.cpp @@ -158,6 +158,9 @@ namespace Ndk UnregisterAllHandles(); + m_components.clear(); + m_componentBits.Reset(); + m_valid = false; } From 4565cd6089d89bea98afe86d9ae30ae9ee8e57f7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:29:12 +0200 Subject: [PATCH 3/6] Test AppVeyor Former-commit-id: 44e37f739c27026173c1928e65aa6228fbb1f784 [formerly 5629c7c880d437e2dbed1efc6c36d5bfee27c053] [formerly 577e36b635666e883ff56ce74260f3f93e330c4c [formerly df96d563b970bf18240f200b1408ca372aa60ecc]] Former-commit-id: 38787f2bfb98aea4199c56474e9e0621e30d3782 [formerly 2238b00a69dac9327c6d16cc5e1aacc4bb17e1d4] Former-commit-id: 53ee458a235a8089ac92d162ed89ab24bce76dba --- appveyor.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..756c1e14b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +shallow_clone: true + +os: + - Visual Studio 2015 + +environment: + matrix: + - TOOLSET: vs2010 + - TOOLSET: vs2013 + - TOOLSET: vs2015 + +install: + - cd build && "./premake5.exe" %TOOLSET% && cd .. + +configuration: + - Debug + - Release + +build: + project: NazaraEngine/build/$(TOOLSET)/NazaraEngine.sln + +after_test: + - NazaraEngine\tests\Tests.exe From 64f8f63a9e958b99ce588ce32d64825a5936a506 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:30:45 +0200 Subject: [PATCH 4/6] Try to fix build Former-commit-id: 18e448bb4fca705b15850ed3159dfe33ccbb7c5a [formerly a916f662377a1a5eb40ab9f8cd3dbb957c5e5cae] [formerly 5add32ceef4978ce39d3f73e8668af0886ee08fb [formerly b7d0e9b3773e7a50e46159f2918cad43d9902445]] Former-commit-id: c297e8dfb352ce5babe432c36b7f0bbe56a919b1 [formerly 4814adb5fa186d5f8e90c81384230b1413f99c4e] Former-commit-id: 14e280fdce38240c854cb507ebd8d9850d484a8f --- appveyor.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 756c1e14b..498270c14 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,6 @@ os: environment: matrix: - - TOOLSET: vs2010 - - TOOLSET: vs2013 - TOOLSET: vs2015 install: @@ -17,7 +15,4 @@ configuration: - Release build: - project: NazaraEngine/build/$(TOOLSET)/NazaraEngine.sln - -after_test: - - NazaraEngine\tests\Tests.exe + project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file From 5c681d11ce9b175ee97fc07991ce076c1975c8cc Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:35:58 +0200 Subject: [PATCH 5/6] Damnit Former-commit-id: aad22f6569e9d096a8af02034f7dd2ecc3bbe4eb [formerly a9fa210a8442a12064c5e768b3e03beb8ab1c10b] [formerly ca732eb0b0b42f7fce822e8ab0aae44e22c1e651 [formerly 11a53e81205d74e5b9cbb9fdbe9c242c5c7736c1]] Former-commit-id: 291082c51c9d9dc4b361c9ed5196b13c8edfc061 [formerly 8620c5eaff7c69742c98c94f52a028c721240a1e] Former-commit-id: 3f488710c3ab59acd5381dc7877f3ae968847703 --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 498270c14..a705a4c8c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,5 @@ +version: '{branch}-rev{build}' +configuration: DebugDynamic, ReleaseDynamic shallow_clone: true os: From b64e65bbb3608f0bed92448bfda28915697a3dac Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 12 Sep 2016 14:36:34 +0200 Subject: [PATCH 6/6] I'm a moron Former-commit-id: bba4e4d5d99fa7d4f8542ddf4f371578a6fbfde6 [formerly 38666d69d3f61b68f53452f9e08afd5d4545e247] [formerly 5d5ca1fbc58f8f55e49df32e840347807b307df1 [formerly 1268ae19bb805894bc4ea98bca9f3aaee23a884f]] Former-commit-id: db42585f88b7aac2d9d946aa19168a051180875f [formerly 437851904db490748a7b7b946e4823177e782a6a] Former-commit-id: ec09684d4e6f2d0ce7664f73f1c552e5dbde9278 --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a705a4c8c..39ff8f7a8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: '{branch}-rev{build}' -configuration: DebugDynamic, ReleaseDynamic + shallow_clone: true os: @@ -13,8 +13,8 @@ install: - cd build && "./premake5.exe" %TOOLSET% && cd .. configuration: - - Debug - - Release + - DebugDynamic + - ReleaseDynamic build: project: build/$(TOOLSET)/NazaraEngine.sln \ No newline at end of file