Merge branch 'master' into console-widget

This commit is contained in:
Jérôme Leclercq 2018-04-12 12:47:17 +02:00
commit 16014d3f37
1058 changed files with 145127 additions and 7192 deletions

View File

@ -9,6 +9,7 @@ insert_final_newline = true
trim_trailing_whitespace = true
[*.{hpp,inl,cpp,lua}]
indent_size = 4
indent_style = tab
[*.html]

2
.gitattributes vendored
View File

@ -1,4 +1,4 @@
# Auto detect text files and perform LF normalization
* text=auto
extlibs/* linguist-vendored
thirdparty/* linguist-vendored
NazaraModuleTemplate/* linguist-vendored

3
.gitignore vendored
View File

@ -4,6 +4,9 @@ build/config.lua
# Nazara libraries
lib/*
# Self-hosted thirdparty libraries binaries
thirdparty/genlib/*
# Nazara plugin libraries
plugins/lib/*

View File

@ -1,54 +1,26 @@
language:
cpp
dist:
trusty
addons:
apt:
sources:
- llvm-toolchain-precise-3.7
- ubuntu-toolchain-r-test
packages:
- clang-3.7
- libassimp-dev
- libfreetype6-dev
- libgl1-mesa-dev
- libopenal-dev
- libsndfile1-dev
- libx11-dev
- libxcb-cursor-dev
- libxcb-ewmh-dev
- libxcb-icccm4-dev
- libxcb-keysyms1-dev
- libxcb-randr0-dev
- mesa-common-dev
sudo:
required
notifications:
email: true
compiler:
- clang
services:
- docker
env:
global:
- COMPILER=clang++-3.7
- CFLAGS="-Wall -Wextra"
- CXXFLAGS="-Wall -Wextra"
matrix:
- CONFIG=debug
- CONFIG=release
before_install:
- docker build -t nazara .
script:
- cd build &&
./premake5-linux64 --cc=clang gmake
- cd gmake &&
make -j4 -f NazaraEngine.make config=${CONFIG}dynamic_x64
after_script:
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ &&
cd ../../tests &&
./NazaraUnitTestsServer
- docker run --name Nazara -v `pwd`:/NazaraEngine nazara
sh -c "
cd build &&
./premake5-linux64 --cc=clang gmake &&
cd gmake &&
make -j4 &&
cd ../../tests &&
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../lib/gmake/x64/:../extlibs/lib/gmake/x64/ &&
./NazaraUnitTestsServer
"

362
ChangeLog.md Normal file
View File

@ -0,0 +1,362 @@
# Upcoming version:
Miscellaneous:
- Add possibility to excludes with one commande all tests/examples/tools/etc.
- Units tests are now part of the "test" exclusion category
- Fix project exclusion not working (but correctly excluding projects relying upon it)
- Upgraded Catch to v2.0.1
- ⚠️ Merged NazaraExtlibs workspace to main workspace (allowing `make` command to work without -f parameter) and removed extern libraries precompiled
- Updated stb_image to version 2.16 and stb_image_write to version 1.07 (allowing support for JPEG writing)
- ⚠️ Renamed extlibs folder to thirdparty
- Partial fix for Premake regenerating projects for no reason
- FirstScene now uses the EventHandler (#151)
- ⚠️ Rename Prerequesites.hpp to Prerequisites.hpp (#153)
- Updated premake5-linux64 with a nightly to fix a build error when a previous version of Nazara was installed on the system.
- Fix compilation with some MinGW distributions
- Add Lua unit tests
- NDEBUG is now defined in Release
- Replaced typedefs keywords with modern using keywords
Nazara Engine:
- VertexMapper:GetComponentPtr no longer throw an error if component is disabled or incompatible with template type, instead a null pointer is returned.
- Bitset swap operation is now correctly marked as noexcept`
- Mesh loaders now takes MeshParams vertexDeclaration into account
- ⚠️ Replaced RenderTarget::Get[Height|Width] by RenderTarget::GetSize
- ⚠️ Removed Window::Get[Height|Width] methods
- Fix compilation error when including Nazara/Renderer/ShaderBuilder.hpp
- Fix reflection sometimes being enabled by default for Materials
- Fix built-in unserialization of std::string which was corruption memory
- Fix Buffer::Destroy() not really destroying buffer
- Fix Bitset::TestAll() returned wrong result on full of '1' bitset
- ByteStream now returns the number of bytes written as the other streams
- Total rewriting of the color conversions
- Fix NormalizeAngle to the correct range
- Fix BoundingVolume::Lerp() with Extend_Null
- Simplification of methods Matrix4::SetRotation() and Quaternion::MakeRotationBetween()
- Fix mouve moved event generated on X11 platform when doing Mouse::SetPosition()
- EnumAsFlags specialization no longer require a `value` field to enable flags operators
- EnumAsFlags specialization `max` field can be of the same type as the enum
- Flags class now use an UInt8 or UInt16 to store the value if possible.
- Flags class is now explicitly convertible to any integer type of the same size (or greater size) than the internal size.
- Fix String movement constructor, which was leaving a null shared string (which was not reusable)
- Add Flags<E>::Test method, in order to test one or multiple flags at once.
- ⚠️ Vector2, Vector3 and Vector4 array/pointer constructor is now explicit to prevent some mistakes as `Vector2 vec2; vec2 = 0;`
- Fix RigidBody2D::SetGeom attribute copy and possible crash with static objects
- Fix error when opening a non-existent file on Posix
- Fix Directory::Create not working on Posix systems when recursive option was enabled
- Fix default directory permission (now created with 777)
- Add linear and angular damping accessor to RigidBody3D
- Fix MemoryStream::WriteBlock "Invalid buffer" assertion triggering when writing a zero-sized block
- ⚠️ Rename RigidBody3D::[Get|Set]Velocity to [Get|Set]LinearVelocity
- Fix RigidBody3D copy constructor not copying all physics states (angular/linear damping/velocity, mass center, position and rotation)
- Add RigidBody3D simulation control (via EnableSimulation and IsSimulationEnabled), which allows to disable physics and collisions at will.
- Fix some uninitialized values (found by Valgrind) in Network module
- Fix possible infinite recursion when outputting a Thread::Id object
- ⚠️ Replaced implicit conversion from a Nz::String to a std::string by an explicit method ToStdString()
- Fix LuaInstance movement constructor/assignment operator which was corrupting Lua memory
- Fix potential bug on SocketImpl::Connect (used by TcpClient::Connect) on POSIX platforms
- It is now possible to initialize a StackArray with a size of zero on every platforms (this was not possible on non-Windows platforms before)
- Calling PlacementDestroy on a null pointer is now a no-op (was triggering an undefined behavior)
- Fix OBJParser relative offsets handling
- Add JPEG image saver
- Update Constraint2Ds classes (Add : Ref, Library, ConstRef, New function and Update : ctors)
- Fix LuaClass not working correctly when Lua stack wasn't empty
- Add RigidBody2D simulation control (via EnableSimulation and IsSimulationEnabled), which allows to disable physics and collisions at will.
- ⚠️ LuaInstance no longer load all lua libraries on construction, this is done in the new LoadLibraries method which allows you to excludes some libraries
- Clock::Restart now returns the elapsed microseconds since construction or last Restart call
- Add PhysWorld2D::[Get|Set]IterationCount to control how many iterations chipmunk will perform per step.
- Add PhysWorld2D::UseSpatialHash to use spatial hashing instead of bounding box trees, which may speedup simulation in some cases.
- Add PhysWorld[2D|3D] max step count per Step call (default: 50), to avoid spirals of death when the physics engine simulation time is over step size.
- Fix Window triggering KeyPressed event after triggering a resize/movement event on Windows
- (WIP) Add support for materials and callbacks to Physics3D module.
- PhysWorld3D class is now movable
- ⚠️ Removed array/pointer constructor from Vector classes
- Fixed Platform module not being classified as client-only
- ⚠️ Renamed Bitset::Read to Bitset::Write
- Fixed ENetCompressor class destructor not being virtual
- ⚠️ Added a type tag parameter to Serialize and Unserialize functions, to prevent implicit conversions with overloads
- Added Collider3D::ForEachPolygon method, allowing construction of a debug mesh based on the physics collider
- Fixed ConvexCollider3D::GetType returning Compound instead of ConvexHull.
- Dual-stack sockets are now supported (by using NetProtocol_Any at creation/opening)
- Fixed IPv6 addresses not being correctly encoded/decoded from the socket API.
- Fix copy and move semantic on HandledObject and ObjectHandle
- Add support for emissive and normal maps in .mtl loader using custom keywords ([map_]emissive and [map_]normal)
- Music, Sound and SoundEmitter are now movable
- Fixed Sound copy which was not copying looping state
- Fixed Billboard bounding volume
- Fixed Directory::GetResultSize and Directory::IsResultDirectory on Posix systems
- Fixed Quaternion::Inverse which was not correctly normalizing quaternions
Nazara Development Kit:
- Added ImageWidget (#139)
- ⚠️ Removed TextAreaWidget::GetLineCount
- Fix World movement which could cause crashes when updating systems
- Fix crash occuring sometimes on keyboard event
- Add support for EchoMode to TextAreaWidget (which allows to setup password text area)
- Add signal OnTextChanged to TextAreaWidget
- ⚠️ Removed TextAreaWidget::GetGlyphUnderCursor
- Fixed minor issues relative to TextAreaWidget cursor handling
- ⚠️ Renamed BaseWidget::GrabKeyboard method to SetFocus
- Added BaseWidget::ClearFocus method and OnFocus[Lost|Received] virtual methods
- TextAreaWidget will now show a cursor as long as it has focus
- Fix BaseWidget linking error on Linux
- ⚠️ Rewrite StateMachine to fix instantaneous state changing (state change is no longer effective until the next update call)
- Fix entities destruction when coming from World::Clear() (also called by destructor), which invalidated world entities handles before destroying entities (preventing destruction callback to get valid entities handles from world)
- Add Entity::Disable method, which is a shortcut to Enable(false)
- Add BaseWidget::HasFocus
- Fix TextAreaWidget cursor sometimes showing up in readonly mode
- ⚠️ BaseWidget::OnKeyPressed now returns a boolean to indicate if it should block default action (such as tab to switch to the previous/next widget)
- Pressing tab/shift-tab will now move to the next/previous widget able to be focused on
- Fix GraphicsComponent::Clear method now clearing reflective states
- Add linear and angular damping accessor to PhysicsComponent3D
- Fix GraphicsComponent cloning not copying renderable local matrices
- ⚠️ Rename PhysicsComponent3D::[Get|Set]Velocity to [Get|Set]LinearVelocity
- Add OnEntityDisabled and OnEntityEnabled callbacks to BaseComponent
- Disabling an entity with a CollisionComponent3D or PhysicsComponent3D will properly disable it from the physics simulation
- It is now possible to disable synchronization between a PhysicsComponent3D and the NodeComponent
- Fix PhysicsComponent3D copy which was not copying physics state (such as mass, mass center, damping values, gravity factor and auto-sleep mode)
- Fix TextAreaWidget::Clear crash
- Add ConstraintComponent2D class
- Fix CollisionComponent3D initialization (teleportation to their real coordinates) which could sometimes mess up the physics scene.
- ⚠️ Renamed World::Update() to World::Refresh() for more clarity and to differentiate it from World::Update(elapsedTime)
- World entity ids are now reused from lowest to highest (they were previously reused in reverse order of death)
- World now has an internal profiler, allowing to measure the refresh and system update time
- CollisionComponent[2D|3D] and PhysicsComponent[2D|3D] now configures their internal RigidBody userdata to the entity ID they belong to (useful for callbacks).
- Fixed EntityList copy/movement assignment operator which was not properly unregistering contained entities.
- ListenerSystem now handles velocity in a generic way (no longer require a VelocityComponent and is compatible with physics)
- World now has const getters for systems
- Add World::ForEachSystem method, allowing iteration on every active system on a specific world
- Fix GraphicsComponent bounding volume not taking local matrix in account
- ⚠️ Rewrote all render queue system, which should be more efficient, take scissor box into account
- ⚠️ All widgets are now bound to a scissor box when rendering
# 0.4:
Build system:
- ⚠️ Update premake binaries version to premake5-alpha12
- It is now possible to generate a tool project running which will run the premake when built on Windows (PremakeProject=true).
- Added VS2017 Windows shortcut
Nazara Engine:
- Improved Particle Demo
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/126 File locking now works properly on Linux
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/136 Fixed std::getline with Nz::String not setting eofbit.
- Added support for CRC64
- Added MovablePtr utility class
- ⚠️ StackAllocation class has been replaced with much-more user-friendly StackArray class.
- ⚠️ ParameterList now takes double and long long parameter instead of float and int parameters.
- Threads can now be named (for debug purposes)
- Added ParameterList::ForEach method
- Flags<T> operators works in the global namespace as well
- **Added support for skybox reflections, realtime reflections are on the tracks!**
- ⚠️ InstancedRenderable now handle materials and skins in a generic way (which means you can use skins on every InstancedRenderable such as Billboard, Sprites, etc.).
- **Added support for coroutines (LuaCoroutine class)**
- ⚠️ Introduction of a new class, LuaState (inherited by LuaCoroutine and LuaInstance).
- **Added ENet protocol support for reliable UDP communication**
- ⚠️ SocketPoller is now able to wait on read/write status of socket
- ⚠️ SocketPoller::Wait() has now support for infinite waiting (-1)
- Added UdpSocket::ReceiveMultiple method
- **Added WIP shader build (based on AST, with support for GLSL)**
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/127 Fixed RigidBody2D::GetAABB() wrong AABB
- **Added basic support for constraints**
- Added support for collision callbacks
- Added support for raycast
- Added support for nearest body queries
- Added support for debug draw
- Added support for damping
- ⚠️ RigidBody2D created without mass are now kinematic by default instead of statics
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/128 ⚠️ **Platform-specific classes were moved to a new module: Platform** (this means Utility module no longer needs to be linked to X11/xcb or gdi32).
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/135 ⚠️ Improved vertex declarations (they now checks template type with real type)
- Mesh index buffer optimization is now disabled by default in debug mode
- It is now possible to set the vertex declaration wanted when building/loading a mesh
- It is now possible to set index/vertex buffer usage flags when building/loading a mesh
- Added VertexMapper::GetVertexBuffer()
- Added VertexMapper::GetVertexCount()
- Added VertexMapper::HasComponentOfType()
- Fixed SimpleTextDrawer bounds computation
Nazara Development Kit:
- ⚠️ Components no longer need to be copyable by assignation
- Added BaseComponent::GetEntity()
- ⚠Systems are no longer copyable/clonable
- ⚠World::[Get|Set]UpdateRate has been renamed World::[Get|Set]FixedUpdateRate.
- Added World::[Get|Set]MaximumUpdateRate.
- Added BaseWidget::CenterHorizontal()
- Added BaseWidget::CenterVertical()
- EntityHandle are now handled in such a way they will never move in memory until a world update is triggered, this means it is now safe to returns const reference to EntityHandle as long as you do not keep them from one world update to another.
- Fixed a crash when destroying a hovered widget
- Added CollisionComponent2D::GetAABB()
- Added Entity::OnEntityDestruction signal
- ⚠EntityList were remade to take less memory and are easier to use but can only be iterated from front to back
- Entities are now automatically removed from EntityLists when destroyed.
- It is no longer required for a component to have a default constructor to be binded to Lua.
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/123 StateMachine can now handle multiple states at once
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/132 Added ProgressBarWidget
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/133 ButtonWidget color and texture can now be customized
- https://github.com/DigitalPulseSoftware/NazaraEngine/pull/130 Added CheckboxWidget
- Added OnEntityDestruction() event on components in order to let them do better cleanup.
# 0.3
Build system:
- Added `Configurations` parameter for build system, with support for ReleaseWithDebug. (67dcf166b80b4de1ecb5256a271a5ac80526435d)
Nazara Engine:
- **Added new particle demo (Space battle)**. (3c6a6cd3a9294e5ba577af9ec3bef695438c28b7)
- **Added back automatic Frustum Culling**. (a349b931e6a5b45586316763a458e1d89758542a)
- **Added Nz::Flags class to properly handle enum flags**. (d6b793f46178a05998182a4bbe595c425465eb07)
- **Refactored Buffer classes to prepare the new Renderer**. (9e0fd0a8e82567d03f063728e76f6dd5571760f2)
- **Added a way to override über-shaders used by the engine at runtime**. (d2d6bae47f326562a2c50631f169100e35ecdd09)
- ⚠️ **Reworked Nz::Cursor, it now includes default system cursors, allows to retrieve its image and is ref-counted** (6751d480b152a6203262b72e2cbe120007741621, 6751d480b152a6203262b72e2cbe120007741621, 0cab95e8aea4d2fb8a58c9dba2d609e33c748093).
- ⚠️ Nz::WindowCursor has been renamed to Nz::SystemCursor. (6751d480b152a6203262b72e2cbe120007741621)
- Added Nz::CursorController class, for indirect cursor control. (a2e5e4874469958b658c24d8a52bb9bc274e9398)
- Added Nz::UdpSocket::SendMultiple method, allowing to merge multiple buffers into the same datagram. (ea0d42f4234bcca184bb42aef16fb2a4e1346913).
- Added [Nz::TcpClient::SendMultiple](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_tcp_client.html#a495c32beb46ed9192699a3b82d358035) method, allowing to send multiple buffers at once.
- Added [Nz::PlacementDestroy](https://nazara.digitalpulsesoftware.net/doc/namespace_nz.html#a27c8667def991fc896c5beff3e62668a). (ea985fa76586762f008e4054938db3234eeaf0cb)
- Added [Nz::String::Format](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_string.html#a4b699982e7f9ea38f6d44b43ac1e2040) and [Nz::String::FormatVA](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_string.html#abe0fcbce11224b157ac756b60e8dee92) static methods. (cc6e4127dc6c61799a64404770992cef0804ad34).
- Added [Nz::ParticleGroup::GetBuffer](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_particle_mapper.html#aefe1b251efc8c9b8668842275561be0c) method. (4dc85789b59e50d964c83321dbd4b6485c04bef6)
- Added Nz::ParticleMapper::GetPointer method. (1f4e6c2d1594b7bb9dd6f4ea5480fdd16cf5f208)
- ⚠️ Structures provied by ParticleStruct header now have a float life. (472d964d587d906764ad1e05bfcc9ab1bf979483)
- Fixed scale property of Nz::TextSprite not affecting its bounding volume. (52b29bac775823294c4ad7de70f4dc3f4adfa743)
- ⚠️ Nz:MeshParams::flipUVs has been replaced by texCoordOffset and texCoordScale. (a1a7d908adc060fd7a43491c903dfe3b501d98e5)
- Fixed [Nz::Music::Stop](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_music.html#a9f0eb20328d6b35ab290b19364e95ee8) which was not resetting the playing offset. (12d7bc9aa3b672fc855478904072ed18f06e37ca, 24be97447af5c55b444a96e8d5d000e590279171)
- Reworked LuaBinding classes to try to improve compile time and generated objects memory. (5555d24afca2ec766c7625bb8e959560677b69c2).
- ⚠️ Convert OpenMode to use the new Nz::Flags class. (49dfe31fa036cdac4f531a15972e2bd52fa9ab57)
- ⚠️ Convert StreamOption to use the new Nz::Flags class. (49dfe31fa036cdac4f531a15972e2bd52fa9ab57)
- ⚠️ Convert WindowStyleFlags to use the new Nz::Flags class. (6c0422350fea520f96253df1113ee7c49233bd06)
- ⚠️ Fix typo in OpenMode_MustExist (previously written as "MustExit"). (445ab13ef8a78c07697556ae50086a9276cbf7c2)
- Added [Nz::String::GetCharacterPosition](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_string.html#acd89bc8d5afaa808c8baa480501d5f58) method. (2f4ca23cdaefc8350a95d2d6aa741602b5ee00f1)
- Exposed Nz::SoftwareBuffer class. (842786d2d482890ad3ed9ba88613f1d2a0f901ba)
- ⚠️ Removed Sphere::SquaredDistance method, use Vector3::SquaredDistance with its center instead. (5b017aecfdb86246fe8517453376801b00c23843)
- Fixed SceneAmbient shader uniform not being sent by DepthRenderTechnique. (83e345a2fc25073a9f10b0a3547a75692613f9b3)
- Fixed light selection bug (causing an object to not have any light on it although it is within its radius). (9c04d79b2906940067a32d84800edd1ffd38d9bd)
- Renderer::SetTexture and Renderer::SetTextureSampler now takes `unsigned int` instead of `UInt8` texture indexes. (09c2cbf1c5eeadac52c72459b0fb6df3064fc16a)
- When a shader fails to validate, its uniform are now dumped to the log. (0d37a3d4bf68bce9f533ad8c95225809cc312cdd)
- When a shader fails to compile, its code is now dumped to the log. (53ee8915fa0255b5c7492952919edd3a70e29b6c)
- ⚠️ Texture units used by Nazara are now static, fixes a bug with shadow. (b290a1233d725636d73c3bd8b37c394d93789524)
- Nz::Signal move constructor and assignement operators are now `noexcept`. (00144e944e6d8d894aef8b7bced9a6b364091626)
- Nz::EventHandler is now a handled object. (498b84fc690bae084a63ef379452cd45173c933a).
- Added a way to specify receive and send buffer size per socket. (c4459f5910d1f7e5833e2cbdca1dbd048a9a0416).
- Fixed ObjectHandle <= operator. (6f601101d23fe790dd83a1f69a137009116ad91b)
- Fixed Nz::UdpSocket::Receive failing when peers suddenly closes its socket. (12401e0e2f0cee0ab8fcd9124cce368e54f8037b)
- All noises classes now uses std::mt19937 as a random number generator, to ensure the same results on every machine. (1f5ea9839016964c173d919263827dee69ecb65d)
Nazara Development Kit:
- **Added basic widgets**. (c8a12083b3133e946bf60dd060331a4b4631f8d8)
- VelocitySystem will no longer affect entities with PhysicsComponent2D. (a6853234412c744cdcb28344f02f7b0c92704d77)
- Fixed EulerAngles constructor in Lua. (d55149a0a70f6230b6f1c3fb50e37dc82a2feb9f)
- Fixed Component::OnDetached not being called on entity destruction. (5b777eb4853639d7aeb232ca46d17f0d432f47ca)
Nazara Engine:
# 0.2.1
Nazara Engine:
- Nazara binaries are now compiled with Run-Time Type-Information. (a70acdc8f44010627a65282fd3099202116d3e13)
- Nazara demos are now compiled with relative dependencies on Linux.
(d6fbb4c408d48c4a768fad7b43460c76a0df1777)
- Added [**Nz::BitCount**](https://nazara.digitalpulsesoftware.net/doc/group__core.html#ga6bfbcff78eb6cfbe3ddaedcfc8c04196) function. (82e31a3ec8449da6618f41690164c2e1d883edb4)
- Added [**Nz::Bitset::AppendBits**](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_bitset.html#a5ca8f365006c86d6d699d02471904f7e) method. (b018a400499a2356c4455a40d9f6a6c12b3cb36b)
- Added [**Nz::Bitset::Read**](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_bitset.html#aca204e1d71e36d6c8c2c544ffd9824ac) method. (f0c40ecb2f2f64f5af46f38e4b589d8c1dea824c)
- Added [**Nz::Bitset::Reverse**](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_bitset.html#af372e64f33a2114837fb25daffcc1008) method. (0abd1bbfbf6b949e350a78170aae1b45698620eb)
- Added [**Nz::Bitset::FromPointer**](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_bitset.html#a487836f91821e6d7901eb753baf47de3) static method. (f0c40ecb2f2f64f5af46f38e4b589d8c1dea824c)
- Added an operator<< for `ostream` and `Nz::Bitset`. (9d9efac2baf29842e58b3e73f255ca06cb24d1fb)
- Added `Nz::Image::HasAlpha` method. (1029b37d3654aea9fcc4fd2a43e6d32c9842268a)
- Added a [**Sprite::SetMaterial**](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_sprite.html#a3074f991b72af8146c5b5ba2fdda42fa) overload taking a material name. (d50f5ed7c88e613e01c76c3765d86b2014773ba8)
- Added a [**Sprite::SetTexture**](https://nazara.digitalpulsesoftware.net/doc/class_nz_1_1_sprite.html#a6ddf41ffff1e155a99b06487e72ae47d) overload taking a texture name. (d50f5ed7c88e613e01c76c3765d86b2014773ba8)
- Added Nz::SegmentCollider2D class. (0ede1e893aab6ab159b57eea24af273e82d68d16)
- Nz::CountBits now returns a `std::size_t`. (63e9d77e77d35f9f0b14529dd8d86b2cd39b751e)
- Improved bitset unit tests by checking them with multiple blocks size (f6426a53d77ccee2297a0efa8b811e482f65a48b)
- `NDEBUG` is no longer automatically defined by Nazara headers. (fef5337279ea33f0675c55002f1df77234252168)
- The engine now asserts on CHAR_BIT equality to 8. (01be79f8524e5f68e713a6070d3b5aacfa595aa5)
- Fixed a crash occuring after a RigidBody2D got modified/removed. (874362a606f513be1888997f2f1b87cad4fbca53)
- Fixed Nz::Bitset::PerformandsAND (called by &= operator) giving wrong result. (ecfce94461d1c2b96bdab7f957e14856c7100108)
- PixelFormats with over 64 bits per components are now rejected. (119b7bcad4dd16f5499e2ec6a9da48c3985b036f)
- Fixed `PixelFormatInfo` masks bit order. (62197da39e6dccbe957794e5422454c49c4f039f)
- Fixed RigidBody2D collisions. (c99d7fd640a69f18a5f615d2ebc6d7f15d329f6e)
- Fixed RigidBody2D::AddForce application point. (7eb240e4a1fa1af16aa68197ec688f71ff3d32c4)
- Fixed Nz::Quaternion::Lerp compilation. (739291651eef4bc90ad14342415bf88d20142f0f)
Nazara Development Kit:
- Fixed missing [group **NDK**](https://nazara.digitalpulsesoftware.net/doc/group___n_d_k.html) in documentation. (51c6b0241c074c64319f2347eaea72992951322f)
- Fixed CollisionComponent2D position when used alone. (e24d433f7563fcd4156ac3be01570752bd7c734a)
- Including the following changes in the Lua API:
- CameraComponent is now accessible from Lua (cfb40bf4dc4777012a11fea528f8203ef53c5686).
- Methods from EulerAngles and Quaternions classes are now accessible from Lua. (0886292c00ea3826c6c23e1e9d1c76bd6c0cf28d)
- Keyboard is now accessible from Lua (e50c9757e4f64aed553ebfa3859d2642c03ba58e)
# 0.2
Build system:
- Added a .editorconfig file to help consistency (8126c981946591c4e5a4bc0e56268aecbe6a76f1)
- Code::Blocks is now supported by Premake5 (40276139b52e0aae7daf20d3f0a84b007e84a993)
- Global headers no longer include generation date. (fd3161c8e9bb9e262ed2359d679f1c47564dbac2)
- Upgraded Premake5 to alpha10, removing Premake4 in the process. (110064c08f429664f2ecc2a86319afee2441b28e)
Nazara Engine:
- ⚠️**The Physics module has been renamed to Physics3D** (65bfd77623d1bf337849cc828022adf190c1d677)
- The PhysObject class has been renamed to RigidBody3D (d2c8ca0f0cfc91869e1802ee759ea2b356fc0a30)
- The PhysWorld class has been renamed to PhysWorld3D (d130719c5fd9521062f8c9e48729aba430061c77)
- The *Geom classes have been renamed to *Collider3D (fc1ea178c7e1dba7739443afcec339f6622243ae)
- The GeomType enum has been renamed to ColliderType3D and is now part of thz Nz namespace (1f75d449d61612909b1e879f2558c89dd41c2394)
- **A new Physics2D module has been added, using [chipmunk](https://chipmunk-physics.net)** (e9be18d1813197004a06d5eb13fe87232ccd6168)
- ⚠️ **`NAZARA_UTILITY_THREADED_WINDOW` got replaced by the runtime flag `WindowStyle_Threaded`**. (a7dd0e0a20c4c4401c663f4665ea9133dfbca1a5)
- LuaClass is now default-constructable and (re)initialized later with its `Reset` method (dc3e125bdac3e0c790743af78fead3a2e28c73b3)
- LuaClass is now able to bind classes with deleted destructor (3168e5ae07e29168223666dd23c29cb6cd7788ed)
- Added a `LuaInstance::Push` variadic overload able to push multiple arguments (a19edf1676181ec8765d9d61a02c8b0f2533c9df)
- The Vector classes now have a std::hash overload (74b446af2fc0898afa170c7fec8eaf6b5cf30614)
- The TextEntered event handling on Linux has been improved (7d1c5fa1af98abc2f253fd4a9c6b6d8604dbccaa)
- An interactive unit test has been added for testing the window events (34d92320b6252e1bf4e86e3544ecc06dc3126d8d)
- `AbstractLogger::IsStdReplicationEnabled()` is now const (5df095c0f178fcb5f772aaf9a9fb4bf79257b008)
- `FileLogger::IsTimeLoggingEnabled()` is now const (de0f93116aad07d5893e8d3ba3ec1313d7458bdf)
- Fixed `Apply` return type not taking references into account (1eb49d38691798d78c7e6559007d4f496b625db3)
- Fixed `LuaInstance::PushInstance` memory corruption (54b77c0f48a005e345109a85f49cbc4b28d93f07)
- Fixed `Matrix4::Get(Column|Row)` compilation (728d7b829e6604e314e9b8a6dfa5bd5d85602c7a)
- Fixed `ResourceManager::Purge` compilation (c7002830f58f092adb6c055a911397abc949fd4a)
- Fixed `Quaterniond::operator*` compilation (19dc95ae7c65b148cc5faeb897ded4880b9fba28)
- Fixed the <= operator with two ObjectRef (7597578bbf400e7610103b191e4b8e9e2af0b47f)
- ⚠️ LuaClass methods now include an `argumentCount` parameter, and the instance remains at the top of the Lua stack, shifting all parameters by one (9b7947812b4c4a4543a1447daea4472f4f674b7f)
- Fixed automatic lua binding of `T& T::Method()`, which will now return the original Lua instance instead of copying it. (d20fa0077a74dbe5e9e914f7adfd0c62faf5fa3a)
- `VideoMode` third argument (`bpp`) is now optional. (2ab311e0a68523b2113b25f24244b855cc4712bb)
- `ByteArray::ToHex` is now implemented in ByteArray.cpp, to reduce the amount of warnings generated by MSVC because of the `sprintf` call. (41e7e6af601fbd3b2ca96b188e4906c010903ef0)
Nazara Development Kit:
- ⚠️ The Collision and Physics components now have a 3D suffix (6e289fe789d64ac9730ddc0f4cc240e02754e8a3)
- Added Collision and Physics components for 2D physics. (b5048dfb3704675b9f7438d080a9347c99884972)
- `LuaAPI::GetBinding()` will now implicitly initialize LuaAPI if required (ec161141d8d99db250f4f5a1e739123ad4f91750)
- It is now possible to change the update order of a world's systems. (51b6979bb59b6d880d0bcacef1b3d8d7420a5fa6)
- By default, the Render and Listener systems update are now performed last. (dd22e5f1054da80b5b6aff5ae96e9832b4425ed7)
- PhysicsSystem3D no longer initialize an internal PhysWorld3D if no physical entity gets created (e282442407c028c5d1cff96847b5b7f857a646bb)
- Including the following changes in the Lua API:
- `GraphicsComponent:Attach` overloads (taking local matrix and render order) are fixed. (d525669f3ae0d40266df9c34b6b1525a10a26d7e)
- Material is now accessible from Lua (aed4e1ee91d9875592adb178334220339afb72a0)
- Matrix4 is now accessible from Lua (fb518403659455ae79be848b99dd8f6083f1ab58)
- Sprite is now accessible from Lua (e034dce76dc6a2fd1f403221e1945c1a2c3e28ee)
- SpriteLibrary is now accessible from Lua (013a133f60d46114e1b02fed7eab9f9a9f506068)
- Texture is now accessible from Lua (f8b55a5063c058965668ed4277a7e50280ea100d)
- TextureLibrary is now accessible from Lua (3a64ef9e136c457a8207440e37361b5b3384e133)
- TextureManager is now accessible from Lua (3a64ef9e136c457a8207440e37361b5b3384e133)
Issues fixed:
- #102: Some shaders used by the Graphics module may fail to compile with some drivers.
- #104: On Windows, when using threaded windows, the window position obtained by `Window::GetPosition()` never gets updated.
- #105: On Windows, when not using threaded windows, a lot of Moved events gets generated instead of just one for every movement.
- #111: On Linux, `IsKeyPressed(Keyboard::Q);` returns true if the `A` key is pressed.
- #114: Box/cubic sphere submesh generation is broken.
# 0.1.1
Additions/Changes:
- Nz::Bitset now supports shifting operations (along with <<, >> operators) (37089d9a5fba52ba83f46d603381584a13036ac0).
Issues fixed:
- #73, #81: Nazara fails to compile on Linux with x86 target.
- #75: Lua constructors may fail in some cases.
- #77: Packaging the engine under Linux fails to copy the executable binaries of the demo and unit tests.
- #78: Building with Clang fails.
- #79: `SocketPoller::Wait` does not update its `error` parameter on Linux.
- #80: When initializing the engine, some pixel format errors occurs, this currently has no side-effect.
# 0.1
- Initial release

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM debian:stretch
RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libxcb-cursor-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev libassimp-dev
RUN mkdir /NazaraEngine
WORKDIR /NazaraEngine

View File

@ -38,7 +38,7 @@ PROJECT_NAME = "Nazara Engine"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 0.3
PROJECT_NUMBER = 0.4
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -7,7 +7,7 @@
#ifndef NAZARA_MODULENAME_HPP
#define NAZARA_MODULENAME_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/Initializer.hpp>
#include <Nazara/ModuleName/Config.hpp>

View File

@ -1,13 +1,13 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_ALGORITHM_HPP
#define NDK_ALGORITHM_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <Nazara/Core/Endianness.hpp>
@ -21,7 +21,7 @@ namespace Ndk
static_assert(N-1 <= sizeof(ComponentId), "Name too long for this size of component id");
ComponentId componentId = 0;
for (unsigned int i = 0; i < N; ++i)
for (unsigned int i = 0; i < N - 1; ++i)
componentId |= static_cast<ComponentId>(name[i]) << i*8;
return componentId;

View File

@ -1,20 +1,18 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_APPLICATION_HPP
#define NDK_APPLICATION_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/EntityOwner.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/World.hpp>
#include <Nazara/Core/Clock.hpp>
#include <map>
#include <list>
#include <set>
#include <vector>
#ifndef NDK_SERVER
#include <NDK/Canvas.hpp>

View File

@ -1,10 +1,8 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Application.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <type_traits>
#include <NDK/Sdk.hpp>
namespace Ndk

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -50,6 +50,8 @@ namespace Ndk
virtual void OnComponentDetached(BaseComponent& component);
virtual void OnDetached();
virtual void OnEntityDestruction();
virtual void OnEntityDisabled();
virtual void OnEntityEnabled();
void SetEntity(Entity* entity);

View File

@ -1,8 +1,7 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/BaseComponent.hpp>
#include <Nazara/Core/Error.hpp>
namespace Ndk

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -8,9 +8,7 @@
#define NDK_BASESYSTEM_HPP
#include <Nazara/Core/Bitset.hpp>
#include <NDK/Entity.hpp>
#include <NDK/EntityList.hpp>
#include <vector>
namespace Ndk
{
@ -24,28 +22,28 @@ namespace Ndk
public:
inline BaseSystem(SystemIndex systemId);
inline BaseSystem(const BaseSystem&);
BaseSystem(const BaseSystem&) = delete;
BaseSystem(BaseSystem&&) noexcept = default;
virtual ~BaseSystem();
inline void Enable(bool enable = true);
virtual std::unique_ptr<BaseSystem> Clone() const = 0;
bool Filters(const Entity* entity) const;
inline const EntityList& GetEntities() const;
inline float GetFixedUpdateRate() const;
inline SystemIndex GetIndex() const;
inline float GetMaximumUpdateRate() const;
inline int GetUpdateOrder() const;
inline float GetUpdateRate() const;
inline World& GetWorld() const;
inline bool IsEnabled() const;
inline bool HasEntity(const Entity* entity) const;
inline void SetFixedUpdateRate(float updatePerSecond);
inline void SetMaximumUpdateRate(float updatePerSecond);
void SetUpdateOrder(int updateOrder);
inline void SetUpdateRate(float updatePerSecond);
inline void Update(float elapsedTime);
@ -93,8 +91,9 @@ namespace Ndk
SystemIndex m_systemIndex;
World* m_world;
bool m_updateEnabled;
float m_fixedUpdateRate;
float m_maxUpdateRate;
float m_updateCounter;
float m_updateRate;
int m_updateOrder;
static SystemIndex s_nextIndex;

View File

@ -1,8 +1,7 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/BaseSystem.hpp>
#include <Nazara/Core/Error.hpp>
#include <type_traits>
@ -20,24 +19,8 @@ namespace Ndk
m_updateEnabled(true),
m_updateOrder(0)
{
SetUpdateRate(30);
}
/*!
* \brief Constructs a BaseSystem object by copy semantic
*
* \param system System to copy
*/
inline BaseSystem::BaseSystem(const BaseSystem& system) :
m_excludedComponents(system.m_excludedComponents),
m_requiredComponents(system.m_requiredComponents),
m_systemIndex(system.m_systemIndex),
m_updateEnabled(system.m_updateEnabled),
m_updateCounter(0.f),
m_updateRate(system.m_updateRate),
m_updateOrder(system.m_updateOrder)
{
SetFixedUpdateRate(0);
SetMaximumUpdateRate(30);
}
/*!
@ -61,6 +44,24 @@ namespace Ndk
return m_entities;
}
/*!
* \brief Gets the maximum rate of update of the system
* \return Update rate
*/
inline float BaseSystem::GetFixedUpdateRate() const
{
return (m_fixedUpdateRate > 0.f) ? 1.f / m_fixedUpdateRate : 0.f;
}
/*!
* \brief Gets the maximum rate of update of the system
* \return Update rate
*/
inline float BaseSystem::GetMaximumUpdateRate() const
{
return (m_maxUpdateRate > 0.f) ? 1.f / m_maxUpdateRate : 0.f;
}
/*!
* \brief Gets the index of the system
* \return Index of the system
@ -82,16 +83,6 @@ namespace Ndk
return m_updateOrder;
}
/*!
* \brief Gets the rate of update of the system
* \return Update rate
*/
inline float BaseSystem::GetUpdateRate() const
{
return (m_updateRate > 0.f) ? 1.f / m_updateRate : 0.f;
}
/*!
* \brief Gets the world on which the system operate
* \return World in which the system is
@ -125,15 +116,25 @@ namespace Ndk
}
/*!
* \brief Sets the rate of update for the system
* \brief Sets the fixed update rate for the system
*
* \param updatePerSecond Update rate, 0 means update rate is not fixed
*/
inline void BaseSystem::SetFixedUpdateRate(float updatePerSecond)
{
m_updateCounter = 0.f;
m_fixedUpdateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
}
/*!
* \brief Sets the maximum update rate for the system
*
* \param updatePerSecond Update rate, 0 means as much as possible
*/
inline void BaseSystem::SetUpdateRate(float updatePerSecond)
inline void BaseSystem::SetMaximumUpdateRate(float updatePerSecond)
{
m_updateCounter = 0.f;
m_updateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
m_maxUpdateRate = (updatePerSecond > 0.f) ? 1.f / updatePerSecond : 0.f; // 0.f means no limit
}
/*!
@ -147,18 +148,42 @@ namespace Ndk
if (!IsEnabled())
return;
if (m_updateRate > 0.f)
{
m_updateCounter += elapsedTime;
m_updateCounter += elapsedTime;
while (m_updateCounter >= m_updateRate)
if (m_maxUpdateRate > 0.f)
{
if (m_updateCounter >= m_maxUpdateRate)
{
OnUpdate(m_updateRate);
m_updateCounter -= m_updateRate;
if (m_fixedUpdateRate > 0.f)
{
while (m_updateCounter >= m_fixedUpdateRate)
{
OnUpdate(m_fixedUpdateRate);
m_updateCounter -= m_fixedUpdateRate;
}
}
else
{
float updateRate = std::max(elapsedTime, m_maxUpdateRate);
OnUpdate(updateRate);
m_updateCounter -= updateRate;
}
}
}
else
OnUpdate(elapsedTime);
{
if (m_fixedUpdateRate > 0.f)
{
while (m_updateCounter >= m_fixedUpdateRate)
{
OnUpdate(m_fixedUpdateRate);
m_updateCounter -= m_fixedUpdateRate;
}
}
else
OnUpdate(elapsedTime);
}
}
/*!

View File

@ -1,18 +1,17 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_BASEWIDGET_HPP
#define NDK_BASEWIDGET_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/Entity.hpp>
#include <NDK/EntityOwner.hpp>
#include <NDK/World.hpp>
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Platform/Cursor.hpp>
#include <Nazara/Platform/Event.hpp>
#include <Nazara/Platform/Mouse.hpp>
#include <Nazara/Utility/Node.hpp>
@ -38,8 +37,12 @@ namespace Ndk
inline void AddChild(std::unique_ptr<BaseWidget>&& widget);
inline void Center();
inline void CenterHorizontal();
inline void CenterVertical();
inline void Destroy();
void ClearFocus();
void Destroy();
void EnableBackground(bool enable);
@ -53,15 +56,16 @@ namespace Ndk
inline const Nz::Vector2f& GetContentSize() const;
inline Nz::Vector2f GetSize() const;
inline bool IsVisible() const;
bool HasFocus() const;
void GrabKeyboard();
inline bool IsVisible() const;
virtual void ResizeToContent() = 0;
void SetBackgroundColor(const Nz::Color& color);
void SetCursor(Nz::SystemCursor systemCursor);
inline void SetContentSize(const Nz::Vector2f& size);
void SetFocus();
inline void SetPadding(float left, float top, float right, float bottom);
void SetSize(const Nz::Vector2f& size);
@ -79,12 +83,16 @@ namespace Ndk
};
protected:
EntityHandle CreateEntity();
const EntityHandle& CreateEntity(bool isContentEntity);
void DestroyEntity(Entity* entity);
virtual void Layout();
void InvalidateNode() override;
virtual void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key);
virtual bool IsFocusable() const;
virtual void OnFocusLost();
virtual void OnFocusReceived();
virtual bool OnKeyPressed(const Nz::WindowEvent::KeyEvent& key);
virtual void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key);
virtual void OnMouseEnter();
virtual void OnMouseMoved(int x, int y, int deltaX, int deltaY);
@ -104,11 +112,18 @@ namespace Ndk
void RegisterToCanvas();
inline void UpdateCanvasIndex(std::size_t index);
void UnregisterFromCanvas();
void UpdatePositionAndSize();
struct WidgetEntity
{
EntityOwner handle;
bool isContent;
};
static constexpr std::size_t InvalidCanvasIndex = std::numeric_limits<std::size_t>::max();
std::size_t m_canvasIndex;
std::vector<EntityOwner> m_entities;
std::vector<WidgetEntity> m_entities;
std::vector<std::unique_ptr<BaseWidget>> m_children;
Canvas* m_canvas;
EntityOwner m_backgroundEntity;

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/BaseWidget.hpp>
#include <Nazara/Core/Error.hpp>
@ -46,6 +46,24 @@ namespace Ndk
SetPosition((parentSize.x - mySize.x) / 2.f, (parentSize.y - mySize.y) / 2.f);
}
inline void BaseWidget::CenterHorizontal()
{
NazaraAssert(m_widgetParent, "Widget has no parent");
Nz::Vector2f parentSize = m_widgetParent->GetSize();
Nz::Vector2f mySize = GetSize();
SetPosition((parentSize.x - mySize.x) / 2.f, GetPosition(Nz::CoordSys_Local).y);
}
inline void BaseWidget::CenterVertical()
{
NazaraAssert(m_widgetParent, "Widget has no parent");
Nz::Vector2f parentSize = m_widgetParent->GetSize();
Nz::Vector2f mySize = GetSize();
SetPosition(GetPosition(Nz::CoordSys_Local).x, (parentSize.y - mySize.y) / 2.f);
}
inline const Nz::Color& BaseWidget::GetBackgroundColor() const
{
return m_backgroundColor;

View File

@ -1,13 +1,13 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_CANVAS_HPP
#define NDK_CANVAS_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/BaseWidget.hpp>
#include <Nazara/Platform/CursorController.hpp>
#include <Nazara/Platform/EventHandler.hpp>
@ -34,12 +34,16 @@ namespace Ndk
Canvas& operator=(Canvas&&) = delete;
protected:
inline void ClearKeyboardOwner(std::size_t canvasIndex);
inline bool IsKeyboardOwner(std::size_t canvasIndex) const;
inline void NotifyWidgetBoxUpdate(std::size_t index);
inline void NotifyWidgetCursorUpdate(std::size_t index);
std::size_t RegisterWidget(BaseWidget* widget);
inline void SetKeyboardOwner(BaseWidget* widget);
inline void SetKeyboardOwner(std::size_t canvasIndex);
void UnregisterWidget(std::size_t index);
@ -52,7 +56,7 @@ namespace Ndk
void OnEventKeyReleased(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event);
void OnEventTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event);
struct WidgetBox
struct WidgetEntry
{
BaseWidget* widget;
Nz::Boxf box;
@ -67,10 +71,10 @@ namespace Ndk
NazaraSlot(Nz::EventHandler, OnMouseLeft, m_mouseLeftSlot);
NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot);
std::vector<WidgetBox> m_widgetBoxes;
std::size_t m_keyboardOwner;
std::size_t m_hoveredWidget;
std::vector<WidgetEntry> m_widgetEntries;
Nz::CursorControllerHandle m_cursorController;
const WidgetBox* m_hoveredWidget;
BaseWidget* m_keyboardOwner;
WorldHandle m_world;
};
}

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Canvas.hpp>
#include <Nazara/Platform/Cursor.hpp>
@ -8,9 +8,9 @@
namespace Ndk
{
inline Canvas::Canvas(WorldHandle world, Nz::EventHandler& eventHandler, Nz::CursorControllerHandle cursorController) :
m_keyboardOwner(InvalidCanvasIndex),
m_hoveredWidget(InvalidCanvasIndex),
m_cursorController(cursorController),
m_hoveredWidget(nullptr),
m_keyboardOwner(nullptr),
m_world(std::move(world))
{
m_canvas = this;
@ -46,27 +46,47 @@ namespace Ndk
return m_world;
}
inline void Canvas::ClearKeyboardOwner(std::size_t canvasIndex)
{
if (m_keyboardOwner == canvasIndex)
SetKeyboardOwner(InvalidCanvasIndex);
}
inline bool Canvas::IsKeyboardOwner(std::size_t canvasIndex) const
{
return m_keyboardOwner == canvasIndex;
}
inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index)
{
WidgetBox& entry = m_widgetBoxes[index];
WidgetEntry& entry = m_widgetEntries[index];
Nz::Vector3f pos = entry.widget->GetPosition();
Nz::Vector2f size = entry.widget->GetContentSize();
Nz::Vector2f size = entry.widget->GetSize();
entry.box.Set(pos.x, pos.y, pos.z, size.x, size.y, 1.f);
}
inline void Canvas::NotifyWidgetCursorUpdate(std::size_t index)
{
WidgetBox& entry = m_widgetBoxes[index];
WidgetEntry& entry = m_widgetEntries[index];
entry.cursor = entry.widget->GetCursor();
if (m_cursorController && m_hoveredWidget == &entry)
if (m_cursorController && m_hoveredWidget == index)
m_cursorController->UpdateCursor(Nz::Cursor::Get(entry.cursor));
}
inline void Ndk::Canvas::SetKeyboardOwner(BaseWidget* widget)
inline void Canvas::SetKeyboardOwner(std::size_t canvasIndex)
{
m_keyboardOwner = widget;
if (m_keyboardOwner != canvasIndex)
{
if (m_keyboardOwner != InvalidCanvasIndex)
m_widgetEntries[m_keyboardOwner].widget->OnFocusLost();
m_keyboardOwner = canvasIndex;
if (m_keyboardOwner != InvalidCanvasIndex)
m_widgetEntries[m_keyboardOwner].widget->OnFocusReceived();
}
}
}

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Algorithm.hpp>
#include <type_traits>

View File

@ -17,5 +17,6 @@
#include <NDK/Components/PhysicsComponent2D.hpp>
#include <NDK/Components/PhysicsComponent3D.hpp>
#include <NDK/Components/VelocityComponent.hpp>
#include <NDK/Components/ConstraintComponent2D.hpp>
#endif // NDK_COMPONENTS_GLOBAL_HPP

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -19,7 +19,6 @@
namespace Ndk
{
class CameraComponent;
class Entity;
using CameraComponentHandle = Nz::ObjectHandle<CameraComponent>;

View File

@ -1,8 +1,7 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Components/CameraComponent.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Math/Algorithm.hpp>
@ -238,10 +237,9 @@ namespace Ndk
NazaraAssert(m_target, "Component has no render target");
// We compute the region necessary to make this view port with the actual size of the target
float invWidth = 1.f / m_target->GetWidth();
float invHeight = 1.f / m_target->GetHeight();
Nz::Vector2f invSize = 1.f / Nz::Vector2f(m_target->GetSize());
SetTargetRegion(Nz::Rectf(invWidth * viewport.x, invHeight * viewport.y, invWidth * viewport.width, invHeight * viewport.height));
SetTargetRegion(Nz::Rectf(invSize.x * viewport.x, invSize.y * viewport.y, invSize.x * viewport.width, invSize.y * viewport.height));
}
/*!

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -8,21 +8,16 @@
#define NDK_COMPONENTS_COLLISIONCOMPONENT2D_HPP
#include <Nazara/Physics2D/Collider2D.hpp>
#include <Nazara/Physics2D/RigidBody2D.hpp>
#include <NDK/Component.hpp>
#include <memory>
namespace Nz
{
class RigidBody2D;
}
namespace Ndk
{
class Entity;
class NDK_API CollisionComponent2D : public Component<CollisionComponent2D>
{
friend class PhysicsSystem2D;
friend class ConstraintComponent2D;
public:
CollisionComponent2D(Nz::Collider2DRef geom = Nz::Collider2DRef());

View File

@ -1,12 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Components/CollisionComponent2D.hpp>
#include <NDK/Entity.hpp>
#include <NDK/World.hpp>
#include <NDK/Components/PhysicsComponent2D.hpp>
#include <NDK/Systems/PhysicsSystem2D.hpp>
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -8,18 +8,12 @@
#define NDK_COMPONENTS_COLLISIONCOMPONENT3D_HPP
#include <Nazara/Physics3D/Collider3D.hpp>
#include <Nazara/Physics3D/RigidBody3D.hpp>
#include <NDK/Component.hpp>
#include <memory>
namespace Nz
{
class RigidBody3D;
}
namespace Ndk
{
class Entity;
class NDK_API CollisionComponent3D : public Component<CollisionComponent3D>
{
friend class PhysicsSystem3D;
@ -46,6 +40,8 @@ namespace Ndk
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
void OnEntityDisabled() override;
void OnEntityEnabled() override;
std::unique_ptr<Nz::RigidBody3D> m_staticBody;
Nz::Collider3DRef m_geom;

View File

@ -1,11 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Entity.hpp>
#include <NDK/World.hpp>
#include <NDK/Components/PhysicsComponent3D.hpp>
#include <NDK/Systems/PhysicsSystem3D.hpp>
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -0,0 +1,34 @@
#pragma once
#ifndef NDK_COMPONENTS_CONSTRAINTCOMPONENT2D_HPP
#define NDK_COMPONENTS_CONSTRAINTCOMPONENT2D_HPP
#include <NDK/Component.hpp>
#include <Nazara/Physics2D/Constraint2D.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <vector>
#include <memory>
namespace Ndk
{
class NDK_API ConstraintComponent2D : public Component<ConstraintComponent2D>
{
public:
ConstraintComponent2D() = default;
ConstraintComponent2D(const ConstraintComponent2D& joint) = default;
ConstraintComponent2D(ConstraintComponent2D&& joint) = default;
template<typename T, typename... Args> inline Nz::ObjectRef<T> CreateConstraint(const Ndk::EntityHandle& first, const Ndk::EntityHandle& second, Args&&... args);
static ComponentIndex componentIndex;
private:
std::vector<Nz::Constraint2DRef> m_constraints;
};
}
#include <NDK/Components/ConstraintComponent2D.inl>
#endif// NDK_COMPONENTS_CONSTRAINTCOMPONENT2D_HPP

View File

@ -0,0 +1,31 @@
#include <NDK/Components/ConstraintComponent2D.hpp>
#include <NDK/Components/PhysicsComponent2D.hpp>
#include <NDK/Components/CollisionComponent2D.hpp>
namespace Ndk
{
template<typename T, typename ...Args>
Nz::ObjectRef<T> ConstraintComponent2D::CreateConstraint(const Ndk::EntityHandle& first, const Ndk::EntityHandle& second, Args && ...args)
{
auto FetchBody = [](const Ndk::EntityHandle& entity) -> Nz::RigidBody2D*
{
if (entity->HasComponent<Ndk::PhysicsComponent2D>())
return entity->GetComponent<Ndk::PhysicsComponent2D>().GetRigidBody();
else if (entity->HasComponent<Ndk::CollisionComponent2D>())
return entity->GetComponent<Ndk::CollisionComponent2D>().GetStaticBody();
return nullptr;
};
Nz::RigidBody2D* firstBody = FetchBody(first);
NazaraAssert(firstBody, "First entity has no CollisionComponent2D nor PhysicsComponent2D component");
Nz::RigidBody2D* secondBody = FetchBody(second);
NazaraAssert(secondBody, "Second entity has no CollisionComponent2D nor PhysicsComponent2D component");
Nz::ObjectRef<T> constraint = T::New(*firstBody, *secondBody, std::forward<Args>(args)...);
m_constraints.push_back(constraint);
return constraint;
}
}

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -12,6 +12,7 @@
#include <Nazara/Graphics/InstancedRenderable.hpp>
#include <Nazara/Utility/Node.hpp>
#include <NDK/Component.hpp>
#include <unordered_map>
namespace Ndk
{
@ -27,20 +28,22 @@ namespace Ndk
public:
using RenderableList = std::vector<Nz::InstancedRenderableRef>;
GraphicsComponent() = default;
GraphicsComponent();
inline GraphicsComponent(const GraphicsComponent& graphicsComponent);
~GraphicsComponent() = default;
inline void AddToCullingList(GraphicsComponentCullingList* cullingList) const;
void AddToRenderQueue(Nz::AbstractRenderQueue* renderQueue) const;
void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
void Attach(Nz::InstancedRenderableRef renderable, const Nz::Matrix4f& localMatrix, int renderOrder = 0);
inline void Clear();
inline void Detach(const Nz::InstancedRenderable* renderable);
inline bool DoesRequireRealTimeReflections() const;
inline void EnsureBoundingVolumeUpdate() const;
inline void EnsureTransformMatrixUpdate() const;
@ -51,28 +54,51 @@ namespace Ndk
inline void RemoveFromCullingList(GraphicsComponentCullingList* cullingList) const;
inline void SetScissorRect(const Nz::Recti& scissorRect);
inline void UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix);
inline void UpdateRenderOrder(const Nz::InstancedRenderable* instancedRenderable, int renderOrder);
static ComponentIndex componentIndex;
private:
struct Renderable;
void ConnectInstancedRenderableSignals(Renderable& renderable);
inline void InvalidateBoundingVolume() const;
void InvalidateRenderableData(const Nz::InstancedRenderable* renderable, Nz::UInt32 flags, std::size_t index);
void InvalidateRenderableMaterial(const Nz::InstancedRenderable* renderable, std::size_t skinIndex, std::size_t matIndex, const Nz::MaterialRef& newMat);
inline void InvalidateRenderables();
void InvalidateReflectionMap();
inline void InvalidateTransformMatrix();
void RegisterMaterial(Nz::Material* material, std::size_t count = 1);
void OnAttached() override;
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
void OnInstancedRenderableResetMaterials(const Nz::InstancedRenderable* renderable, std::size_t newMaterialCount);
void OnInstancedRenderableSkinChange(const Nz::InstancedRenderable* renderable, std::size_t newSkinIndex);
void OnMaterialReflectionChange(const Nz::Material* material, Nz::ReflectionMode reflectionMode);
void OnNodeInvalidated(const Nz::Node* node);
void UnregisterMaterial(Nz::Material* material);
void UpdateBoundingVolume() const;
void UpdateTransformMatrix() const;
NazaraSlot(Nz::Node, OnNodeInvalidation, m_nodeInvalidationSlot);
struct MaterialEntry
{
NazaraSlot(Nz::Material, OnMaterialReflectionModeChange, reflectionModelChangeSlot);
std::size_t renderableCounter;
};
struct Renderable
{
Renderable(const Nz::Matrix4f& transformMatrix) :
@ -81,15 +107,8 @@ namespace Ndk
{
}
Renderable(Renderable&& rhs) noexcept :
renderableBoundingVolumeInvalidationSlot(std::move(rhs.renderableBoundingVolumeInvalidationSlot)),
renderableDataInvalidationSlot(std::move(rhs.renderableDataInvalidationSlot)),
renderableReleaseSlot(std::move(rhs.renderableReleaseSlot)),
data(std::move(rhs.data)),
renderable(std::move(rhs.renderable)),
dataUpdated(rhs.dataUpdated)
{
}
Renderable(const Renderable&) = delete;
Renderable(Renderable&& rhs) noexcept = default;
~Renderable()
{
@ -97,21 +116,15 @@ namespace Ndk
renderableReleaseSlot.Disconnect();
}
Renderable& operator=(Renderable&& r) noexcept
{
data = std::move(r.data);
dataUpdated = r.dataUpdated;
renderable = std::move(r.renderable);
renderableBoundingVolumeInvalidationSlot = std::move(r.renderableBoundingVolumeInvalidationSlot);
renderableDataInvalidationSlot = std::move(r.renderableDataInvalidationSlot);
renderableReleaseSlot = std::move(r.renderableReleaseSlot);
return *this;
}
Renderable& operator=(const Renderable&) = delete;
Renderable& operator=(Renderable&& r) noexcept = default;
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateBoundingVolume, renderableBoundingVolumeInvalidationSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableDataInvalidationSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateMaterial, renderableMaterialInvalidationSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableRelease, renderableReleaseSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableResetMaterials, renderableResetMaterialsSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableSkinChange, renderableSkinChangeSlot);
mutable Nz::InstancedRenderable::InstanceData data;
Nz::InstancedRenderableRef renderable;
@ -127,12 +140,17 @@ namespace Ndk
NazaraSlot(GraphicsComponentCullingList, OnCullingListRelease, cullingListReleaseSlot);
};
std::size_t m_reflectiveMaterialCount;
mutable std::vector<VolumeCullingEntry> m_volumeCullingEntries;
std::vector<Renderable> m_renderables;
std::unordered_map<const Nz::Material*, MaterialEntry> m_materialEntries;
mutable Nz::BoundingVolumef m_boundingVolume;
mutable Nz::Matrix4f m_transformMatrix;
Nz::Recti m_scissorRect;
Nz::TextureRef m_reflectionMap;
mutable bool m_boundingVolumeUpdated;
mutable bool m_transformMatrixUpdated;
unsigned int m_reflectionMapSize;
};
}

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Components/GraphicsComponent.hpp>
#include <NDK/World.hpp>
@ -9,12 +9,16 @@
namespace Ndk
{
inline GraphicsComponent::GraphicsComponent() :
m_scissorRect(-1, -1)
{
}
/*!
* \brief Constructs a GraphicsComponent object by copy semantic
*
* \param graphicsComponent GraphicsComponent to copy
*/
inline GraphicsComponent::GraphicsComponent(const GraphicsComponent& graphicsComponent) :
Component(graphicsComponent),
HandledObject(graphicsComponent),
@ -25,7 +29,7 @@ namespace Ndk
{
m_renderables.reserve(graphicsComponent.m_renderables.size());
for (const Renderable& r : graphicsComponent.m_renderables)
Attach(r.renderable, r.data.renderOrder);
Attach(r.renderable, r.data.localMatrix, r.data.renderOrder);
}
inline void GraphicsComponent::AddToCullingList(GraphicsComponentCullingList* cullingList) const
@ -38,14 +42,32 @@ namespace Ndk
InvalidateBoundingVolume();
}
/*!
* \brief Attaches a renderable to the entity
*
* \param renderable Reference to a renderable element
* \param renderOrder Render order of the element
*/
inline void GraphicsComponent::Attach(Nz::InstancedRenderableRef renderable, int renderOrder)
{
return Attach(std::move(renderable), Nz::Matrix4f::Identity(), renderOrder);
}
/*!
* \brief Clears every renderable elements
*/
inline void GraphicsComponent::Clear()
{
m_materialEntries.clear();
m_renderables.clear();
if (m_reflectiveMaterialCount > 0)
{
m_reflectiveMaterialCount = 0;
InvalidateReflectionMap();
}
InvalidateBoundingVolume();
}
@ -62,12 +84,29 @@ namespace Ndk
if (it->renderable == renderable)
{
InvalidateBoundingVolume();
std::size_t materialCount = renderable->GetMaterialCount();
for (std::size_t i = 0; i < materialCount; ++i)
UnregisterMaterial(renderable->GetMaterial(i));
m_renderables.erase(it);
break;
}
}
}
/*!
* \brief Checks if this graphics component requires real-time reflections to be generated
*
* If any of the materials attached to a GraphicsComponent (via the attached instanced renderable) needs real-time reflections, this function will return true.
*
* \return True if real-time reflections needs to be generated or false
*/
inline bool GraphicsComponent::DoesRequireRealTimeReflections() const
{
return m_reflectiveMaterialCount != 0 && m_reflectionMap;
}
/*!
* \brief Ensures the bounding volume is up to date
*/
@ -142,6 +181,14 @@ namespace Ndk
}
}
inline void GraphicsComponent::SetScissorRect(const Nz::Recti& scissorRect)
{
m_scissorRect = scissorRect;
for (VolumeCullingEntry& entry : m_volumeCullingEntries)
entry.listEntry.ForceInvalidation(); //< Invalidate render queues
}
inline void GraphicsComponent::UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix)
{
for (auto& renderable : m_renderables)

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <Nazara/Core/Error.hpp>
#include <NDK/Entity.hpp>

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -9,7 +9,6 @@
#define NDK_COMPONENTS_PARTICLEEMITTERCOMPONENT_HPP
#include <Nazara/Graphics/ParticleEmitter.hpp>
#include <Nazara/Graphics/ParticleGroup.hpp>
#include <NDK/Component.hpp>
namespace Ndk

View File

@ -1,8 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Components/ParticleEmitterComponent.hpp>
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,8 +1,7 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Components/ParticleGroupComponent.hpp>
#include <NDK/Components/ParticleEmitterComponent.hpp>
#include <Nazara/Core/Error.hpp>
@ -50,7 +49,7 @@ namespace Ndk
inline void ParticleGroupComponent::AddEmitter(Entity* emitter)
{
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a NodeComponent");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a ParticleEmitterComponent");
auto& emitterComponent = emitter->GetComponent<ParticleEmitterComponent>();
ParticleGroup::AddEmitter(&emitterComponent);
@ -69,7 +68,7 @@ namespace Ndk
inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter)
{
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a NodeComponent");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a ParticleEmitterComponent");
auto& emitterComponent = emitter->GetComponent<ParticleEmitterComponent>();
ParticleGroup::RemoveEmitter(&emitterComponent);

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -13,12 +13,11 @@
namespace Ndk
{
class Entity;
class NDK_API PhysicsComponent2D : public Component<PhysicsComponent2D>
{
friend class CollisionComponent2D;
friend class PhysicsSystem2D;
friend class ConstraintComponent2D;
public:
PhysicsComponent2D() = default;
@ -27,6 +26,8 @@ namespace Ndk
void AddForce(const Nz::Vector2f& force, Nz::CoordSys coordSys = Nz::CoordSys_Global);
void AddForce(const Nz::Vector2f& force, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
void AddImpulse(const Nz::Vector2f& impulse, Nz::CoordSys coordSys = Nz::CoordSys_Global);
void AddImpulse(const Nz::Vector2f& impulse, const Nz::Vector2f& point, Nz::CoordSys coordSys = Nz::CoordSys_Global);
void AddTorque(float torque);
Nz::Rectf GetAABB() const;
@ -49,7 +50,7 @@ namespace Ndk
static ComponentIndex componentIndex;
private:
Nz::RigidBody2D& GetRigidBody();
Nz::RigidBody2D* GetRigidBody();
void OnAttached() override;
void OnComponentAttached(BaseComponent& component) override;

View File

@ -1,9 +1,8 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <Nazara/Core/Error.hpp>
#include "PhysicsComponent2D.hpp"
namespace Ndk
{
@ -52,6 +51,37 @@ namespace Ndk
m_object->AddForce(force, point, coordSys);
}
/*!
* \brief Applies a impulse to the entity
*
* \param impulse Impulse to apply on the entity
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent2D::AddImpulse(const Nz::Vector2f& impulse, Nz::CoordSys coordSys)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->AddImpulse(impulse, coordSys);
}
/*!
* \brief Applies a impulse to the entity
*
* \param impulse Impulse to apply on the entity
* \param point Point where the impulse is applied
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent2D::AddImpulse(const Nz::Vector2f& impulse, const Nz::Vector2f& point, Nz::CoordSys coordSys)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->AddImpulse(impulse, point, coordSys);
}
/*!
* \brief Applies a torque to the entity
*
@ -277,8 +307,8 @@ namespace Ndk
* \return A reference to the physics object
*/
inline Nz::RigidBody2D& PhysicsComponent2D::GetRigidBody()
inline Nz::RigidBody2D* PhysicsComponent2D::GetRigidBody()
{
return *m_object.get();
return m_object.get();
}
}

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -13,15 +13,13 @@
namespace Ndk
{
class Entity;
class NDK_API PhysicsComponent3D : public Component<PhysicsComponent3D>
{
friend class CollisionComponent3D;
friend class PhysicsSystem3D;
public:
PhysicsComponent3D() = default;
inline PhysicsComponent3D();
PhysicsComponent3D(const PhysicsComponent3D& physics);
~PhysicsComponent3D() = default;
@ -30,41 +28,67 @@ namespace Ndk
void AddTorque(const Nz::Vector3f& torque, Nz::CoordSys coordSys = Nz::CoordSys_Global);
void EnableAutoSleep(bool autoSleep);
void EnableNodeSynchronization(bool nodeSynchronization);
Nz::Boxf GetAABB() const;
Nz::Vector3f GetAngularDamping() const;
Nz::Vector3f GetAngularVelocity() const;
float GetGravityFactor() const;
float GetLinearDamping() const;
Nz::Vector3f GetLinearVelocity() const;
float GetMass() const;
Nz::Vector3f GetMassCenter(Nz::CoordSys coordSys = Nz::CoordSys_Local) const;
const Nz::Matrix4f& GetMatrix() const;
Nz::Vector3f GetPosition() const;
Nz::Quaternionf GetRotation() const;
Nz::Vector3f GetVelocity() const;
bool IsAutoSleepEnabled() const;
bool IsMoveable() const;
bool IsNodeSynchronizationEnabled() const;
bool IsSleeping() const;
void SetAngularDamping(const Nz::Vector3f& angularDamping);
void SetAngularVelocity(const Nz::Vector3f& angularVelocity);
void SetGravityFactor(float gravityFactor);
void SetLinearDamping(float damping);
void SetLinearVelocity(const Nz::Vector3f& velocity);
void SetMass(float mass);
void SetMassCenter(const Nz::Vector3f& center);
void SetMaterial(const Nz::String& materialName);
void SetMaterial(int materialIndex);
void SetPosition(const Nz::Vector3f& position);
void SetRotation(const Nz::Quaternionf& rotation);
void SetVelocity(const Nz::Vector3f& velocity);
static ComponentIndex componentIndex;
private:
Nz::RigidBody3D& GetRigidBody();
void ApplyPhysicsState(Nz::RigidBody3D& rigidBody) const;
void CopyPhysicsState(const Nz::RigidBody3D& rigidBody);
Nz::RigidBody3D* GetRigidBody();
const Nz::RigidBody3D& GetRigidBody() const;
void OnAttached() override;
void OnComponentAttached(BaseComponent& component) override;
void OnComponentDetached(BaseComponent& component) override;
void OnDetached() override;
void OnEntityDestruction() override;
void OnEntityDisabled() override;
void OnEntityEnabled() override;
struct PendingPhysObjectStates
{
Nz::Vector3f angularDamping;
Nz::Vector3f massCenter;
bool autoSleep;
bool valid = false;
float gravityFactor;
float linearDamping;
float mass;
};
std::unique_ptr<Nz::RigidBody3D> m_object;
PendingPhysObjectStates m_pendingStates;
bool m_nodeSynchronizationEnabled;
};
}

View File

@ -1,21 +1,27 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <Nazara/Core/Error.hpp>
#include "PhysicsComponent3D.hpp"
namespace Ndk
{
inline PhysicsComponent3D::PhysicsComponent3D() :
m_nodeSynchronizationEnabled(true)
{
}
/*!
* \brief Constructs a PhysicsComponent3D object by copy semantic
*
* \param physics PhysicsComponent3D to copy
*/
inline PhysicsComponent3D::PhysicsComponent3D(const PhysicsComponent3D& physics)
inline PhysicsComponent3D::PhysicsComponent3D(const PhysicsComponent3D& physics) :
m_nodeSynchronizationEnabled(physics.m_nodeSynchronizationEnabled)
{
// No copy of physical object (because we only create it when attached to an entity)
NazaraUnused(physics);
// We can't make a copy of the RigidBody3D, as we are not attached yet (and will possibly be attached to another world)
CopyPhysicsState(physics.GetRigidBody());
}
/*!
@ -74,7 +80,6 @@ namespace Ndk
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::EnableAutoSleep(bool autoSleep)
{
NazaraAssert(m_object, "Invalid physics object");
@ -82,13 +87,28 @@ namespace Ndk
m_object->EnableAutoSleep(autoSleep);
}
/*!
* \brief Enables position/rotation synchronization with the NodeComponent
*
* By default, at every update of the PhysicsSystem3D, the NodeComponent's position and rotation (if any) will be synchronized with
* the values of the PhysicsComponent3D. This function allows to enable/disable this behavior on a per-entity basis.
*
* \param nodeSynchronization Should synchronization occur between NodeComponent and PhysicsComponent3D
*/
inline void PhysicsComponent3D::EnableNodeSynchronization(bool nodeSynchronization)
{
m_nodeSynchronizationEnabled = nodeSynchronization;
if (m_entity)
m_entity->Invalidate();
}
/*!
* \brief Gets the AABB of the physics object
* \return AABB of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline Nz::Boxf PhysicsComponent3D::GetAABB() const
{
NazaraAssert(m_object, "Invalid physics object");
@ -96,13 +116,23 @@ namespace Ndk
return m_object->GetAABB();
}
/*!
* \brief Gets the angular damping of the physics object
* \return Angular damping of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline Nz::Vector3f PhysicsComponent3D::GetAngularDamping() const
{
return m_object->GetAngularDamping();
}
/*!
* \brief Gets the angular velocity of the physics object
* \return Angular velocity of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline Nz::Vector3f PhysicsComponent3D::GetAngularVelocity() const
{
NazaraAssert(m_object, "Invalid physics object");
@ -116,7 +146,6 @@ namespace Ndk
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline float PhysicsComponent3D::GetGravityFactor() const
{
NazaraAssert(m_object, "Invalid physics object");
@ -124,6 +153,33 @@ namespace Ndk
return m_object->GetGravityFactor();
}
/*!
* \brief Gets the linear damping of the physics object
* \return Linear damping of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline float PhysicsComponent3D::GetLinearDamping() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetLinearDamping();
}
/*!
* \brief Gets the linear velocity of the physics object
* \return Linear velocity of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline Nz::Vector3f PhysicsComponent3D::GetLinearVelocity() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetLinearVelocity();
}
/*!
* \brief Gets the mass of the physics object
* \return Mass of the object
@ -196,27 +252,12 @@ namespace Ndk
return m_object->GetRotation();
}
/*!
* \brief Gets the velocity of the physics object
* \return Velocity of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline Nz::Vector3f PhysicsComponent3D::GetVelocity() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->GetVelocity();
}
/*!
* \brief Checks whether the auto sleep is enabled
* \return true If it is the case
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline bool PhysicsComponent3D::IsAutoSleepEnabled() const
{
NazaraAssert(m_object, "Invalid physics object");
@ -224,13 +265,36 @@ namespace Ndk
return m_object->IsAutoSleepEnabled();
}
/*!
* \brief Checks whether the object is moveable
* \return true If it is the case
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline bool PhysicsComponent3D::IsMoveable() const
{
NazaraAssert(m_object, "Invalid physics object");
return m_object->IsMoveable();
}
/*!
* \brief Checks if position & rotation are synchronized with NodeComponent
* \return true If synchronization is enabled
*
* \see EnableNodeSynchronization
*/
inline bool PhysicsComponent3D::IsNodeSynchronizationEnabled() const
{
return m_nodeSynchronizationEnabled;
}
/*!
* \brief Checks whether the entity is currently sleeping
* \return true If it is the case
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline bool PhysicsComponent3D::IsSleeping() const
{
NazaraAssert(m_object, "Invalid physics object");
@ -238,6 +302,20 @@ namespace Ndk
return m_object->IsSleeping();
}
/*!
* \brief Sets the angular damping of the physics object
*
* \param angularDamping Angular damping of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetAngularDamping(const Nz::Vector3f& angularDamping)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetAngularDamping(angularDamping);
}
/*!
* \brief Sets the angular velocity of the physics object
*
@ -245,7 +323,6 @@ namespace Ndk
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetAngularVelocity(const Nz::Vector3f& angularVelocity)
{
NazaraAssert(m_object, "Invalid physics object");
@ -260,7 +337,6 @@ namespace Ndk
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetGravityFactor(float gravityFactor)
{
NazaraAssert(m_object, "Invalid physics object");
@ -268,6 +344,34 @@ namespace Ndk
m_object->SetGravityFactor(gravityFactor);
}
/*!
* \brief Sets the linear damping of the physics object
*
* \param damping Linear damping of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetLinearDamping(float damping)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetLinearDamping(damping);
}
/*!
* \brief Sets the linear velocity of the physics object
*
* \param velocity New linear velocity of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetLinearVelocity(const Nz::Vector3f& velocity)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetLinearVelocity(velocity);
}
/*!
* \brief Sets the mass of the physics object
*
@ -276,11 +380,11 @@ namespace Ndk
* \remark Produces a NazaraAssert if the physics object is invalid
* \remark Produces a NazaraAssert if the mass is negative
*/
inline void PhysicsComponent3D::SetMass(float mass)
{
NazaraAssert(m_object, "Invalid physics object");
NazaraAssert(mass > 0.f, "Mass should be positive");
NazaraAssert(mass >= 0.f, "Mass must be positive and finite");
NazaraAssert(std::isfinite(mass), "Mass must be positive and finite");
m_object->SetMass(mass);
}
@ -292,7 +396,6 @@ namespace Ndk
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetMassCenter(const Nz::Vector3f& center)
{
NazaraAssert(m_object, "Invalid physics object");
@ -300,6 +403,34 @@ namespace Ndk
m_object->SetMassCenter(center);
}
/*!
* \brief Sets the material of the object, affecting how object does respond to collisions
*
* \param materialName Name of the material, previously registered to physics world
*
* \remark materialName must exists in PhysWorld before this call
*/
inline void PhysicsComponent3D::SetMaterial(const Nz::String& materialName)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetMaterial(materialName);
}
/*!
* \brief Sets the material of the object, affecting how object does respond to collisions
*
* \param materialIndex Id of the material, previously retrieved from a physics world
*
* \remark materialIndex must come from a call to in PhysWorld::CreateMaterial
*/
inline void PhysicsComponent3D::SetMaterial(int materialIndex)
{
NazaraAssert(m_object, "Invalid physics object");
m_object->SetMaterial(materialIndex);
}
/*!
* \brief Sets the position of the physics object
*
@ -330,27 +461,43 @@ namespace Ndk
m_object->SetRotation(rotation);
}
/*!
* \brief Sets the velocity of the physics object
*
* \param velocity Velocity of the object
*
* \remark Produces a NazaraAssert if the physics object is invalid
*/
inline void PhysicsComponent3D::SetVelocity(const Nz::Vector3f& velocity)
inline void PhysicsComponent3D::ApplyPhysicsState(Nz::RigidBody3D& rigidBody) const
{
NazaraAssert(m_object, "Invalid physics object");
assert(m_pendingStates.valid);
m_object->SetVelocity(velocity);
rigidBody.EnableAutoSleep(m_pendingStates.autoSleep);
rigidBody.SetAngularDamping(m_pendingStates.angularDamping);
rigidBody.SetGravityFactor(m_pendingStates.gravityFactor);
rigidBody.SetLinearDamping(m_pendingStates.linearDamping);
rigidBody.SetMass(m_pendingStates.mass);
rigidBody.SetMassCenter(m_pendingStates.massCenter);
}
inline void PhysicsComponent3D::CopyPhysicsState(const Nz::RigidBody3D& rigidBody)
{
m_pendingStates.autoSleep = rigidBody.IsAutoSleepEnabled();
m_pendingStates.angularDamping = rigidBody.GetAngularDamping();
m_pendingStates.gravityFactor = rigidBody.GetGravityFactor();
m_pendingStates.linearDamping = rigidBody.GetLinearDamping();
m_pendingStates.mass = rigidBody.GetMass();
m_pendingStates.massCenter = rigidBody.GetMassCenter(Nz::CoordSys_Local);
m_pendingStates.valid = true;
}
/*!
* \brief Gets the underlying physics object
* \return A reference to the physics object
*/
inline Nz::RigidBody3D* PhysicsComponent3D::GetRigidBody()
{
return m_object.get();
}
inline Nz::RigidBody3D& PhysicsComponent3D::GetRigidBody()
/*!
* \brief Gets the underlying physics object
* \return A reference to the physics object
*/
inline const Nz::RigidBody3D& PhysicsComponent3D::GetRigidBody() const
{
return *m_object.get();
}

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,9 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <Nazara/Core/Error.hpp>
#include <NDK/Entity.hpp>
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -12,7 +12,6 @@
#include <Nazara/Core/ObjectHandle.hpp>
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Graphics/TextSprite.hpp>
#include <Nazara/Platform/Event.hpp>
#include <Nazara/Utility/Node.hpp>
#include <Nazara/Utility/SimpleTextDrawer.hpp>
#include <NDK/BaseWidget.hpp>
@ -21,6 +20,7 @@
namespace Nz
{
class LuaState;
struct WindowEvent;
}
namespace Ndk

View File

@ -1,9 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <Nazara/Core/Error.hpp>
#include "Console.hpp"
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -11,6 +11,7 @@
#include <Nazara/Core/HandledObject.hpp>
#include <Nazara/Core/Signal.hpp>
#include <NDK/Algorithm.hpp>
#include <NDK/Prerequisites.hpp>
#include <memory>
#include <vector>
@ -40,7 +41,8 @@ namespace Ndk
const EntityHandle& Clone() const;
inline void Enable(bool enable = true);
inline void Disable();
void Enable(bool enable = true);
inline BaseComponent& GetComponent(ComponentIndex index);
template<typename ComponentType> ComponentType& GetComponent();

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Entity.hpp>
#include <Nazara/Core/Error.hpp>
@ -8,7 +8,6 @@
#include <algorithm>
#include <cassert>
#include <type_traits>
#include <utility>
namespace Ndk
{
@ -30,18 +29,13 @@ namespace Ndk
}
/*!
* \brief Enables the entity
* \brief Disables the entity
*
* \param enable Should the entity be enabled
* This is just a shortcut to Enable(false)
*/
inline void Entity::Enable(bool enable)
inline void Entity::Disable()
{
if (m_enabled != enable)
{
m_enabled = enable;
Invalidate();
}
Enable(false);
}
/*!

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -8,7 +8,7 @@
#define NDK_ENTITYLIST_HPP
#include <Nazara/Core/Bitset.hpp>
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/Entity.hpp>
namespace Ndk
@ -35,6 +35,7 @@ namespace Ndk
inline void Insert(Entity* entity);
inline void Remove(Entity* entity);
inline void Reserve(std::size_t entityCount);
// STL API
inline iterator begin() const;

View File

@ -1,8 +1,7 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/EntityList.hpp>
#include <Nazara/Core/Error.hpp>
#include <algorithm>
@ -137,6 +136,16 @@ namespace Ndk
}
}
/*!
* \brief Reserves enough space to contains entityCount entities
*
* \param entityCount Number of entities to reserve
*/
inline void EntityList::Reserve(std::size_t entityCount)
{
m_entityBits.Reserve(entityCount);
}
// STL Interface
inline EntityList::iterator EntityList::begin() const
{
@ -160,6 +169,9 @@ namespace Ndk
inline EntityList& EntityList::operator=(const EntityList& entityList)
{
for (const Ndk::EntityHandle& entity : *this)
entity->UnregisterEntityList(this);
m_entityBits = entityList.m_entityBits;
m_world = entityList.m_world;
@ -171,6 +183,12 @@ namespace Ndk
inline EntityList& EntityList::operator=(EntityList&& entityList) noexcept
{
if (this == &entityList)
return *this;
for (const Ndk::EntityHandle& entity : *this)
entity->UnregisterEntityList(this);
m_entityBits = std::move(entityList.m_entityBits);
m_world = entityList.m_world;

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -31,4 +31,4 @@ namespace Ndk
#include <NDK/EntityOwner.inl>
#endif // NDK_ENTITYOwner_HPP
#endif // NDK_ENTITYOWNER_HPP

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <Nazara/Core/StringStream.hpp>
#include <functional>

View File

@ -1,13 +1,12 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_LUABINDING_HPP
#define NDK_LUABINDING_HPP
#include <NDK/BaseComponent.hpp>
#include <NDK/Entity.hpp>
#include <NDK/Lua/LuaBinding_Base.hpp>
#include <memory>

View File

@ -1,8 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Lua/LuaBinding.hpp>
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -9,7 +9,7 @@
#include <Nazara/Lua/LuaClass.hpp>
#include <Nazara/Lua/LuaInstance.hpp>
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -11,6 +11,7 @@
#include <NDK/Components.hpp>
#include <NDK/Console.hpp>
#include <NDK/Entity.hpp>
#include <NDK/World.hpp>
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,13 +1,13 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_LUAINTERFACE_HPP
#define NDK_LUAINTERFACE_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
namespace Nz
{

View File

@ -1,8 +1,7 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/LuaAPI.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Lua/LuaState.hpp>
#include <Nazara/Math/EulerAngles.hpp>
@ -16,7 +15,6 @@
#include <NDK/Components.hpp>
#include <NDK/Entity.hpp>
#include <NDK/World.hpp>
#include <algorithm>
#ifndef NDK_SERVER
#include <Nazara/Audio/Music.hpp>
@ -310,9 +308,22 @@ namespace Nz
return ret;
}
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::Entity** handle, TypeTag<Ndk::Entity*>)
{
if (!state.IsOfType(index, LuaType_Nil))
*handle = *static_cast<Ndk::EntityHandle*>(state.CheckUserdata(index, "Entity"));
else
*handle = nullptr;
return 1;
}
inline unsigned int LuaImplQueryArg(const LuaState& state, int index, Ndk::EntityHandle* handle, TypeTag<Ndk::EntityHandle>)
{
*handle = *static_cast<Ndk::EntityHandle*>(state.CheckUserdata(index, "Entity"));
if (!state.IsOfType(index, LuaType_Nil))
*handle = *static_cast<Ndk::EntityHandle*>(state.CheckUserdata(index, "Entity"));
else
handle->Reset();
return 1;
}

View File

@ -22,15 +22,15 @@
SOFTWARE.
*/
#ifndef NDK_PREREQUESITES_HPP
#define NDK_PREREQUESITES_HPP
#ifndef NDK_PREREQUISITES_HPP
#define NDK_PREREQUISITES_HPP
/*!
* \defgroup NDK (NazaraSDK) Nazara Development Kit
* A library grouping every modules of Nazara into multiple higher-level features suchs as scene management (handled by an ECS), application, lua binding, etc.
*/
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Prerequisites.hpp>
// Importation/Exportation of the API
#if defined(NAZARA_STATIC)
@ -51,4 +51,4 @@ namespace Ndk
using SystemIndex = Nz::UInt32;
}
#endif // NDK_PREREQUESITES_HPP
#endif // NDK_PREREQUISITES_HPP

View File

@ -1,13 +1,13 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_SDK_HPP
#define NDK_SDK_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,13 +1,13 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_STATE_HPP
#define NDK_STATE_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
namespace Ndk
{

View File

@ -1,13 +1,13 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_STATEMACHINE_HPP
#define NDK_STATEMACHINE_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/State.hpp>
#include <memory>
#include <vector>
@ -24,15 +24,13 @@ namespace Ndk
inline void ChangeState(std::shared_ptr<State> state);
inline const std::shared_ptr<State>& GetCurrentState() const;
inline bool IsTopState(const State* state) const;
inline std::shared_ptr<State> PopState();
inline bool PopStatesUntil(std::shared_ptr<State> state);
inline void PopState();
inline void PopStatesUntil(std::shared_ptr<State> state);
inline void PushState(std::shared_ptr<State> state);
inline void SetState(std::shared_ptr<State> state);
inline void ResetState(std::shared_ptr<State> state);
inline bool Update(float elapsedTime);
@ -40,7 +38,21 @@ namespace Ndk
StateMachine& operator=(const StateMachine&) = delete;
private:
enum class TransitionType
{
Pop,
PopUntil,
Push,
};
struct StateTransition
{
TransitionType type;
std::shared_ptr<State> state;
};
std::vector<std::shared_ptr<State>> m_states;
std::vector<StateTransition> m_transitions;
};
}

View File

@ -1,7 +1,8 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/StateMachine.hpp>
#include <Nazara/Core/Error.hpp>
#include <utility>
@ -16,66 +17,56 @@ namespace Ndk
/*!
* \brief Constructs a StateMachine object with an original state
*
* \param originalState State which is the entry point of the application
*
* \remark Calls "Enter" on the state
* \remark Produces a NazaraAssert if nullptr is given
* \param originalState State which is the entry point of the application, a nullptr will create an empty state machine
*/
inline StateMachine::StateMachine(std::shared_ptr<State> originalState)
{
NazaraAssert(originalState, "StateMachine must have a state to begin with");
PushState(std::move(originalState));
if (originalState)
PushState(std::move(originalState));
}
/*!
* \brief Destructs the object
*
* \remark Calls "Leave" on all the states
* \remark Calls "Leave" on all the states from top to bottom
*/
inline StateMachine::~StateMachine()
{
for (std::shared_ptr<State>& state : m_states)
state->Leave(*this);
// Leave state from top to bottom (as if states were popped out)
for (auto it = m_states.rbegin(); it != m_states.rend(); ++it)
(*it)->Leave(*this);
}
/*!
* \brief Replaces the current state on the top of the machine
*
* \param state State to replace the top one if it is nullptr, no action is performed
*
* \remark It is forbidden for a state machine to have (at any moment) the same state in its list multiple times
* \remark Like all actions popping or pushing a state, this is not immediate and will only take effect when state machine is updated
*/
inline void StateMachine::ChangeState(std::shared_ptr<State> state)
{
if (state)
{
PopState();
PushState(std::move(state));
// Change state is just a pop followed by a push
StateTransition transition;
transition.type = TransitionType::Pop;
m_transitions.emplace_back(std::move(transition));
transition.state = std::move(state);
transition.type = TransitionType::Push;
m_transitions.emplace_back(std::move(transition));
}
}
/*!
* \brief Gets the current state on the top of the machine
* \return A constant reference to the state
*
* \remark The stack is supposed to be non empty, otherwise it is undefined behaviour
*
* \see PopStatesUntil
*/
inline const std::shared_ptr<State>& StateMachine::GetCurrentState() const
{
return m_states.back();
}
/*!
* \brief Checks whether the state is on the top of the machine
* \return true If it is the case
*
* \param state State to compare the top with
* \remark Because all actions popping or pushing a state don't take effect until next state machine update, this can return false on a just pushed state
*/
inline bool StateMachine::IsTopState(const State* state) const
{
if (m_states.empty())
@ -86,40 +77,36 @@ namespace Ndk
/*!
* \brief Pops the state on the top of the machine
* \return Old state on the top, nullptr if stack was empty
*
* \remark This method can completely empty the stack
* \remark Like all actions popping or pushing a state, this is not immediate and will only take effect when state machine is updated
*/
inline std::shared_ptr<State> StateMachine::PopState()
inline void StateMachine::PopState()
{
if (m_states.empty())
return nullptr;
StateTransition transition;
transition.type = TransitionType::Pop;
m_states.back()->Leave(*this);
std::shared_ptr<State> oldTopState = std::move(m_states.back());
m_states.pop_back();
return oldTopState;
m_transitions.emplace_back(std::move(transition));
}
/*!
* \brief Pops all the states of the machine until a specific one is reached
* \return true If that specific state is on top, false if stack is empty
* \brief Pops all states of the machine until a specific one is reached
*
* \param state State to find on the stack if it is nullptr, no action is performed
* \param state State to find on the stack. If nullptr is passed, no action is performed
*
* \remark This method can completely empty the stack
* \remark This method will completely empty the stack if state is not present
* \remark Like all actions popping or pushing a state, this is not immediate and will only take effect when state machine is updated
*/
inline bool StateMachine::PopStatesUntil(std::shared_ptr<State> state)
inline void StateMachine::PopStatesUntil(std::shared_ptr<State> state)
{
if (!state)
return false;
if (state)
{
StateTransition transition;
transition.state = std::move(state);
transition.type = TransitionType::PopUntil;
while (!m_states.empty() && !IsTopState(state.get()))
PopState();
return !m_states.empty();
m_transitions.emplace_back(std::move(transition));
}
}
/*!
@ -127,34 +114,40 @@ namespace Ndk
*
* \param state Next state to represent if it is nullptr, it performs no action
*
* \remark Produces a NazaraAssert if the same state is pushed two times on the stack
* \remark It is forbidden for a state machine to have (at any moment) the same state in its list multiple times
* \remark Like all actions popping or pushing a state, this is not immediate and will only take effect when state machine is updated
*/
inline void StateMachine::PushState(std::shared_ptr<State> state)
{
if (state)
{
NazaraAssert(std::find(m_states.begin(), m_states.end(), state) == m_states.end(), "The same state was pushed two times");
StateTransition transition;
transition.state = std::move(state);
transition.type = TransitionType::Push;
m_states.push_back(std::move(state));
m_states.back()->Enter(*this);
m_transitions.emplace_back(std::move(transition));
}
}
/*!
* \brief Pops every states of the machine to put a new one
*
* \param state State to reset the stack with if it is nullptr, no action is performed
* \param state State to reset the stack with. If state is invalid, this will clear the state machine
*
* \remark It is forbidden for a state machine to have (at any moment) the same state in its list multiple times
* \remark Like all actions popping or pushing a state, this is not immediate and will only take effect when state machine is updated
*/
inline void StateMachine::SetState(std::shared_ptr<State> state)
inline void StateMachine::ResetState(std::shared_ptr<State> state)
{
StateTransition transition;
transition.type = TransitionType::PopUntil; //< Pop until nullptr, which basically clears the state machine
m_transitions.emplace_back(std::move(transition));
if (state)
{
while (!m_states.empty())
PopState();
PushState(std::move(state));
transition.state = std::move(state);
transition.type = TransitionType::Push;
m_transitions.emplace_back(std::move(transition));
}
}
@ -164,9 +157,41 @@ namespace Ndk
*
* \param elapsedTime Delta time used for the update
*/
inline bool StateMachine::Update(float elapsedTime)
{
for (StateTransition& transition : m_transitions)
{
switch (transition.type)
{
case TransitionType::Pop:
{
std::shared_ptr<State>& topState = m_states.back();
topState->Leave(*this); //< Call leave before popping to ensure consistent IsTopState behavior
m_states.pop_back();
break;
}
case TransitionType::PopUntil:
{
while (!m_states.empty() && m_states.back() != transition.state)
{
m_states.back()->Leave(*this);
m_states.pop_back();
}
break;
}
case TransitionType::Push:
{
m_states.emplace_back(std::move(transition.state));
m_states.back()->Enter(*this);
break;
}
}
}
m_transitions.clear();
return std::all_of(m_states.begin(), m_states.end(), [=](std::shared_ptr<State>& state) {
return state->Update(*this, elapsedTime);
});

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -16,12 +16,10 @@ namespace Ndk
{
public:
System();
System(const System&) = default;
System(const System&) = delete;
System(System&&) = default;
virtual ~System();
std::unique_ptr<BaseSystem> Clone() const override;
System& operator=(const System&) = delete;
System& operator=(System&&) = default;

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Algorithm.hpp>
#include <type_traits>
@ -28,22 +28,6 @@ namespace Ndk
template<typename SystemType>
System<SystemType>::~System() = default;
/*!
* \brief Clones the system
* \return The clone newly created
*
* \remark The system to clone should be trivially copy constructible
*/
template<typename SystemType>
std::unique_ptr<BaseSystem> System<SystemType>::Clone() const
{
///FIXME: Not fully supported in GCC (4.9.2)
//static_assert(std::is_trivially_copy_constructible<SystemType>::value, "SystemType should be copy-constructible");
return std::make_unique<SystemType>(static_cast<const SystemType&>(*this));
}
/*!
* \brief Registers the system by assigning it an index
*/

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,3 +1,3 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,3 +1,3 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -18,7 +18,6 @@ namespace Ndk
{
public:
PhysicsSystem3D();
PhysicsSystem3D(const PhysicsSystem3D& system);
~PhysicsSystem3D() = default;
Nz::PhysWorld3D& GetWorld();

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -11,16 +11,16 @@
#include <Nazara/Graphics/AbstractBackground.hpp>
#include <Nazara/Graphics/CullingList.hpp>
#include <Nazara/Graphics/DepthRenderTechnique.hpp>
#include <Nazara/Graphics/ForwardRenderTechnique.hpp>
#include <Nazara/Renderer/RenderTexture.hpp>
#include <NDK/Components/GraphicsComponent.hpp>
#include <NDK/EntityList.hpp>
#include <NDK/System.hpp>
#include <unordered_map>
#include <NDK/Components/GraphicsComponent.hpp>
#include <vector>
namespace Ndk
{
class AbstractViewer;
class NDK_API RenderSystem : public System<RenderSystem>
{
public:
@ -52,6 +52,7 @@ namespace Ndk
void OnEntityValidation(Entity* entity, bool justAdded) override;
void OnUpdate(float elapsedTime) override;
void UpdateDynamicReflections();
void UpdateDirectionalShadowMaps(const Nz::AbstractViewer& viewer);
void UpdatePointSpotShadowMaps();
@ -63,6 +64,7 @@ namespace Ndk
EntityList m_lights;
EntityList m_pointSpotLights;
EntityList m_particleGroups;
EntityList m_realtimeReflected;
GraphicsComponentCullingList m_drawableCulling;
Nz::BackgroundRef m_background;
Nz::DepthRenderTechnique m_shadowTechnique;

View File

@ -1,20 +1,9 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{
/*!
* \brief Constructs a RenderSystem object by copy semantic
*
* \param renderSystem RenderSystem to copy
*/
inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) :
System(renderSystem)
{
}
/*!
* \brief Changes the render technique used for the system
* \return A reference to the render technique type

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once

View File

@ -1,3 +1,3 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp

View File

@ -7,6 +7,8 @@
#include <NDK/Widgets/ButtonWidget.hpp>
#include <NDK/Widgets/CheckboxWidget.hpp>
#include <NDK/Widgets/Enums.hpp>
#include <NDK/Widgets/ImageWidget.hpp>
#include <NDK/Widgets/LabelWidget.hpp>
#include <NDK/Widgets/ProgressBarWidget.hpp>
#include <NDK/Widgets/TextAreaWidget.hpp>

View File

@ -1,22 +1,25 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_WIDGETS_BUTTONWIDGET_HPP
#define NDK_WIDGETS_BUTTONWIDGET_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/BaseWidget.hpp>
#include <Nazara/Utility/AbstractTextDrawer.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Graphics/TextSprite.hpp>
namespace Nz
{
class AbstractTextDrawer;
}
namespace Ndk
{
class World;
class NDK_API ButtonWidget : public BaseWidget
{
public:
@ -29,17 +32,44 @@ namespace Ndk
void ResizeToContent() override;
inline const Nz::Color& GetColor() const;
inline const Nz::Color& GetCornerColor() const;
inline const Nz::Color& GetHoverColor() const;
inline const Nz::Color& GetHoverCornerColor() const;
inline const Nz::Color& GetPressColor() const;
inline const Nz::Color& GetPressCornerColor() const;
inline const Nz::TextureRef& GetTexture() const;
inline const Nz::TextureRef& GetHoverTexture() const;
inline const Nz::TextureRef& GetPressTexture() const;
inline void SetColor(const Nz::Color& color, const Nz::Color& cornerColor);
inline void SetHoverColor(const Nz::Color& color, const Nz::Color& cornerColor);
inline void SetPressColor(const Nz::Color& color, const Nz::Color& cornerColor);
inline void SetTexture(const Nz::TextureRef& texture);
inline void SetHoverTexture(const Nz::TextureRef& texture);
inline void SetPressTexture(const Nz::TextureRef& texture);
inline void UpdateText(const Nz::AbstractTextDrawer& drawer);
ButtonWidget& operator=(const ButtonWidget&) = delete;
ButtonWidget& operator=(ButtonWidget&&) = default;
static const Nz::Color& GetDefaultColor();
static const Nz::Color& GetDefaultCornerColor();
static const Nz::Color& GetDefaultHoverColor();
static const Nz::Color& GetDefaultHoverCornerColor();
static const Nz::Color& GetDefaultPressColor();
static const Nz::Color& GetDefaultPressCornerColor();
NazaraSignal(OnButtonTrigger, const ButtonWidget* /*button*/);
private:
void Layout() override;
void OnMouseEnter() override;
void OnMouseButtonPress(int x, int y, Nz::Mouse::Button button) override;
void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button) override;
void OnMouseExit() override;
@ -47,6 +77,24 @@ namespace Ndk
EntityHandle m_gradientEntity;
Nz::SpriteRef m_gradientSprite;
Nz::TextSpriteRef m_textSprite;
Nz::Color m_color;
Nz::Color m_cornerColor;
Nz::Color m_hoverColor;
Nz::Color m_hoverCornerColor;
Nz::Color m_pressColor;
Nz::Color m_pressCornerColor;
Nz::TextureRef m_texture;
Nz::TextureRef m_hoverTexture;
Nz::TextureRef m_pressTexture;
static Nz::Color s_color;
static Nz::Color s_cornerColor;
static Nz::Color s_hoverColor;
static Nz::Color s_hoverCornerColor;
static Nz::Color s_pressColor;
static Nz::Color s_pressCornerColor;
};
}

View File

@ -1,11 +1,94 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Widgets/ButtonWidget.hpp>
namespace Ndk
{
inline const Nz::Color& ButtonWidget::GetColor() const
{
return m_color;
}
inline const Nz::Color& ButtonWidget::GetCornerColor() const
{
return m_cornerColor;
}
inline const Nz::Color& ButtonWidget::GetHoverColor() const
{
return m_hoverColor;
}
inline const Nz::Color& ButtonWidget::GetHoverCornerColor() const
{
return m_hoverCornerColor;
}
inline const Nz::Color& ButtonWidget::GetPressColor() const
{
return m_pressColor;
}
inline const Nz::Color& ButtonWidget::GetPressCornerColor() const
{
return m_pressCornerColor;
}
inline const Nz::TextureRef& ButtonWidget::GetTexture() const
{
return m_texture;
}
inline const Nz::TextureRef& ButtonWidget::GetHoverTexture() const
{
return m_hoverTexture;
}
inline const Nz::TextureRef& ButtonWidget::GetPressTexture() const
{
return m_pressTexture;
}
inline void ButtonWidget::SetColor(const Nz::Color& color, const Nz::Color& cornerColor)
{
m_color = color;
m_cornerColor = cornerColor;
m_gradientSprite->SetColor(m_color);
m_gradientSprite->SetCornerColor(Nz::RectCorner_LeftBottom, m_cornerColor);
m_gradientSprite->SetCornerColor(Nz::RectCorner_RightBottom, m_cornerColor);
}
inline void ButtonWidget::SetHoverColor(const Nz::Color& color, const Nz::Color& cornerColor)
{
m_hoverColor = color;
m_hoverCornerColor = cornerColor;
}
inline void ButtonWidget::SetPressColor(const Nz::Color& color, const Nz::Color& cornerColor)
{
m_pressColor = color;
m_pressCornerColor = cornerColor;
}
inline void ButtonWidget::SetTexture(const Nz::TextureRef& texture)
{
m_texture = texture;
m_gradientSprite->SetTexture(m_texture);
}
inline void ButtonWidget::SetHoverTexture(const Nz::TextureRef& texture)
{
m_hoverTexture = texture;
}
inline void ButtonWidget::SetPressTexture(const Nz::TextureRef& texture)
{
m_pressTexture = texture;
}
inline void ButtonWidget::UpdateText(const Nz::AbstractTextDrawer& drawer)
{
m_textSprite->Update(drawer);

View File

@ -1,27 +1,28 @@
// Copyright (C) 2017 Samy Bensaid
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_WIDGETS_CHECKBOXWIDGET_HPP
#define NDK_WIDGETS_CHECKBOXWIDGET_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/BaseWidget.hpp>
#include <NDK/Widgets/Enums.hpp>
#include <NDK/Components/NodeComponent.hpp>
#include <NDK/Widgets/Enums.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Utility/AbstractTextDrawer.hpp>
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Graphics/TextSprite.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Math/Rect.hpp>
namespace Nz
{
class AbstractTextDrawer;
}
namespace Ndk
{
class World;
class NDK_API CheckboxWidget : public BaseWidget
{
friend class Sdk;

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Samy Bensaid
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
namespace Ndk
{

View File

@ -1,6 +1,6 @@
// Copyright (C) 2017 Samy Bensaid
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
@ -17,6 +17,15 @@ namespace Ndk
CheckboxState_Max = CheckboxState_Unchecked
};
enum EchoMode
{
EchoMode_Normal,
EchoMode_Password,
EchoMode_PasswordExceptLast,
EchoMode_Max = EchoMode_PasswordExceptLast
};
}
#endif // NAZARA_ENUMS_SDK_HPP

View File

@ -0,0 +1,53 @@
// Copyright (C) 2017 Samy Bensaid
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_WIDGETS_IMAGEWIDGET_HPP
#define NDK_WIDGETS_IMAGEWIDGET_HPP
#include <NDK/Prerequisites.hpp>
#include <NDK/BaseWidget.hpp>
#include <NDK/Entity.hpp>
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Math/Vector2.hpp>
namespace Ndk
{
class NDK_API ImageWidget : public BaseWidget
{
public:
ImageWidget(BaseWidget* parent = nullptr);
ImageWidget(const ImageWidget&) = delete;
ImageWidget(ImageWidget&&) = default;
~ImageWidget() = default;
//virtual ImageWidget* Clone() const = 0;
void ResizeToContent() override;
inline const Nz::Color& GetColor() const;
inline const Nz::TextureRef& GetTexture() const;
inline const Nz::Rectf& GetTextureCoords() const;
inline void SetColor(const Nz::Color& color);
inline void SetTexture(const Nz::TextureRef& texture, bool resizeToContent = true);
inline void SetTextureCoords(const Nz::Rectf& coords);
inline void SetTextureRect(const Nz::Rectui& rect);
ImageWidget& operator=(const ImageWidget&) = delete;
ImageWidget& operator=(ImageWidget&&) = default;
private:
void Layout() override;
Ndk::EntityHandle m_entity;
Nz::SpriteRef m_sprite;
};
}
#include <NDK/Widgets/ImageWidget.inl>
#endif // NDK_WIDGETS_IMAGEWIDGET_HPP

View File

@ -0,0 +1,46 @@
// Copyright (C) 2017 Samy Bensaid
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#include <NDK/Widgets/ImageWidget.hpp>
namespace Ndk
{
inline const Nz::Color& ImageWidget::GetColor() const
{
return m_sprite->GetColor();
}
inline const Nz::TextureRef& ImageWidget::GetTexture() const
{
return m_sprite->GetMaterial()->GetDiffuseMap();
}
inline const Nz::Rectf& ImageWidget::GetTextureCoords() const
{
return m_sprite->GetTextureCoords();
}
inline void ImageWidget::SetColor(const Nz::Color& color)
{
m_sprite->SetColor(color);
}
inline void ImageWidget::SetTexture(const Nz::TextureRef& texture, bool resizeToContent)
{
m_sprite->SetTexture(texture, false);
if (resizeToContent)
ResizeToContent();
}
inline void ImageWidget::SetTextureCoords(const Nz::Rectf& coords)
{
m_sprite->SetTextureCoords(coords);
}
inline void ImageWidget::SetTextureRect(const Nz::Rectui& rect)
{
m_sprite->SetTextureRect(rect);
}
}

View File

@ -1,21 +1,23 @@
// Copyright (C) 2017 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
// For conditions of distribution and use, see copyright notice in Prerequisites.hpp
#pragma once
#ifndef NDK_WIDGETS_LABELWIDGET_HPP
#define NDK_WIDGETS_LABELWIDGET_HPP
#include <NDK/Prerequesites.hpp>
#include <NDK/Prerequisites.hpp>
#include <NDK/BaseWidget.hpp>
#include <Nazara/Utility/AbstractTextDrawer.hpp>
#include <Nazara/Graphics/TextSprite.hpp>
namespace Nz
{
class AbstractTextDrawer;
}
namespace Ndk
{
class World;
class NDK_API LabelWidget : public BaseWidget
{
public:
@ -26,7 +28,7 @@ namespace Ndk
//virtual LabelWidget* Clone() const = 0;
void ResizeToContent();
void ResizeToContent() override;
inline void UpdateText(const Nz::AbstractTextDrawer& drawer);
@ -34,6 +36,8 @@ namespace Ndk
LabelWidget& operator=(LabelWidget&&) = default;
private:
void Layout() override;
EntityHandle m_textEntity;
Nz::TextSpriteRef m_textSprite;
};

Some files were not shown because too many files have changed in this diff Show More