Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

OSS bell, misc fixes

- ozCore
  * OSS bell, enabled instead of ALSA on non-Linux-based Unices
- ozDynamics
 * working ODE
-glsl
  * fog fixed on low detail
- README, .spec & PKGBUILD updates
  • Loading branch information...
commit 63eb7c2acaffe84bb3083e03ffdcdf8debb4bdca 1 parent 5b0f9f9
@ducakar authored
View
16 CMakeLists.txt
@@ -82,9 +82,6 @@ elseif( NACL )
link_directories( ${PLATFORM_PORTS_PREFIX}/usr/lib )
endif()
-# Local libmad, faad and eSpeak headers.
-include_directories( SYSTEM ./include )
-
find_package( PhysFS REQUIRED )
mark_as_advanced( PHYSFS_INCLUDE_DIR )
mark_as_advanced( PHYSFS_LIBRARY )
@@ -96,7 +93,7 @@ endif()
if( OZ_LUAJIT )
pkg_check_modules( LUAJIT REQUIRED luajit )
- include_directories( SYSTEM ${LUAJIT_INCLUDE_DIR} )
+ include_directories( SYSTEM ${LUAJIT_INCLUDE_DIRS} )
else()
find_package( Lua51 REQUIRED )
endif()
@@ -105,7 +102,7 @@ if( OZ_SDL2 )
pkg_check_modules( SDL2 REQUIRED sdl2 )
pkg_check_modules( SDL2_TTF REQUIRED SDL2_ttf )
- include_directories( SYSTEM ${SDL2_INCLUDE_DIR} )
+ include_directories( SYSTEM ${SDL2_INCLUDE_DIRS} )
else()
find_package( SDL REQUIRED )
find_package( SDL_ttf REQUIRED )
@@ -119,7 +116,7 @@ endif()
if( OZ_GL_ES )
# On embedded platform GLES is part of system libraries and is guaranteed to exist in toolchain or
- # platform directory, no need to explicitly check existence or detect library names.
+ # platform directory, no need to explicitly check existence or to detect library names.
if( NOT PLATFORM_EMBEDDED )
pkg_check_modules( GLES2 REQUIRED gles2 )
endif()
@@ -136,7 +133,7 @@ if( PLATFORM_EMBEDDED )
pkg_check_modules( VORBIS REQUIRED vorbis ) # required by vorbisfile
pkg_check_modules( OGG REQUIRED ogg ) # required by vorbisfile
find_package( Freetype REQUIRED ) # required by SDL_ttf
- find_package( ZLIB ) # required by PhysicsFS & FreeType
+ find_package( ZLIB REQUIRED ) # required by PhysicsFS & FreeType
endif()
if( NOT PLATFORM_EMBEDDED )
@@ -163,9 +160,14 @@ mark_as_advanced( MINGW32_LIBRARY )
# Compiler flags
#
+# Local libmad, faad and eSpeak headers.
+include_directories( SYSTEM ./include )
+
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang )
set( flags "-std=c++11 -pedantic" )
+ # Use libc++ instead of libstdc++.
+ # set( flags "${flags} -stdlib=libc++" )
# AddressSanitizer memory checker
# set( flags "${flags} -faddress-sanitizer" )
elseif( ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.5 )
View
2  ChangeLog.md
@@ -11,7 +11,7 @@
* new Mat33 class
* SIMD support in linear algebra classes
* new SpinLock class
- * PulseAudio replaced with ALSA for System::bell()
+ * ALSA and OSS back-ends for System::bell()
* linear algebra classes added as primitives to streams, Log and JSON
- ozDynamics
* collision
View
23 README.md
@@ -10,15 +10,16 @@ This README file is intended for developers only. See `doc/README.html` if you a
Building
--------
-Building is currently supported under Linux. You can build Linux, Windows (MinGW) and Native Client
-ports. Android port in still under development.
+Building is currently supported under Linux. You can build Linux/Unix, Windows (MinGW) and Native
+Client ports. Android port in still under development.
For generic Linux builds, make sure you have all the dependencies installed. You need to install
development packages for the following libraries:
-- libpulse
-- ALSA
+- ALSA (Linux only)
+- libpulse (Linux/Unix only)
- PhysicsFS 2.0 or 2.1
+- ODE (optional)
- Lua 5.1 or 5.2 or LuaJIT 2.0
- SDL 1.2 or 2.0
- SDL_ttf
@@ -28,11 +29,6 @@ development packages for the following libraries:
- FreeImage
- libsquish (optional)
-If you don't have libmad, faad and eSpeak on your system, you can use headers located in `include`
-subdirectory. Those are automatically used on Android, NaCl and Windows, overriding any of those
-headers found on the system. On Linux one may add "`-I./include`" to `CMAKE_CXXFLAGS` for the same
-effect.
-
You can then use generic steps for building CMake projects:
mkdir build
@@ -55,11 +51,6 @@ MinGW32 is searched in `/usr/i486-mingw32` by default. You may change that in
You may also want to set several options when configuring CMake build system:
-- `OZ_SHARED_LIBS`: Build liboz (OpenZone Core Library plus OpenZone Dynamics Library) as a shared
- library. This is useful if one wants to put liboz into a separate Linux package so other programs
- can use it too.
- `OFF` by default, forced to `OFF` on Android and NaCl.
-
- `OZ_TRACK_ALLOCS`: Enable tracking of allocated memory chunks in liboz. Stack trace for every
memory allocation performed via new operator is saved for later diagnostics. It detects new/delete
mismatches and one can check for currently allocated memory chunks (and hence memory leaks).
@@ -71,6 +62,10 @@ You may also want to set several options when configuring CMake build system:
vector components in OpenZone code.
`OFF` by default.
+- `OZ_ODE`: Compile with Open Dynamics Engine. Without this option ozDynamics builds only partially,
+ without physics support.
+ `OFF` by default.
+
- `OZ_LUAJIT`: Use LuaJIT instead of official Lua library. Lua scripts execute significantly faster.
`OFF` by default.
View
4 TODO.md
@@ -41,7 +41,3 @@ CURRENT
- unittest
* write missing tests
- documentation
-
-2.0
-
-- ozdynamics
View
2  cmake/NaCl-i686.Toolchain.cmake
@@ -7,7 +7,7 @@ set( PLATFORM_PORTS_PREFIX "${CMAKE_SOURCE_DIR}/ports/NaCl-i686" )
set( CMAKE_SYSTEM_NAME "Linux" CACHE STRING "Target system." )
set( CMAKE_SYSTEM_PROCESSOR "i686" CACHE STRING "Target processor." )
-set( CMAKE_FIND_ROOT_PATH "${PLATFORM_PORTS_PREFIX};${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}" )
+set( CMAKE_FIND_ROOT_PATH "${PLATFORM_PORTS_PREFIX};${PLATFORM_PREFIX}/x86_64-nacl" )
set( CMAKE_C_COMPILER "${PLATFORM_PREFIX}/bin/${PLATFORM_TRIPLET}-gcc" )
set( CMAKE_CXX_COMPILER "${PLATFORM_PREFIX}/bin/${PLATFORM_TRIPLET}-g++" )
set( CMAKE_C_FLAGS "-msse3 -mfpmath=sse" CACHE STRING "" )
View
2  cmake/NaCl-x86_64.Toolchain.cmake
@@ -7,7 +7,7 @@ set( PLATFORM_PORTS_PREFIX "${CMAKE_SOURCE_DIR}/ports/NaCl-x86_64" )
set( CMAKE_SYSTEM_NAME "Linux" CACHE STRING "Target system." )
set( CMAKE_SYSTEM_PROCESSOR "x86_64" CACHE STRING "Target processor." )
-set( CMAKE_FIND_ROOT_PATH "${PLATFORM_PORTS_PREFIX};${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}" )
+set( CMAKE_FIND_ROOT_PATH "${PLATFORM_PORTS_PREFIX};${PLATFORM_PREFIX}/x86_64-nacl" )
set( CMAKE_C_COMPILER "${PLATFORM_PREFIX}/bin/${PLATFORM_TRIPLET}-gcc" )
set( CMAKE_CXX_COMPILER "${PLATFORM_PREFIX}/bin/${PLATFORM_TRIPLET}-g++" )
set( CMAKE_C_FLAGS "-msse3" CACHE STRING "" )
View
2  data/ozbase/glsl/mesh.frag
@@ -32,7 +32,7 @@ void main()
vec3 normal = normalize( exNormal );
#ifdef OZ_LOW_DETAIL
- float dist = gl_FragCoord.w / gl_FragCoord.z;
+ float dist = 1.0 / gl_FragCoord.w;
#else
vec3 toCamera = oz_CameraPosition - exPosition;
float dist = length( toCamera );
View
2  data/ozbase/glsl/terraLand.frag
@@ -34,7 +34,7 @@ void main()
vec3 normal = normalize( exNormal );
#ifdef OZ_LOW_DETAIL
- float dist = gl_FragCoord.w / gl_FragCoord.z;
+ float dist = 1.0 / gl_FragCoord.w;
#else
vec3 toCamera = oz_CameraPosition - exPosition;
float dist = length( toCamera );
View
2  data/rz_base/glsl/mesh.frag
@@ -32,7 +32,7 @@ void main()
vec3 normal = normalize( exNormal );
#ifdef OZ_LOW_DETAIL
- float dist = gl_FragCoord.w / gl_FragCoord.z;
+ float dist = 1.0 / gl_FragCoord.w;
#else
vec3 toCamera = oz_CameraPosition - exPosition;
float dist = length( toCamera );
View
2  data/rz_base/glsl/terraLand.frag
@@ -34,7 +34,7 @@ void main()
vec3 normal = normalize( exNormal );
#ifdef OZ_LOW_DETAIL
- float dist = gl_FragCoord.w / gl_FragCoord.z;
+ float dist = 1.0 / gl_FragCoord.w;
#else
vec3 toCamera = oz_CameraPosition - exPosition;
float dist = length( toCamera );
View
26 doc/PREBERI.html
@@ -432,7 +432,7 @@ <h1 class="centre">OpenZone</h1>
</td>
</tr>
<tr>
- <th>dir.music [string] ""</th>
+ <th>dir.music [string] "<a href="#dirs">&lt;music&gt;</a>/OpenZone"</th>
</tr>
<tr>
<td>
@@ -693,6 +693,30 @@ <h1 class="centre">OpenZone</h1>
</tr>
</table>
+<h4>Imenik &lt;music&gt;</h4>
+<table>
+ <tr>
+ <th>Platforma</th>
+ <th>Natančna pot</th>
+ <th>Običajna pot</th>
+ </tr>
+ <tr>
+ <td>Linux</td>
+ <td>$XDG_MUSIC_DIR/OpenZone</td>
+ <td>~/Music/OpenZone</td>
+ </tr>
+ <tr>
+ <td>Windows XP</td>
+ <td>%MYMUSIC%\OpenZone</td>
+ <td>C:\Documents and Settings\&lt;uporabniško_ime&gt;\My Music\OpenZone</td>
+ </tr>
+ <tr>
+ <td>Windows 7</td>
+ <td>%MYMUSIC%\OpenZone</td>
+ <td>C:\Users\&lt;uporabniško_ime&gt;\Music\OpenZone</td>
+ </tr>
+</table>
+
<h2><a name="vfs" href="#">Navidezni datotečni sistem</a></h2>
<p>
Podatki za igro se preberejo iz notranjega navideznega datotečnega sistema, ki je unija naslednjih
View
26 doc/README.html
@@ -430,7 +430,7 @@ <h1 class="centre">OpenZone</h1>
</td>
</tr>
<tr>
- <th>dir.music [string] ""</th>
+ <th>dir.music [string] "<a href="#dirs">&lt;music&gt;</a>/OpenZone"</th>
</tr>
<tr>
<td>
@@ -691,6 +691,30 @@ <h1 class="centre">OpenZone</h1>
</tr>
</table>
+<h4>&lt;music&gt; directory</h4>
+<table>
+ <tr>
+ <th>Platform</th>
+ <th>Exact location</th>
+ <th>Typical location</th>
+ </tr>
+ <tr>
+ <td>Linux</td>
+ <td>$XDG_MUSIC_DIR/OpenZone</td>
+ <td>~/Music/OpenZone</td>
+ </tr>
+ <tr>
+ <td>Windows XP</td>
+ <td>%MYMUSIC%\OpenZone</td>
+ <td>C:\Documents and Settings\&lt;username&gt;\My Music\OpenZone</td>
+ </tr>
+ <tr>
+ <td>Windows 7</td>
+ <td>%MYMUSIC%\OpenZone</td>
+ <td>C:\Users\&lt;username&gt;\Music\OpenZone</td>
+ </tr>
+</table>
+
<h2><a name="vfs" href="#">Virtual Filesystem</a></h2>
<p>
Game data are read from internal virtual filesystem that is a union of the following locations:
View
36 etc/PKGBUILD
@@ -7,14 +7,14 @@ pkgrel=1
url="http://ducakar.github.com/openzone/"
license=('GPL3')
arch=('i686' 'x86_64')
-makedepends=('cmake' 'freeimage' 'git' 'libpulse' 'luajit' 'mesa' 'openal' 'physfs' 'sdl_ttf')
-source=("https://github.com/downloads/ducakar/openzone/openzone-src-$pkgver.tar.xz"
- "https://github.com/downloads/ducakar/openzone/openzone-data-$pkgver.tar.xz")
+makedepends=('cmake' 'freeimage' 'libpulse' 'luajit' 'mesa' 'openal' 'physfs' 'sdl_ttf' 'libsquish')
+source=("https://github.com/downloads/ducakar/openzone/${pkgbase}-src-${pkgver}.tar.xz"
+ "https://github.com/downloads/ducakar/openzone/${pkgbase}-data-${pkgver}.tar.xz")
sha1sums=()
build()
{
- cd "$srcdir/$pkgbase-$pkgver/build"
+ cd "${srcdir}/${pkgbase}-${pkgver}/build"
cmake \
-D CMAKE_BUILD_TYPE=Release \
@@ -31,15 +31,15 @@ package_liboz()
{
pkgdesc='OpenZone Core and Dynamics libraries'
license=('ZLIB')
- depends=('libpulse' 'physfs' 'ode-sp')
+ depends=('libpulse' 'physfs')
- cd "$srcdir/$pkgbase-$pkgver"
+ cd "${srcdir}/${pkgbase}-${pkgver}"
- ( cd build && make install DESTDIR="$pkgdir" )
+ ( cd build && make install DESTDIR="${pkgdir}" )
- rm -rf "$pkgdir/usr/"{bin,share}
+ rm -rf "${pkgdir}"/usr/{bin,share}
- install -Dm644 "src/ozCore/COPYING" "$pkgdir/usr/share/licenses/liboz/COPYING"
+ install -Dm644 "src/ozCore/COPYING" "${pkgdir}/usr/share/licenses/liboz/COPYING"
}
package_openzone()
@@ -53,15 +53,15 @@ package_openzone()
'zip: building ZIP game data archives'
'p7zip: building 7zip game data archives')
- cd "$srcdir/$pkgbase-$pkgver"
+ cd "${srcdir}/${pkgbase}-${pkgver}"
- ( cd build && make install DESTDIR="$pkgdir" )
+ ( cd build && make install DESTDIR="${pkgdir}" )
- rm -rf "$pkgdir/usr/"{lib,include,share/doc}
+ rm -rf "${pkgdir}/usr/"{lib,include,share/doc}
- install -dm755 "$pkgdir/usr/share/doc/openzone/licences"
- install -m644 AUTHORS README.md ChangeLog.md doc/*.html "$pkgdir/usr/share/doc/openzone"
- install -m644 doc/licences/* "$pkgdir/usr/share/doc/openzone/licences"
+ install -dm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/licences"
+ install -m644 doc/*.html "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
+ install -m644 doc/licences/* "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/licences"
}
package_openzone-data()
@@ -70,8 +70,8 @@ package_openzone-data()
license=('custom')
arch=('any')
- cd "$srcdir/$pkgbase-$pkgver"
+ cd "${srcdir}/${pkgbase}-${pkgver}"
- install -dm755 "$pkgdir/usr/share/openzone"
- install -m644 "share/openzone/"*.zip "$pkgdir/usr/share/openzone"
+ install -dm755 "${pkgdir}/usr/share/openzone"
+ install -m644 "share/openzone/"*.zip "${pkgdir}/usr/share/openzone"
}
View
51 etc/PKGBUILD.aur
@@ -0,0 +1,51 @@
+# Maintainer: Davorin Učakar <davorin.ucakar@gmail.com>
+
+pkgname=openzone
+pkgver=0.3.81
+pkgrel=1
+pkgdesc='Simple cross-platform FPS/RTS game engine'
+url="http://ducakar.github.com/openzone/"
+license=('GPL3' 'ZLIB')
+arch=('i686' 'x86_64')
+depends=('libpulse' 'physfs' 'freeimage' 'libgl' 'luajit' 'openal' 'sdl_ttf')
+optdepends=('openzone-data: game data'
+ 'espeak: speech synthesis'
+ 'libmad: MP3 playing'
+ 'faad2: AAC playing'
+ 'zip: building ZIP game data archives'
+ 'p7zip: building 7zip game data archives')
+makedepends=('cmake' 'freeimage' 'libpulse' 'luajit' 'mesa' 'openal' 'physfs' 'sdl_ttf' 'libsquish')
+source=("https://github.com/downloads/ducakar/openzone/${pkgname}-src-${pkgver}.tar.xz"
+ "https://github.com/downloads/ducakar/openzone/${pkgname}-data-${pkgver}.tar.xz")
+sha1sums=()
+
+build()
+{
+ cd "${srcdir}/${pkgbase}-${pkgver}/build"
+
+ cmake \
+ -D CMAKE_BUILD_TYPE=Release \
+ -D CMAKE_INSTALL_PREFIX=/usr \
+ -D CMAKE_CXX_FLAGS="$CXXFLAGS -msse3 -mfpmath=sse" \
+ -D OZ_LUAJIT=1 \
+ -D OZ_NONFREE=1 \
+ ..
+
+ make
+}
+
+package()
+{
+ cd "${srcdir}/${pkgbase}-${pkgver}"
+
+ ( cd build && make install DESTDIR="${pkgdir}" )
+
+ install -Dm644 "src/ozCore/COPYING" "${pkgdir}/usr/share/licenses/openzone/COPYING.liboz"
+
+ install -dm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/licences"
+ install -m644 doc/*.html "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
+ install -m644 doc/licences/* "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}/licences"
+
+ install -dm755 "${pkgdir}/usr/share/openzone"
+ install -m644 "share/openzone/"*.zip "${pkgdir}/usr/share/openzone"
+}
View
97 etc/openzone.spec
@@ -1,37 +1,27 @@
Name: openzone
Version: 0.3.81
-Release: 1
-Summary: Simple cross-platform FPS/RTS game engine (meta package)
-URL: http://ducakar.github.com/openzone/
-License: GPLv3+
+Release: 1%{?dist}
+Summary: Simple cross-platform FPS/RTS game engine
Group: Amusements/Games
+License: GPLv3+
+URL: http://ducakar.github.com/openzone/
Packager: Davorin Učakar <davorin.ucakar@gmail.com>
-
-Source: openzone-src-%{version}.tar.xz
-Source1: openzone-data-%{version}.tar.xz
-
-Requires: %{name}-client = %{version}
Requires: %{name}-data = %{version}
-%package -n liboz
-Summary: OpenZone Core and Dynamics libraries
-License: zlib
-Group: System Environment/Libraries
-
-%package -n liboz-devel
-Summary: Headers for OpenZone Core and Dynamics libraries
-License: zlib
-Group: Development/Libraries
-Requires: liboz-core = %{version}
-
-%package client
-Summary: Simple cross-platform FPS/RTS game engine
-
-%package data
-Summary: OpenZone game data
-License: Custom
-Group: Amusements/Games
-Requires: %{name}-client = %{version}
+Source0: https://github.com/downloads/ducakar/openzone/%{name}-src-%{version}.tar.xz
+Source1: https://github.com/downloads/ducakar/openzone/%{name}-data-%{version}.tar.xz
+
+BuildRequires: cmake
+BuildRequires: alsa-lib-devel
+BuildRequires: pulseaudio-libs-devel
+BuildRequires: physfs-devel
+BuildRequires: lua-devel
+BuildRequires: SDL
+BuildRequires: SDL_ttf
+BuildRequires: mesa-libGL-devel
+BuildRequires: openal-soft-devel
+BuildRequires: libvorbis-devel
+BuildRequires: freeimage-devel
%description
OpenZone is a relatively simple cross-platform game engine, suitable for FPS,
@@ -39,7 +29,11 @@ RTS and RPG genres. It is strictly divided into several layers. Back-end runs
a complete simulation of a world (physics, object handlers, controllers, AI)
and front-end that renders it and enables the player to manipulate with the
simulated world.
-This is a meta package that installs engine and game data.
+
+%package -n liboz
+Summary: OpenZone Core and Dynamics libraries
+Group: System Environment/Libraries
+License: zlib
%description -n liboz
OpenZone Core Library provides facilities like container templates, array
@@ -47,23 +41,26 @@ utilities, string class, memory manager with memory leak tracing, crash
handlers, I/O buffers and classes for filesystem access with PhysicsFS support,
log writer, JSON file manipulation class, math functions and linear algebra
classes.
-OpenZone Dynamics Library is a simple rigid body physics engine used in OpenZone
-game.
+OpenZone Dynamics Library is a simple rigid body physics engine used in
+OpenZone game.
+
+%package -n liboz-devel
+Summary: Headers for OpenZone Core and Dynamics libraries
+Group: Development/Libraries
+License: zlib
+Requires: liboz = %{version}
%description -n liboz-devel
This package contains header files OpenZone Core and Dynamics libraries.
-%description client
-OpenZone is a relatively simple cross-platform game engine, suitable for FPS,
-RTS and RPG genres. It is strictly divided into several layers. Back-end runs
-a complete simulation of a world (physics, object handlers, controllers, AI)
-and front-end that renders it and enables the player to manipulate with the
-simulated world.
-This package only includes engine. Game data packages must be installed
-separately.
+%package data
+Summary: OpenZone game data
+License: Custom
+BuildArch: noarch
+Requires: %{name} = %{version}
%description data
-Game data for OpenZone. Includes tutorial, testing world and cviček missions.
+Game data for OpenZone. Includes tutorial, test world and cviček mission.
%prep
%setup -q -b 1
@@ -74,6 +71,7 @@ cd build
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr \
+ -D CMAKE_C_FLAGS="-msse3 -mfpmath=sse" \
-D CMAKE_CXX_FLAGS="-msse3 -mfpmath=sse" \
..
@@ -96,29 +94,26 @@ if [[ %{_libdir} != /usr/lib ]]; then
fi
%files
-%defattr(-, root, root)
+%defattr(-, root, root, -)
+%{_bindir}/*
+%{_datadir}/applications
+%{_datadir}/pixmaps
+%doc AUTHORS COPYING README.md ChangeLog.md doc/*.html doc/licences
%files -n liboz
-%defattr(-, root, root)
+%defattr(-, root, root, -)
%{_libdir}/libozCore.so*
%{_libdir}/libozDynamics.so*
%doc src/ozCore/COPYING
%files -n liboz-devel
-%defattr(-, root, root)
+%defattr(-, root, root, -)
%{_libdir}/pkgconfig/ozCore.pc
%{_libdir}/pkgconfig/ozDynamics.pc
%{_includedir}/ozCore
%{_includedir}/ozDynamics
%doc src/ozCore/COPYING
-%files client
-%defattr(-, root, root)
-%{_bindir}/*
-%{_datadir}/applications
-%{_datadir}/pixmaps
-%doc AUTHORS COPYING README.md ChangeLog.md doc/*.html doc/licences
-
%files data
-%defattr(-, root, root)
+%defattr(-, root, root, -)
%{_datadir}/openzone
View
5 src/CMakeLists.txt
@@ -16,7 +16,10 @@ add_subdirectory( tools )
if( NOT ANDROID AND NOT NACL )
add_subdirectory( builder )
- add_subdirectory( txc_dxtn )
+
+ if( UNIX )
+ add_subdirectory( txc_dxtn )
+ endif()
endif()
add_subdirectory( tests )
View
5 src/client/Client.cc
@@ -165,7 +165,7 @@ int Client::init( int argc, char** argv )
String configDir = String::str( "%s\\openzone", configRoot );
String localDir = String::str( "%s\\openzone", localRoot );
- String musicDir = musicRoot;
+ String musicDir = String::str( "%s\\OpenZone", musicRoot );
#else
@@ -186,7 +186,8 @@ int Client::init( int argc, char** argv )
String::str( "%s/.local/share/openzone", home ) :
String::str( "%s/openzone", localRoot );
- String musicDir = musicRoot == nullptr ? String::str( "%s/Music", home ) : String( musicRoot );
+ String musicDir = musicRoot == nullptr ? String::str( "%s/Music/OpenZone", home ) :
+ String( musicRoot );
#endif
View
45 src/client/Render.cc
@@ -774,6 +774,7 @@ Render render;
#include <ozDynamics/ozDynamics.hh>
#include "Input.hh"
+#include <common/Timer.hh>
namespace oz
{
@@ -786,21 +787,20 @@ static oz::Physics physics;
void Render::drawDyn()
{
- Vec4 colour = Vec4( 0.0f, 0.0f, 1.0f, 1.0f );
-
- if( oz::Collider::overlaps( space.bodies[0], space.bodies[1] ) ) {
- colour = Vec4( 1.0f, 1.0f, 1.0f, 1.0f );
+ if( timer.frameTime > 0.0f ) {
+ physics.update( timer.frameTime );
}
+ Vec4 colour = Vec4( 0.0f, 0.0f, 1.0f, 1.0f );
+
for( int i = 0; i < space.bodies.length(); ++i ) {
Body* body = space.bodies[i];
- if( i == 2 ) {
- body->rot *= Quat::rotationZXZ( float( input.mouseX ) * 0.01f, float( input.mouseY ) * 0.01f,
- 0.0f );
+ if( i < 2 && pcollider.overlaps( body, space.bodies[2] ) ) {
+ colour = Vec4( 1.0f, 1.0f, 1.0f, 1.0f );
}
else {
- body->rot *= Quat::rotationAxis( ~Vec3( 1.0f, float( i ), 1.0f ), 0.002f );
+ colour = Vec4( 0.0f, 0.0f, 1.0f, 1.0f );
}
body->rot = ~body->rot;
@@ -816,33 +816,50 @@ void Render::loadDyn()
{
physics.init( &space, &pcollider );
- Compound* c = new Compound();
- c->add( new Box( Vec3( 1.0f, 1.0f, 1.0f ) ), Vec3( 1.0f, 1.0f, 1.0f ), Mat33::ID );
+ DBody* body;
+
+// Compound* c = new Compound();
+// c->add( new Box( Vec3( 1.0f, 1.0f, 1.0f ) ), Vec3( 1.0f, 1.0f, 1.0f ), Mat33::ID );
// c->add( new Capsule( 1, 1 ), Vec3( -2, 1, 0 ), Mat33::rotationX( Math::TAU / 6.0f ) );
-// Box* c = new Box( Vec3( 1, 1, 2 ) );
+ Box* c = new Box( Vec3( 1, 1, 2 ) );
// Capsule* c = new Capsule( 1, 1 );
- Body* body = new Body();
+ body = new DBody();
body->pos = Point( 140, 0, 80 );
body->rot = Quat::ID;
+ body->rotMat = Mat33::rotation( body->rot );
body->setShape( c );
space.bodies.add( body );
+ physics.add( body );
+
Box* b = new Box( Vec3( 1, 1, 2 ) );
- body = new Body();
+ body = new DBody();
body->pos = Point( 143, 0, 80 );
body->rot = Quat::ID;
+ body->rotMat = Mat33::rotation( body->rot );
body->setShape( b );
space.bodies.add( body );
+
+ physics.add( body );
+
+ Box* p = new Box( Vec3( 10, 10, 1 ) );
+
+ body = new DBody();
+ body->pos = Point( 142, 0, 75 );
+ body->rot = Quat::ID;
+ body->rotMat = Mat33::rotation( body->rot );
+ body->setShape( p );
+ space.bodies.add( body );
}
void Render::unloadDyn()
{
+ physics.destroy();
space.clear();
Space::deallocate();
- physics.destroy();
}
}
View
4 src/ozCore/CMakeLists.txt
@@ -82,8 +82,10 @@ elseif( NACL )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} ${ZLIB_LIBRARY} -lppapi_cpp -lppapi -lpthread )
elseif( WIN32 )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} -lwinmm )
-else()
+elseif( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
target_link_libraries( ozCore ${PHYSFS_LIBRARY} -lpulse-simple -lasound -lrt -lpthread )
+else()
+ target_link_libraries( ozCore ${PHYSFS_LIBRARY} -lpulse-simple -lrt -lpthread )
endif()
install( TARGETS ozCore RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib )
View
98 src/ozCore/System.cc
@@ -53,11 +53,17 @@
# define _exit( code ) _Exit( code )
# define isatty( fd ) _isatty( fd )
#else
-# include <alsa/asoundlib.h>
# include <ctime>
# include <pthread.h>
-# include <pulse/simple.h>
# include <unistd.h>
+# include <pulse/simple.h>
+# ifdef __linux__
+# include <alsa/asoundlib.h>
+# else
+# include <sys/fcntl.h>
+# include <sys/ioctl.h>
+# include <sys/soundcard.h>
+# endif
#endif
#if defined( __native_client__ ) && !defined( __GLIBC__ )
@@ -363,24 +369,24 @@ static void* bellMain( void* )
pa_simple* pa = pa_simple_new( nullptr, "oz", PA_STREAM_PLAYBACK, nullptr, "bell",
&PA_SAMPLE_SPEC, nullptr, nullptr, nullptr );
-
if( pa != nullptr ) {
int nSamples = int( BELL_TIME * float( BELL_PREFERRED_RATE ) );
- size_t size = size_t( nSamples ) * 2 * sizeof( short );
+ size_t size = size_t( nSamples * 2 ) * sizeof( short );
short* samples = static_cast<short*>( malloc( size ) );
genBellSamples( samples, nSamples, BELL_PREFERRED_RATE, 0, nSamples );
-
pa_simple_write( pa, samples, size, nullptr );
+ free( samples );
+
pa_simple_drain( pa, nullptr );
pa_simple_free( pa );
- free( samples );
-
isBellPlaying = false;
return nullptr;
}
+#ifdef __linux__
+
snd_pcm_t* alsa;
if( snd_pcm_open( &alsa, "default", SND_PCM_STREAM_PLAYBACK, 0 ) != 0 ) {
isBellPlaying = false;
@@ -393,45 +399,71 @@ static void* bellMain( void* )
uint rate = BELL_PREFERRED_RATE;
- if( snd_pcm_hw_params_set_access( alsa, params, SND_PCM_ACCESS_RW_INTERLEAVED ) != 0 ) {
- isBellPlaying = false;
- return nullptr;
- }
- if( snd_pcm_hw_params_set_format( alsa, params, SND_PCM_FORMAT_S16 ) != 0 ) {
- isBellPlaying = false;
- return nullptr;
- }
- if( snd_pcm_hw_params_set_channels( alsa, params, 2 ) != 0 ) {
- isBellPlaying = false;
- return nullptr;
- }
- if( snd_pcm_hw_params_set_rate_resample( alsa, params, 0 ) != 0 ) {
+ if( snd_pcm_hw_params_set_access( alsa, params, SND_PCM_ACCESS_RW_INTERLEAVED ) != 0 ||
+ snd_pcm_hw_params_set_format( alsa, params, SND_PCM_FORMAT_S16 ) != 0 ||
+ snd_pcm_hw_params_set_channels( alsa, params, 2 ) != 0 ||
+ snd_pcm_hw_params_set_rate_resample( alsa, params, 0 ) != 0 ||
+ snd_pcm_hw_params_set_rate_near( alsa, params, &rate, nullptr ) != 0 ||
+ snd_pcm_hw_params( alsa, params ) != 0 ||
+ snd_pcm_prepare( alsa ) != 0 )
+ {
+ snd_pcm_close( alsa );
+
isBellPlaying = false;
return nullptr;
}
- if( snd_pcm_hw_params_set_rate_near( alsa, params, &rate, nullptr ) != 0 ) {
+
+ int nSamples = int( BELL_TIME * float( rate ) );
+ size_t size = size_t( nSamples * 2 ) * sizeof( short );
+ short* samples = static_cast<short*>( malloc( size ) );
+
+ genBellSamples( samples, nSamples, int( rate ), 0, nSamples );
+ snd_pcm_writei( alsa, samples, snd_pcm_uframes_t( nSamples ) );
+ free( samples );
+
+ snd_pcm_drain( alsa );
+ snd_pcm_close( alsa );
+
+#else
+
+ int fd;
+ if( ( fd = open( "/dev/dsp", O_WRONLY, 0 ) ) < 0 &&
+ ( fd = open( "/dev/dsp0", O_WRONLY, 0 ) ) < 0 &&
+ ( fd = open( "/dev/dsp1", O_WRONLY, 0 ) ) < 0 )
+ {
isBellPlaying = false;
return nullptr;
}
- if( snd_pcm_hw_params( alsa, params ) != 0 ) {
+
+# ifdef OZ_BIG_ENDIAN
+ int format = AFMT_S16_BE;
+# else
+ int format = AFMT_S16_LE;
+# endif
+ int channels = 2;
+ int rate = BELL_PREFERRED_RATE;
+
+ if( ioctl( fd, SNDCTL_DSP_SETFMT, &format ) < 0 ||
+ ioctl( fd, SNDCTL_DSP_CHANNELS, &channels ) < 0 ||
+ ioctl( fd, SNDCTL_DSP_SPEED, &rate ) < 0 )
+ {
+ close( fd );
+
isBellPlaying = false;
return nullptr;
}
- if( snd_pcm_prepare( alsa ) >= 0 ) {
- int nSamples = int( BELL_TIME * float( rate ) );
- size_t size = size_t( nSamples ) * 2 * sizeof( short );
- short* samples = static_cast<short*>( malloc( size ) );
-
- genBellSamples( samples, nSamples, int( rate ), 0, nSamples );
+ int nSamples = int( BELL_TIME * float( rate ) );
+ size_t size = size_t( nSamples * channels ) * sizeof( short );
+ short* samples = static_cast<short*>( malloc( size ) );
- snd_pcm_writei( alsa, samples, snd_pcm_uframes_t( nSamples ) );
- snd_pcm_drain( alsa );
+ genBellSamples( samples, nSamples, int( rate ), 0, nSamples );
+ write( fd, samples, size );
+ free( samples );
- free( samples );
- }
+ close( fd );
- snd_pcm_close( alsa );
+#endif
isBellPlaying = false;
return nullptr;
View
15 src/ozCore/System.hh
@@ -91,14 +91,11 @@ class System
/**
* Play a sound alert.
*
- * Sine wave from `oz/bellSample.inc` is played asynchronously through platform's native sound
- * system (PulseAudio and ALSA on Linux, `PlaySound` system call on Windows).
+ * Sine wave with decreasing volume lasting ~0.3 s is played asynchronously through platform's
+ * native sound system (PulseAudio and ALSA/OSS as fallback on Linux/Unix, `PlaySound` system
+ * call on Windows, Pepper API on NaCl).
*
- * Bell depends upon several statically initialised structures. If it is called inside static
- * initialisation/deinitialisation before/after those are initialised/deinitialised, it won't
- * play.
- *
- * On NaCl, `System::instance` and `System::core` must be set properly for bell to work.
+ * On NaCl, `System::instance` and `System::core` must be set for bell to work.
*/
static void bell();
@@ -132,11 +129,13 @@ class System
const char* msg, ... );
/**
- * Initialise current thread's signal handlers according to `flags` passed to `System::init()`.
+ * Initialise thread's signal handlers if `HANDLERS_BIT` has been passed to `System::init()`.
*
* Signal handlers must be set-up for each thread in a process separately. `System::init()`
* method sets them up for the caller thread only, for other threads this method should be used
* unless created with `Thread::start()`, which calls this method implicitly.
+ *
+ * If `HANDLERS_BIT` hasn't been passed to `System::init()` this method is a no-op.
*/
static void threadInit();
View
22 src/ozCore/config.hh.in
@@ -39,15 +39,15 @@
* Compiler and platform-specific macros
*/
-// #if defined( _MSC_VER )
-// # define OZ_MSVC _MSC_VER
-// # error Microsoft Compiler cannot compile OpenZone due to lack of C++11 support.
-// # error GCC >= 4.4 and LLVM/Clang >= 3.0 are the only supported compilers.
-// #elif defined( __OPENCC__ )
-// # define OZ_OPEN64 ( __OPENCC__ * 100 + __OPENCC_MINOR__ )
-// # error Open64 cannot compile OpenZone due to lack of C++11 support.
-// # error GCC >= 4.4 and LLVM/Clang >= 3.0 are the only supported compilers.
-#if defined( __clang__ )
+#if defined( _MSC_VER )
+# define OZ_MSVC _MSC_VER
+# error Microsoft Compiler cannot compile OpenZone due to lack of C++11 support.
+# error GCC >= 4.4 and LLVM/Clang >= 3.0 are the only supported compilers.
+#elif defined( __OPENCC__ )
+# define OZ_OPEN64 ( __OPENCC__ * 100 + __OPENCC_MINOR__ )
+# error Open64 cannot compile OpenZone due to lack of C++11 support.
+# error GCC >= 4.4 and LLVM/Clang >= 3.0 are the only supported compilers.
+#elif defined( __clang__ )
# define OZ_CLANG ( __clang_major__ * 100 + __clang_minor__ )
# if OZ_CLANG < 300
# error GCC >= 4.4 and LLVM/Clang >= 3.0 are the only supported compilers.
@@ -73,8 +73,8 @@ namespace std { typedef __PTRDIFF_TYPE__ nullptr_t; }
# endif
#endif
-// Workaround for a development snapshot of LLVM/Clang 3.2.
-#if defined( OZ_CLANG ) && OZ_CLANG == 302
+// Workaround for LLVM/Clang 3.2+ using glibc headers.
+#if defined( OZ_CLANG ) && OZ_CLANG >= 302
# define __extern_always_inline extern __always_inline __attribute__(( __gnu_inline__ ))
#endif
View
2  src/ozCore/ozCore.pc.in
@@ -7,4 +7,4 @@ Name: ozCore
Description: OpenZone Core Library
Version: @OZ_VERSION@
Libs: -L${libdir} -lozCore
-Cflags: -I${includedir} -std=c++11
+Cflags: -std=c++11 -I${includedir}
View
107 src/ozDynamics/collision/Collider.cc
@@ -40,30 +40,38 @@ bool Collider::boxBox( const Mat33& rot0, const Shape* box0_,
const Mat33& rot1, const Shape* box1_,
const Vec3& relPos, Result* result )
{
- const Box* box0 = static_cast<const Box*>( box0_ );
- const Box* box1 = static_cast<const Box*>( box1_ );
+ const Box* box0 = static_cast<const Box*>( box0_ );
+ const Box* box1 = static_cast<const Box*>( box1_ );
- Vec3 ext0 = box0->ext;
- Vec3 ext1 = box1->ext;
- Mat33 c = ~rot0 * rot1;
- Mat33 d = abs( c );
+ Vec3 ext0 = box0->ext;
+ Vec3 ext1 = box1->ext;
+ Mat33 c = ~rot0 * rot1;
+ Mat33 d = abs( c );
- Vec3 lastAxis = Vec3::ZERO;
- float lastDepth = -1.0f;
+ Vec3 lastAxis = Vec3::ZERO;
+ float lastDepth = Math::INF;
+ int lastPoint[3] = { 0, 0, 0 }; // [0] = whether generated by edges,
+ // [1] = face/edge on first box,
+ // [2] = face/edge on second box.
// Separating axes for faces of `box0`.
for( int j = 0; j < 3; ++j ) {
float r0 = ext0[j];
float r1 = ext1 * d.row( j );
- float dist = rot0[j] * relPos;
+ float dist = abs( rot0[j] * relPos );
float depth = r0 + r1 - dist;
- if( depth < 0.0f ) {
+ if( depth <= 0.0f ) {
return false;
}
- else if( depth > lastDepth ) {
- lastAxis = rot0[j];
- lastDepth = depth;
+ else if( depth < lastDepth ) {
+ lastAxis = rot0[j];
+ lastDepth = depth;
+ //lastPoint[0] = 0;
+ lastPoint[1] = j;
+ //lastPoint[2] = 0;
+
+ hard_assert( lastAxis.sqN() > 0.0f );
}
}
@@ -71,15 +79,20 @@ bool Collider::boxBox( const Mat33& rot0, const Shape* box0_,
for( int j = 0; j < 3; ++j ) {
float r0 = ext0 * d[j];
float r1 = ext1[j];
- float dist = rot1[j] * relPos;
+ float dist = abs( rot1[j] * relPos );
float depth = r0 + r1 - dist;
- if( depth < 0.0f ) {
+ if( depth <= 0.0f ) {
return false;
}
- else if( depth > lastDepth ) {
+ else if( depth < lastDepth ) {
lastAxis = rot1[j];
lastDepth = depth;
+ //lastPoint[0] = 0;
+ //lastPoint[1] = 0;
+ lastPoint[2] = j;
+
+ hard_assert( lastAxis.sqN() > 0.0f );
}
}
@@ -88,32 +101,56 @@ bool Collider::boxBox( const Mat33& rot0, const Shape* box0_,
int ia1 = ( 2 + i ) % 3;
for( int j = 0; j < 3; ++j ) {
- int ib0 = ( 1 + j ) % 3;
- int ib1 = ( 2 + j ) % 3;
+ int ib0 = ( 1 + j ) % 3;
+ int ib1 = ( 2 + j ) % 3;
+
+ float ca0 = d[j][ia1];
+ float ca1 = d[j][ia0];
+ float cb0 = d[ib1][i];
+ float cb1 = d[ib0][i];
+
+ float r0 = ext0[ia0] * ca0 + ext0[ia1] * ca1;
+ float r1 = ext1[ib0] * cb0 + ext1[ib1] * cb1;
+
+ if( r0 * r1 != 0.0f ) {
+ float dist = abs( c[j][ia1] * ( rot0[ia0] * relPos ) - c[j][ia0] * ( rot0[ia1] * relPos ) );
+ float depth = r0 + r1 - dist;
+
+ if( depth <= 0.0f ) {
+ return false;
+ }
+ else if( depth < lastDepth ) {
+ lastAxis = rot0[i] ^ rot1[j];
+ lastDepth = depth;
+ lastPoint[0] = 1;
+ lastPoint[1] = i;
+ lastPoint[2] = j;
+
+ hard_assert( lastAxis.sqN() > 0.0f );
+ }
+ }
+ }
+ }
+
+ if( result != nullptr ) {
+ hard_assert( lastAxis.sqN() > 0.0f );
- float ca0 = d[j][ia1];
- float ca1 = d[j][ia0];
- float cb0 = d[ib1][i];
- float cb1 = d[ib0][i];
+ result->axis = lastAxis;
+ result->depth = lastDepth;
- float r0 = ext0[ia0] * ca0 + ext0[ia1] * ca1;
- float r1 = ext1[ib0] * cb0 + ext1[ib1] * cb1;
- float dist = abs( c[j][ia1] * ( rot0[ia0] * relPos ) - c[j][ia0] * ( rot0[ia1] * relPos ) );
- float depth = r0 + r1 - dist;
+ // Separating plane is one of the faces.
+ if( lastPoint[0] == 0 ) {
+ if( lastPoint[2] == 0 ) {
- if( depth < 0.0f ) {
- return false;
}
- else if( depth > lastDepth ) {
- lastAxis = rot0[i] ^ rot1[j];
- lastDepth = depth;
+ else {
+
}
}
- }
+ // Separating plane is generated by two edges.
+ else {
- if( result != nullptr && lastDepth > result->depth ) {
- result->axis = lastAxis;
- result->depth = lastDepth;
+ }
}
return true;
View
9 src/ozDynamics/collision/Collider.hh
@@ -41,6 +41,15 @@ class Collider
{
Vec3 axis;
float depth;
+
+ explicit Result() :
+ depth( Math::INF )
+ {}
+
+ void reset()
+ {
+ depth = Math::INF;
+ }
};
private:
View
2  src/ozDynamics/ozDynamics.pc.in
@@ -8,4 +8,4 @@ Description: OpenZone Dynamics Library
Version: @OZ_VERSION@
Requires: ozCore
Libs: -L${libdir} -lozDynamics
-Cflags: -I${includedir} -std=c++11
+Cflags: -std=c++11 -I${includedir}
View
34 src/ozDynamics/physics/Physics.cc
@@ -30,7 +30,7 @@
#ifdef OZ_ODE
-// If ODE is not compiled with single precision, this won't end good.
+// If ODE is not compiled with single precision, bad things are going to happen.
#define dSINGLE
#include <ode/ode.h>
@@ -80,7 +80,7 @@ void Physics::erase( DBody* body )
body->odeId = nullptr;
}
-void Physics::update()
+void Physics::update( float time )
{
for( int i = 0; i < space->bodies.length(); ++i ) {
const DBody* body0 = static_cast<const DBody*>( space->bodies[i] );
@@ -96,19 +96,20 @@ void Physics::update()
if( collider->overlaps( body0, body1, &result ) ) {
Point p = Math::mix( body0->pos, body1->pos, 0.5f );
+ Log() << result.depth << ", " << result.axis << "\n";
+
dContact contact;
- contact.surface.mode = dContactBounce | dContactSoftCFM;
+ contact.surface.mode = dContactBounce;
contact.surface.mu = dInfinity;
contact.surface.bounce = 0.8f;
- contact.surface.bounce_vel = 0.1f;
- contact.surface.soft_cfm = 0.001f;
+ contact.surface.bounce_vel = 0.5f;
contact.geom.normal[0] = result.axis[0];
contact.geom.normal[1] = result.axis[1];
contact.geom.normal[2] = result.axis[2];
contact.geom.pos[0] = p.x;
contact.geom.pos[1] = p.y;
contact.geom.pos[2] = p.z;
- contact.geom.depth = result.depth;
+ contact.geom.depth = -result.depth;
dJointID joint = dJointCreateContact( world, contactGroup, &contact );
dJointAttach( joint, body0->odeId, body1->odeId );
@@ -116,14 +117,17 @@ void Physics::update()
}
}
- dWorldQuickStep( world, 0.02f );
+ dWorldQuickStep( world, time );
+ dJointGroupEmpty( contactGroup );
foreach( i, space->bodies.citer() ) {
DBody* body = static_cast<DBody*>( *i );
- body->pos = Point( dBodyGetPosition( body->odeId ) );
- body->rot = Quat( dBodyGetQuaternion( body->odeId ) );
- body->rotMat = Mat33( dBodyGetRotation( body->odeId ) );
+ if( body->odeId != nullptr ) {
+ body->pos = Point( dBodyGetPosition( body->odeId ) );
+ body->rot = Quat( dBodyGetQuaternion( body->odeId ) );
+ body->rotMat = Mat33::rotation( body->rot );
+ }
}
}
@@ -135,13 +139,21 @@ void Physics::init( Space* space_, Collider* collider_ )
dInitODE();
world = dWorldCreate();
- dWorldSetGravity( world, 0.0f, 0.0f, -1.0f );
+ dWorldSetGravity( world, 0.0f, 0.0f, -9.81f );
contactGroup = dJointGroupCreate( 0 );
}
void Physics::destroy()
{
+ foreach( i, space->bodies.iter() ) {
+ DBody* body = static_cast<DBody*>( *i );
+
+ if( body->odeId != nullptr ) {
+ erase( body );
+ }
+ }
+
dWorldDestroy( world );
dJointGroupDestroy( contactGroup );
View
2  src/ozDynamics/physics/Physics.hh
@@ -46,7 +46,7 @@ class Physics
void add( DBody* body );
void erase( DBody* body );
- void update();
+ void update( float time );
void init( Space* space, Collider* collider );
void destroy();
View
2  src/tests/test.cc
@@ -24,8 +24,6 @@
#include <ozCore/ozCore.hh>
#include <ozDynamics/ozDynamics.hh>
-#include <physfs.h>
-
using namespace oz;
class Foo
Please sign in to comment.
Something went wrong with that request. Please try again.