diff --git a/Kiwano/2d/Action.h b/Kiwano/2d/Action.h index beecd92a..fe3e6c28 100644 --- a/Kiwano/2d/Action.h +++ b/Kiwano/2d/Action.h @@ -28,7 +28,7 @@ namespace kiwano class ActionManager; class KGE_API Action - : public virtual Object + : public Object , protected IntrusiveListItem { friend class ActionManager; diff --git a/Kiwano/2d/Frames.h b/Kiwano/2d/Frames.h index 0f13324f..11eabe32 100644 --- a/Kiwano/2d/Frames.h +++ b/Kiwano/2d/Frames.h @@ -25,7 +25,7 @@ namespace kiwano { // 序列帧 class KGE_API Frames - : public virtual Object + : public Object { public: Frames(); diff --git a/Kiwano/2d/Geometry.h b/Kiwano/2d/Geometry.h index 249605b8..6f54a492 100644 --- a/Kiwano/2d/Geometry.h +++ b/Kiwano/2d/Geometry.h @@ -26,7 +26,7 @@ namespace kiwano { // 几何抽象 class KGE_API Geometry - : public virtual Object + : public Object { friend class Canvas; friend class GeometryNode; diff --git a/Kiwano/2d/Image.h b/Kiwano/2d/Image.h index d47c8dc8..3e6319d8 100644 --- a/Kiwano/2d/Image.h +++ b/Kiwano/2d/Image.h @@ -27,7 +27,7 @@ namespace kiwano { // 图片 class KGE_API Image - : public virtual Object + : public Object { public: Image(); diff --git a/Kiwano/2d/Node.h b/Kiwano/2d/Node.h index 0794ec68..60ea6394 100644 --- a/Kiwano/2d/Node.h +++ b/Kiwano/2d/Node.h @@ -31,7 +31,7 @@ namespace kiwano // 节点 class KGE_API Node - : public virtual Object + : public Object , public TimerManager , public ActionManager , public EventDispatcher diff --git a/Kiwano/2d/Transition.h b/Kiwano/2d/Transition.h index 0d605cb7..20d1ab3c 100644 --- a/Kiwano/2d/Transition.h +++ b/Kiwano/2d/Transition.h @@ -28,7 +28,7 @@ namespace kiwano // 场景过渡 class KGE_API Transition - : public virtual Object + : public Object { friend class Application; diff --git a/Kiwano/audio/Sound.h b/Kiwano/audio/Sound.h index f2c0dd97..a7ae2b1e 100644 --- a/Kiwano/audio/Sound.h +++ b/Kiwano/audio/Sound.h @@ -27,7 +27,7 @@ namespace kiwano // 音乐对象 class KGE_API Sound - : public virtual Object + : public Object { public: Sound(); diff --git a/Kiwano/base/EventListener.h b/Kiwano/base/EventListener.h index 7af83d46..7edebffb 100644 --- a/Kiwano/base/EventListener.h +++ b/Kiwano/base/EventListener.h @@ -37,7 +37,7 @@ namespace kiwano // 事件监听器 class KGE_API EventListener - : public virtual Object + : public Object , protected IntrusiveListItem { friend class EventDispatcher; diff --git a/Kiwano/base/Timer.h b/Kiwano/base/Timer.h index abed8099..ed5512e4 100644 --- a/Kiwano/base/Timer.h +++ b/Kiwano/base/Timer.h @@ -34,7 +34,7 @@ namespace kiwano // 定时任务 class KGE_API Timer - : public virtual Object + : public Object , protected IntrusiveListItem { friend class TimerManager; diff --git a/Kiwano/math/Rect.hpp b/Kiwano/math/Rect.hpp index 9d502e95..c45480ae 100644 --- a/Kiwano/math/Rect.hpp +++ b/Kiwano/math/Rect.hpp @@ -49,8 +49,8 @@ namespace kiwano {} RectT( - const Vec2& pos, - const Vec2& size + const Vec2T& pos, + const Vec2T& size ) : origin(pos.x, pos.y) , size(size.x, size.y) @@ -75,36 +75,38 @@ namespace kiwano return (origin == rect.origin) && (size == rect.size); } - inline void Set(value_type x, value_type y, value_type width, value_type height) { origin = Vec2{ x, y }; size = Vec2{ width, height }; } + inline void Set(value_type x, value_type y, value_type width, value_type height) + { + origin = Vec2T{ x, y }; + size = Vec2T{ width, height }; + } - inline Vec2 GetCenter() const { return Vec2{ origin.x + size.x / 2, origin.y + size.y / 2 }; } + inline Vec2T GetCenter() const { return Vec2T{ origin.x + size.x / 2, origin.y + size.y / 2 }; } - inline Vec2 GetLeftTop() const { return origin; } + inline Vec2T GetLeftTop() const { return origin; } - inline Vec2 GetRightBottom() const { return Vec2{ GetRight(), GetBottom() }; } + inline Vec2T GetRightBottom() const { return Vec2T{ GetRight(), GetBottom() }; } - inline Vec2 GetRightTop() const { return Vec2{ GetRight(), GetTop() }; } + inline Vec2T GetRightTop() const { return Vec2T{ GetRight(), GetTop() }; } - inline Vec2 GetLeftBottom() const { return Vec2{ GetLeft(), GetBottom() }; } + inline Vec2T GetLeftBottom() const { return Vec2T{ GetLeft(), GetBottom() }; } - inline value_type GetLeft() const { return origin.x; } + inline value_type GetLeft() const { return origin.x; } - inline value_type GetTop() const { return origin.y; } + inline value_type GetTop() const { return origin.y; } - inline value_type GetRight() const { return origin.x + size.x; } + inline value_type GetRight() const { return origin.x + size.x; } - inline value_type GetBottom() const { return origin.y + size.y; } + inline value_type GetBottom() const { return origin.y + size.y; } - inline bool IsEmpty() const { return origin.IsOrigin() && size.IsOrigin(); } + inline bool IsEmpty() const { return origin.IsOrigin() && size.IsOrigin(); } - // 判断点是否在矩形内 - inline bool ContainsPoint(const Vec2& point) const + inline bool ContainsPoint(const Vec2T& point) const { return point.x >= origin.x && point.x <= (origin.x + size.x) && point.y >= origin.y && point.y <= (origin.y + size.y); } - // 判断两矩形是否相交 inline bool Intersects(const RectT& rect) const { return !((origin.x + size.x) < rect.origin.x || diff --git a/Kiwano/math/Vec2.hpp b/Kiwano/math/Vec2.hpp index ac2bf2ca..acdd8168 100644 --- a/Kiwano/math/Vec2.hpp +++ b/Kiwano/math/Vec2.hpp @@ -80,6 +80,34 @@ namespace kiwano return Vec2T(-x, -y); } + inline Vec2T& operator += (const Vec2T& other) + { + x += other.x; + y += other.y; + return (*this); + } + + inline Vec2T& operator -= (const Vec2T& other) + { + x -= other.x; + y -= other.y; + return (*this); + } + + inline Vec2T& operator *= (value_type val) + { + x *= val; + y *= val; + return (*this); + } + + inline Vec2T& operator /= (value_type val) + { + x /= val; + y /= val; + return (*this); + } + inline bool operator== (const Vec2T& other) const { return (x == other.x) && (y == other.y); diff --git a/Kiwano/renderer/D2DDeviceResources.h b/Kiwano/renderer/D2DDeviceResources.h index 817a1e23..a67e0515 100644 --- a/Kiwano/renderer/D2DDeviceResources.h +++ b/Kiwano/renderer/D2DDeviceResources.h @@ -69,12 +69,12 @@ namespace kiwano _In_ ComPtr const& target ); - inline ID2D1Factory1* GetD2DFactory() const { return d2d_factory_.Get(); } - inline IWICImagingFactory* GetWICImagingFactory() const { return imaging_factory_.Get(); } - inline IDWriteFactory* GetDWriteFactory() const { return dwrite_factory_.Get(); } - inline ID2D1Device* GetD2DDevice() const { return d2d_device_.Get(); } - inline ID2D1DeviceContext* GetD2DDeviceContext() const { return d2d_device_context_.Get(); } - inline ID2D1Bitmap1* GetD2DTargetBitmap() const { return d2d_target_bitmap_.Get(); } + inline ID2D1Factory1* GetD2DFactory() const { KGE_ASSERT(d2d_factory_); return d2d_factory_.Get(); } + inline IWICImagingFactory* GetWICImagingFactory() const { KGE_ASSERT(imaging_factory_); return imaging_factory_.Get(); } + inline IDWriteFactory* GetDWriteFactory() const { KGE_ASSERT(dwrite_factory_); return dwrite_factory_.Get(); } + inline ID2D1Device* GetD2DDevice() const { KGE_ASSERT(d2d_device_); return d2d_device_.Get(); } + inline ID2D1DeviceContext* GetD2DDeviceContext() const { KGE_ASSERT(d2d_device_context_); return d2d_device_context_.Get(); } + inline ID2D1Bitmap1* GetD2DTargetBitmap() const { KGE_ASSERT(d2d_target_bitmap_); return d2d_target_bitmap_.Get(); } ID2D1StrokeStyle* GetStrokeStyle(StrokeStyle stroke) const; diff --git a/Kiwano/renderer/D3D10DeviceResources.h b/Kiwano/renderer/D3D10DeviceResources.h index e8540dde..35a5176d 100644 --- a/Kiwano/renderer/D3D10DeviceResources.h +++ b/Kiwano/renderer/D3D10DeviceResources.h @@ -50,12 +50,12 @@ namespace kiwano void DiscardResources(); - inline ID3D10Device* GetD3DDevice() const { return d3d_device_.Get(); } - inline ID3D10Device* GetD3DDeviceContext() const { return d3d_device_.Get(); } - inline ID3D10RenderTargetView* GetD3DRenderTargetView() const { return d3d_rt_view_.Get(); } - inline ID3D10DepthStencilView* GetD3DDepthStencilView() const { return d3d_ds_view_.Get(); } - inline IDXGIFactory* GetDXGIFactory() const { return dxgi_factory_.Get(); } - inline IDXGISwapChain* GetDXGISwapChain() const { return dxgi_swap_chain_.Get(); } + inline ID3D10Device* GetD3DDevice() const { KGE_ASSERT(d3d_device_); return d3d_device_.Get(); } + inline ID3D10Device* GetD3DDeviceContext() const { KGE_ASSERT(d3d_device_); return d3d_device_.Get(); } + inline ID3D10RenderTargetView* GetD3DRenderTargetView() const { KGE_ASSERT(d3d_rt_view_); return d3d_rt_view_.Get(); } + inline ID3D10DepthStencilView* GetD3DDepthStencilView() const { KGE_ASSERT(d3d_ds_view_); return d3d_ds_view_.Get(); } + inline IDXGIFactory* GetDXGIFactory() const { KGE_ASSERT(dxgi_factory_); return dxgi_factory_.Get(); } + inline IDXGISwapChain* GetDXGISwapChain() const { KGE_ASSERT(dxgi_swap_chain_); return dxgi_swap_chain_.Get(); } inline Size const& GetLogicalSize() const { return logical_size_; } inline Size const& GetOutputSize() const { return output_size_; } diff --git a/Kiwano/renderer/D3D11DeviceResources.h b/Kiwano/renderer/D3D11DeviceResources.h index 1ffe41e9..8d62f24d 100644 --- a/Kiwano/renderer/D3D11DeviceResources.h +++ b/Kiwano/renderer/D3D11DeviceResources.h @@ -50,12 +50,12 @@ namespace kiwano void DiscardResources(); - inline ID3D11Device* GetD3DDevice() const { return d3d_device_.Get(); } - inline ID3D11DeviceContext* GetD3DDeviceContext() const { return d3d_device_context_.Get(); } - inline ID3D11RenderTargetView* GetD3DRenderTargetView() const { return d3d_rt_view_.Get(); } - inline ID3D11DepthStencilView* GetD3DDepthStencilView() const { return d3d_ds_view_.Get(); } - inline IDXGIFactory* GetDXGIFactory() const { return dxgi_factory_.Get(); } - inline IDXGISwapChain* GetDXGISwapChain() const { return dxgi_swap_chain_.Get(); } + inline ID3D11Device* GetD3DDevice() const { KGE_ASSERT(d3d_device_); return d3d_device_.Get(); } + inline ID3D11DeviceContext* GetD3DDeviceContext() const { KGE_ASSERT(d3d_device_context_); return d3d_device_context_.Get(); } + inline ID3D11RenderTargetView* GetD3DRenderTargetView() const { KGE_ASSERT(d3d_rt_view_); return d3d_rt_view_.Get(); } + inline ID3D11DepthStencilView* GetD3DDepthStencilView() const { KGE_ASSERT(d3d_ds_view_); return d3d_ds_view_.Get(); } + inline IDXGIFactory* GetDXGIFactory() const { KGE_ASSERT(dxgi_factory_); return dxgi_factory_.Get(); } + inline IDXGISwapChain* GetDXGISwapChain() const { KGE_ASSERT(dxgi_swap_chain_); return dxgi_swap_chain_.Get(); } inline D3D_FEATURE_LEVEL GetDeviceFeatureLevel() const { return d3d_feature_level_; } inline Size const& GetLogicalSize() const { return logical_size_; } diff --git a/Kiwano/renderer/render.h b/Kiwano/renderer/render.h index 1b3f5f71..47bb45d6 100644 --- a/Kiwano/renderer/render.h +++ b/Kiwano/renderer/render.h @@ -151,11 +151,11 @@ namespace kiwano inline Size const& GetOutputSize() const { return output_size_; } - inline DeviceResources* GetDeviceResources() const { return device_resources_.Get(); } + inline DeviceResources* GetDeviceResources() const { KGE_ASSERT(device_resources_); return device_resources_.Get(); } - inline ITextRenderer* GetTextRenderer() const { return text_renderer_.Get(); } + inline ITextRenderer* GetTextRenderer() const { KGE_ASSERT(text_renderer_); return text_renderer_.Get(); } - inline ID2D1SolidColorBrush* GetSolidColorBrush() const { return solid_color_brush_.Get(); } + inline ID2D1SolidColorBrush* GetSolidColorBrush() const { KGE_ASSERT(solid_color_brush_); return solid_color_brush_.Get(); } private: Renderer();