Permalink
Browse files

Events for bot gestures, Window++, Math::index1()

- ozCore
  * JSON::clear() returns true on unused variable warning
  * Math::index1()
- ozEngine
  * Window++
- common
  * posWrap(), posDiff() for toroidal world
- matrix
  * events (sounds) for all gestures
  * partial toroidal world support
  • Loading branch information...
ducakar committed Apr 7, 2013
1 parent a34e9a0 commit a5a69f0cb69a3546dc70e833630c1bfcf81458d2
View
@@ -15,7 +15,7 @@
buildType=Debug
platforms=(
-# Linux-x86_64
+ Linux-x86_64
Linux-x86_64-Clang
# Linux-i686
# Linux-i686-Clang
@@ -60,12 +60,12 @@
"hit": "oz/land",
"land": "oz/land",
"splash": "free/splash1",
- "jump": "aard/jump",
- "melee": "aard/tak",
- "flip": "ppm/deathb",
- "death": "ppm/deathb",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "ppm/deathb",
+ "jump": "aard/jump",
+ "melee": "aard/tak",
+ "flip": "ppm/deathb"
}
}
@@ -42,11 +42,11 @@
"hit": "oz/land",
"land": "oz/land",
"splash": "free/splash1",
- "jump": "aard/jump",
- "flip": "ppm/deathb",
- "death": "ppm/deathb",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "ppm/deathb",
+ "jump": "aard/jump",
+ "flip": "ppm/deathb"
}
}
@@ -66,11 +66,11 @@
"hit": "oz/land",
"land": "oz/land",
"splash": "free/splash1",
- "jump": "aard/jump",
- "flip": "ppm/deathb",
- "death": "ppm/deathb",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "ppm/deathb",
+ "jump": "aard/jump",
+ "flip": "ppm/deathb"
}
}
@@ -58,11 +58,11 @@
"hit": "droid-sounds/fall2",
"land": "droid-sounds/fall1",
"splash": "free/splash1",
- "jump": "droid-sounds/pain50_1",
- "flip": "droid-sounds/death4",
- "death": "droid-sounds/death2",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "droid-sounds/death2",
+ "jump": "droid-sounds/pain50_1",
+ "flip": "droid-sounds/death4"
}
}
@@ -60,11 +60,11 @@
"hit": "droid-sounds/fall2",
"land": "droid-sounds/fall1",
"splash": "free/splash1",
- "jump": "droid-sounds/pain50_1",
- "flip": "droid-sounds/death4",
- "death": "droid-sounds/death2",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "droid-sounds/death2",
+ "jump": "droid-sounds/pain50_1",
+ "flip": "droid-sounds/death4"
}
}
@@ -57,12 +57,12 @@
"hit": "oz/land",
"land": "oz/land",
"splash": "free/splash1",
- "jump": "aard/jump",
- "melee": "aard/tak",
- "flip": "ppm/deathd",
- "death": "ppm/deathd",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "ppm/deathd",
+ "jump": "aard/jump",
+ "melee": "aard/tak",
+ "flip": "ppm/deathd"
}
}
@@ -40,12 +40,12 @@
"hit": "oz/land",
"land": "oz/land",
"splash": "free/splash1",
- "jump": "aard/jump",
- "melee": "aard/tak",
- "flip": "ppm/deathb",
- "death": "ppm/deathb",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "ppm/deathb",
+ "jump": "aard/jump",
+ "melee": "aard/tak",
+ "flip": "ppm/deathb"
}
}
@@ -38,12 +38,16 @@
"hit": "oz/land",
"land": "oz/land",
"splash": "free/splash1",
- "jump": "aard/jump",
- "melee": "aard/tak",
- "flip": "aard/grunt1",
- "death": "aard/die1",
"step": "openarena/boot4",
"waterStep": "openarena/splash1",
- "swimSurface": "openarena/watr_in"
+ "swimSurface": "openarena/watr_in",
+ "death": "aard/die1",
+ "jump": "aard/jump",
+ "melee": "aard/tak",
+ "point": "aard/grunt1",
+ "fallBack": "aard/grunt1",
+ "salute": "aard/grunt1",
+ "wave": "aard/grunt1",
+ "flip": "aard/grunt1"
}
}
@@ -1,6 +1,6 @@
-diff -Naur lua-5.2.1/src/llex.c lua-5.2.1-android/src/llex.c
---- lua-5.2.1/src/llex.c 2012-01-24 00:05:51.000000000 +0100
-+++ lua-5.2.1-android/src/llex.c 2012-10-14 01:05:28.384042154 +0200
+diff -Naur lua-5.2.2.orig/src/llex.c lua-5.2.2/src/llex.c
+--- lua-5.2.2.orig/src/llex.c 2013-03-16 22:10:18.000000000 +0100
++++ lua-5.2.2/src/llex.c 2013-04-03 18:42:00.327551527 +0200
@@ -211,7 +211,7 @@
*/
static void trydecpoint (LexState *ls, SemInfo *seminfo) {
View
@@ -365,7 +365,7 @@ function fetch()
fi
# Lua
- download 'http://www.lua.org/ftp/lua-5.2.1.tar.gz'
+ download 'http://www.lua.org/ftp/lua-5.2.2.tar.gz'
# LuaJIT
# download 'http://luajit.org/download/LuaJIT-2.0.0.tar.gz'
@@ -486,8 +486,8 @@ function build_physfs()
function build_lua()
{
- prepare lua-5.2.1 lua-5.2.1.tar.gz || return
- applyPatches lua-5.2.1.patch
+ prepare lua-5.2.2 lua-5.2.2.tar.gz || return
+ applyPatches lua-5.2.2.patch
make -j4 CC="$CC" AR="$AR rcu" RANLIB="$RANLIB" CFLAGS="$CFLAGS" PLAT="generic" MYLIBS="$LDFLAGS"
make INSTALL_TOP="$buildDir/usr" install
View
@@ -359,31 +359,43 @@ void Class::fillBot( const char* className )
fillDynamic( className );
flags |= Object::BOT_BIT | Object::CYLINDER_BIT | Object::UPDATE_FUNC_BIT;
- // we don't allow browsing bots' inventory as long as they are alive
+ // We don't allow browsing a bot's inventory as long as one is alive.
flags &= ~Object::BROWSABLE_BIT;
life *= 2.0f;
if( !audioType.isEmpty() ) {
const JSON& soundsConfig = config["audioSounds"];
- audioSounds[Bot::EVENT_JUMP] = soundsConfig["jump"].get( "" );
- audioSounds[Bot::EVENT_MELEE] = soundsConfig["melee"].get( "" );
- audioSounds[Bot::EVENT_FLIP] = soundsConfig["flip"].get( "" );
- audioSounds[Bot::EVENT_DEATH] = soundsConfig["death"].get( "" );
audioSounds[Bot::EVENT_STEP] = soundsConfig["step"].get( "" );
audioSounds[Bot::EVENT_WATERSTEP] = soundsConfig["waterStep"].get( "" );
audioSounds[Bot::EVENT_SWIM_SURFACE] = soundsConfig["swimSurface"].get( "" );
audioSounds[Bot::EVENT_SWIM_SUBMERGED] = soundsConfig["swimSubmerged"].get( "" );
- context.usedSounds.include( audioSounds[Bot::EVENT_JUMP] );
- context.usedSounds.include( audioSounds[Bot::EVENT_MELEE] );
- context.usedSounds.include( audioSounds[Bot::EVENT_FLIP] );
- context.usedSounds.include( audioSounds[Bot::EVENT_DEATH] );
+ audioSounds[Bot::EVENT_DEATH] = soundsConfig["death"].get( "" );
+ audioSounds[Bot::EVENT_JUMP] = soundsConfig["jump"].get( "" );
+ audioSounds[Bot::EVENT_MELEE] = soundsConfig["melee"].get( "" );
+
+ audioSounds[Bot::EVENT_POINT] = soundsConfig["point"].get( "" );
+ audioSounds[Bot::EVENT_FALL_BACK] = soundsConfig["fallBack"].get( "" );
+ audioSounds[Bot::EVENT_SALUTE] = soundsConfig["salute"].get( "" );
+ audioSounds[Bot::EVENT_WAVE] = soundsConfig["wave"].get( "" );
+ audioSounds[Bot::EVENT_FLIP] = soundsConfig["flip"].get( "" );
+
context.usedSounds.include( audioSounds[Bot::EVENT_STEP] );
context.usedSounds.include( audioSounds[Bot::EVENT_WATERSTEP] );
context.usedSounds.include( audioSounds[Bot::EVENT_SWIM_SURFACE] );
context.usedSounds.include( audioSounds[Bot::EVENT_SWIM_SUBMERGED] );
+
+ context.usedSounds.include( audioSounds[Bot::EVENT_DEATH] );
+ context.usedSounds.include( audioSounds[Bot::EVENT_JUMP] );
+ context.usedSounds.include( audioSounds[Bot::EVENT_MELEE] );
+
+ context.usedSounds.include( audioSounds[Bot::EVENT_POINT] );
+ context.usedSounds.include( audioSounds[Bot::EVENT_FALL_BACK] );
+ context.usedSounds.include( audioSounds[Bot::EVENT_SALUTE] );
+ context.usedSounds.include( audioSounds[Bot::EVENT_WAVE] );
+ context.usedSounds.include( audioSounds[Bot::EVENT_FLIP] );
}
state = 0;
View
@@ -112,7 +112,8 @@ void Caelum::draw()
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ibo );
glEnableVertexAttribArray( Attrib::POSITION );
- glVertexAttribPointer( Attrib::POSITION, 3, GL_FLOAT, GL_FALSE, sizeof( float[3] ), nullptr );
+ glVertexAttribPointer( Attrib::POSITION, 3, GL_FLOAT, GL_FALSE, int( sizeof( float[3] ) ),
+ nullptr );
glDrawElements( GL_TRIANGLE_STRIP, MAX_STARS * 6, GL_UNSIGNED_SHORT, nullptr );
View
@@ -107,7 +107,7 @@ MD2::AnimType MD2::AnimState::extractAnim()
if( bot->state & Bot::GESTURE_POINT_BIT ) {
return ANIM_POINT;
}
- else if( bot->state & Bot::GESTURE_BACK_BIT ) {
+ else if( bot->state & Bot::GESTURE_FALL_BACK_BIT ) {
return ANIM_FALLBACK;
}
else if( bot->state & Bot::GESTURE_SALUTE_BIT ) {
View
@@ -36,15 +36,15 @@ namespace client
void Vertex::setFormat()
{
glEnableVertexAttribArray( Attrib::POSITION );
- glVertexAttribPointer( Attrib::POSITION, 3, GL_FLOAT, GL_FALSE, sizeof( Vertex ),
+ glVertexAttribPointer( Attrib::POSITION, 3, GL_FLOAT, GL_FALSE, int( sizeof( Vertex ) ),
static_cast<char*>( nullptr ) + offsetof( Vertex, pos ) );
glEnableVertexAttribArray( Attrib::TEXCOORD );
- glVertexAttribPointer( Attrib::TEXCOORD, 2, GL_FLOAT, GL_FALSE, sizeof( Vertex ),
+ glVertexAttribPointer( Attrib::TEXCOORD, 2, GL_FLOAT, GL_FALSE, int( sizeof( Vertex ) ),
static_cast<char*>( nullptr ) + offsetof( Vertex, texCoord ) );
glEnableVertexAttribArray( Attrib::NORMAL );
- glVertexAttribPointer( Attrib::NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof( Vertex ),
+ glVertexAttribPointer( Attrib::NORMAL, 3, GL_FLOAT, GL_FALSE, int( sizeof( Vertex ) ),
static_cast<char*>( nullptr ) + offsetof( Vertex, normal ) );
}
View
@@ -168,15 +168,15 @@ void Shape::bind() const
glBindBuffer( GL_ARRAY_BUFFER, vbo );
glEnableVertexAttribArray( Attrib::POSITION );
- glVertexAttribPointer( Attrib::POSITION, 3, GL_FLOAT, GL_FALSE, sizeof( Vertex ),
+ glVertexAttribPointer( Attrib::POSITION, 3, GL_FLOAT, GL_FALSE, int( sizeof( Vertex ) ),
static_cast<char*>( nullptr ) + offsetof( Vertex, pos ) );
glEnableVertexAttribArray( Attrib::TEXCOORD );
- glVertexAttribPointer( Attrib::TEXCOORD, 2, GL_FLOAT, GL_FALSE, sizeof( Vertex ),
+ glVertexAttribPointer( Attrib::TEXCOORD, 2, GL_FLOAT, GL_FALSE, int( sizeof( Vertex ) ),
static_cast<char*>( nullptr ) + offsetof( Vertex, texCoord ) );
glEnableVertexAttribArray( Attrib::NORMAL );
- glVertexAttribPointer( Attrib::NORMAL, 3, GL_FLOAT, GL_FALSE, sizeof( Vertex ),
+ glVertexAttribPointer( Attrib::NORMAL, 3, GL_FLOAT, GL_FALSE, int( sizeof( Vertex ) ),
static_cast<char*>( nullptr ) + offsetof( Vertex, normal ) );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ibo );
View
@@ -53,7 +53,7 @@ void Terra::draw()
}
// to match strip triangles with matrix terrain we have to make them clockwise since
- // we draw column-major (strips along y axis) for better cache performance
+ // we draw column-major (triangle strips along y axis) for better cache performance
glFrontFace( GL_CW );
span.minX = max( int( ( camera.p.x - frustum.radius + matrix::Terra::DIM ) / TILE_SIZE ), 0 );
View
@@ -58,6 +58,11 @@ namespace common
*/
const int MAX_WORLD_COORD = 2048;
+/**
+ * Extent of world bounding box (equals `MAX_WORLD_COORD` but float type).
+ */
+const float WORLD_DIM = float( MAX_WORLD_COORD );
+
/**
* Margin for collision detection.
*
@@ -74,10 +79,21 @@ const int MAX_WORLD_COORD = 2048;
const float EPSILON = float( MAX_WORLD_COORD ) * 4.0f * Math::FLOAT_EPS;
/**
- * Wrap angle to interval \f$ [0, \tau) \f$.
+ * 2D integer span.
+ */
+struct Span
+{
+ int minX; ///< Minimum X.
+ int minY; ///< Minimum Y.
+ int maxX; ///< Maximum X.
+ int maxY; ///< Maximum Y.
+};
+
+/**
+ * Wrap angle to the interval \f$ [0, \tau) \f$.
*
- * This adjustment should be made after each angle addition/subtraction. It assumes the input angle
- * lies on interval \f$ [-\tau, \infty) \f$.
+ * This adjustment should be made after each angle change. It assumes the input angle lies on
+ * the interval \f$ [-\tau, \infty) \f$.
*/
OZ_ALWAYS_INLINE
inline float angleWrap( float x )
@@ -88,7 +104,7 @@ inline float angleWrap( float x )
/**
* Difference between two angles, maps to interval \f$ [-\frac{\tau}{2}, +\frac{\tau}{2}) \f$.
*
- * This function assumes that both angles lie on interval \f$ [0, \tau) \f$.
+ * This function assumes that both angles lie on the interval \f$ [0, \tau) \f$.
*/
OZ_ALWAYS_INLINE
inline float angleDiff( float x, float y )
@@ -97,15 +113,33 @@ inline float angleDiff( float x, float y )
}
/**
- * 2D integer span.
+ * Wrap position to the interval \f$ [-WORLD_DIM, +WORLD_DIM) \f$.
+ *
+ * This adjustment should be made after each position change. It assumes the input position lies
+ * on the interval \f$ [-2 WORLD_DIM, \infty) \f$.
*/
-struct Span
+OZ_ALWAYS_INLINE
+inline Point posWrap( const Point& p )
{
- int minX; ///< Minimum X.
- int minY; ///< Minimum Y.
- int maxX; ///< Maximum X.
- int maxY; ///< Maximum Y.
-};
+ return Point( Math::fmod( p.x + 3.0f*WORLD_DIM, 2.0f*WORLD_DIM ) - WORLD_DIM,
+ Math::fmod( p.y + 3.0f*WORLD_DIM, 2.0f*WORLD_DIM ) - WORLD_DIM,
+ Math::fmod( p.z + 3.0f*WORLD_DIM, 2.0f*WORLD_DIM ) - WORLD_DIM );
+}
+
+/**
+ * Difference between two points in the world.
+ *
+ * This function assumes that both points lie on the interval \f$ [-WORLD_DIM, +WORLD_DIM) \f$.
+ */
+OZ_ALWAYS_INLINE
+inline Vec3 posDiff( const Point& p0, const Point& p1 )
+{
+ Vec3 diff = p0 - p1;
+
+ return Vec3( Math::fmod( diff.x + 3.0f*WORLD_DIM, 2.0f*WORLD_DIM ) - WORLD_DIM,
+ Math::fmod( diff.y + 3.0f*WORLD_DIM, 2.0f*WORLD_DIM ) - WORLD_DIM,
+ Math::fmod( diff.z + 3.0f*WORLD_DIM, 2.0f*WORLD_DIM ) - WORLD_DIM );
+}
}
}
Oops, something went wrong.

0 comments on commit a5a69f0

Please sign in to comment.