Core: Add MovablePtr class

This commit is contained in:
Lynix 2017-09-30 13:57:25 +02:00
parent f95fc332f1
commit 2cd9fa2b7a
29 changed files with 157 additions and 259 deletions

View File

@ -10,6 +10,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Audio/Enums.hpp>
#include <Nazara/Audio/SoundEmitter.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceParameters.hpp>
@ -37,7 +38,7 @@ namespace Nz
public:
Music() = default;
Music(const Music&) = delete;
Music(Music&&) = delete; ///TODO
Music(Music&&) noexcept = default;
~Music();
bool Create(SoundStream* soundStream);
@ -66,10 +67,10 @@ namespace Nz
void Stop() override;
Music& operator=(const Music&) = delete;
Music& operator=(Music&&) = delete; ///TODO
Music& operator=(Music&&) noexcept = default;
private:
MusicImpl* m_impl = nullptr;
MovablePtr<MusicImpl> m_impl = nullptr;
bool FillAndQueueBuffer(unsigned int buffer);
void MusicThread();

View File

@ -10,6 +10,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Audio/Config.hpp>
#include <Nazara/Audio/Enums.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/RefCounted.hpp>
@ -52,7 +53,7 @@ namespace Nz
SoundBuffer() = default;
SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples);
SoundBuffer(const SoundBuffer&) = delete;
SoundBuffer(SoundBuffer&&) = delete;
SoundBuffer(SoundBuffer&&) noexcept = default;
~SoundBuffer();
bool Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples);
@ -74,7 +75,7 @@ namespace Nz
template<typename... Args> static SoundBufferRef New(Args&&... args);
SoundBuffer& operator=(const SoundBuffer&) = delete;
SoundBuffer& operator=(SoundBuffer&&) = delete; ///TODO
SoundBuffer& operator=(SoundBuffer&&) noexcept = default;
// Signals:
NazaraSignal(OnSoundBufferDestroy, const SoundBuffer* /*soundBuffer*/);
@ -86,7 +87,7 @@ namespace Nz
static bool Initialize();
static void Uninitialize();
SoundBufferImpl* m_impl = nullptr;
MovablePtr<SoundBufferImpl> m_impl = nullptr;
static SoundBufferLibrary::LibraryMap s_library;
static SoundBufferLoader::LoaderList s_loaders;

View File

@ -8,6 +8,7 @@
#define NAZARA_CONDITIONVARIABLE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
namespace Nz
{
@ -19,7 +20,7 @@ namespace Nz
public:
ConditionVariable();
ConditionVariable(const ConditionVariable&) = delete;
inline ConditionVariable(ConditionVariable&& condition) noexcept;
ConditionVariable(ConditionVariable&& condition) noexcept = default;
~ConditionVariable();
void Signal();
@ -29,10 +30,10 @@ namespace Nz
bool Wait(Mutex* mutex, UInt32 timeout);
ConditionVariable& operator=(const ConditionVariable&) = delete;
ConditionVariable& operator=(ConditionVariable&& condition) noexcept;
ConditionVariable& operator=(ConditionVariable&& condition) noexcept = default;
private:
ConditionVariableImpl* m_impl;
MovablePtr<ConditionVariableImpl> m_impl;
};
}

View File

@ -11,15 +11,6 @@ namespace Nz
/*!
* \class Nz::ConditionVariable
*/
/*!
* \brief Constructs a ConditionVariable object by moving another one
*/
inline ConditionVariable::ConditionVariable(ConditionVariable&& condition) noexcept :
m_impl(condition.m_impl)
{
condition.m_impl = nullptr;
}
}
#include <Nazara/Core/DebugOff.hpp>

View File

@ -8,6 +8,7 @@
#define NAZARA_DIRECTORY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/String.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS)
@ -35,7 +36,7 @@ namespace Nz
Directory();
Directory(const String& dirPath);
Directory(const Directory&) = delete;
Directory(Directory&&) = delete; ///TODO
Directory(Directory&&) noexcept = default;
~Directory();
void Close();
@ -67,14 +68,14 @@ namespace Nz
static bool SetCurrent(const String& dirPath);
Directory& operator=(const Directory&) = delete;
Directory& operator=(Directory&&) = delete; ///TODO
Directory& operator=(Directory&&) noexcept = delete;
private:
NazaraMutexAttrib(m_mutex, mutable)
String m_dirPath;
String m_pattern;
DirectoryImpl* m_impl;
MovablePtr<DirectoryImpl> m_impl;
};
}

View File

@ -8,6 +8,7 @@
#define NAZARA_DYNLIB_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/String.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS)
@ -28,7 +29,7 @@
namespace Nz
{
using DynLibFunc = int (*)(); // "Generic" type of poiter to function
using DynLibFunc = int (*)(); // "Generic" type of pointer to function
class DynLibImpl;
@ -37,7 +38,7 @@ namespace Nz
public:
DynLib();
DynLib(const DynLib&) = delete;
DynLib(DynLib&& lib);
DynLib(DynLib&&) noexcept = default;
~DynLib();
String GetLastError() const;
@ -49,13 +50,13 @@ namespace Nz
void Unload();
DynLib& operator=(const DynLib&) = delete;
DynLib& operator=(DynLib&& lib);
DynLib& operator=(DynLib&& lib) noexcept = default;
private:
NazaraMutexAttrib(m_mutex, mutable)
mutable String m_lastError;
DynLibImpl* m_impl;
MovablePtr<DynLibImpl> m_impl;
};
}

View File

@ -11,6 +11,7 @@
#include <Nazara/Core/ByteArray.hpp>
#include <Nazara/Core/Directory.hpp>
#include <Nazara/Core/Endianness.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Stream.hpp>
#include <Nazara/Core/String.hpp>
@ -33,7 +34,7 @@ namespace Nz
File(const String& filePath);
File(const String& filePath, OpenModeFlags openMode);
File(const File&) = delete;
File(File&& file) noexcept;
File(File&& file) noexcept = default;
~File();
bool Copy(const String& newFilePath);
@ -69,7 +70,7 @@ namespace Nz
File& operator=(const String& filePath);
File& operator=(const File&) = delete;
File& operator=(File&& file) noexcept;
File& operator=(File&& file) noexcept = default;
static String AbsolutePath(const String& filePath);
static inline ByteArray ComputeHash(HashType hash, const String& filePath);
@ -95,7 +96,7 @@ namespace Nz
std::size_t WriteBlock(const void* buffer, std::size_t size) override;
String m_filePath;
FileImpl* m_impl;
MovablePtr<FileImpl> m_impl;
};
NAZARA_CORE_API bool HashAppend(AbstractHash* hash, const File& originalFile);

View File

@ -0,0 +1,38 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_MOVABLE_PTR_HPP
#define NAZARA_MOVABLE_PTR_HPP
namespace Nz
{
template<typename T>
class MovablePtr
{
public:
MovablePtr(T* value = nullptr);
MovablePtr(const MovablePtr&) = default;
MovablePtr(MovablePtr&& ptr) noexcept;
~MovablePtr() = default;
T* Get() const;
T* operator->() const;
operator T*() const;
MovablePtr& operator=(T* value);
MovablePtr& operator=(const MovablePtr&) = default;
MovablePtr& operator=(MovablePtr&& ptr) noexcept;
private:
T* m_value;
};
}
#include <Nazara/Core/MovablePtr.inl>
#endif // NAZARA_MOVABLE_PTR_HPP

View File

@ -0,0 +1,61 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/MovablePtr.hpp>
#include <cassert>
namespace Nz
{
/*!
* \ingroup core
* \class Nz::MovablePtr
* \brief Wraps a raw (non-proprietary) to allows it to be moved implicitly
*/
template<typename T>
MovablePtr<T>::MovablePtr(T* value) :
m_value(value)
{
}
template<typename T>
MovablePtr<T>::MovablePtr(MovablePtr&& ptr) noexcept :
m_value(ptr.m_value)
{
ptr.m_value = nullptr;
}
template<typename T>
inline T* MovablePtr<T>::Get() const
{
return m_value;
}
template<typename T>
T* MovablePtr<T>::operator->() const
{
return m_value;
}
template<typename T>
MovablePtr<T>::operator T*() const
{
return m_value;
}
template<typename T>
inline MovablePtr<T>& MovablePtr<T>::operator=(T* value)
{
m_value = value;
return *this;
}
template<typename T>
MovablePtr<T>& MovablePtr<T>::operator=(MovablePtr&& ptr) noexcept
{
std::swap(m_value, ptr.m_value);
return *this;
}
}

View File

@ -8,6 +8,7 @@
#define NAZARA_MUTEX_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
namespace Nz
{
@ -20,7 +21,7 @@ namespace Nz
public:
Mutex();
Mutex(const Mutex&) = delete;
inline Mutex(Mutex&& mutex) noexcept;
Mutex(Mutex&&) noexcept = default;
~Mutex();
void Lock();
@ -28,10 +29,10 @@ namespace Nz
void Unlock();
Mutex& operator=(const Mutex&) = delete;
Mutex& operator=(Mutex&& mutex) noexcept;
Mutex& operator=(Mutex&&) noexcept = default;
private:
MutexImpl* m_impl;
MovablePtr<MutexImpl> m_impl;
};
}

View File

@ -12,15 +12,6 @@ namespace Nz
* \ingroup core
* \class Nz::Mutex
*/
/*!
* \brief Constructs a Mutex object by moving another one
*/
inline Mutex::Mutex(Mutex&& mutex) noexcept :
m_impl(mutex.m_impl)
{
mutex.m_impl = nullptr;
}
}
#include <Nazara/Core/DebugOff.hpp>

View File

@ -9,6 +9,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Functor.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <iosfwd>
namespace Nz
@ -25,7 +26,7 @@ namespace Nz
template<typename F, typename... Args> Thread(F function, Args&&... args);
template<typename C> Thread(void (C::*function)(), C* object);
Thread(const Thread&) = delete;
Thread(Thread&& other) noexcept;
Thread(Thread&& other) noexcept = default;
~Thread();
void Detach();
@ -35,7 +36,7 @@ namespace Nz
void SetName(const String& name);
Thread& operator=(const Thread&) = delete;
Thread& operator=(Thread&& thread);
Thread& operator=(Thread&& thread) noexcept = default;
static unsigned int HardwareConcurrency();
static void SetCurrentThreadName(const String& name);
@ -44,7 +45,7 @@ namespace Nz
private:
void CreateImpl(Functor* functor);
ThreadImpl* m_impl;
MovablePtr<ThreadImpl> m_impl;
};
class NAZARA_CORE_API Thread::Id

View File

@ -8,6 +8,7 @@
#define NAZARA_SOCKETPOLLER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Network/AbstractSocket.hpp>
#include <Nazara/Network/IpAddress.hpp>
@ -19,7 +20,7 @@ namespace Nz
{
public:
SocketPoller();
inline SocketPoller(SocketPoller&& socketPoller);
SocketPoller(SocketPoller&&) noexcept = default;
~SocketPoller();
void Clear();
@ -33,10 +34,10 @@ namespace Nz
bool Wait(int msTimeout);
inline SocketPoller& operator=(SocketPoller&& socketPoller);
SocketPoller& operator=(SocketPoller&&) noexcept = default;
private:
SocketPollerImpl* m_impl;
MovablePtr<SocketPollerImpl> m_impl;
};
}

View File

@ -8,30 +8,6 @@
namespace Nz
{
/*!
* \brief Constructs a SocketPoller object with another one by move semantic
*
* \param socketPoller SocketPoller to move into this
*/
inline SocketPoller::SocketPoller(SocketPoller&& socketPoller) :
m_impl(socketPoller.m_impl)
{
socketPoller.m_impl = nullptr;
}
/*!
* \brief Moves the SocketPoller into this
* \return A reference to this
*
* \param socketPoller SocketPoller to move in this
*/
inline SocketPoller& SocketPoller::operator=(SocketPoller&& socketPoller)
{
m_impl = socketPoller.m_impl;
socketPoller.m_impl = nullptr;
return *this;
}
}
#include <Nazara/Network/DebugOff.hpp>

View File

@ -11,6 +11,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ConditionVariable.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Mutex.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Vector2.hpp>
@ -40,7 +41,7 @@ namespace Nz
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
inline explicit Window(WindowHandle handle);
Window(const Window&) = delete;
inline Window(Window&& window) noexcept;
Window(Window&&) = default;
virtual ~Window();
inline void Close();
@ -103,14 +104,14 @@ namespace Nz
bool WaitEvent(WindowEvent* event);
Window& operator=(const Window&) = delete;
inline Window& operator=(Window&& window);
Window& operator=(Window&&) = default;
protected:
virtual bool OnWindowCreated();
virtual void OnWindowDestroy();
virtual void OnWindowResized();
WindowImpl* m_impl;
MovablePtr<WindowImpl> m_impl;
private:
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;

View File

@ -27,26 +27,6 @@ namespace Nz
Create(handle);
}
/*!
* \brief Constructs a Window object by moving another one
*/
inline Window::Window(Window&& window) noexcept :
m_impl(window.m_impl),
m_events(std::move(window.m_events)),
m_pendingEvents(std::move(window.m_pendingEvents)),
m_eventCondition(std::move(window.m_eventCondition)),
m_eventHandler(std::move(window.m_eventHandler)),
m_eventMutex(std::move(window.m_eventMutex)),
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
m_closed(window.m_closed),
m_closeOnQuit(window.m_closeOnQuit),
m_eventPolling(window.m_eventPolling),
m_ownsWindow(window.m_ownsWindow),
m_waitForEvent(window.m_waitForEvent)
{
window.m_impl = nullptr;
}
inline void Window::Close()
{
m_closed = true; // The window will be closed at the next non-const IsOpen() call
@ -145,32 +125,6 @@ namespace Nz
}
}
}
/*!
* \brief Moves a window to another window object
* \return A reference to the object
*/
inline Window& Window::operator=(Window&& window)
{
Destroy();
m_closed = window.m_closed;
m_closeOnQuit = window.m_closeOnQuit;
m_eventCondition = std::move(window.m_eventCondition);
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
m_eventHandler = std::move(window.m_eventHandler);
m_eventMutex = std::move(window.m_eventMutex);
m_eventPolling = window.m_eventPolling;
m_impl = window.m_impl;
m_events = std::move(window.m_events);
m_pendingEvents = std::move(window.m_pendingEvents);
m_ownsWindow = window.m_ownsWindow;
m_waitForEvent = window.m_waitForEvent;
window.m_impl = nullptr;
return *this;
}
}
#include <Nazara/Platform/DebugOff.hpp>

View File

@ -8,6 +8,7 @@
#define NAZARA_CONTEXT_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@ -35,7 +36,7 @@ namespace Nz
public:
Context() = default;
Context(const Context&) = delete;
Context(Context&&) = delete;
Context(Context&&) noexcept = default;
~Context();
bool Create(const ContextParameters& parameters = ContextParameters());
@ -52,7 +53,7 @@ namespace Nz
void SwapBuffers();
Context& operator=(const Context&) = delete;
Context& operator=(Context&&) = delete;
Context& operator=(Context&&) noexcept = default;
static bool EnsureContext();
@ -69,7 +70,7 @@ namespace Nz
static void Uninitialize();
ContextParameters m_parameters;
ContextImpl* m_impl = nullptr;
MovablePtr<ContextImpl> m_impl = nullptr;
static std::unique_ptr<Context> s_reference;
static std::vector<std::unique_ptr<Context>> s_contexts;

View File

@ -8,6 +8,7 @@
#define NAZARA_RENDERTEXTURE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
@ -30,7 +31,7 @@ namespace Nz
public:
inline RenderTexture();
RenderTexture(const RenderTexture&) = delete;
RenderTexture(RenderTexture&&) = delete; ///TODO?
RenderTexture(RenderTexture&&) noexcept = default;
inline ~RenderTexture();
bool AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, RenderBuffer* buffer);
@ -64,7 +65,7 @@ namespace Nz
bool HasContext() const override;
RenderTexture& operator=(const RenderTexture&) = delete;
RenderTexture& operator=(RenderTexture&&) = delete; ///TODO?
RenderTexture& operator=(RenderTexture&&) noexcept = default;
static inline void Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false);
static void Blit(RenderTexture* src, Rectui srcRect, RenderTexture* dst, Rectui dstRect, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false);
@ -85,7 +86,7 @@ namespace Nz
void UpdateSize() const;
void UpdateTargets() const;
RenderTextureImpl* m_impl;
MovablePtr<RenderTextureImpl> m_impl;
mutable bool m_checked ;
mutable bool m_drawBuffersUpdated;
mutable bool m_sizeUpdated;

View File

@ -8,6 +8,7 @@
#define NAZARA_ANIMATION_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
@ -98,7 +99,7 @@ namespace Nz
static bool Initialize();
static void Uninitialize();
AnimationImpl* m_impl = nullptr;
MovablePtr<AnimationImpl> m_impl = nullptr;
static AnimationLibrary::LibraryMap s_library;
static AnimationLoader::LoaderList s_loaders;

View File

@ -102,18 +102,4 @@ namespace Nz
NazaraAssert(mutex != nullptr, "Mutex must be valid");
return m_impl->Wait(mutex->m_impl, timeout);
}
/*!
* \brief Moves a condition to another ConditionVariable object
* \return A reference to the object
*/
ConditionVariable& ConditionVariable::operator=(ConditionVariable&& condition) noexcept
{
delete m_impl;
m_impl = condition.m_impl;
condition.m_impl = nullptr;
return *this;
}
}

View File

@ -40,19 +40,6 @@ namespace Nz
{
}
/*!
* \brief Constructs a DynLib object by move semantic
*
* \param lib DynLib to move into this
*/
DynLib::DynLib(DynLib&& lib) :
m_lastError(std::move(lib.m_lastError)),
m_impl(lib.m_impl)
{
lib.m_impl = nullptr;
}
/*!
* \brief Destructs the object and calls Unload
*
@ -150,23 +137,4 @@ namespace Nz
m_impl = nullptr;
}
}
/*!
* \brief Moves the other lib into this
* \return A reference to this
*
* \param lib DynLib to move in this
*/
DynLib& DynLib::operator=(DynLib&& lib)
{
Unload();
m_impl = lib.m_impl;
m_lastError = std::move(lib.m_lastError);
lib.m_impl = nullptr;
return *this;
}
}

View File

@ -70,20 +70,6 @@ namespace Nz
Open(filePath, openMode);
}
/*!
* \brief Constructs a File object by move semantic
*
* \param file File to move into this
*/
File::File(File&& file) noexcept :
Stream(std::move(file)),
m_filePath(std::move(file.m_filePath)),
m_impl(file.m_impl)
{
file.m_impl = nullptr;
}
/*!
* \brief Destructs the object and calls Close
*
@ -487,23 +473,6 @@ namespace Nz
return *this;
}
/*!
* \brief Moves the other file into this
* \return A reference to this
*
* \param file File to move in this
*/
File& File::operator=(File&& file) noexcept
{
NazaraLock(m_mutex)
std::swap(m_filePath, file.m_filePath);
std::swap(m_impl, file.m_impl);
return *this;
}
/*!
* \brief Gets the absolute path of the file
* \return Absolute path of the file

View File

@ -77,18 +77,4 @@ namespace Nz
NazaraAssert(m_impl, "Cannot unlock a moved mutex");
m_impl->Unlock();
}
/*!
* \brief Moves a mutex to another mutex object
* \return A reference to the object
*/
Mutex& Mutex::operator=(Mutex&& mutex) noexcept
{
delete m_impl;
m_impl = mutex.m_impl;
mutex.m_impl = nullptr;
return *this;
}
}

View File

@ -6,6 +6,7 @@
#include <Nazara/Core/Config.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/HardwareInfo.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <ostream>
#include <stdexcept>
@ -36,18 +37,6 @@ namespace Nz
{
}
/*!
* \brief Constructs a Thread<T> object by move semantic
*
* \param other Thread to move into this
*/
Thread::Thread(Thread&& other) noexcept :
m_impl(other.m_impl)
{
other.m_impl = nullptr;
}
/*!
* \brief Waits that the thread ends and then destroys this
*/
@ -136,30 +125,6 @@ namespace Nz
m_impl->SetName(name);
}
/*!
* \brief Moves the other thread into this
* \return A reference to this
*
* \param thread Thread to move in this
*
* \remark Produce a NazaraError if no functor was assigned and NAZARA_CORE_SAFE is defined
* \remark And call std::terminate if no functor was assigned and NAZARA_CORE_SAFE is defined
*/
Thread& Thread::operator=(Thread&& thread)
{
#if NAZARA_CORE_SAFE
if (m_impl)
{
NazaraError("This thread cannot be joined");
std::terminate();
}
#endif
std::swap(m_impl, thread.m_impl);
return *this;
}
/*!
* \brief Gets the number of simulatenous threads that can run on the same cpu
* \return The number of simulatenous threads

View File

@ -50,7 +50,7 @@ namespace Nz
}
}
bool ContextImpl::Activate()
bool ContextImpl::Activate() const
{
return glXMakeCurrent(m_display, m_window, m_context) == true;
}

View File

@ -19,7 +19,7 @@ namespace Nz
ContextImpl();
~ContextImpl();
bool Activate();
bool Activate() const;
bool Create(ContextParameters& parameters);

View File

@ -20,7 +20,7 @@ namespace Nz
{
}
bool ContextImpl::Activate()
bool ContextImpl::Activate() const
{
return wglMakeCurrent(m_deviceContext, m_context) == TRUE;
}

View File

@ -18,7 +18,7 @@ namespace Nz
public:
ContextImpl();
bool Activate();
bool Activate() const;
bool Create(ContextParameters& parameters);

View File

@ -88,8 +88,8 @@ namespace Nz
{
Joint* joint = targetSkeleton->GetJoint(i);
SequenceJoint& sequenceJointA = m_impl->sequenceJoints[frameA*m_impl->jointCount + i];
SequenceJoint& sequenceJointB = m_impl->sequenceJoints[frameB*m_impl->jointCount + i];
const SequenceJoint& sequenceJointA = m_impl->sequenceJoints[frameA*m_impl->jointCount + i];
const SequenceJoint& sequenceJointB = m_impl->sequenceJoints[frameB*m_impl->jointCount + i];
joint->SetPosition(Vector3f::Lerp(sequenceJointA.position, sequenceJointB.position, interpolation));
joint->SetRotation(Quaternionf::Slerp(sequenceJointA.rotation, sequenceJointB.rotation, interpolation));