diff options
Diffstat (limited to 'extern')
202 files changed, 78 insertions, 42984 deletions
diff --git a/extern/SConscript b/extern/SConscript index 6bc067c0f03..716aee8991f 100644 --- a/extern/SConscript +++ b/extern/SConscript @@ -14,9 +14,6 @@ if env['WITH_BF_BULLET']: if env['WITH_BF_INTERNATIONAL']: SConscript(['bFTGL/SConscript']) -if env['WITH_BF_VERSE']: - SConscript(['verse/dist/SConstruct']) - if env['WITH_BF_FFMPEG'] and env['BF_FFMPEG_LIB'] == '': SConscript(['x264/SConscript']) SConscript(['libmp3lame/SConscript']) diff --git a/extern/bFTGL/SConscript b/extern/bFTGL/SConscript index f377c61f01d..03a17a62a17 100644 --- a/extern/bFTGL/SConscript +++ b/extern/bFTGL/SConscript @@ -9,4 +9,4 @@ defs = '' sources = env.Glob('src/*.cpp') -env.BlenderLib ( 'extern_ftgl', sources, Split(incs), Split(defs), libtype=['international','player'], priority=[5, 210]) +env.BlenderLib ( 'extern_ftgl', sources, Split(incs), Split(defs), libtype=['extern'], priority=[5]) diff --git a/extern/bFTGL/src/Makefile b/extern/bFTGL/src/Makefile index 17c6016ad03..d91bcb2559d 100644 --- a/extern/bFTGL/src/Makefile +++ b/extern/bFTGL/src/Makefile @@ -1,3 +1,5 @@ +# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- +# vim: tabstop=8 # # $Id$ # @@ -22,7 +24,7 @@ # # The Original Code is: all of this file. # -# Contributor(s): none yet. +# Contributor(s): GSR # # ***** END GPL LICENSE BLOCK ***** # @@ -46,15 +48,13 @@ CPPFLAGS += -I../include CPPFLAGS += -I$(NAN_FREETYPE)/include -I$(NAN_FREETYPE)/include/freetype2 CPPFLAGS += -I$(OPENGL_HEADERS) -install: all debug +install: $(ALL_OR_DEBUG) @[ -d $(NAN_FTGL) ] || mkdir -p $(NAN_FTGL) @[ -d $(NAN_FTGL)/include ] || mkdir -p $(NAN_FTGL)/include - @[ -d $(NAN_FTGL)/lib ] || mkdir -p $(NAN_FTGL)/lib - @[ -d $(NAN_FTGL)/lib/debug ] || mkdir -p $(NAN_FTGL)/lib/debug - @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/lib$(LIBNAME).a $(NAN_FTGL)/lib/ -# @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/debug/lib$(LIBNAME).a $(NAN_FTGL)/lib/debug/ + @[ -d $(NAN_FTGL)/lib/$(DEBUG_DIR) ] || mkdir -p $(NAN_FTGL)/lib/$(DEBUG_DIR) + @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a $(NAN_FTGL)/lib/$(DEBUG_DIR) ifeq ($(OS),darwin) - ranlib $(NAN_FTGL)/lib/lib$(LIBNAME).a + ranlib $(NAN_FTGL)/lib/$(DEBUG_DIR)lib$(LIBNAME).a endif @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh ../include/*.h $(NAN_FTGL)/include/ diff --git a/extern/binreloc/Makefile b/extern/binreloc/Makefile index dbd093500a1..d303ab3afcc 100644 --- a/extern/binreloc/Makefile +++ b/extern/binreloc/Makefile @@ -1,3 +1,5 @@ +# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- +# vim: tabstop=8 # # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -30,8 +32,7 @@ CPPFLAGS += -I./include include nan_compile.mk - -install: all debug +install: $(ALL_OR_DEBUG) @[ -d $(DIR) ] || mkdir $(DIR) @[ -d $(DIR)/include ] || mkdir $(DIR)/include @../../intern/tools/cpifdiff.sh include/*.h $(DIR)/include/ diff --git a/extern/binreloc/SConscript b/extern/binreloc/SConscript index 2747702985d..98d7adb2d1e 100644 --- a/extern/binreloc/SConscript +++ b/extern/binreloc/SConscript @@ -9,5 +9,5 @@ cflags = [] sources = ['binreloc.c'] incs = 'include' -env.BlenderLib ( 'extern_binreloc', sources, Split(incs), Split(defs), libtype=['intern','player'], priority=[36, 226], compileflags = cflags) +env.BlenderLib ( 'extern_binreloc', sources, Split(incs), Split(defs), libtype=['extern'], priority=[36], compileflags = cflags) diff --git a/extern/bullet2/Makefile b/extern/bullet2/Makefile index f3abb86e404..d974569e63d 100644 --- a/extern/bullet2/Makefile +++ b/extern/bullet2/Makefile @@ -1,3 +1,5 @@ +# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- +# vim: tabstop=8 # # $Id$ # @@ -48,7 +50,7 @@ include nan_subdirs.mk CP = $(NANBLENDERHOME)/intern/tools/cpifdiff.sh -install: all debug +install: $(ALL_OR_DEBUG) @[ -d $(NAN_BULLET2) ] || mkdir -p $(NAN_BULLET2) @[ -d $(NAN_BULLET2)/include ] || mkdir -p $(NAN_BULLET2)/include @for i in $(BULLETDIRS); do \ diff --git a/extern/bullet2/make/msvc_9_0/Bullet.vcproj b/extern/bullet2/make/msvc_9_0/Bullet.vcproj index 6ec064913a5..9c8f9668f56 100644 --- a/extern/bullet2/make/msvc_9_0/Bullet.vcproj +++ b/extern/bullet2/make/msvc_9_0/Bullet.vcproj @@ -45,7 +45,7 @@ Optimization="0"
AdditionalIncludeDirectories="..\..\src"
PreprocessorDefinitions="_DEBUG;_LIB;WIN32;BUM_INLINED;USE_ALGEBRAIC"
- ExceptionHandling="0"
+ ExceptionHandling="1"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@@ -445,6 +445,10 @@ Name="Dynamics"
>
<File
+ RelativePath="..\..\src\BulletDynamics\Dynamics\btActionInterface.h"
+ >
+ </File>
+ <File
RelativePath="..\..\src\BulletDynamics\Dynamics\btContinuousDynamicsWorld.cpp"
>
</File>
diff --git a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp index d4e29882d37..eecf927ee10 100644 --- a/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp +++ b/extern/bullet2/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp @@ -172,6 +172,9 @@ int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint) #if MANIFOLD_CACHE_SIZE >= 4 //sort cache so best points come first, based on area insertIndex = sortCachedPoints(newPoint); + + if (insertIndex<0) + insertIndex=0; #else insertIndex = 0; #endif @@ -180,11 +183,7 @@ int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint) } else { m_cachedPoints++; - - } - if (insertIndex<0) - insertIndex=0; btAssert(m_pointCache[insertIndex].m_userPersistentData==0); m_pointCache[insertIndex] = newPoint; diff --git a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp index ea2e0ad2a2b..b6231a8fda6 100644 --- a/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp +++ b/extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp @@ -350,12 +350,13 @@ int btDiscreteDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, for (int i=0;i<clampedSimulationSteps;i++) { internalSingleStepSimulation(fixedTimeStep); - synchronizeMotionStates(); + //for Blender, no need to synchronize here, it is done in blender anyway + //synchronizeMotionStates(); } } - - synchronizeMotionStates(); + //else + // synchronizeMotionStates(); clearForces(); @@ -725,9 +726,13 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands() { if (colObj0->isActive() || colObj1->isActive()) { - - getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), - (colObj1)->getIslandTag()); + if ((colObj0)->getIslandTag() != -1 && (colObj1)->getIslandTag() != -1) + { + + getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(), + (colObj1)->getIslandTag()); + } + } } } diff --git a/extern/bullet2/src/SConscript b/extern/bullet2/src/SConscript index 48e30cdf58a..bd7fb87b01f 100644 --- a/extern/bullet2/src/SConscript +++ b/extern/bullet2/src/SConscript @@ -7,7 +7,7 @@ Import('env') defs = 'USE_DOUBLES QHULL _LIB' cflags = [] -if env['OURPLATFORM']=='win32-vc': +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): defs += ' WIN32 NDEBUG _WINDOWS _LIB' #cflags += ['/MT', '/W3', '/GX', '/O2', '/Op'] cflags += ['/MT', '/W3', '/GX', '/Og', '/Ot', '/Ob1', '/Op', '/G6', '/O3'] @@ -35,11 +35,11 @@ softbody_src = env.Glob("BulletSoftBody/*.cpp") incs = '. BulletCollision BulletDynamics LinearMath BulletSoftBody' -env.BlenderLib ( libname = 'extern_bullet2linmath', sources=linearmath_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[20, 170], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2dynamics', sources=bulletdyn_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[19, 169], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2collision_broadphase', sources=collision_broadphase_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[25, 175], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2collision_dispatch', sources=collision_dispatch_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[20, 170], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2collision_gimpact', sources=collision_gimpact_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[20, 170], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2collision_shapes', sources=collision_shapes_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[20, 170], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2collision_narrowphase', sources=collision_narrowphase_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[20, 170], compileflags=cflags ) -env.BlenderLib ( libname = 'extern_bullet2softbody', sources=softbody_src, includes=Split(incs), defines=Split(defs), libtype=['game2', 'player'], priority=[18,168], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2linmath', sources=linearmath_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[20], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2dynamics', sources=bulletdyn_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[19], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2collision_broadphase', sources=collision_broadphase_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[25], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2collision_dispatch', sources=collision_dispatch_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[20], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2collision_gimpact', sources=collision_gimpact_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[20], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2collision_shapes', sources=collision_shapes_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[20], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2collision_narrowphase', sources=collision_narrowphase_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[20], compileflags=cflags ) +env.BlenderLib ( libname = 'extern_bullet2softbody', sources=softbody_src, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[18], compileflags=cflags ) diff --git a/extern/glew/SConscript b/extern/glew/SConscript index 3badbeb040e..b83525daffe 100644 --- a/extern/glew/SConscript +++ b/extern/glew/SConscript @@ -9,4 +9,4 @@ sources = ['src/glew.c'] defs = '' incs = 'include' -env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['blender', 'player'], priority=[50, 50]) +env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['extern'], priority=[50]) diff --git a/extern/glew/src/Makefile b/extern/glew/src/Makefile index 55cc7cfccad..ebcecae45c8 100644 --- a/extern/glew/src/Makefile +++ b/extern/glew/src/Makefile @@ -1,3 +1,5 @@ +# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- +# vim: tabstop=8 # # $Id$ # @@ -25,7 +27,7 @@ # # The Original Code is: all of this file. # -# Contributor(s): none yet. +# Contributor(s): GSR # # ***** END GPL/BL DUAL LICENSE BLOCK ***** # @@ -42,15 +44,13 @@ CSRCS = glew.c CCSRCS = include nan_compile.mk -install: all debug +install: $(ALL_OR_DEBUG) @[ -d $(NAN_GLEW) ] || mkdir -p $(NAN_GLEW) @[ -d $(NAN_GLEW)/include/GL ] || mkdir -p $(NAN_GLEW)/include/GL - @[ -d $(NAN_GLEW)/lib ] || mkdir -p $(NAN_GLEW)/lib - @[ -d $(NAN_GLEW)/lib/debug ] || mkdir -p $(NAN_GLEW)/lib/debug - @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/lib$(LIBNAME).a $(NAN_GLEW)/lib/ + @[ -d $(NAN_GLEW)/lib/$(DEBUG_DIR) ] || mkdir -p $(NAN_GLEW)/lib/$(DEBUG_DIR) + @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a $(NAN_GLEW)/lib/$(DEBUG_DIR) ifeq ($(OS),darwin) - ranlib $(NAN_GLEW)/lib/lib$(LIBNAME).a - ranlib $(NAN_GLEW)/lib/lib$(LIBNAME).a + ranlib $(NAN_GLEW)/lib/$(DEBUG_DIR)lib$(LIBNAME).a endif @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh ../include/GL/*.h $(NAN_GLEW)/include/GL diff --git a/extern/libopenjpeg/SConscript b/extern/libopenjpeg/SConscript index a27ac0d13df..13a34bf5598 100644 --- a/extern/libopenjpeg/SConscript +++ b/extern/libopenjpeg/SConscript @@ -24,5 +24,5 @@ if not env['OURPLATFORM'] == 'win32-vc': oj_env.BlenderLib ( libname='extern_openjpeg', sources=sources, includes=Split(incs), defines=defs, - libtype=['core','intern','player'], - priority=[300, 300, 300], compileflags = flags) + libtype=['extern'], + priority=[10], compileflags = flags) diff --git a/extern/libopenjpeg/opj_includes.h b/extern/libopenjpeg/opj_includes.h index 80d43df990f..3464cfcf9ed 100644 --- a/extern/libopenjpeg/opj_includes.h +++ b/extern/libopenjpeg/opj_includes.h @@ -88,6 +88,12 @@ Most compilers implement their own version of this keyword ... /* MSVC does not have lrintf */ #ifdef _MSC_VER +#ifdef _M_X64 +#include <emmintrin.h> +static INLINE long lrintf(float f) { + return _mm_cvtss_si32(_mm_load_ss(&f)); +} +#else static INLINE long lrintf(float f){ int i; @@ -99,6 +105,7 @@ static INLINE long lrintf(float f){ return i; } #endif +#endif #include "j2k_lib.h" #include "opj_malloc.h" diff --git a/extern/make/msvc_9_0/build_install_all.vcproj b/extern/make/msvc_9_0/build_install_all.vcproj index 523b1c5d0a3..7909bbe63a0 100644 --- a/extern/make/msvc_9_0/build_install_all.vcproj +++ b/extern/make/msvc_9_0/build_install_all.vcproj @@ -23,7 +23,7 @@ ConfigurationType="10"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
- ManagedExtensions="4"
+ ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
diff --git a/extern/ode/Makefile b/extern/ode/Makefile deleted file mode 100644 index 51be666aa69..00000000000 --- a/extern/ode/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2002 by Hans Lambermont -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** - -include nan_definitions.mk - -DISTDIR = dist -CP = ../../intern/tools/cpifdiff.sh -USERSETTINGS = ./dist/config/user-settings -TEMPSETTINGS = ./user-settings - -all: - [ -d $(DISTDIR)/lib ] || mkdir $(DISTDIR)/lib - # prepare settings for patching, clean in case of interruption - ifeq ($(OS),$(findstring $(OS), "darwin windows")) - [ ! -f $(TEMPSETTINGS) ] || mv $(TEMPSETTINGS) $(USERSETTINGS) - cp $(USERSETTINGS) $(TEMPSETTINGS) - endif - ifeq ($(OS),freebsd) - (grep FreeBSD $(DISTDIR)/Makefile >/dev/null ; \ - [ $$? -eq 0 ] || patch < patchfile.FreeBSD ) - endif - ifeq ($(OS),darwin) - cat $(TEMPSETTINGS) | sed s/unix-gcc/osx/ > $(USERSETTINGS) - endif - ifeq ($(OS),windows) - # compile with MSVC - cat $(TEMPSETTINGS) | sed s/unix-gcc/msvc/ > $(USERSETTINGS) - env PATH=".:$(PATH)" $(MAKE) -C $(DISTDIR) - endif - ifeq ($(OS),$(findstring $(OS), "freebsd linux darwin")) - $(MAKE) -C $(DISTDIR) - endif - # restore settings - ifeq ($(OS),$(findstring $(OS), "darwin windows")) - mv $(TEMPSETTINGS) $(USERSETTINGS) - endif - -# fake debug target -debug: - -install: all - ifeq ($(OS),$(findstring $(OS), "freebsd linux darwin")) - [ -d $(LCGDIR) ] || mkdir $(LCGDIR) - [ -d $(NAN_ODE) ] || mkdir $(NAN_ODE) - [ -d $(NAN_ODE)/include ] || mkdir $(NAN_ODE)/include - [ -d $(NAN_ODE)/include/ode ] || mkdir $(NAN_ODE)/include/ode - [ -d $(NAN_ODE)/lib ] || mkdir $(NAN_ODE)/lib - [ -d $(NAN_ODE)/ode ] || mkdir $(NAN_ODE)/ode - [ -d $(NAN_ODE)/ode/src ] || mkdir $(NAN_ODE)/ode/src - @$(CP) $(DISTDIR)/lib/libode.a $(NAN_ODE)/lib/ - @$(CP) $(DISTDIR)/include/ode/*.h $(NAN_ODE)/include/ode/ - @$(CP) $(DISTDIR)/ode/src/array.h $(NAN_ODE)/ode/src/ - @$(CP) $(DISTDIR)/ode/src/joint.h $(NAN_ODE)/ode/src/ - @$(CP) $(DISTDIR)/ode/src/objects.h $(NAN_ODE)/ode/src/ - @$(CP) $(DISTDIR)/ode/src/obstack.h $(NAN_ODE)/ode/src/ - ifeq ($(OS),darwin) - ranlib $(NAN_ODE)/lib/libode.a - endif - endif - ifeq ($(OS),windows) - @echo "====> $(MAKE) $@ in $(SOURCEDIR)" - [ -d $(LCGDIR) ] || mkdir $(LCGDIR) - [ -d $(NAN_ODE) ] || mkdir $(NAN_ODE) - [ -d $(NAN_ODE)/include ] || mkdir $(NAN_ODE)/include - [ -d $(NAN_ODE)/include/ode ] || mkdir $(NAN_ODE)/include/ode - [ -d $(NAN_ODE)/lib ] || mkdir $(NAN_ODE)/lib - [ -d $(NAN_ODE)/ode ] || mkdir $(NAN_ODE)/ode - [ -d $(NAN_ODE)/ode/src ] || mkdir $(NAN_ODE)/ode/src - cp $(DISTDIR)/lib/ode.lib $(NAN_ODE)/lib/libode.a - cp $(DISTDIR)/include/ode/*.h $(NAN_ODE)/include/ode/ - cp $(DISTDIR)/ode/src/array.h $(NAN_ODE)/ode/src/ - cp $(DISTDIR)/ode/src/joint.h $(NAN_ODE)/ode/src/ - cp $(DISTDIR)/ode/src/objects.h $(NAN_ODE)/ode/src/ - cp $(DISTDIR)/ode/src/obstack.h $(NAN_ODE)/ode/src/ - endif - -clean: - ifeq ($(OS),$(findstring $(OS), "freebsd linux darwin")) - [ ! -f dist/Makefile ] || $(MAKE) -C dist clean - endif - ifeq ($(OS),freebsd) - (grep FreeBSD $(DISTDIR)/Makefile >/dev/null ; \ - [ $$? -ne 0 ] || patch -R < patchfile.FreeBSD ) - endif - diff --git a/extern/ode/dist/INSTALL b/extern/ode/dist/INSTALL deleted file mode 100644 index f82285db1b2..00000000000 --- a/extern/ode/dist/INSTALL +++ /dev/null @@ -1,44 +0,0 @@ - -here are the steps to buid ODE: - -(1) get the GNU 'make' tool. many unix platforms come with this, although - sometimes it is called 'gmake'. i have provided a version of GNU make - for windows at: http://q12.org/ode/bin/make.exe - -(2) edit the settings in the file config/user-settings. the list of supported - platforms is given in that file. - -(3) run 'make' to configure and build ODE and the graphical test programs. - to build parts of ODE the make targets are: - - make configure create configuration file include/ode/config.h - make ode-lib build the core ODE library - make drawstuff-lib build the OpenGL-based graphics library - make ode-test build some ODE tests (they need drawstuff) - make drawstuff-test build a test app for the drawstuff library - - all of these targets will do an implicit 'make configure'. if the - configurator screws up then you can edit the settings directly in - include/ode/config.h. - -(4) to install the ODE library onto your system you should copy the 'lib' and - 'include' directories to a suitable place, e.g. on unix: - - include/ode --> /usr/local/include/ode - lib/libode.a --> /usr/local/lib/libode.a - -ODE has been verified to build on the following platforms: - - config ode-lib ode-test - ------ ------- -------- - windows - MSVC msvc * * - MinGW mingw * * - CygWin cygwin * * - linux (x86, mandrake 8.1) unix-gcc * * - linux (alpha, debian 2.2) unix-gcc * ? - linux (RS/6000, debian 2.2) unix-gcc * ? - linux (Sparc U60, debian 2.2) unix-gcc * ? - freebsd 4.3 unix-gcc * ? - Mac OS-X osx * ? - Solaris 8 (Sparc R220) unix-gcc * ? diff --git a/extern/ode/dist/LICENSE-BSD.TXT b/extern/ode/dist/LICENSE-BSD.TXT deleted file mode 100644 index 05929239487..00000000000 --- a/extern/ode/dist/LICENSE-BSD.TXT +++ /dev/null @@ -1,34 +0,0 @@ - -This is the BSD-style license for the Open Dynamics Engine ----------------------------------------------------------- - -Open Dynamics Engine -Copyright (c) 2001,2002, Russell L. Smith. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -Neither the names of ODE's copyright owner nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/extern/ode/dist/LICENSE.TXT b/extern/ode/dist/LICENSE.TXT deleted file mode 100644 index cfe59bcadb8..00000000000 --- a/extern/ode/dist/LICENSE.TXT +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/extern/ode/dist/Makefile b/extern/ode/dist/Makefile deleted file mode 100644 index 34fbd53f792..00000000000 --- a/extern/ode/dist/Makefile +++ /dev/null @@ -1,280 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -USER_SETTINGS=config/user-settings -include $(USER_SETTINGS) -PLATFORM_MAKEFILE=config/makefile.$(PLATFORM) -include $(PLATFORM_MAKEFILE) - -############################################################################## -# check some variables that were supposed to be defined - -ifneq ($(BUILD),debug) -ifneq ($(BUILD),release) -$(error the BUILD variable is not set properly) -endif -endif - -ifneq ($(PRECISION),SINGLE) -ifneq ($(PRECISION),DOUBLE) -$(error the PRECISION variable is not set properly) -endif -endif - -############################################################################## -# package settings - -ODE_SRC = \ - ode/src/array.cpp \ - ode/src/error.cpp \ - ode/src/memory.cpp \ - ode/src/obstack.cpp \ - ode/src/odemath.cpp \ - ode/src/matrix.cpp \ - ode/src/misc.cpp \ - ode/src/rotation.cpp \ - ode/src/mass.cpp \ - ode/src/ode.cpp \ - ode/src/step.cpp \ - ode/src/lcp.cpp \ - ode/src/joint.cpp \ - ode/src/space.cpp \ - ode/src/geom.cpp \ - ode/src/timer.cpp \ - ode/src/mat.cpp \ - ode/src/testing.cpp -ODE_PREGEN_SRC = \ - ode/src/fastldlt.c \ - ode/src/fastlsolve.c \ - ode/src/fastltsolve.c \ - ode/src/fastdot.c - -ifeq ($(WINDOWS),1) -DRAWSTUFF_SRC = drawstuff/src/drawstuff.cpp drawstuff/src/windows.cpp -RESOURCE_FILE=lib/resources.RES -else -DRAWSTUFF_SRC = drawstuff/src/drawstuff.cpp drawstuff/src/x11.cpp -endif - -ODE_LIB_NAME=ode -DRAWSTUFF_LIB_NAME=drawstuff - -INCPATH=include -LIBPATH=lib - -ODE_TEST_SRC_CPP = \ - ode/test/test_ode.cpp \ - ode/test/test_chain2.cpp \ - ode/test/test_hinge.cpp \ - ode/test/test_slider.cpp \ - ode/test/test_collision.cpp \ - ode/test/test_boxstack.cpp \ - ode/test/test_buggy.cpp \ - ode/test/test_joints.cpp \ - ode/test/test_space.cpp \ - ode/test/test_I.cpp \ - ode/test/test_step.cpp \ - ode/test/test_friction.cpp -ODE_TEST_SRC_C = \ - ode/test/test_chain1.c -DRAWSTUFF_TEST_SRC_CPP = \ - drawstuff/dstest/dstest.cpp - -CONFIGURATOR_SRC=configurator.c -CONFIG_H=include/ode/config.h - -############################################################################## -# derived things - -DEFINES= - -# add some defines depending on the build mode -ifeq ($(BUILD),release) -DEFINES+=$(C_DEF)dNODEBUG -endif -ifeq ($(BUILD),debug) -DEFINES+=$(C_DEF)dDEBUG_ALLOC -endif - -# object file names -ODE_PREGEN_OBJECTS=$(ODE_PREGEN_SRC:%.c=%$(OBJ)) -ODE_OBJECTS=$(ODE_SRC:%.cpp=%$(OBJ)) $(ODE_PREGEN_OBJECTS) -DRAWSTUFF_OBJECTS=$(DRAWSTUFF_SRC:%.cpp=%$(OBJ)) $(RESOURCE_FILE) - -# side-effect variables causing creation of files containing lists of -# filenames to be linked, to work around command-line-length limitations -# on outdated 16-bit operating systems. because of command-line length -# limitations we cannot issue a link command with all object filenames -# specified (because this command is too long and overflows the command -# buffer), but instead must create a file containing all object filenames -# to be linked, and specify this list-file with @listfile on the command-line. -# -# the difficult part is doing this in a flexible way; we don't want to -# hard-code the to-be-linked object filenames in a file, but instead -# want to dynamically create a file containing a list of all object filenames -# within the $XXX_OBJECTS makefile variables. to do this, we use side-effect -# variables. -# -# idea: when these variables are EVALUATED (i.e. later during rule execution, -# not now during variable definition), they cause a SIDE EFFECT which creates -# a file with the list of all ODE object files. why the chicanery??? because -# if we have a command-line length limitation, no SINGLE command we issue will -# be able to create a file containing all object files to be linked -# (because that command itself would need to include all filenames, making -# it too long to be executed). instead, we must use the gnu-make "foreach" -# function, combined - probably in an unintended way - with the "shell" -# function. this is probably unintended because we are not using the "shell" -# function to return a string value for variable evaluation, but are instead -# using the "shell" function to cause a side effect (appending of each filename -# to the filename-list-file). -# -# one possible snag is that, forbidding use of any external EXE utilities and -# relying only on the facilities provided by the outdated 16-bit operating -# system, there is no way to issue a SERIES of commands which append text to -# the end of a file WITHOUT adding newlines. therefore, the list of to-be- -# linked object files is separated by newlines in the list file. fortunately, -# the linker utility for this outdated 16-bit operating system accepts -# filenames on separate lines in the list file. - -# remember: when we evaluate these variables later, this causes the creation -# of the appropriate list file. -ifeq ($(WINDOWS16),1) -SIDE_EFFECT_ODE_OBJLIST = $(foreach o,$(ODE_OBJECTS),$(shell echo $(o) >> odeobj.txt )) -SIDE_EFFECT_DRAWSTUFF_OBJLIST = $(foreach o,$(DRAWSTUFF_OBJECTS),$(shell echo $(o) >> dsobj.txt )) -endif - -# library file names -ODE_LIB=$(LIBPATH)/$(LIB_PREFIX)$(ODE_LIB_NAME)$(LIB_SUFFIX) -DRAWSTUFF_LIB=$(LIBPATH)/$(LIB_PREFIX)$(DRAWSTUFF_LIB_NAME)$(LIB_SUFFIX) - -# executable file names -ODE_TEST_EXE=$(ODE_TEST_SRC_CPP:%.cpp=%.exe) $(ODE_TEST_SRC_C:%.c=%.exe) -DRAWSTUFF_TEST_EXE=$(DRAWSTUFF_TEST_SRC_CPP:%.cpp=%.exe) -CONFIGURATOR_EXE=$(CONFIGURATOR_SRC:%.c=%.exe) - -############################################################################## -# rules -# -# NOTE: the '.c' files are pregenerated sources, and must be compiled with -# -O1 optimization. that is why the rule for .c files is a bit different. -# why should it be compiled with O1? it is numerical code that is generated -# by fbuild. O1 optimization is used to preserve the operation orders that -# were discovered by fbuild to be the fastest on that platform. believe it or -# not, O2 makes this code run much slower for most compilers. - -debug: all -all: ode-lib drawstuff-lib ode-test drawstuff-test - @echo SUCCESS - -ode-lib: configure $(ODE_LIB) -drawstuff-lib: configure $(DRAWSTUFF_LIB) -ode-test: ode-lib drawstuff-lib $(ODE_TEST_EXE) -drawstuff-test: drawstuff-lib $(DRAWSTUFF_TEST_EXE) - -ifndef ODE_LIB_AR_RULE -ODE_LIB_AR_RULE=$(AR)$@ -endif - -$(ODE_LIB): pre_ode_lib $(ODE_OBJECTS) -ifeq ($(WINDOWS16),1) -# if we have a command-line-length limitation, then dynamically create -# a file containing all object filenames, and pass this file to the linker -# instead of directly specifying the object filenames on the command line. -# the very evaluation of the following variable causes creation of file -# odeobj.txt - $(SIDE_EFFECT_ODE_OBJLIST) - $(ODE_LIB_AR_RULE) @odeobj.txt -else -# if we have no command-line-length limitation, directly specify all -# object files to be linked. - $(ODE_LIB_AR_RULE) $(ODE_OBJECTS) -endif - -ifdef RANLIB - $(RANLIB) $@ -endif - -$(DRAWSTUFF_LIB): pre_drawstuff_lib $(DRAWSTUFF_OBJECTS) -ifeq ($WINDOWS16),1) -# if we have a command-line-length limitation, then do the same as above. - $(SIDE_EFFECT_DRAWSTUFF_OBJLIST) - $(AR)$@ @dsobj.txt -else -# if we have no command-line-length limitation, directly specify all object -# files to be linked. - $(AR)$@ $(DRAWSTUFF_OBJECTS) -endif -ifdef RANLIB - $(RANLIB) $@ -endif - -# rules to be executed before library linking starts: delete list file (if one is used) - -pre_ode_lib: -ifeq ($WINDOWS16),1) - $(DEL_CMD) odeobj.txt -endif - -pre_drawstuff_lib: -ifeq ($WINDOWS16),1) - $(DEL_CMD) dsobj.txt -endif - -clean: - -$(DEL_CMD) $(ODE_OBJECTS) $(ODE_TEST_EXE) $(ODE_LIB) $(DRAWSTUFF_OBJECTS) $(DRAWSTUFF_TEST_EXE) $(DRAWSTUFF_LIB) ode/test/*$(OBJ) drawstuff/dstest/*$(OBJ) $(CONFIGURATOR_EXE) $(CONFIG_H) - -%$(OBJ): %.c - $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)1 $(C_OUT)$@ $< - -%$(OBJ): %.cpp - $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)$(OPT) $(C_OUT)$@ $< - -%.exe: %$(OBJ) - $(CC) $(C_EXEOUT)$@ $< $(ODE_LIB) $(DRAWSTUFF_LIB) $(RESOURCE_FILE) $(LINK_OPENGL) $(LINK_MATH) - -# windows specific rules - -lib/resources.RES: drawstuff/src/resources.rc - $(RC_RULE) - - -# configurator rules - -configure: $(CONFIG_H) - -$(CONFIG_H): $(CONFIGURATOR_EXE) $(USER_SETTINGS) $(PLATFORM_MAKEFILE) - $(THIS_DIR)$(CONFIGURATOR_EXE) $(CONFIG_H) "$(CC) $(DEFINES) $(C_EXEOUT)" "$(DEL_CMD)" $(THIS_DIR) - -$(CONFIGURATOR_EXE): $(CONFIGURATOR_SRC) $(USER_SETTINGS) $(PLATFORM_MAKEFILE) - $(CC) $(C_DEF)d$(PRECISION) $(DEFINES) $(C_EXEOUT)$@ $< - - -# unix-gcc specific dependency making - -DEP_RULE=gcc -M $(C_INC)$(INCPATH) $(DEFINES) -depend: $(ODE_SRC) $(ODE_PREGEN_SRC) $(DRAWSTUFF_SRC) $(ODE_TEST_SRC_CPP) $(ODE_TEST_SRC_C) $(DRAWSTUFF_TEST_SRC_CPP) - $(DEP_RULE) $(ODE_SRC) $(ODE_PREGEN_SRC) | tools/process_deps ode/src/ > Makefile.deps - $(DEP_RULE) $(DRAWSTUFF_SRC) | tools/process_deps drawstuff/src/ >> Makefile.deps - $(DEP_RULE) $(ODE_TEST_SRC_CPP) | tools/process_deps ode/test/ >> Makefile.deps - $(DEP_RULE) $(DRAWSTUFF_TEST_SRC_CPP) | tools/process_deps drawstuff/dstest/ >> Makefile.deps - -include Makefile.deps diff --git a/extern/ode/dist/Makefile.deps b/extern/ode/dist/Makefile.deps deleted file mode 100644 index ad11f01353f..00000000000 --- a/extern/ode/dist/Makefile.deps +++ /dev/null @@ -1,456 +0,0 @@ -ode/src/array.o: \ - ode/src/array.cpp \ - include/ode/config.h \ - include/ode/memory.h \ - include/ode/error.h \ - ode/src/array.h -ode/src/error.o: \ - ode/src/error.cpp \ - include/ode/config.h \ - include/ode/error.h -ode/src/memory.o: \ - ode/src/memory.cpp \ - include/ode/config.h \ - include/ode/memory.h \ - include/ode/error.h -ode/src/obstack.o: \ - ode/src/obstack.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/memory.h \ - ode/src/obstack.h \ - ode/src/objects.h \ - include/ode/mass.h \ - ode/src/array.h -ode/src/odemath.o: \ - ode/src/odemath.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/odemath.h -ode/src/matrix.o: \ - ode/src/matrix.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/matrix.h -ode/src/misc.o: \ - ode/src/misc.cpp \ - include/ode/config.h \ - include/ode/misc.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/matrix.h -ode/src/rotation.o: \ - ode/src/rotation.cpp \ - include/ode/rotation.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h -ode/src/mass.o: \ - ode/src/mass.cpp \ - include/ode/config.h \ - include/ode/mass.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/odemath.h \ - include/ode/matrix.h -ode/src/ode.o: \ - ode/src/ode.cpp \ - ode/src/objects.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/mass.h \ - ode/src/array.h \ - include/ode/ode.h \ - include/ode/contact.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - ode/src/joint.h \ - ode/src/obstack.h \ - ode/src/step.h -ode/src/step.o: \ - ode/src/step.cpp \ - ode/src/objects.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/mass.h \ - ode/src/array.h \ - ode/src/joint.h \ - include/ode/contact.h \ - ode/src/obstack.h \ - include/ode/odemath.h \ - include/ode/rotation.h \ - include/ode/timer.h \ - include/ode/matrix.h \ - ode/src/lcp.h -ode/src/lcp.o: \ - ode/src/lcp.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - ode/src/lcp.h \ - include/ode/matrix.h \ - include/ode/misc.h \ - ode/src/mat.h \ - include/ode/timer.h -ode/src/joint.o: \ - ode/src/joint.cpp \ - include/ode/odemath.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/rotation.h \ - include/ode/matrix.h \ - ode/src/joint.h \ - ode/src/objects.h \ - include/ode/memory.h \ - include/ode/mass.h \ - ode/src/array.h \ - include/ode/contact.h \ - ode/src/obstack.h -ode/src/space.o: \ - ode/src/space.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/contact.h \ - include/ode/memory.h \ - ode/src/objects.h \ - include/ode/mass.h \ - ode/src/array.h \ - ode/src/geom_internal.h -ode/src/geom.o: \ - ode/src/geom.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/geom.h \ - include/ode/space.h \ - include/ode/contact.h \ - include/ode/rotation.h \ - include/ode/odemath.h \ - include/ode/memory.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/mass.h \ - include/ode/matrix.h \ - ode/src/objects.h \ - ode/src/array.h \ - ode/src/geom_internal.h -ode/src/timer.o: \ - ode/src/timer.cpp \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h \ - include/ode/timer.h -ode/src/mat.o: \ - ode/src/mat.cpp \ - include/ode/config.h \ - include/ode/misc.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/matrix.h \ - include/ode/memory.h \ - ode/src/mat.h -ode/src/testing.o: \ - ode/src/testing.cpp \ - include/ode/config.h \ - include/ode/misc.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - ode/src/testing.h \ - ode/src/array.h -ode/src/fastldlt.o: \ - ode/src/fastldlt.c \ - include/ode/matrix.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h -ode/src/fastlsolve.o: \ - ode/src/fastlsolve.c \ - include/ode/matrix.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h -ode/src/fastltsolve.o: \ - ode/src/fastltsolve.c \ - include/ode/matrix.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h -ode/src/fastdot.o: \ - ode/src/fastdot.c \ - include/ode/matrix.h \ - include/ode/common.h \ - include/ode/config.h \ - include/ode/error.h -drawstuff/src/drawstuff.o: \ - drawstuff/src/drawstuff.cpp \ - include/ode/config.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h \ - drawstuff/src/internal.h -drawstuff/src/x11.o: \ - drawstuff/src/x11.cpp \ - include/ode/config.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h \ - drawstuff/src/internal.h -ode/test/test_ode.o: \ - ode/test/test_ode.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h -ode/test/test_chain2.o: \ - ode/test/test_chain2.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_hinge.o: \ - ode/test/test_hinge.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_slider.o: \ - ode/test/test_slider.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_collision.o: \ - ode/test/test_collision.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_boxstack.o: \ - ode/test/test_boxstack.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_buggy.o: \ - ode/test/test_buggy.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_joints.o: \ - ode/test/test_joints.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_space.o: \ - ode/test/test_space.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_I.o: \ - ode/test/test_I.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_step.o: \ - ode/test/test_step.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -ode/test/test_friction.o: \ - ode/test/test_friction.cpp \ - include/ode/ode.h \ - include/ode/config.h \ - include/ode/contact.h \ - include/ode/common.h \ - include/ode/error.h \ - include/ode/memory.h \ - include/ode/odemath.h \ - include/ode/matrix.h \ - include/ode/timer.h \ - include/ode/rotation.h \ - include/ode/mass.h \ - include/ode/space.h \ - include/ode/geom.h \ - include/ode/misc.h \ - include/ode/objects.h \ - include/ode/odecpp.h \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h -drawstuff/dstest/dstest.o: \ - drawstuff/dstest/dstest.cpp \ - include/drawstuff/drawstuff.h \ - include/drawstuff/version.h diff --git a/extern/ode/dist/README b/extern/ode/dist/README deleted file mode 100644 index 6b151d1a27b..00000000000 --- a/extern/ode/dist/README +++ /dev/null @@ -1,30 +0,0 @@ -The Open Dynamics Engine (ODE), Copyright (C) 2001,2002 Russell L. Smith. -------------------------------------------------------------------------- - -ODE is a free, industrial quality library for simulating articulated -rigid body dynamics - for example ground vehicles, legged creatures, -and moving objects in VR environments. It is fast, flexible, robust -and platform independent, with advanced joints, contact with friction, -and built-in collision detection. - -This library is free software; you can redistribute it and/or -modify it under the terms of EITHER: - (1) The GNU Lesser General Public License as published by the Free - Software Foundation; either version 2.1 of the License, or (at - your option) any later version. The text of the GNU Lesser - General Public License is included with this library in the - file LICENSE.TXT. - (2) The BSD-style license that is included with this library in - the file LICENSE-BSD.TXT. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files -LICENSE.TXT and LICENSE-BSD.TXT for more details. - - * Installation instructions are in the INSTALL file - - * The ODE web pages are at http://q12.org/ode/ - - * The ODE documentation is in the file ode/doc/ode.html, or you - can view it on the web at http://q12.org/ode/ode-docs.html diff --git a/extern/ode/dist/README_BLENDER b/extern/ode/dist/README_BLENDER deleted file mode 100644 index 64d97624a55..00000000000 --- a/extern/ode/dist/README_BLENDER +++ /dev/null @@ -1,18 +0,0 @@ -Checked out from ODE cvs (http://q12.org) on or around -Fri Oct 18 14:24:11 GMT 2002 - -Note that ODE has its own build system. The source/ode/ -directory is traversed by Blender's source/Makefile. However -source/ode/config/user-settings has to be set correctly -depending on the target platform. This needs to be done in the -source/Makefile which determines the proper platform, then copies -the appropriate platform-specific user-settings.platform file to -source/ode/config/user-settings. Currently source/ode/user-settings is -for Linux. - -Don't change the source in this directory. This source code is -maintained on the CVS server at http://q12.org and is provided here -so that Blender developers can compile ODE without having to separately -download and install it. This source code can and should periodically -be synchronized (manually) with the source code at http://q12.org. - diff --git a/extern/ode/dist/config/README b/extern/ode/dist/config/README deleted file mode 100644 index 0fa18062a4e..00000000000 --- a/extern/ode/dist/config/README +++ /dev/null @@ -1,41 +0,0 @@ - -variable names used in the per-platform makefile configuration files: - -platform stuff --------------- - -WINDOWS set to 1 if this is a microsoft windows based platform - -filesystem stuff and commands ------------------------------ - -THIS_DIR prefix to run a command from the current directory -DEL_CMD the name of the delete command - -compiler stuff --------------- - -CC the C/C++ compiler to use -OBJ the object file extension -C_FLAGS the standard set of compiler flags -C_INC flag to add an include path -C_OUT flag to specify the object file output -C_EXEOUT flag to specify the executable file output -C_DEF flag to add a define -C_OPT flag to set the optimization level -OPT the optimization level to use - -library archiver ----------------- - -AR library archiver command -RANLIB ranlib command, if necessary -LIB_PREFIX library file prefix -LIB_SUFFIX library file suffix -LINK_OPENGL link flags to link in windowing stuff and opengl -LINK_MATH link flags to link in the system math library - -windows specific stuff ----------------------- - -RC_RULE makefile rule to use for the resource compiler diff --git a/extern/ode/dist/config/makefile.cygwin b/extern/ode/dist/config/makefile.cygwin deleted file mode 100644 index de23b71a29f..00000000000 --- a/extern/ode/dist/config/makefile.cygwin +++ /dev/null @@ -1,28 +0,0 @@ -WINDOWS=1 -THIS_DIR=./ -DEL_CMD=rm -f -CC=gcc -OBJ=.o -C_FLAGS=-c -Wall -fno-exceptions -fno-rtti -DWIN32 -DCYGWIN -C_INC=-I -C_OUT=-o -C_EXEOUT=-o -C_DEF=-D -C_OPT=-O -AR=ar rc -RANLIB= -LIB_PREFIX=lib -LIB_SUFFIX=.a -LINK_OPENGL=-lComctl32 -lkernel32 -luser32 -lgdi32 -lOpenGL32 -lGlu32 -LINK_MATH=-lm -RC_RULE=windres -I rc -O coff $< $@ - -ifeq ($(BUILD),release) -OPT=2 -C_FLAGS+=-fomit-frame-pointer -ffast-math -endif - -ifeq ($(BUILD),debug) -OPT=0 -C_FLAGS+=-g -endif diff --git a/extern/ode/dist/config/makefile.mingw b/extern/ode/dist/config/makefile.mingw deleted file mode 100644 index 4b18fb6bcdc..00000000000 --- a/extern/ode/dist/config/makefile.mingw +++ /dev/null @@ -1,28 +0,0 @@ -WINDOWS=1 -THIS_DIR= -DEL_CMD=tools\rm -CC=gcc -OBJ=.o -C_FLAGS=-c -Wall -fno-exceptions -fno-rtti -DWIN32 -C_INC=-I -C_OUT=-o -C_EXEOUT=-o -C_DEF=-D -C_OPT=-O -AR=ar rc -RANLIB= -LIB_PREFIX=lib -LIB_SUFFIX=.a -LINK_OPENGL=-lComctl32 -lkernel32 -luser32 -lgdi32 -lOpenGL32 -lGlu32 -LINK_MATH=-lm -RC_RULE=windres -I rc -O coff $< $@ - -ifeq ($(BUILD),release) -OPT=2 -C_FLAGS+=-fomit-frame-pointer -ffast-math -endif - -ifeq ($(BUILD),debug) -OPT=0 -C_FLAGS+=-g -endif diff --git a/extern/ode/dist/config/makefile.msvc b/extern/ode/dist/config/makefile.msvc deleted file mode 100644 index 9d4da0bf912..00000000000 --- a/extern/ode/dist/config/makefile.msvc +++ /dev/null @@ -1,27 +0,0 @@ -WINDOWS=1 -THIS_DIR= -DEL_CMD=tools\rm -CC=cl /nologo /DWIN32 /DMSVC /DSHAREDLIBEXPORT= /DSHAREDLIBIMPORT= -OBJ=.obj -C_FLAGS=/c /GR- /GX- /W3 /GF -C_INC=/I -C_OUT=/Fo -C_EXEOUT=/Fe -C_DEF=/D -C_OPT=/O -AR=lib /nologo /OUT: -RANLIB= -LIB_PREFIX= -LIB_SUFFIX=.lib -LINK_OPENGL=Comctl32.lib kernel32.lib user32.lib gdi32.lib OpenGL32.lib Glu32.lib -LINK_MATH= -RC_RULE=rc /r /fo$@ $< - -ifeq ($(BUILD),release) -OPT=2 -C_FLAGS+=/Oy -endif - -ifeq ($(BUILD),debug) -OPT=d -endif diff --git a/extern/ode/dist/config/makefile.msvc-dll b/extern/ode/dist/config/makefile.msvc-dll deleted file mode 100644 index fe495893616..00000000000 --- a/extern/ode/dist/config/makefile.msvc-dll +++ /dev/null @@ -1,29 +0,0 @@ -WINDOWS=1 -THIS_DIR= -DEL_CMD=tools\rm -CC=cl /nologo /DWIN32 /DMSVC /DSHAREDLIBIMPORT=__declspec(dllimport) /DSHAREDLIBEXPORT=__declspec(dllexport) -OBJ=.obj -C_FLAGS=/c /GR- /GX- /W3 /GF -C_INC=/I -C_OUT=/Fo -C_EXEOUT=/Fe -C_DEF=/D -C_OPT=/O -AR=lib /nologo /OUT: -RANLIB= -LIB_PREFIX= -LIB_SUFFIX=.lib -LINK_OPENGL=Comctl32.lib kernel32.lib user32.lib gdi32.lib OpenGL32.lib Glu32.lib -LINK_MATH= -RC_RULE=rc /r /fo$@ $< - -ifeq ($(BUILD),release) -OPT=2 -C_FLAGS+=/Oy -endif - -ifeq ($(BUILD),debug) -OPT=d -endif - -ODE_LIB_AR_RULE=link /dll /nologo /SUBSYSTEM:WINDOWS /LIBPATH:"C:\Programme\Micros~2\VC98\Lib" /def:config/msvcdefs.def $(LINK_OPENGL) /OUT:$(patsubst %.lib,%.dll,$@) diff --git a/extern/ode/dist/config/makefile.osx b/extern/ode/dist/config/makefile.osx deleted file mode 100644 index 1d5e0f42252..00000000000 --- a/extern/ode/dist/config/makefile.osx +++ /dev/null @@ -1,26 +0,0 @@ -THIS_DIR=./ -DEL_CMD=rm -f -CC=cc -OBJ=.o -C_FLAGS=-c -Wall -fno-rtti -fno-exceptions -Wall -I/usr/X11R6/include -C_INC=-I -C_OUT=-o -C_EXEOUT=-o -C_DEF=-D -C_OPT=-O -AR=ar rc -RANLIB=ranlib -LIB_PREFIX=lib -LIB_SUFFIX=.a -LINK_OPENGL=-L/usr/X11R6/lib -L/usr/X11/lib -L/usr/lib/X11R6 -L/usr/lib/X11 -lX11 -lGL -lGLU -lstdc++ -LINK_MATH=-lm - -ifeq ($(BUILD),release) -OPT=2 -C_FLAGS+=-fomit-frame-pointer -ffast-math -endif - -ifeq ($(BUILD),debug) -OPT=0 -C_FLAGS+=-g -endif diff --git a/extern/ode/dist/config/makefile.unix-gcc b/extern/ode/dist/config/makefile.unix-gcc deleted file mode 100644 index b9d07632353..00000000000 --- a/extern/ode/dist/config/makefile.unix-gcc +++ /dev/null @@ -1,29 +0,0 @@ -THIS_DIR=./ -DEL_CMD=rm -f -CC=gcc -OBJ=.o -C_FLAGS=-c -Wall -fno-rtti -fno-exceptions -Wall -C_INC=-I -C_OUT=-o -C_EXEOUT=-o -C_DEF=-D -C_OPT=-O -AR=ar rc -RANLIB= -LIB_PREFIX=lib -LIB_SUFFIX=.a -LINK_OPENGL=-L/usr/X11R6/lib -L/usr/X11/lib -L/usr/lib/X11R6 -L/usr/lib/X11 -lX11 -lGL -lGLU -LINK_MATH=-lm - -ifeq ($(BUILD),release) -OPT=2 -C_FLAGS+=-fomit-frame-pointer -ffast-math -endif - -ifeq ($(BUILD),debug) -OPT=0 -C_FLAGS+=-g -endif - -# some other possible flags: -# -malign-double -mpentiumpro -march=pentiumpro diff --git a/extern/ode/dist/config/makefile.unix-generic b/extern/ode/dist/config/makefile.unix-generic deleted file mode 100644 index f435e1a0db8..00000000000 --- a/extern/ode/dist/config/makefile.unix-generic +++ /dev/null @@ -1,24 +0,0 @@ -THIS_DIR=./ -DEL_CMD=rm -f -CC=CC -OBJ=.o -C_FLAGS=-c -C_INC=-I -C_OUT=-o -C_EXEOUT=-o -C_DEF=-D -C_OPT=-O -AR=ar rc -RANLIB= -LIB_PREFIX=lib -LIB_SUFFIX=.a -LINK_OPENGL=-L/usr/X11R6/lib -L/usr/X11/lib -L/usr/lib/X11R6 -L/usr/lib/X11 -lX11 -lGL -lGLU -LINK_MATH=-lm - -ifeq ($(BUILD),release) -OPT=2 -endif - -ifeq ($(BUILD),debug) -OPT=0 -endif diff --git a/extern/ode/dist/config/msvcdefs.def b/extern/ode/dist/config/msvcdefs.def deleted file mode 100644 index 11258ab9aa8..00000000000 --- a/extern/ode/dist/config/msvcdefs.def +++ /dev/null @@ -1,228 +0,0 @@ -LIBRARY ODE -EXPORTS -dAreConnected -dBodyAddForce -dBodyAddForceAtPos -dBodyAddForceAtRelPos -dBodyAddRelForce -dBodyAddRelForceAtPos -dBodyAddRelForceAtRelPos -dBodyAddRelTorque -dBodyAddTorque -dBodyCreate -dBodyDestroy -dBodyDisable -dBodyEnable -dBodyGetAngularVel -dBodyGetData -dBodyGetFiniteRotationAxis -dBodyGetFiniteRotationMode -dBodyGetForce -dBodyGetGravityMode -dBodyGetJoint -dBodyGetLinearVel -dBodyGetMass -dBodyGetNumJoints -dBodyGetPointVel -dBodyGetPosRelPoint -dBodyGetPosition -dBodyGetQuaternion -dBodyGetRelPointPos -dBodyGetRelPointVel -dBodyGetRotation -dBodyGetTorque -dBodyIsEnabled -dBodySetAngularVel -dBodySetData -dBodySetFiniteRotationAxis -dBodySetFiniteRotationMode -dBodySetForce -dBodySetGravityMode -dBodySetLinearVel -dBodySetMass -dBodySetPosition -dBodySetQuaternion -dBodySetRotation -dBodySetTorque -dBodyVectorFromWorld -dBodyVectorToWorld -dBoxBox -dBoxClass -dBoxTouchesBox -dCCylinderClass -dClearUpperTriangle -dCloseODE -dClosestLineSegmentPoints -dCollide -dCreateBox -dCreateCCylinder -dCreateGeom -dCreateGeomClass -dCreateGeomGroup -dCreateGeomTransform -dCreatePlane -dCreateSphere -dError -dFactorCholesky -dFactorLDLT -dGeomBoxGetLengths -dGeomBoxSetLengths -dGeomCCylinderGetParams -dGeomCCylinderSetParams -dGeomDestroy -dGeomGetAABB -dGeomGetBody -dGeomGetClass -dGeomGetClassData -dGeomGetData -dGeomGetPosition -dGeomGetRotation -dGeomGetSpaceAABB -dGeomGroupAdd -dGeomGroupGetGeom -dGeomGroupGetNumGeoms -dGeomGroupRemove -dGeomPlaneGetParams -dGeomPlaneSetParams -dGeomSetBody -dGeomSetData -dGeomSetPosition -dGeomSetRotation -dGeomSphereGetRadius -dGeomSphereSetRadius -dGeomTransformClass -dGeomTransformGetCleanup -dGeomTransformGetGeom -dGeomTransformSetCleanup -dGeomTransformSetGeom -dHashSpaceCreate -dHashSpaceSetLevels -dInfiniteAABB -dInfinityValue -dInvertPDMatrix -dIsPositiveDefinite -dJointAttach -dJointCreateAMotor -dJointCreateBall -dJointCreateContact -dJointCreateFixed -dJointCreateHinge -dJointCreateHinge2 -dJointCreateSlider -dJointCreateUniversal -dJointDestroy -dJointGetAMotorAngle -dJointGetAMotorAngleRate -dJointGetAMotorAxis -dJointGetAMotorAxisRel -dJointGetAMotorMode -dJointGetAMotorNumAxes -dJointGetAMotorParam -dJointGetBallAnchor -dJointGetBody -dJointGetData -dJointGetHinge2Anchor -dJointGetHinge2Angle1 -dJointGetHinge2Angle1Rate -dJointGetHinge2Angle2Rate -dJointGetHinge2Axis1 -dJointGetHinge2Axis2 -dJointGetHinge2Param -dJointGetHingeAnchor -dJointGetHingeAngle -dJointGetHingeAngleRate -dJointGetHingeAxis -dJointGetHingeParam -dJointGetSliderAxis -dJointGetSliderParam -dJointGetSliderPosition -dJointGetSliderPositionRate -dJointGetType -dJointGetUniversalAnchor -dJointGetUniversalAxis1 -dJointGetUniversalAxis2 -dJointGroupCreate -dJointGroupDestroy -dJointGroupEmpty -dJointSetAMotorAngle -dJointSetAMotorAxis -dJointSetAMotorMode -dJointSetAMotorNumAxes -dJointSetAMotorParam -dJointSetBallAnchor -dJointSetData -dJointSetFixed -dJointSetHinge2Anchor -dJointSetHinge2Axis1 -dJointSetHinge2Axis2 -dJointSetHinge2Param -dJointSetHingeAnchor -dJointSetHingeAxis -dJointSetHingeParam -dJointSetSliderAxis -dJointSetSliderParam -dJointSetUniversalAnchor -dJointSetUniversalAxis1 -dJointSetUniversalAxis2 -dLDLTAddTL -dLDLTRemove -dMakeRandomMatrix -dMakeRandomVector -dMassAdd -dMassAdjust -dMassRotate -dMassSetBox -dMassSetCappedCylinder -dMassSetParameters -dMassSetSphere -dMassSetZero -dMassTranslate -dMaxDifference -dMultiply0 -dMultiply1 -dMultiply2 -dNormalize3 -dNormalize4 -dPlaneSpace -dQFromAxisAndAngle -dQMultiply0 -dQMultiply1 -dQMultiply2 -dQMultiply3 -dQSetIdentity -dQtoR -dRFrom2Axes -dRFromAxisAndAngle -dRFromEulerAngles -dRSetIdentity -dRandInt -dRandReal -dRandSetSeed -dRemoveRowCol -dRtoQ -dSetMessageHandler -dSetZero -dSimpleSpaceCreate -dSolveCholesky -dSolveLDLT -dSpaceAdd -dSpaceCollide -dSpaceDestroy -dSpaceQuery -dSpaceRemove -dSphereClass -dTestMatrixComparison -dTestRand -dTestSolveLCP -dWorldCreate -dWorldDestroy -dWorldGetCFM -dWorldGetERP -dWorldGetGravity -dWorldImpulseToForce -dWorldSetCFM -dWorldSetERP -dWorldSetGravity -dWorldStep -dWorldStep -dWtoDQ diff --git a/extern/ode/dist/config/user-settings b/extern/ode/dist/config/user-settings deleted file mode 100644 index d632eba9678..00000000000 --- a/extern/ode/dist/config/user-settings +++ /dev/null @@ -1,31 +0,0 @@ -# ODE user settings: the following variables must be set by the user - -# (1) the platform to use. this name should have a corresponding -# makefile.PLATFORM file. currently supported platforms are: -# msvc microsoft visual C/C++ -# msvc-dll microsoft visual C/C++, create a DLL -# mingw minimalist GNU for windows -# cygwin cygnus GNU for windows -# unix-gcc GNU gcc on unix -# unix-generic generic unix compiler. you may need to edit the CC -# variable in makefile.unix-generic -# osx Mac OS-X, with the gnu compiler. - -PLATFORM=unix-gcc - -# (2) the floating point precision to use (either "SINGLE" or "DOUBLE") - -PRECISION=SINGLE -#PRECISION=DOUBLE - -# (3) the library type to build (either "debug" if you are doing development, -# or "release" for the optimized library) - -#BUILD=debug -BUILD=release - -# (4) if you are using an old version of MS-Windows that has command line -# length limitations then you will need to set this to "1". otherwise, -# leave it at "0". - -WINDOWS16=0 diff --git a/extern/ode/dist/config/user-settings.example b/extern/ode/dist/config/user-settings.example deleted file mode 100644 index 0b0d480a25a..00000000000 --- a/extern/ode/dist/config/user-settings.example +++ /dev/null @@ -1,31 +0,0 @@ -# ODE user settings: the following variables must be set by the user - -# (1) the platform to use. this name should have a corresponding -# makefile.PLATFORM file. currently supported platforms are: -# msvc microsoft visual C/C++ -# msvc-dll microsoft visual C/C++, create a DLL -# mingw minimalist GNU for windows -# cygwin cygnus GNU for windows -# unix-gcc GNU gcc on unix -# unix-generic generic unix compiler. you may need to edit the CC -# variable in makefile.unix-generic -# osx Mac OS-X, with the gnu compiler. - -PLATFORM=unix-gcc - -# (2) the floating point precision to use (either "SINGLE" or "DOUBLE") - -#PRECISION=SINGLE -PRECISION=DOUBLE - -# (3) the library type to build (either "debug" if you are doing development, -# or "release" for the optimized library) - -#BUILD=debug -BUILD=release - -# (4) if you are using an old version of MS-Windows that has command line -# length limitations then you will need to set this to "1". otherwise, -# leave it at "0". - -WINDOWS16=0 diff --git a/extern/ode/dist/configurator.c b/extern/ode/dist/configurator.c deleted file mode 100644 index 8129716881d..00000000000 --- a/extern/ode/dist/configurator.c +++ /dev/null @@ -1,437 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -this program discovers some system configuration stuff, prior to compiling -ODE. the usage is: - - configurator <config.h-file-to-generate> <compiler-command-line> - <delete-command-line> <THIS_DIR-variable> - -this program looks long, but it really has an extremely simple structure and -should be very easy for anyone to modify. it should be very portable as it -is written in straight ANSI C and only uses the following library functions: - * printf - * fopen (assumes 0 returned on failure) - * fclose - * fprintf - * system - * exit -except where stated, we do not assume anything about the return codes from -these functions. - -why didn't i just use GNU autoconf? : - * autoconf needs a bourne shell and a bunch of other tools that windows - users may not have. - * i like reinventing the wheel. - -*/ - -#include <stdio.h> - -/****************************************************************************/ -/* project constants */ - -#define SETUP_SHLIB_DEFS \ - "#ifndef SHAREDLIBIMPORT\n" \ - "#define SHAREDLIBIMPORT\n" \ - "#endif\n" \ - "#ifndef SHAREDLIBEXPORT\n" \ - "#define SHAREDLIBEXPORT\n" \ - "#endif\n" - -/* the config.h header */ -char *config_h_part1 = -"/* per-machine configuration. this file is automatically generated. */\n" -"\n" -"#ifndef _ODE_CONFIG_H_\n" -"#define _ODE_CONFIG_H_\n" -"\n" -"/* shared lib definitions */\n" -SETUP_SHLIB_DEFS -"\n" -"/* standard system headers */\n"; - - -char *config_h_part2 = -"\n" -"#ifdef __cplusplus\n" -"extern \"C\" {\n" -"#endif\n" -"\n"; - -/* the config.h footer */ -char *config_h_footer = -"#ifdef __cplusplus\n" -"}\n" -"#endif\n" -"#endif\n"; - -/****************************************************************************/ -/* implementations of some string functions. these are prefixed with 'x' - * to prevent any conflicts with built-in functions. - */ - -#define strcpy xstrcpy -void xstrcpy (char *dest, char *src) -{ - while (*src) *dest++ = *src++; - *dest = 0; -} - - -#define strcat xstrcat -void xstrcat (char *dest, char *src) -{ - while (*dest) dest++; - while (*src) *dest++ = *src++; - *dest = 0; -} - -/****************************************************************************/ -/* utility functions */ - -/* print an error message and exit */ - -void fatal_error (char *message) -{ - printf ("\n*** configurator failed: %s.\n\n" - "please fix your configuration and try again.\n" - "if you have to fix the configurator program or the makefiles, " - "please email\n" - "your changes to the ODE mailing list (ode@q12.org).\n\n", message); - exit (0); -} - - -/* open a file, generate an error if it can't be done */ - -FILE * xfopen (char *filename, char *mode) -{ - FILE *f; - f = fopen (filename,mode); - if (!f) fatal_error ("can not open a file"); - return f; -} - - -/* return 1 if the file exists or 0 if not */ - -int file_exists (char *filename) -{ - FILE *f; - f = fopen (filename,"rb"); - if (f) fclose (f); - return (f != 0); -} - - -/* write a string to a new file */ - -void write_to_file (char *filename, char *s) -{ - FILE *f = xfopen (filename,"wt"); - fprintf (f,"%s",s); - fclose (f); -} - - -/* write a comment to a header file */ - -void write_header_comment (FILE *file, char *description) -{ - fprintf (file,"/* %s */\n",description); - printf ("%s ...\n",description); -} - - -/* delete a file */ - -char *delete_cmd_line = 0; -void delete_file (char *filename) -{ - char cmd[1000]; - strcpy (cmd,delete_cmd_line); - strcat (cmd," "); - strcat (cmd,filename); - printf ("%s\n",cmd); - system (cmd); -} - - -/* run a compile command */ - -char *compile_cmd_line = 0; -void compile (char *output, char *input) -{ - char cmd[1000]; - strcpy (cmd,compile_cmd_line); - strcat (cmd,output); - strcat (cmd," "); - strcat (cmd,input); - printf ("%s\n",cmd); - system (cmd); -} - - -/* run a program we've just compiled */ - -char *run_prefix = ""; -void run (char *filename) -{ - char cmd[1000]; - strcpy (cmd,run_prefix); - strcat (cmd,filename); - printf ("%s\n",cmd); - system (cmd); -} - -/****************************************************************************/ -/* system tests */ - -void check_if_this_is_a_pentium (FILE *file) -{ - write_header_comment (file,"is this a pentium on a gcc-based platform?"); - write_to_file ("ctest.c", - "int main() {\n" - " asm (\"mov $0,%%eax\\n cpuid\\n\" : : : \"%eax\");\n" - " return 0;\n" - "}\n"); - delete_file ("ctest.exe"); - compile ("ctest.exe","ctest.c"); - if (file_exists ("ctest.exe")) { - fprintf (file,"#define PENTIUM 1\n\n"); - } - else { - fprintf (file,"/* #define PENTIUM 1 -- not a pentium */\n\n"); - } - - delete_file ("ctest.c"); - delete_file ("ctest.exe"); -} - -/****************************************************************************/ -/* tests: standard headers */ - -void get_all_standard_headers (FILE *file) -{ - int i; - FILE *f; - char *header[7] = {"stdio.h", "stdlib.h", "math.h", "string.h", - "stdarg.h", "malloc.h", "alloca.h"}; - - for (i=0; i < sizeof(header)/sizeof(char*); i++) { - FILE *f = xfopen ("ctest.c","wt"); - fprintf (f,"#include <%s>\nint main() { return 0; }\n",header[i]); - fclose (f); - delete_file ("ctest.exe"); - compile ("ctest.exe","ctest.c"); - if (file_exists ("ctest.exe")) { - fprintf (file,"#include <%s>\n",header[i]); - } - } - - delete_file ("ctest.c"); - delete_file ("ctest.exe"); -} - -/****************************************************************************/ -/* tests: typedefs and constants for ODE */ - -void get_ODE_integer_typedefs (FILE *file) -{ - write_header_comment (file,"integer types (we assume int >= 32 bits)"); - if (sizeof(char) != 1) fatal_error ("expecting sizeof(char) == 1"); - if (sizeof(int) < 4) fatal_error ("expecting sizeof(int) >= 4"); - fprintf (file,"typedef char int8;\ntypedef unsigned char uint8;\n"); - if (sizeof(short) == 4) { - fprintf (file,"typedef short int32;\ntypedef unsigned short uint32;\n"); - } - else if (sizeof(int) == 4) { - fprintf (file,"typedef int int32;\ntypedef unsigned int uint32;\n"); - } - else { - fatal_error ("can not find 4 byte integer type"); - } - fprintf (file,"\n" - "/* an integer type that we can safely cast a pointer to and\n" - " * from without loss of bits.\n" - " */\n"); - if (sizeof(short) == sizeof(void*)) { - fprintf (file,"typedef unsigned short intP;\n"); - } - else if (sizeof(int) == sizeof(void*)) { - fprintf (file,"typedef unsigned int intP;\n"); - } - else if (sizeof(long int) == sizeof(void*)) { - fprintf (file,"typedef unsigned long int intP;\n"); - } - fprintf (file,"\n"); -} - - -void get_ODE_float_stuff (FILE *file) -{ - char *suffix,*type; - int i; - FILE *f; - -#define SHARED_LIB_SPEC_DECISION \ - "#if defined SHARED_CONFIG_H_INCLUDED_FROM_DEFINING_FILE\n" \ - " #define GLOBAL_SHAREDLIB_SPEC SHAREDLIBEXPORT\n" \ - "#else \n" \ - " #define GLOBAL_SHAREDLIB_SPEC SHAREDLIBIMPORT\n" \ - "#endif\n" - -#define UNDEF_SHAREDLIB_SPEC "\n#undef GLOBAL_SHAREDLIB_SPEC\n" - -#ifdef dSINGLE - -#define INFBYTES SHARED_LIB_SPEC_DECISION "union dInfBytes { unsigned char c[4]; float f; };\nextern GLOBAL_SHAREDLIB_SPEC union dInfBytes dInfinityValue;\n#define dInfinity (dInfinityValue.f)" - - char *inc[6] = {"#include <math.h>", - "#include <math.h>", - "", - "", - "", - ""}; - char *decl[6] = { - "SHAREDLIBEXPORT double dInfinityValue = HUGE_VALF;", - "SHAREDLIBEXPORT double dInfinityValue = HUGE_VAL;", - "SHAREDLIBEXPORT union dInfBytes dInfinityValue = {{0x7f,0x80,0,0}};", - "SHAREDLIBEXPORT union dInfBytes dInfinityValue = {{0,0,0x80,0x7f}};", - "SHAREDLIBEXPORT double dInfinityValue = 1.0f/0.0f;", - "SHAREDLIBEXPORT double dInfinityValue = 1e20f;"}; - char *inf[6] = { - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC, - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC, - INFBYTES UNDEF_SHAREDLIB_SPEC, - INFBYTES UNDEF_SHAREDLIB_SPEC, - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC, - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC}; - -#else /* not dSINGLE, must be dDOUBLE */ - -#define INFBYTES SHARED_LIB_SPEC_DECISION "union dInfBytes { unsigned char c[8]; double d; };\nextern GLOBAL_SHAREDLIB_SPEC union dInfBytes dInfinityValue;\n#define dInfinity (dInfinityValue.d)" - - char *inc[5] = { - "#include <math.h>", - "", - "", - "", - ""}; - char *decl[5] = { - "SHAREDLIBEXPORT double dInfinityValue = HUGE_VAL;", - "SHAREDLIBEXPORT union dInfBytes dInfinityValue = {{0x7f,0xf0,0,0,0,0,0,0}};", - "SHAREDLIBEXPORT union dInfBytes dInfinityValue = {{0,0,0,0,0,0,0xf0,0x7f}};", - "SHAREDLIBEXPORT double dInfinityValue = 1.0/0.0;", - "SHAREDLIBEXPORT double dInfinityValue = 1e20;"}; - char *inf[5] = { - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC, - INFBYTES UNDEF_SHAREDLIB_SPEC, - INFBYTES UNDEF_SHAREDLIB_SPEC, - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC, - SHARED_LIB_SPEC_DECISION "extern GLOBAL_SHAREDLIB_SPEC double dInfinityValue;\n#define dInfinity dInfinityValue" UNDEF_SHAREDLIB_SPEC}; -#endif - - write_header_comment (file,"select the base floating point type"); -#ifdef dSINGLE - fprintf (file,"#define dSINGLE 1\n\n"); - type = "float"; - suffix = "f"; -#else - fprintf (file,"#define dDOUBLE 1\n\n"); - type = "double"; - suffix = ""; -#endif - - /* infinity */ - write_header_comment (file,"the floating point infinity"); - - /* try the different infinity constants until one works */ - for (i=0; i < sizeof(inf)/sizeof(char*); i++) { - f = xfopen ("ctest.c","wt"); - fprintf (f, - "#include <stdio.h>\n" - "#define SHARED_CONFIG_H_INCLUDED_FROM_DEFINING_FILE 1\n" - SETUP_SHLIB_DEFS - "%s\n" - "%s\n" - "%s\n" - "int main() {\n" - " if (dInfinity > 1e10%s && -dInfinity < -1e10%s &&\n" - " -dInfinity < dInfinity) {\n" - " FILE *f = fopen (\"data\",\"wt\");\n" - " fprintf (f,\"foo\\n\");\n" - " fclose (f);\n" - " }\n" - " return 0;\n" - "}\n" - ,inc[i],inf[i],decl[i],suffix,suffix); - fclose (f); - delete_file ("data"); - compile ("ctest.exe","ctest.c"); - run ("ctest.exe"); - if (file_exists ("data")) { - fprintf (file,"#define DINFINITY_DECL %s\n",decl[i]); - fprintf (file,"%s\n\n",inf[i]); - delete_file ("ctest.c"); - delete_file ("ctest.exe"); - delete_file ("data"); - return; - } - } - - fatal_error ("can't determine dInfinity constant"); -} - -/****************************************************************************/ - -int main (int argc, char **argv) -{ - FILE *file; - - if (argc < 4 || argc > 5) - fatal_error ("configurator expects 3 or 4 arguments"); - compile_cmd_line = argv[2]; - delete_cmd_line = argv[3]; - if (argc >= 5) run_prefix = argv[4]; - - /* check some defines we should have been compiled with */ -#if !defined(dSINGLE) && !defined(dDOUBLE) - fatal_error ("you must set PRECISION to either SINGLE or DOUBLE"); -#endif - - file = xfopen (argv[1],"wt"); - fprintf (file,config_h_part1); - get_all_standard_headers (file); - fprintf (file,config_h_part2); - check_if_this_is_a_pentium (file); - get_ODE_integer_typedefs (file); - get_ODE_float_stuff (file); - fprintf (file,config_h_footer); - fclose (file); - - printf ("\n*** configurator succeeded ***\n\n"); - return 0; -} diff --git a/extern/ode/dist/include/ode/README b/extern/ode/dist/include/ode/README deleted file mode 100644 index aaedfcc38fe..00000000000 --- a/extern/ode/dist/include/ode/README +++ /dev/null @@ -1,18 +0,0 @@ - -this is the public C interface to the ODE library. - -all these files should be includable from C, i.e. they should not use any -C++ features. everything should be protected with - - #ifdef __cplusplus - extern "C" { - #endif - - ... - - #ifdef __cplusplus - } - #endif - -the only exception is the odecpp.h file, which defines a C++ wrapper for -the C interface. remember to keep this in sync! diff --git a/extern/ode/dist/include/ode/common.h b/extern/ode/dist/include/ode/common.h deleted file mode 100644 index bd29d904028..00000000000 --- a/extern/ode/dist/include/ode/common.h +++ /dev/null @@ -1,307 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_COMMON_H_ -#define _ODE_COMMON_H_ - -#include <ode/config.h> -#include <ode/error.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -/* configuration stuff */ - -/* the efficient alignment. most platforms align data structures to some - * number of bytes, but this is not always the most efficient alignment. - * for example, many x86 compilers align to 4 bytes, but on a pentium it - * is important to align doubles to 8 byte boundaries (for speed), and - * the 4 floats in a SIMD register to 16 byte boundaries. many other - * platforms have similar behavior. setting a larger alignment can waste - * a (very) small amount of memory. NOTE: this number must be a power of - * two. this is set to 16 by default. - */ -#define EFFICIENT_ALIGNMENT 16 - - -/* constants */ - -/* pi and 1/sqrt(2) are defined here if necessary because they don't get - * defined in <math.h> on some platforms (like MS-Windows) - */ - -#ifndef M_PI -#define M_PI REAL(3.1415926535897932384626433832795029) -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 REAL(0.7071067811865475244008443621048490) -#endif - - -/* debugging: - * IASSERT is an internal assertion, i.e. a consistency check. if it fails - * we want to know where. - * UASSERT is a user assertion, i.e. if it fails a nice error message - * should be printed for the user. - * AASSERT is an arguments assertion, i.e. if it fails "bad argument(s)" - * is printed. - * DEBUGMSG just prints out a message - */ - -#ifndef dNODEBUG -#ifdef __GNUC__ -#define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \ - "assertion \"" #a "\" failed in %s() [%s]",__FUNCTION__,__FILE__); -#define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \ - msg " in %s()", __FUNCTION__); -#define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \ - msg " in %s()", __FUNCTION__); -#else -#define dIASSERT(a) if (!(a)) dDebug (d_ERR_IASSERT, \ - "assertion \"" #a "\" failed in %s:%d",__FILE__,__LINE__); -#define dUASSERT(a,msg) if (!(a)) dDebug (d_ERR_UASSERT, \ - msg " (%s:%d)", __FILE__,__LINE__); -#define dDEBUGMSG(msg) dMessage (d_ERR_UASSERT, \ - msg " (%s:%d)", __FILE__,__LINE__); -#endif -#else -#define dIASSERT(a) ; -#define dUASSERT(a,msg) ; -#define dDEBUGMSG(msg) ; -#endif -#define dAASSERT(a) dUASSERT(a,"Bad argument(s)") - -/* floating point data type, vector, matrix and quaternion types */ - -#if defined(dSINGLE) -typedef float dReal; -#elif defined(dDOUBLE) -typedef double dReal; -#else -#error You must #define dSINGLE or dDOUBLE -#endif - - -/* round an integer up to a multiple of 4, except that 0 and 1 are unmodified - * (used to compute matrix leading dimensions) - */ -#define dPAD(a) (((a) > 1) ? ((((a)-1)|3)+1) : (a)) - -/* these types are mainly just used in headers */ -typedef dReal dVector3[4]; -typedef dReal dVector4[4]; -typedef dReal dMatrix3[4*3]; -typedef dReal dMatrix4[4*4]; -typedef dReal dMatrix6[8*6]; -typedef dReal dQuaternion[4]; - - -/* precision dependent scalar math functions */ - -#if defined(dSINGLE) - -#define REAL(x) (x ## f) /* form a constant */ -#define dRecip(x) ((float)(1.0f/(x))) /* reciprocal */ -#define dSqrt(x) ((float)sqrt(x)) /* square root */ -#define dRecipSqrt(x) ((float)(1.0f/sqrt(x))) /* reciprocal square root */ -#define dSin(x) ((float)sin(x)) /* sine */ -#define dCos(x) ((float)cos(x)) /* cosine */ -#define dFabs(x) ((float)fabs(x)) /* absolute value */ -#define dAtan2(y,x) ((float)atan2((y),(x))) /* arc tangent with 2 args */ - -#elif defined(dDOUBLE) - -#define REAL(x) (x) -#define dRecip(x) (1.0/(x)) -#define dSqrt(x) sqrt(x) -#define dRecipSqrt(x) (1.0/sqrt(x)) -#define dSin(x) sin(x) -#define dCos(x) cos(x) -#define dFabs(x) fabs(x) -#define dAtan2(y,x) atan2((y),(x)) - -#else -#error You must #define dSINGLE or dDOUBLE -#endif - - -/* utility */ - - -/* round something up to be a multiple of the EFFICIENT_ALIGNMENT */ - -#define dEFFICIENT_SIZE(x) ((((x)-1)|(EFFICIENT_ALIGNMENT-1))+1) - - -/* alloca aligned to the EFFICIENT_ALIGNMENT. note that this can waste - * up to 15 bytes per allocation, depending on what alloca() returns. - */ - -#define dALLOCA16(n) \ - ((char*)dEFFICIENT_SIZE(((int)(alloca((n)+(EFFICIENT_ALIGNMENT-1)))))) - - -/* internal object types (all prefixed with `dx') */ - -struct dxWorld; /* dynamics world */ -struct dxSpace; /* collision space */ -struct dxBody; /* rigid body (dynamics object) */ -struct dxGeom; /* geometry (collision object) */ -struct dxJoint; -struct dxJointNode; -struct dxJointGroup; - -typedef struct dxWorld *dWorldID; -typedef struct dxSpace *dSpaceID; -typedef struct dxBody *dBodyID; -typedef struct dxGeom *dGeomID; -typedef struct dxJoint *dJointID; -typedef struct dxJointGroup *dJointGroupID; - - -/* error numbers */ - -enum { - d_ERR_UNKNOWN = 0, /* unknown error */ - d_ERR_IASSERT, /* internal assertion failed */ - d_ERR_UASSERT, /* user assertion failed */ - d_ERR_LCP /* user assertion failed */ -}; - - -/* joint type numbers */ - -enum { - dJointTypeNone = 0, /* or "unknown" */ - dJointTypeBall, - dJointTypeHinge, - dJointTypeSlider, - dJointTypeContact, - dJointTypeUniversal, - dJointTypeHinge2, - dJointTypeFixed, - dJointTypeNull, - dJointTypeAMotor -}; - - -/* an alternative way of setting joint parameters, using joint parameter - * structures and member constants. we don't actually do this yet. - */ - -/* -typedef struct dLimot { - int mode; - dReal lostop, histop; - dReal vel, fmax; - dReal fudge_factor; - dReal bounce, soft; - dReal suspension_erp, suspension_cfm; -} dLimot; - -enum { - dLimotLoStop = 0x0001, - dLimotHiStop = 0x0002, - dLimotVel = 0x0004, - dLimotFMax = 0x0008, - dLimotFudgeFactor = 0x0010, - dLimotBounce = 0x0020, - dLimotSoft = 0x0040 -}; -*/ - - -/* standard joint parameter names. why are these here? - because we don't want - * to include all the joint function definitions in joint.cpp. hmmmm. - * MSVC complains if we call D_ALL_PARAM_NAMES_X with a blank second argument, - * which is why we have the D_ALL_PARAM_NAMES macro as well. please copy and - * paste between these two. - */ - -#define D_ALL_PARAM_NAMES(start) \ - /* parameters for limits and motors */ \ - dParamLoStop = start, \ - dParamHiStop, \ - dParamVel, \ - dParamFMax, \ - dParamFudgeFactor, \ - dParamBounce, \ - dParamCFM, \ - dParamStopERP, \ - dParamStopCFM, \ - /* parameters for suspension */ \ - dParamSuspensionERP, \ - dParamSuspensionCFM, - -#define D_ALL_PARAM_NAMES_X(start,x) \ - /* parameters for limits and motors */ \ - dParamLoStop ## x = start, \ - dParamHiStop ## x, \ - dParamVel ## x, \ - dParamFMax ## x, \ - dParamFudgeFactor ## x, \ - dParamBounce ## x, \ - dParamCFM ## x, \ - dParamStopERP ## x, \ - dParamStopCFM ## x, \ - /* parameters for suspension */ \ - dParamSuspensionERP ## x, \ - dParamSuspensionCFM ## x, - -enum { - D_ALL_PARAM_NAMES(0) - D_ALL_PARAM_NAMES_X(0x100,2) - D_ALL_PARAM_NAMES_X(0x200,3) - - /* add a multiple of this constant to the basic parameter numbers to get - * the parameters for the second, third etc axes. - */ - dParamGroup=0x100 -}; - - -/* angular motor mode numbers */ - -enum{ - dAMotorUser = 0, - dAMotorEuler = 1 -}; - - -/* joint force feedback information */ - -typedef struct dJointFeedback { - dVector3 f1; // force applied to body 1 - dVector3 t1; // torque applied to body 1 - dVector3 f2; // force applied to body 2 - dVector3 t2; // torque applied to body 2 -} dJointFeedback; - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/contact.h b/extern/ode/dist/include/ode/contact.h deleted file mode 100644 index 6fc66a179c0..00000000000 --- a/extern/ode/dist/include/ode/contact.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_CONTACT_H_ -#define _ODE_CONTACT_H_ - -#include <ode/common.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -enum { - dContactMu2 = 0x001, - dContactFDir1 = 0x002, - dContactBounce = 0x004, - dContactSoftERP = 0x008, - dContactSoftCFM = 0x010, - dContactMotion1 = 0x020, - dContactMotion2 = 0x040, - dContactSlip1 = 0x080, - dContactSlip2 = 0x100, - - dContactApprox0 = 0x0000, - dContactApprox1_1 = 0x1000, - dContactApprox1_2 = 0x2000, - dContactApprox1 = 0x3000 -}; - - -typedef struct dSurfaceParameters { - /* must always be defined */ - int mode; - dReal mu; - - /* only defined if the corresponding flag is set in mode */ - dReal mu2; - dReal bounce; - dReal bounce_vel; - dReal soft_erp; - dReal soft_cfm; - dReal motion1,motion2; - dReal slip1,slip2; -} dSurfaceParameters; - - -/* contact info set by collision functions */ - -typedef struct dContactGeom { - dVector3 pos; - dVector3 normal; - dReal depth; - dGeomID g1,g2; -} dContactGeom; - - -/* contact info used by contact joint */ - -typedef struct dContact { - dSurfaceParameters surface; - dContactGeom geom; - dVector3 fdir1; -} dContact; - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/error.h b/extern/ode/dist/include/ode/error.h deleted file mode 100644 index 1350bbc8427..00000000000 --- a/extern/ode/dist/include/ode/error.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* this comes from the `reuse' library. copy any changes back to the source */ - -#ifndef _ODE_ERROR_H_ -#define _ODE_ERROR_H_ - -#include <ode/config.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* all user defined error functions have this type. error and debug functions - * should not return. - */ -typedef void dMessageFunction (int errnum, const char *msg, va_list ap); - -/* set a new error, debug or warning handler. if fn is 0, the default handlers - * are used. - */ -void dSetErrorHandler (dMessageFunction *fn); -void dSetDebugHandler (dMessageFunction *fn); -void dSetMessageHandler (dMessageFunction *fn); - -/* return the current error, debug or warning handler. if the return value is - * 0, the default handlers are in place. - */ -dMessageFunction *dGetErrorHandler(); -dMessageFunction *dGetDebugHandler(); -dMessageFunction *dGetMessageHandler(); - -/* generate a fatal error, debug trap or a message. */ -void dError (int num, const char *msg, ...); -void dDebug (int num, const char *msg, ...); -void dMessage (int num, const char *msg, ...); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/geom.h b/extern/ode/dist/include/ode/geom.h deleted file mode 100644 index 20fc8998ded..00000000000 --- a/extern/ode/dist/include/ode/geom.h +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_GEOM_H_ -#define _ODE_GEOM_H_ - -#include <ode/common.h> -#include <ode/space.h> -#include <ode/contact.h> - -#if defined SHARED_GEOM_H_INCLUDED_FROM_DEFINING_FILE -#define GLOBAL_SHAREDLIB_SPEC SHAREDLIBEXPORT -#else -#define GLOBAL_SHAREDLIB_SPEC SHAREDLIBIMPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* ************************************************************************ */ -/* utility functions */ - -void dClosestLineSegmentPoints (const dVector3 a1, const dVector3 a2, - const dVector3 b1, const dVector3 b2, - dVector3 cp1, dVector3 cp2); - -int dBoxTouchesBox (const dVector3 _p1, const dMatrix3 R1, - const dVector3 side1, const dVector3 _p2, - const dMatrix3 R2, const dVector3 side2); - -void dInfiniteAABB (dGeomID geom, dReal aabb[6]); -void dCloseODE(); - -/* ************************************************************************ */ -/* standard classes */ - -/* class numbers */ -extern GLOBAL_SHAREDLIB_SPEC int dSphereClass; -extern GLOBAL_SHAREDLIB_SPEC int dBoxClass; -extern GLOBAL_SHAREDLIB_SPEC int dCCylinderClass; -extern GLOBAL_SHAREDLIB_SPEC int dPlaneClass; -extern GLOBAL_SHAREDLIB_SPEC int dGeomGroupClass; -extern GLOBAL_SHAREDLIB_SPEC int dGeomTransformClass; - -/* constructors */ -dGeomID dCreateSphere (dSpaceID space, dReal radius); -dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz); -dGeomID dCreatePlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d); -dGeomID dCreateCCylinder (dSpaceID space, dReal radius, dReal length); -dGeomID dCreateGeomGroup (dSpaceID space); - -/* set geometry parameters */ -void dGeomSphereSetRadius (dGeomID sphere, dReal radius); -void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz); -void dGeomPlaneSetParams (dGeomID plane, dReal a, dReal b, dReal c, dReal d); -void dGeomCCylinderSetParams (dGeomID ccylinder, dReal radius, dReal length); - -/* get geometry parameters */ -int dGeomGetClass (dGeomID); -dReal dGeomSphereGetRadius (dGeomID sphere); -void dGeomBoxGetLengths (dGeomID box, dVector3 result); -void dGeomPlaneGetParams (dGeomID plane, dVector4 result); -void dGeomCCylinderGetParams (dGeomID ccylinder, - dReal *radius, dReal *length); - -/* general functions */ -void dGeomSetData (dGeomID, void *); -void *dGeomGetData (dGeomID); -void dGeomSetBody (dGeomID, dBodyID); -dBodyID dGeomGetBody (dGeomID); -void dGeomSetPosition (dGeomID, dReal x, dReal y, dReal z); -void dGeomSetRotation (dGeomID, const dMatrix3 R); -const dReal * dGeomGetPosition (dGeomID); -const dReal * dGeomGetRotation (dGeomID); -void dGeomDestroy (dGeomID); -void dGeomGetAABB (dGeomID, dReal aabb[6]); -dReal *dGeomGetSpaceAABB (dGeomID); - -/* ************************************************************************ */ -/* geometry group functions */ - -void dGeomGroupAdd (dGeomID group, dGeomID x); -void dGeomGroupRemove (dGeomID group, dGeomID x); -int dGeomGroupGetNumGeoms (dGeomID group); -dGeomID dGeomGroupGetGeom (dGeomID group, int i); - -/* ************************************************************************ */ -/* transformed geometry functions */ - -dGeomID dCreateGeomTransform (dSpaceID space); -void dGeomTransformSetGeom (dGeomID g, dGeomID obj); -dGeomID dGeomTransformGetGeom (dGeomID g); -void dGeomTransformSetCleanup (dGeomID g, int mode); -int dGeomTransformGetCleanup (dGeomID g); -void dGeomTransformSetInfo (dGeomID g, int mode); -int dGeomTransformGetInfo (dGeomID g); - -/* ************************************************************************ */ -/* general collision */ - -int dCollide (dGeomID o1, dGeomID o2, int flags, dContactGeom *contact, - int skip); - -/* ************************************************************************ */ -/* custom classes */ - -typedef void dGetAABBFn (dGeomID, dReal aabb[6]); -typedef int dColliderFn (dGeomID o1, dGeomID o2, - int flags, dContactGeom *contact, int skip); -typedef dColliderFn * dGetColliderFnFn (int num); -typedef void dGeomDtorFn (dGeomID o); -typedef int dAABBTestFn (dGeomID o1, dGeomID o2, dReal aabb[6]); - -typedef struct dGeomClass { - int bytes; - dGetColliderFnFn *collider; - dGetAABBFn *aabb; - dAABBTestFn *aabb_test; - dGeomDtorFn *dtor; -} dGeomClass; - -int dCreateGeomClass (const dGeomClass *classptr); -void * dGeomGetClassData (dGeomID); -dGeomID dCreateGeom (int classnum); - -/* ************************************************************************ */ - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/mass.h b/extern/ode/dist/include/ode/mass.h deleted file mode 100644 index 8e75da0c1eb..00000000000 --- a/extern/ode/dist/include/ode/mass.h +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_MASS_H_ -#define _ODE_MASS_H_ - -#include <ode/common.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct dMass; -typedef struct dMass dMass; - - -void dMassSetZero (dMass *); - -void dMassSetParameters (dMass *, dReal themass, - dReal cgx, dReal cgy, dReal cgz, - dReal I11, dReal I22, dReal I33, - dReal I12, dReal I13, dReal I23); - -void dMassSetSphere (dMass *, dReal density, dReal radius); - -void dMassSetCappedCylinder (dMass *, dReal density, int direction, - dReal a, dReal b); - -void dMassSetBox (dMass *, dReal density, - dReal lx, dReal ly, dReal lz); - -void dMassAdjust (dMass *, dReal newmass); - -void dMassTranslate (dMass *, dReal x, dReal y, dReal z); - -void dMassRotate (dMass *, const dMatrix3 R); - -void dMassAdd (dMass *a, const dMass *b); - - - -struct dMass { - dReal mass; - dVector4 c; - dMatrix3 I; - -#ifdef __cplusplus - dMass() - { dMassSetZero (this); } - void setZero() - { dMassSetZero (this); } - void setParameters (dReal themass, dReal cgx, dReal cgy, dReal cgz, - dReal I11, dReal I22, dReal I33, - dReal I12, dReal I13, dReal I23) - { dMassSetParameters (this,themass,cgx,cgy,cgz,I11,I22,I33,I12,I13,I23); } - void setSphere (dReal density, dReal radius) - { dMassSetSphere (this,density,radius); } - void setCappedCylinder (dReal density, int direction, dReal a, dReal b) - { dMassSetCappedCylinder (this,density,direction,a,b); } - void setBox (dReal density, dReal lx, dReal ly, dReal lz) - { dMassSetBox (this,density,lx,ly,lz); } - void adjust (dReal newmass) - { dMassAdjust (this,newmass); } - void translate (dReal x, dReal y, dReal z) - { dMassTranslate (this,x,y,z); } - void rotate (const dMatrix3 R) - { dMassRotate (this,R); } - void add (const dMass *b) - { dMassAdd (this,b); } -#endif -}; - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/matrix.h b/extern/ode/dist/include/ode/matrix.h deleted file mode 100644 index 94d830095cd..00000000000 --- a/extern/ode/dist/include/ode/matrix.h +++ /dev/null @@ -1,195 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* optimized and unoptimized vector and matrix functions */ - -#ifndef _ODE_MATRIX_H_ -#define _ODE_MATRIX_H_ - -#include <ode/common.h> - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* set a vector/matrix of size n to all zeros, or to a specific value. */ - -void dSetZero (dReal *a, int n); -void dSetValue (dReal *a, int n, dReal value); - - -/* get the dot product of two n*1 vectors. if n <= 0 then - * zero will be returned (in which case a and b need not be valid). - */ - -dReal dDot (const dReal *a, const dReal *b, int n); - - -/* get the dot products of (a0,b), (a1,b), etc and return them in outsum. - * all vectors are n*1. if n <= 0 then zeroes will be returned (in which case - * the input vectors need not be valid). this function is somewhat faster - * than calling dDot() for all of the combinations separately. - */ - -/* NOT INCLUDED in the library for now. -void dMultidot2 (const dReal *a0, const dReal *a1, - const dReal *b, dReal *outsum, int n); -*/ - - -/* matrix multiplication. all matrices are stored in standard row format. - * the digit refers to the argument that is transposed: - * 0: A = B * C (sizes: A:p*r B:p*q C:q*r) - * 1: A = B' * C (sizes: A:p*r B:q*p C:q*r) - * 2: A = B * C' (sizes: A:p*r B:p*q C:r*q) - * case 1,2 are equivalent to saying that the operation is A=B*C but - * B or C are stored in standard column format. - */ - -void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); -void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); -void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p,int q,int r); - - -/* do an in-place cholesky decomposition on the lower triangle of the n*n - * symmetric matrix A (which is stored by rows). the resulting lower triangle - * will be such that L*L'=A. return 1 on success and 0 on failure (on failure - * the matrix is not positive definite). - */ - -int dFactorCholesky (dReal *A, int n); - - -/* solve for x: L*L'*x = b, and put the result back into x. - * L is size n*n, b is size n*1. only the lower triangle of L is considered. - */ - -void dSolveCholesky (const dReal *L, dReal *b, int n); - - -/* compute the inverse of the n*n positive definite matrix A and put it in - * Ainv. this is not especially fast. this returns 1 on success (A was - * positive definite) or 0 on failure (not PD). - */ - -int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n); - - -/* check whether an n*n matrix A is positive definite, return 1/0 (yes/no). - * positive definite means that x'*A*x > 0 for any x. this performs a - * cholesky decomposition of A. if the decomposition fails then the matrix - * is not positive definite. A is stored by rows. A is not altered. - */ - -int dIsPositiveDefinite (const dReal *A, int n); - - -/* factorize a matrix A into L*D*L', where L is lower triangular with ones on - * the diagonal, and D is diagonal. - * A is an n*n matrix stored by rows, with a leading dimension of n rounded - * up to 4. L is written into the strict lower triangle of A (the ones are not - * written) and the reciprocal of the diagonal elements of D are written into - * d. - */ -void dFactorLDLT (dReal *A, dReal *d, int n, int nskip); - - -/* solve L*x=b, where L is n*n lower triangular with ones on the diagonal, - * and x,b are n*1. b is overwritten with x. - * the leading dimension of L is `nskip'. - */ -void dSolveL1 (const dReal *L, dReal *b, int n, int nskip); - - -/* solve L'*x=b, where L is n*n lower triangular with ones on the diagonal, - * and x,b are n*1. b is overwritten with x. - * the leading dimension of L is `nskip'. - */ -void dSolveL1T (const dReal *L, dReal *b, int n, int nskip); - - -/* in matlab syntax: a(1:n) = a(1:n) .* d(1:n) */ - -void dVectorScale (dReal *a, const dReal *d, int n); - - -/* given `L', a n*n lower triangular matrix with ones on the diagonal, - * and `d', a n*1 vector of the reciprocal diagonal elements of an n*n matrix - * D, solve L*D*L'*x=b where x,b are n*1. x overwrites b. - * the leading dimension of L is `nskip'. - */ - -void dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip); - - -/* given an L*D*L' factorization of an n*n matrix A, return the updated - * factorization L2*D2*L2' of A plus the following "top left" matrix: - * - * [ b a' ] <-- b is a[0] - * [ a 0 ] <-- a is a[1..n-1] - * - * - L has size n*n, its leading dimension is nskip. L is lower triangular - * with ones on the diagonal. only the lower triangle of L is referenced. - * - d has size n. d contains the reciprocal diagonal elements of D. - * - a has size n. - * the result is written into L, except that the left column of L and d[0] - * are not actually modified. see ldltaddTL.m for further comments. - */ -void dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip); - - -/* given an L*D*L' factorization of a permuted matrix A, produce a new - * factorization for row and column `r' removed. - * - A has size n1*n1, its leading dimension in nskip. A is symmetric and - * positive definite. only the lower triangle of A is referenced. - * A itself may actually be an array of row pointers. - * - L has size n2*n2, its leading dimension in nskip. L is lower triangular - * with ones on the diagonal. only the lower triangle of L is referenced. - * - d has size n2. d contains the reciprocal diagonal elements of D. - * - p is a permutation vector. it contains n2 indexes into A. each index - * must be in the range 0..n1-1. - * - r is the row/column of L to remove. - * the new L will be written within the old L, i.e. will have the same leading - * dimension. the last row and column of L, and the last element of d, are - * undefined on exit. - * - * a fast O(n^2) algorithm is used. see ldltremove.m for further comments. - */ -void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, - int n1, int n2, int r, int nskip); - - -/* given an n*n matrix A (with leading dimension nskip), remove the r'th row - * and column by moving elements. the new matrix will have the same leading - * dimension. the last row and column of A are untouched on exit. - */ -void dRemoveRowCol (dReal *A, int n, int nskip, int r); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/memory.h b/extern/ode/dist/include/ode/memory.h deleted file mode 100644 index 7ea668e4d39..00000000000 --- a/extern/ode/dist/include/ode/memory.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* this comes from the `reuse' library. copy any changes back to the source */ - -#ifndef _ODE_MEMORY_H_ -#define _ODE_MEMORY_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* function types to allocate and free memory */ -typedef void * dAllocFunction (int size); -typedef void * dReallocFunction (void *ptr, int oldsize, int newsize); -typedef void dFreeFunction (void *ptr, int size); - -/* set new memory management functions. if fn is 0, the default handlers are - * used. */ -void dSetAllocHandler (dAllocFunction *fn); -void dSetReallocHandler (dReallocFunction *fn); -void dSetFreeHandler (dFreeFunction *fn); - -/* get current memory management functions */ -dAllocFunction *dGetAllocHandler (); -dReallocFunction *dGetReallocHandler (); -dFreeFunction *dGetFreeHandler (); - -/* allocate and free memory. */ -void * dAlloc (int size); -void * dRealloc (void *ptr, int oldsize, int newsize); -void dFree (void *ptr, int size); - -/* when alloc debugging is turned on, this indicates that the given block of - * alloc()ed memory should not be reported as "still in use" when the program - * exits. - */ -void dAllocDontReport (void *ptr); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/misc.h b/extern/ode/dist/include/ode/misc.h deleted file mode 100644 index 241ad71ed9e..00000000000 --- a/extern/ode/dist/include/ode/misc.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* miscellaneous math functions. these are mostly useful for testing */ - -#ifndef _ODE_MISC_H_ -#define _ODE_MISC_H_ - -#include <ode/common.h> - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* return 1 if the random number generator is working. */ -int dTestRand(); - -/* return next 32 bit random number. this uses a not-very-random linear - * congruential method. - */ -unsigned long dRand(); - -/* get and set the current random number seed. */ -unsigned long dRandGetSeed(); -void dRandSetSeed (unsigned long s); - -/* return a random integer between 0..n-1. the distribution will get worse - * as n approaches 2^32. - */ -int dRandInt (int n); - -/* return a random real number between 0..1 */ -dReal dRandReal(); - -/* print out a matrix */ -#ifdef __cplusplus -void dPrintMatrix (dReal *A, int n, int m, char *fmt = "%10.4f ", - FILE *f=stdout); -#else -void dPrintMatrix (dReal *A, int n, int m, char *fmt, FILE *f); -#endif - -/* make a random vector with entries between +/- range. A has n elements. */ -void dMakeRandomVector (dReal *A, int n, dReal range); - -/* make a random matrix with entries between +/- range. A has size n*m. */ -void dMakeRandomMatrix (dReal *A, int n, int m, dReal range); - -/* clear the upper triangle of a square matrix */ -void dClearUpperTriangle (dReal *A, int n); - -/* return the maximum element difference between the two n*m matrices */ -dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m); - -/* return the maximum element difference between the lower triangle of two - * n*n matrices */ -dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/objects.h b/extern/ode/dist/include/ode/objects.h deleted file mode 100644 index 606051ead34..00000000000 --- a/extern/ode/dist/include/ode/objects.h +++ /dev/null @@ -1,202 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_OBJECTS_H_ -#define _ODE_OBJECTS_H_ - -#include <ode/common.h> -#include <ode/mass.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* world */ - -dWorldID dWorldCreate(); -void dWorldDestroy (dWorldID); - -void dWorldSetGravity (dWorldID, dReal x, dReal y, dReal z); -void dWorldGetGravity (dWorldID, dVector3 gravity); -void dWorldSetERP (dWorldID, dReal erp); -dReal dWorldGetERP (dWorldID); -void dWorldSetCFM (dWorldID, dReal cfm); -dReal dWorldGetCFM (dWorldID); -void dWorldStep (dWorldID, dReal stepsize); -void dWorldImpulseToForce (dWorldID, dReal stepsize, - dReal ix, dReal iy, dReal iz, dVector3 force); - -/* bodies */ - -dBodyID dBodyCreate (dWorldID); -void dBodyDestroy (dBodyID); - -void dBodySetData (dBodyID, void *data); -void *dBodyGetData (dBodyID); - -void dBodySetPosition (dBodyID, dReal x, dReal y, dReal z); -void dBodySetRotation (dBodyID, const dMatrix3 R); -void dBodySetQuaternion (dBodyID, const dQuaternion q); -void dBodySetLinearVel (dBodyID, dReal x, dReal y, dReal z); -void dBodySetAngularVel (dBodyID, dReal x, dReal y, dReal z); -const dReal * dBodyGetPosition (dBodyID); -const dReal * dBodyGetRotation (dBodyID); /* ptr to 4x3 rot matrix */ -const dReal * dBodyGetQuaternion (dBodyID); -const dReal * dBodyGetLinearVel (dBodyID); -const dReal * dBodyGetAngularVel (dBodyID); - -void dBodySetMass (dBodyID, const dMass *mass); -void dBodyGetMass (dBodyID, dMass *mass); - -void dBodyAddForce (dBodyID, dReal fx, dReal fy, dReal fz); -void dBodyAddTorque (dBodyID, dReal fx, dReal fy, dReal fz); -void dBodyAddRelForce (dBodyID, dReal fx, dReal fy, dReal fz); -void dBodyAddRelTorque (dBodyID, dReal fx, dReal fy, dReal fz); -void dBodyAddForceAtPos (dBodyID, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz); -void dBodyAddForceAtRelPos (dBodyID, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz); -void dBodyAddRelForceAtPos (dBodyID, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz); -void dBodyAddRelForceAtRelPos (dBodyID, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz); - -const dReal * dBodyGetForce (dBodyID); -const dReal * dBodyGetTorque (dBodyID); -void dBodySetForce (dBodyID b, dReal x, dReal y, dReal z); -void dBodySetTorque (dBodyID b, dReal x, dReal y, dReal z); - -void dBodyGetRelPointPos (dBodyID, dReal px, dReal py, dReal pz, - dVector3 result); -void dBodyGetRelPointVel (dBodyID, dReal px, dReal py, dReal pz, - dVector3 result); -void dBodyGetPointVel (dBodyID, dReal px, dReal py, dReal pz, - dVector3 result); -void dBodyGetPosRelPoint (dBodyID, dReal px, dReal py, dReal pz, - dVector3 result); -void dBodyVectorToWorld (dBodyID, dReal px, dReal py, dReal pz, - dVector3 result); -void dBodyVectorFromWorld (dBodyID, dReal px, dReal py, dReal pz, - dVector3 result); - -void dBodySetFiniteRotationMode (dBodyID, int mode); -void dBodySetFiniteRotationAxis (dBodyID, dReal x, dReal y, dReal z); - -int dBodyGetFiniteRotationMode (dBodyID); -void dBodyGetFiniteRotationAxis (dBodyID, dVector3 result); - -int dBodyGetNumJoints (dBodyID b); -dJointID dBodyGetJoint (dBodyID, int index); - -void dBodyEnable (dBodyID); -void dBodyDisable (dBodyID); -int dBodyIsEnabled (dBodyID); - -void dBodySetGravityMode (dBodyID b, int mode); -int dBodyGetGravityMode (dBodyID b); - - -/* joints */ - -dJointID dJointCreateBall (dWorldID, dJointGroupID); -dJointID dJointCreateHinge (dWorldID, dJointGroupID); -dJointID dJointCreateSlider (dWorldID, dJointGroupID); -dJointID dJointCreateContact (dWorldID, dJointGroupID, const dContact *); -dJointID dJointCreateHinge2 (dWorldID, dJointGroupID); -dJointID dJointCreateUniversal (dWorldID, dJointGroupID); -dJointID dJointCreateFixed (dWorldID, dJointGroupID); -dJointID dJointCreateNull (dWorldID, dJointGroupID); -dJointID dJointCreateAMotor (dWorldID, dJointGroupID); - -void dJointDestroy (dJointID); - -dJointGroupID dJointGroupCreate (int max_size); -void dJointGroupDestroy (dJointGroupID); -void dJointGroupEmpty (dJointGroupID); - -void dJointAttach (dJointID, dBodyID body1, dBodyID body2); -void dJointSetData (dJointID, void *data); -void *dJointGetData (dJointID); -int dJointGetType (dJointID); -dBodyID dJointGetBody (dJointID, int index); - -void dJointSetFeedback (dJointID, dJointFeedback *); -dJointFeedback *dJointGetFeedback (dJointID); - -void dJointSetBallAnchor (dJointID, dReal x, dReal y, dReal z); -void dJointSetHingeAnchor (dJointID, dReal x, dReal y, dReal z); -void dJointSetHingeAxis (dJointID, dReal x, dReal y, dReal z); -void dJointSetHingeParam (dJointID, int parameter, dReal value); -void dJointSetSliderAxis (dJointID, dReal x, dReal y, dReal z); -void dJointSetSliderParam (dJointID, int parameter, dReal value); -void dJointSetHinge2Anchor (dJointID, dReal x, dReal y, dReal z); -void dJointSetHinge2Axis1 (dJointID, dReal x, dReal y, dReal z); -void dJointSetHinge2Axis2 (dJointID, dReal x, dReal y, dReal z); -void dJointSetHinge2Param (dJointID, int parameter, dReal value); -void dJointSetUniversalAnchor (dJointID, dReal x, dReal y, dReal z); -void dJointSetUniversalAxis1 (dJointID, dReal x, dReal y, dReal z); -void dJointSetUniversalAxis2 (dJointID, dReal x, dReal y, dReal z); -void dJointSetFixed (dJointID); -void dJointSetAMotorNumAxes (dJointID, int num); -void dJointSetAMotorAxis (dJointID, int anum, int rel, - dReal x, dReal y, dReal z); -void dJointSetAMotorAngle (dJointID, int anum, dReal angle); -void dJointSetAMotorParam (dJointID, int parameter, dReal value); -void dJointSetAMotorMode (dJointID, int mode); - -void dJointGetBallAnchor (dJointID, dVector3 result); -void dJointGetHingeAnchor (dJointID, dVector3 result); -void dJointGetHingeAxis (dJointID, dVector3 result); -dReal dJointGetHingeParam (dJointID, int parameter); -dReal dJointGetHingeAngle (dJointID); -dReal dJointGetHingeAngleRate (dJointID); -dReal dJointGetSliderPosition (dJointID); -dReal dJointGetSliderPositionRate (dJointID); -void dJointGetSliderAxis (dJointID, dVector3 result); -dReal dJointGetSliderParam (dJointID, int parameter); -void dJointGetHinge2Anchor (dJointID, dVector3 result); -void dJointGetHinge2Axis1 (dJointID, dVector3 result); -void dJointGetHinge2Axis2 (dJointID, dVector3 result); -dReal dJointGetHinge2Param (dJointID, int parameter); -dReal dJointGetHinge2Angle1 (dJointID); -dReal dJointGetHinge2Angle1Rate (dJointID); -dReal dJointGetHinge2Angle2Rate (dJointID); -void dJointGetUniversalAnchor (dJointID, dVector3 result); -void dJointGetUniversalAxis1 (dJointID, dVector3 result); -void dJointGetUniversalAxis2 (dJointID, dVector3 result); -int dJointGetAMotorNumAxes (dJointID); -void dJointGetAMotorAxis (dJointID, int anum, dVector3 result); -int dJointGetAMotorAxisRel (dJointID, int anum); -dReal dJointGetAMotorAngle (dJointID, int anum); -dReal dJointGetAMotorAngleRate (dJointID, int anum); -dReal dJointGetAMotorParam (dJointID, int parameter); -int dJointGetAMotorMode (dJointID); - -int dAreConnected (dBodyID, dBodyID); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/ode.h b/extern/ode/dist/include/ode/ode.h deleted file mode 100644 index da7f2e1a0e7..00000000000 --- a/extern/ode/dist/include/ode/ode.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_ODE_H_ -#define _ODE_ODE_H_ - -/* include *everything* here */ - -#include <ode/config.h> -#include <ode/common.h> -#include <ode/contact.h> -#include <ode/error.h> -#include <ode/memory.h> -#include <ode/odemath.h> -#include <ode/matrix.h> -#include <ode/timer.h> -#include <ode/rotation.h> -#include <ode/mass.h> -#include <ode/space.h> -#include <ode/geom.h> -#include <ode/misc.h> -#include <ode/objects.h> -#include <ode/odecpp.h> - -#endif - diff --git a/extern/ode/dist/include/ode/odecpp.h b/extern/ode/dist/include/ode/odecpp.h deleted file mode 100644 index 35712236d1d..00000000000 --- a/extern/ode/dist/include/ode/odecpp.h +++ /dev/null @@ -1,797 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -// C++ interface for everything - - -#ifndef _ODE_ODECPP_H_ -#define _ODE_ODECPP_H_ -#ifdef __cplusplus - -#include <ode/error.h> - - -class dWorld { - dWorldID _id; - - // intentionally undefined, don't use these - dWorld (const dWorld &); - void operator= (const dWorld &); - -public: - dWorld() - { _id = dWorldCreate(); } - ~dWorld() - { dWorldDestroy (_id); } - - dWorldID id() const - { return _id; } - operator dWorldID() const - { return _id; } - - void setGravity (dReal x, dReal y, dReal z) - { dWorldSetGravity (_id,x,y,z); } - void getGravity (dVector3 g) const - { dWorldGetGravity (_id,g); } - - void setERP (dReal erp) - { dWorldSetERP(_id, erp); } - dReal getERP() const - { return dWorldGetERP(_id); } - - void setCFM (dReal cfm) - { dWorldSetCFM(_id, cfm); } - dReal getCFM() const - { return dWorldGetCFM(_id); } - - void step (dReal stepsize) - { dWorldStep (_id,stepsize); } - - void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz, - dVector3 force) - { dWorldImpulseToForce (_id,stepsize,ix,iy,iz,force); } -}; - - -class dBody { - dBodyID _id; - - // intentionally undefined, don't use these - dBody (const dBody &); - void operator= (const dBody &); - -public: - dBody() - { _id = 0; } - dBody (dWorldID world) - { _id = dBodyCreate (world); } - ~dBody() - { if (_id) dBodyDestroy (_id); } - - void create (dWorldID world) { - if (_id) dBodyDestroy (_id); - _id = dBodyCreate (world); - } - - dBodyID id() const - { return _id; } - operator dBodyID() const - { return _id; } - - void setData (void *data) - { dBodySetData (_id,data); } - void *getData() const - { return dBodyGetData (_id); } - - void setPosition (dReal x, dReal y, dReal z) - { dBodySetPosition (_id,x,y,z); } - void setRotation (const dMatrix3 R) - { dBodySetRotation (_id,R); } - void setQuaternion (const dQuaternion q) - { dBodySetQuaternion (_id,q); } - void setLinearVel (dReal x, dReal y, dReal z) - { dBodySetLinearVel (_id,x,y,z); } - void setAngularVel (dReal x, dReal y, dReal z) - { dBodySetAngularVel (_id,x,y,z); } - - const dReal * getPosition() const - { return dBodyGetPosition (_id); } - const dReal * getRotation() const - { return dBodyGetRotation (_id); } - const dReal * getQuaternion() const - { return dBodyGetQuaternion (_id); } - const dReal * getLinearVel() const - { return dBodyGetLinearVel (_id); } - const dReal * getAngularVel() const - { return dBodyGetAngularVel (_id); } - - void setMass (const dMass *mass) - { dBodySetMass (_id,mass); } - void getMass (dMass *mass) const - { dBodyGetMass (_id,mass); } - - void addForce (dReal fx, dReal fy, dReal fz) - { dBodyAddForce (_id, fx, fy, fz); } - void addTorque (dReal fx, dReal fy, dReal fz) - { dBodyAddTorque (_id, fx, fy, fz); } - void addRelForce (dReal fx, dReal fy, dReal fz) - { dBodyAddRelForce (_id, fx, fy, fz); } - void addRelTorque (dReal fx, dReal fy, dReal fz) - { dBodyAddRelTorque (_id, fx, fy, fz); } - void addForceAtPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } - void addForceAtRelPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddForceAtRelPos (_id, fx, fy, fz, px, py, pz); } - void addRelForceAtPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } - void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } - - const dReal * getForce() const - { return dBodyGetForce(_id); } - const dReal * getTorque() const - { return dBodyGetTorque(_id); } - void setForce (dReal x, dReal y, dReal z) - { dBodySetForce (_id,x,y,z); } - void setTorque (dReal x, dReal y, dReal z) - { dBodySetTorque (_id,x,y,z); } - - void enable() - { dBodyEnable (_id); } - void disable() - { dBodyDisable (_id); } - int isEnabled() const - { return dBodyIsEnabled (_id); } - - void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const - { dBodyGetRelPointPos (_id, px, py, pz, result); } - void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const - { dBodyGetRelPointVel (_id, px, py, pz, result); } - void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const - { dBodyGetPointVel (_id,px,py,pz,result); } - void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const - { dBodyGetPosRelPoint (_id,px,py,pz,result); } - void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const - { dBodyVectorToWorld (_id,px,py,pz,result); } - void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) const - { dBodyVectorFromWorld (_id,px,py,pz,result); } - - void setFiniteRotationMode (int mode) - { dBodySetFiniteRotationMode (_id, mode); } - void setFiniteRotationAxis (dReal x, dReal y, dReal z) - { dBodySetFiniteRotationAxis (_id, x, y, z); } - - int getFiniteRotationMode() const - { return dBodyGetFiniteRotationMode (_id); } - void getFiniteRotationAxis (dVector3 result) const - { dBodyGetFiniteRotationAxis (_id, result); } - - int getNumJoints() const - { return dBodyGetNumJoints (_id); } - dJointID getJoint (int index) const - { return dBodyGetJoint (_id, index); } - - void setGravityMode (int mode) - { dBodySetGravityMode (_id,mode); } - int getGravityMode() const - { return dBodyGetGravityMode (_id); } - - int isConnectedTo (dBodyID body) const - { return dAreConnected (_id, body); } -}; - - -class dJointGroup { - dJointGroupID _id; - - // intentionally undefined, don't use these - dJointGroup (const dJointGroup &); - void operator= (const dJointGroup &); - -public: - dJointGroup (int dummy_arg=0) - { _id = dJointGroupCreate (0); } - ~dJointGroup() - { dJointGroupDestroy (_id); } - void create (int dummy_arg=0) { - if (_id) dJointGroupDestroy (_id); - _id = dJointGroupCreate (0); - } - - dJointGroupID id() const - { return _id; } - operator dJointGroupID() const - { return _id; } - - void empty() - { dJointGroupEmpty (_id); } -}; - - -class dJoint { -private: - // intentionally undefined, don't use these - dJoint (const dJoint &) ; - void operator= (const dJoint &); - -protected: - dJointID _id; - -public: - dJoint() - { _id = 0; } - ~dJoint() - { if (_id) dJointDestroy (_id); } - - dJointID id() const - { return _id; } - operator dJointID() const - { return _id; } - - void attach (dBodyID body1, dBodyID body2) - { dJointAttach (_id, body1, body2); } - - void setData (void *data) - { dJointSetData (_id, data); } - void *getData (void *data) const - { return dJointGetData (_id); } - - int getType() const - { return dJointGetType (_id); } - - dBodyID getBody (int index) const - { return dJointGetBody (_id, index); } -}; - - -class dBallJoint : public dJoint { -private: - // intentionally undefined, don't use these - dBallJoint (const dBallJoint &); - void operator= (const dBallJoint &); - -public: - dBallJoint() { } - dBallJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateBall (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateBall (world, group); - } - - void setAnchor (dReal x, dReal y, dReal z) - { dJointSetBallAnchor (_id, x, y, z); } - void getAnchor (dVector3 result) const - { dJointGetBallAnchor (_id, result); } -} ; - - -class dHingeJoint : public dJoint { - // intentionally undefined, don't use these - dHingeJoint (const dHingeJoint &); - void operator = (const dHingeJoint &); - -public: - dHingeJoint() { } - dHingeJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateHinge (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateHinge (world, group); - } - - void setAnchor (dReal x, dReal y, dReal z) - { dJointSetHingeAnchor (_id, x, y, z); } - void getAnchor (dVector3 result) const - { dJointGetHingeAnchor (_id, result); } - - void setAxis (dReal x, dReal y, dReal z) - { dJointSetHingeAxis (_id, x, y, z); } - void getAxis (dVector3 result) const - { dJointGetHingeAxis (_id, result); } - - dReal getAngle() const - { return dJointGetHingeAngle (_id); } - dReal getAngleRate() const - { return dJointGetHingeAngleRate (_id); } - - void setParam (int parameter, dReal value) - { dJointSetHingeParam (_id, parameter, value); } - dReal getParam (int parameter) const - { return dJointGetHingeParam (_id, parameter); } -}; - - -class dSliderJoint : public dJoint { - // intentionally undefined, don't use these - dSliderJoint (const dSliderJoint &); - void operator = (const dSliderJoint &); - -public: - dSliderJoint() { } - dSliderJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateSlider (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateSlider (world, group); - } - - void setAxis (dReal x, dReal y, dReal z) - { dJointSetSliderAxis (_id, x, y, z); } - void getAxis (dVector3 result) const - { dJointGetSliderAxis (_id, result); } - - dReal getPosition() const - { return dJointGetSliderPosition (_id); } - dReal getPositionRate() const - { return dJointGetSliderPositionRate (_id); } - - void setParam (int parameter, dReal value) - { dJointSetSliderParam (_id, parameter, value); } - dReal getParam (int parameter) const - { return dJointGetSliderParam (_id, parameter); } -}; - - -class dUniversalJoint : public dJoint { - // intentionally undefined, don't use these - dUniversalJoint (const dUniversalJoint &); - void operator = (const dUniversalJoint &); - -public: - dUniversalJoint() { } - dUniversalJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateUniversal (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateUniversal (world, group); - } - - void setAnchor (dReal x, dReal y, dReal z) - { dJointSetUniversalAnchor (_id, x, y, z); } - void setAxis1 (dReal x, dReal y, dReal z) - { dJointSetUniversalAxis1 (_id, x, y, z); } - void setAxis2 (dReal x, dReal y, dReal z) - { dJointSetUniversalAxis2 (_id, x, y, z); } - - void getAnchor (dVector3 result) const - { dJointGetUniversalAnchor (_id, result); } - void getAxis1 (dVector3 result) const - { dJointGetUniversalAxis1 (_id, result); } - void getAxis2 (dVector3 result) const - { dJointGetUniversalAxis2 (_id, result); } -}; - - -class dHinge2Joint : public dJoint { - // intentionally undefined, don't use these - dHinge2Joint (const dHinge2Joint &); - void operator = (const dHinge2Joint &); - -public: - dHinge2Joint() { } - dHinge2Joint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateHinge2 (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateHinge2 (world, group); - } - - void setAnchor (dReal x, dReal y, dReal z) - { dJointSetHinge2Anchor (_id, x, y, z); } - void setAxis1 (dReal x, dReal y, dReal z) - { dJointSetHinge2Axis1 (_id, x, y, z); } - void setAxis2 (dReal x, dReal y, dReal z) - { dJointSetHinge2Axis2 (_id, x, y, z); } - - void getAnchor (dVector3 result) const - { dJointGetHinge2Anchor (_id, result); } - void getAxis1 (dVector3 result) const - { dJointGetHinge2Axis1 (_id, result); } - void getAxis2 (dVector3 result) const - { dJointGetHinge2Axis2 (_id, result); } - - dReal getAngle1() const - { return dJointGetHinge2Angle1 (_id); } - dReal getAngle1Rate() const - { return dJointGetHinge2Angle1Rate (_id); } - dReal getAngle2Rate() const - { return dJointGetHinge2Angle2Rate (_id); } - - void setParam (int parameter, dReal value) - { dJointSetHinge2Param (_id, parameter, value); } - dReal getParam (int parameter) const - { return dJointGetHinge2Param (_id, parameter); } -}; - - -class dFixedJoint : public dJoint { - // intentionally undefined, don't use these - dFixedJoint (const dFixedJoint &); - void operator = (const dFixedJoint &); - -public: - dFixedJoint() { } - dFixedJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateFixed (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateFixed (world, group); - } - - void set() - { dJointSetFixed (_id); } -}; - - -class dContactJoint : public dJoint { - // intentionally undefined, don't use these - dContactJoint (const dContactJoint &); - void operator = (const dContactJoint &); - -public: - dContactJoint() { } - dContactJoint (dWorldID world, dJointGroupID group, dContact *contact) - { _id = dJointCreateContact (world, group, contact); } - - void create (dWorldID world, dJointGroupID group, dContact *contact) { - if (_id) dJointDestroy (_id); - _id = dJointCreateContact (world, group, contact); - } -}; - - -class dNullJoint : public dJoint { - // intentionally undefined, don't use these - dNullJoint (const dNullJoint &); - void operator = (const dNullJoint &); - -public: - dNullJoint() { } - dNullJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateNull (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateNull (world, group); - } -}; - - -class dAMotorJoint : public dJoint { - // intentionally undefined, don't use these - dAMotorJoint (const dAMotorJoint &); - void operator = (const dAMotorJoint &); - -public: - dAMotorJoint() { } - dAMotorJoint (dWorldID world, dJointGroupID group=0) - { _id = dJointCreateAMotor (world, group); } - - void create (dWorldID world, dJointGroupID group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateAMotor (world, group); - } - - void setMode (int mode) - { dJointSetAMotorMode (_id, mode); } - int getMode() const - { return dJointGetAMotorMode (_id); } - - void setNumAxes (int num) - { dJointSetAMotorNumAxes (_id, num); } - int getNumAxes() const - { return dJointGetAMotorNumAxes (_id); } - - void setAxis (int anum, int rel, dReal x, dReal y, dReal z) - { dJointSetAMotorAxis (_id, anum, rel, x, y, z); } - void getAxis (int anum, dVector3 result) const - { dJointGetAMotorAxis (_id, anum, result); } - int getAxisRel (int anum) const - { return dJointGetAMotorAxisRel (_id, anum); } - - void setAngle (int anum, dReal angle) - { dJointSetAMotorAngle (_id, anum, angle); } - dReal getAngle (int anum) const - { return dJointGetAMotorAngle (_id, anum); } - dReal getAngleRate (int anum) - { return dJointGetAMotorAngleRate (_id,anum); } - - void setParam (int parameter, dReal value) - { dJointSetAMotorParam (_id, parameter, value); } - dReal getParam (int parameter) const - { return dJointGetAMotorParam (_id, parameter); } -}; - - -class dGeom { - // intentionally undefined, don't use these - dGeom (dGeom &); - void operator= (dGeom &); - -protected: - dGeomID _id; - -public: - dGeom() - { _id = 0; } - ~dGeom() - { if (_id) dGeomDestroy (_id); } - - dGeomID id() const - { return _id; } - operator dGeomID() const - { return _id; } - - void destroy() { - if (_id) dGeomDestroy (_id); - _id = 0; - } - - int getClass() const - { return dGeomGetClass (_id); } - - void setData (void *data) - { dGeomSetData (_id,data); } - void *getData() const - { return dGeomGetData (_id); } - - void setBody (dBodyID b) - { dGeomSetBody (_id,b); } - dBodyID getBody() const - { return dGeomGetBody (_id); } - - void setPosition (dReal x, dReal y, dReal z) - { dGeomSetPosition (_id,x,y,z); } - const dReal * getPosition() const - { return dGeomGetPosition (_id); } - - void setRotation (const dMatrix3 R) - { dGeomSetRotation (_id,R); } - const dReal * getRotation() const - { return dGeomGetRotation (_id); } - - void getAABB (dReal aabb[6]) const - { dGeomGetAABB (_id, aabb); } - const dReal *getSpaceAABB() const - { return dGeomGetSpaceAABB (_id); } -}; - - -class dSpace { - // intentionally undefined, don't use these - dSpace (dSpace &); - void operator= (dSpace &); - -protected: - dSpaceID _id; - - // the default constructor is protected so that you - // can't instance this class. you must instance one - // of its subclasses instead. - dSpace () { _id = 0; } - -public: - ~dSpace() - { dSpaceDestroy (_id); } - - dSpaceID id() const - { return _id; } - operator dSpaceID() const - { return _id; } - - void add (dGeomID x) - { dSpaceAdd (_id, x); } - void remove (dGeomID x) - { dSpaceRemove (_id, x); } - int query (dGeomID x) - { return dSpaceQuery (_id,x); } - - void collide (void *data, dNearCallback *callback) - { dSpaceCollide (_id,data,callback); } -}; - - -class dSimpleSpace : public dSpace { - // intentionally undefined, don't use these - dSimpleSpace (dSimpleSpace &); - void operator= (dSimpleSpace &); - -public: - dSimpleSpace () - { _id = dSimpleSpaceCreate(); } -}; - - -class dHashSpace : public dSpace { - // intentionally undefined, don't use these - dHashSpace (dHashSpace &); - void operator= (dHashSpace &); - -public: - dHashSpace () - { _id = dHashSpaceCreate(); } - void setLevels (int minlevel, int maxlevel) - { dHashSpaceSetLevels (_id,minlevel,maxlevel); } -}; - - -class dSphere : public dGeom { - // intentionally undefined, don't use these - dSphere (dSphere &); - void operator= (dSphere &); - -public: - dSphere () { } - dSphere (dSpaceID space, dReal radius) - { _id = dCreateSphere (space, radius); } - - void create (dSpaceID space, dReal radius) { - if (_id) dGeomDestroy (_id); - _id = dCreateSphere (space, radius); - } - - void setRadius (dReal radius) - { dGeomSphereSetRadius (_id, radius); } - dReal getRadius() const - { return dGeomSphereGetRadius (_id); } -}; - - -class dBox : public dGeom { - // intentionally undefined, don't use these - dBox (dBox &); - void operator= (dBox &); - -public: - dBox () { } - dBox (dSpaceID space, dReal lx, dReal ly, dReal lz) - { _id = dCreateBox (space,lx,ly,lz); } - - void create (dSpaceID space, dReal lx, dReal ly, dReal lz) { - if (_id) dGeomDestroy (_id); - _id = dCreateBox (space,lx,ly,lz); - } - - void setLengths (dReal lx, dReal ly, dReal lz) - { dGeomBoxSetLengths (_id, lx, ly, lz); } - void getLengths (dVector3 result) const - { dGeomBoxGetLengths (_id,result); } -}; - - -class dPlane : public dGeom { - // intentionally undefined, don't use these - dPlane (dPlane &); - void operator= (dPlane &); - -public: - dPlane() { } - dPlane (dSpaceID space, dReal a, dReal b, dReal c, dReal d) - { _id = dCreatePlane (space,a,b,c,d); } - - void create (dSpaceID space, dReal a, dReal b, dReal c, dReal d) { - if (_id) dGeomDestroy (_id); - _id = dCreatePlane (space,a,b,c,d); - } - - void setParams (dReal a, dReal b, dReal c, dReal d) - { dGeomPlaneSetParams (_id, a, b, c, d); } - void getParams (dVector4 result) const - { dGeomPlaneGetParams (_id,result); } -}; - - -class dCCylinder : public dGeom { - // intentionally undefined, don't use these - dCCylinder (dCCylinder &); - void operator= (dCCylinder &); - -public: - dCCylinder() { } - dCCylinder (dSpaceID space, dReal radius, dReal length) - { _id = dCreateCCylinder (space,radius,length); } - - void create (dSpaceID space, dReal radius, dReal length) { - if (_id) dGeomDestroy (_id); - _id = dCreateCCylinder (space,radius,length); - } - - void setParams (dReal radius, dReal length) - { dGeomCCylinderSetParams (_id, radius, length); } - void getParams (dReal *radius, dReal *length) const - { dGeomCCylinderGetParams (_id,radius,length); } -}; - - -class dGeomGroup : public dGeom { - // intentionally undefined, don't use these - dGeomGroup (dGeomGroup &); - void operator= (dGeomGroup &); - -public: - dGeomGroup() { } - dGeomGroup (dSpaceID space) - { _id = dCreateGeomGroup (space); } - - void create (dSpaceID space=0) { - if (_id) dGeomDestroy (_id); - _id = dCreateGeomGroup (space); - } - - void add (dGeomID x) - { dGeomGroupAdd (_id, x); } - void remove (dGeomID x) - { dGeomGroupRemove (_id, x); } - - int getNumGeoms() const - { return dGeomGroupGetNumGeoms (_id); } - dGeomID getGeom (int i) const - { return dGeomGroupGetGeom (_id, i); } -}; - - -class dGeomTransform : public dGeom { - // intentionally undefined, don't use these - dGeomTransform (dGeomTransform &); - void operator= (dGeomTransform &); - -public: - dGeomTransform() { } - dGeomTransform (dSpaceID space) - { _id = dCreateGeomTransform (space); } - - void create (dSpaceID space=0) { - if (_id) dGeomDestroy (_id); - _id = dCreateGeomTransform (space); - } - - void setGeom (dGeomID geom) - { dGeomTransformSetGeom (_id, geom); } - dGeomID getGeom() const - { return dGeomTransformGetGeom (_id); } - - void setCleanup (int mode) - { dGeomTransformSetCleanup (_id,mode); } - int getCleanup (dGeomID g) - { return dGeomTransformGetCleanup (_id); } - - void setInfo (int mode) - { dGeomTransformSetInfo (_id,mode); } - int getInfo() - { return dGeomTransformGetInfo (_id); } -}; - -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/odecpp_old.h b/extern/ode/dist/include/ode/odecpp_old.h deleted file mode 100644 index b7b55232f89..00000000000 --- a/extern/ode/dist/include/ode/odecpp_old.h +++ /dev/null @@ -1,317 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* this is the old C++ interface, the new C++ interface is not quite - * compatible with this. but this file is kept around in case you were - * using the old interface. - */ - -#ifndef _ODE_ODECPP_H_ -#define _ODE_ODECPP_H_ -#ifdef __cplusplus - -#include <ode/error.h> - - -class dWorld { - dWorldID _id; - - dWorld (dWorld &) { dDebug (0,"bad"); } - void operator= (dWorld &) { dDebug (0,"bad"); } - -public: - dWorld() - { _id = dWorldCreate(); } - ~dWorld() - { dWorldDestroy (_id); } - dWorldID id() - { return _id; } - - void setGravity (dReal x, dReal y, dReal z) - { dWorldSetGravity (_id,x,y,z); } - void getGravity (dVector3 g) - { dWorldGetGravity (_id,g); } - void step (dReal stepsize) - { dWorldStep (_id,stepsize); } -}; - - -class dBody { - dBodyID _id; - - dBody (dBody &) { dDebug (0,"bad"); } - void operator= (dBody &) { dDebug (0,"bad"); } - -public: - dBody() - { _id = 0; } - dBody (dWorld &world) - { _id = dBodyCreate (world.id()); } - ~dBody() - { dBodyDestroy (_id); } - void create (dWorld &world) - { if (_id) dBodyDestroy (_id); _id = dBodyCreate (world.id()); } - dBodyID id() - { return _id; } - - void setData (void *data) - { dBodySetData (_id,data); } - void *getData() - { return dBodyGetData (_id); } - - void setPosition (dReal x, dReal y, dReal z) - { dBodySetPosition (_id,x,y,z); } - void setRotation (const dMatrix3 R) - { dBodySetRotation (_id,R); } - void setQuaternion (const dQuaternion q) - { dBodySetQuaternion (_id,q); } - void setLinearVel (dReal x, dReal y, dReal z) - { dBodySetLinearVel (_id,x,y,z); } - void setAngularVel (dReal x, dReal y, dReal z) - { dBodySetAngularVel (_id,x,y,z); } - - const dReal * getPosition() - { return dBodyGetPosition (_id); } - const dReal * getRotation() - { return dBodyGetRotation (_id); } - const dReal * getQuaternion() - { return dBodyGetQuaternion (_id); } - const dReal * getLinearVel() - { return dBodyGetLinearVel (_id); } - const dReal * getAngularVel() - { return dBodyGetAngularVel (_id); } - - void setMass (const dMass *mass) - { dBodySetMass (_id,mass); } - void getMass (dMass *mass) - { dBodyGetMass (_id,mass); } - - void addForce (dReal fx, dReal fy, dReal fz) - { dBodyAddForce (_id, fx, fy, fz); } - void addTorque (dReal fx, dReal fy, dReal fz) - { dBodyAddTorque (_id, fx, fy, fz); } - void addRelForce (dReal fx, dReal fy, dReal fz) - { dBodyAddRelForce (_id, fx, fy, fz); } - void addRelTorque (dReal fx, dReal fy, dReal fz) - { dBodyAddRelTorque (_id, fx, fy, fz); } - void addForceAtPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } - void addRelForceAtPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } - void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) - { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } - - void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) - { dBodyGetRelPointPos (_id, px, py, pz, result); } - void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) - { dBodyGetRelPointVel (_id, px, py, pz, result); } - - int isConnectedTo (const dBody &b) - { return dAreConnected (_id,b._id); } -}; - - -class dJointGroup { - dJointGroupID _id; - - dJointGroup (dJointGroup &) { dDebug (0,"bad"); } - void operator= (dJointGroup &) { dDebug (0,"bad"); } - -public: - dJointGroup() - { _id = 0; } - dJointGroup (int max_size) - { _id = dJointGroupCreate (max_size); } - ~dJointGroup() - { dJointGroupDestroy (_id); } - void create (int max_size) - { if (_id) dJointGroupDestroy (_id); _id = dJointGroupCreate (max_size); } - dJointGroupID id() - { return _id; } - - void empty() - { dJointGroupEmpty (_id); } -}; - - -class dJoint { - dJointID _id; - - dJoint (dJoint &) { dDebug (0,"bad"); } - void operator= (dJoint &) { dDebug (0,"bad"); } - -public: - dJoint() - { _id = 0; } - ~dJoint() - { dJointDestroy (_id); } - dJointID id() - { return _id; } - - void createBall (dWorld &world, dJointGroup *group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateBall (world.id(), group ? group->id() : 0); - } - void createHinge (dWorld &world, dJointGroup *group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateHinge (world.id(), group ? group->id() : 0); - } - void createSlider (dWorld &world, dJointGroup *group=0) { - if (_id) dJointDestroy (_id); - _id = dJointCreateSlider (world.id(), group ? group->id() : 0); - } - void createContact (dWorld &world, dJointGroup *group, dContact *contact) { - if (_id) dJointDestroy (_id); - _id = dJointCreateContact (world.id(), group ? group->id() : 0, contact); - } - - void attach (dBody &body1, dBody &body2) - { dJointAttach (_id, body1.id(), body2.id()); } - - void setBallAnchor (dReal x, dReal y, dReal z) - { dJointSetBallAnchor (_id, x, y, z); } - void setHingeAnchor (dReal x, dReal y, dReal z) - { dJointSetHingeAnchor (_id, x, y, z); } - - void setHingeAxis (dReal x, dReal y, dReal z) - { dJointSetHingeAxis (_id, x, y, z); } - void setSliderAxis (dReal x, dReal y, dReal z) - { dJointSetSliderAxis (_id, x, y, z); } - - void getBallAnchor (dVector3 result) - { dJointGetBallAnchor (_id, result); } - void getHingeAnchor (dVector3 result) - { dJointGetHingeAnchor (_id, result); } - - void getHingeAxis (dVector3 result) - { dJointGetHingeAxis (_id, result); } - void getSliderAxis (dVector3 result) - { dJointGetSliderAxis (_id, result); } -}; - - -class dSpace { - dSpaceID _id; - - dSpace (dSpace &) { dDebug (0,"bad"); } - void operator= (dSpace &) { dDebug (0,"bad"); } - -public: - dSpace () - { _id = dHashSpaceCreate(); } - ~dSpace() - { dSpaceDestroy (_id); } - dSpaceID id() - { return _id; } - void collide (void *data, dNearCallback *callback) - { dSpaceCollide (_id,data,callback); } -}; - - -class dGeom { - dGeomID _id; - - dGeom (dGeom &) { dDebug (0,"bad"); } - void operator= (dGeom &) { dDebug (0,"bad"); } - -public: - dGeom() - { _id = 0; } - ~dGeom() - { dGeomDestroy (_id); } - dGeomID id() - { return _id; } - - void createSphere (dSpace &space, dReal radius) { - if (_id) dGeomDestroy (_id); - _id = dCreateSphere (space.id(),radius); - } - - void createBox (dSpace &space, dReal lx, dReal ly, dReal lz) { - if (_id) dGeomDestroy (_id); - _id = dCreateBox (space.id(),lx,ly,lz); - } - - void createPlane (dSpace &space, dReal a, dReal b, dReal c, dReal d) { - if (_id) dGeomDestroy (_id); - _id = dCreatePlane (space.id(),a,b,c,d); - } - - void createCCylinder (dSpace &space, dReal radius, dReal length) { - if (_id) dGeomDestroy (_id); - _id = dCreateCCylinder (space.id(),radius,length); - } - - void destroy() { - if (_id) dGeomDestroy (_id); - _id = 0; - } - - int getClass() - { return dGeomGetClass (_id); } - - dReal sphereGetRadius() - { return dGeomSphereGetRadius (_id); } - - void boxGetLengths (dVector3 result) - { dGeomBoxGetLengths (_id,result); } - - void planeGetParams (dVector4 result) - { dGeomPlaneGetParams (_id,result); } - - void CCylinderGetParams (dReal *radius, dReal *length) - { dGeomCCylinderGetParams (_id,radius,length); } - - void setData (void *data) - { dGeomSetData (_id,data); } - - void *getData() - { return dGeomGetData (_id); } - - void setBody (dBody &b) - { dGeomSetBody (_id,b.id()); } - void setBody (dBodyID b) - { dGeomSetBody (_id,b); } - - dBodyID getBody() - { return dGeomGetBody (_id); } - - void setPosition (dReal x, dReal y, dReal z) - { dGeomSetPosition (_id,x,y,z); } - - void setRotation (const dMatrix3 R) - { dGeomSetRotation (_id,R); } - - const dReal * getPosition() - { return dGeomGetPosition (_id); } - - const dReal * getRotation() - { return dGeomGetRotation (_id); } -}; - -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/odemath.h b/extern/ode/dist/include/ode/odemath.h deleted file mode 100644 index 5f41a27b5a1..00000000000 --- a/extern/ode/dist/include/ode/odemath.h +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_ODEMATH_H_ -#define _ODE_ODEMATH_H_ - -#include <ode/common.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -/* 3-way dot product. dDOTpq means that elements of `a' and `b' are spaced - * p and q indexes apart respectively. dDOT() means dDOT11. - */ - -#ifdef __cplusplus -inline dReal dDOT (const dReal *a, const dReal *b) - { return ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2]); } -inline dReal dDOT14(const dReal *a, const dReal *b) - { return ((a)[0]*(b)[0] + (a)[1]*(b)[4] + (a)[2]*(b)[8]); } -inline dReal dDOT41(const dReal *a, const dReal *b) - { return ((a)[0]*(b)[0] + (a)[4]*(b)[1] + (a)[8]*(b)[2]); } -inline dReal dDOT44(const dReal *a, const dReal *b) - { return ((a)[0]*(b)[0] + (a)[4]*(b)[4] + (a)[8]*(b)[8]); } -#else -#define dDOT(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2]) -#define dDOT14(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[4] + (a)[2]*(b)[8]) -#define dDOT41(a,b) ((a)[0]*(b)[0] + (a)[4]*(b)[1] + (a)[8]*(b)[2]) -#define dDOT44(a,b) ((a)[0]*(b)[0] + (a)[4]*(b)[4] + (a)[8]*(b)[8]) -#endif - - -/* cross product, set a = b x c. dCROSSpqr means that elements of `a', `b' - * and `c' are spaced p, q and r indexes apart respectively. - * dCROSS() means dCROSS111. `op' is normally `=', but you can set it to - * +=, -= etc to get other effects. - */ - -#define dCROSS(a,op,b,c) \ - (a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \ - (a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \ - (a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); -#define dCROSSpqr(a,op,b,c,p,q,r) \ - (a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \ - (a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \ - (a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); -#define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4) -#define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1) -#define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4) -#define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1) -#define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4) -#define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1) -#define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4) - - -/* set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b. - * A is stored by rows, and has `skip' elements per row. the matrix is - * assumed to be already zero, so this does not write zero elements! - * if (plus,minus) is (+,-) then a positive version will be written. - * if (plus,minus) is (-,+) then a negative version will be written. - */ - -#define dCROSSMAT(A,a,skip,plus,minus) \ - (A)[1] = minus (a)[2]; \ - (A)[2] = plus (a)[1]; \ - (A)[(skip)+0] = plus (a)[2]; \ - (A)[(skip)+2] = minus (a)[0]; \ - (A)[2*(skip)+0] = minus (a)[1]; \ - (A)[2*(skip)+1] = plus (a)[0]; - - -/* compute the distance between two 3-vectors (oops, C++!) */ -#ifdef __cplusplus -inline dReal dDISTANCE (const dVector3 a, const dVector3 b) - { return dSqrt( (a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + - (a[2]-b[2])*(a[2]-b[2]) ); } -#else -#define dDISTANCE(a,b) \ - (dSqrt( ((a)[0]-(b)[0])*((a)[0]-(b)[0]) + ((a)[1]-(b)[1])*((a)[1]-(b)[1]) + \ - ((a)[2]-(b)[2])*((a)[2]-(b)[2]) )) -#endif - - -/* normalize 3x1 and 4x1 vectors (i.e. scale them to unit length) */ -void dNormalize3 (dVector3 a); -void dNormalize4 (dVector4 a); - - -/* given a unit length "normal" vector n, generate vectors p and q vectors - * that are an orthonormal basis for the plane space perpendicular to n. - * i.e. this makes p,q such that n,p,q are all perpendicular to each other. - * q will equal n x p. if n is not unit length then p will be unit length but - * q wont be. - */ - -void dPlaneSpace (const dVector3 n, dVector3 p, dVector3 q); - - -/* special case matrix multipication, with operator selection */ - -#define dMULTIPLYOP0_331(A,op,B,C) \ - (A)[0] op dDOT((B),(C)); \ - (A)[1] op dDOT((B+4),(C)); \ - (A)[2] op dDOT((B+8),(C)); -#define dMULTIPLYOP1_331(A,op,B,C) \ - (A)[0] op dDOT41((B),(C)); \ - (A)[1] op dDOT41((B+1),(C)); \ - (A)[2] op dDOT41((B+2),(C)); -#define dMULTIPLYOP0_133(A,op,B,C) \ - (A)[0] op dDOT14((B),(C)); \ - (A)[1] op dDOT14((B),(C+1)); \ - (A)[2] op dDOT14((B),(C+2)); -#define dMULTIPLYOP0_333(A,op,B,C) \ - (A)[0] op dDOT14((B),(C)); \ - (A)[1] op dDOT14((B),(C+1)); \ - (A)[2] op dDOT14((B),(C+2)); \ - (A)[4] op dDOT14((B+4),(C)); \ - (A)[5] op dDOT14((B+4),(C+1)); \ - (A)[6] op dDOT14((B+4),(C+2)); \ - (A)[8] op dDOT14((B+8),(C)); \ - (A)[9] op dDOT14((B+8),(C+1)); \ - (A)[10] op dDOT14((B+8),(C+2)); -#define dMULTIPLYOP1_333(A,op,B,C) \ - (A)[0] op dDOT44((B),(C)); \ - (A)[1] op dDOT44((B),(C+1)); \ - (A)[2] op dDOT44((B),(C+2)); \ - (A)[4] op dDOT44((B+1),(C)); \ - (A)[5] op dDOT44((B+1),(C+1)); \ - (A)[6] op dDOT44((B+1),(C+2)); \ - (A)[8] op dDOT44((B+2),(C)); \ - (A)[9] op dDOT44((B+2),(C+1)); \ - (A)[10] op dDOT44((B+2),(C+2)); -#define dMULTIPLYOP2_333(A,op,B,C) \ - (A)[0] op dDOT((B),(C)); \ - (A)[1] op dDOT((B),(C+4)); \ - (A)[2] op dDOT((B),(C+8)); \ - (A)[4] op dDOT((B+4),(C)); \ - (A)[5] op dDOT((B+4),(C+4)); \ - (A)[6] op dDOT((B+4),(C+8)); \ - (A)[8] op dDOT((B+8),(C)); \ - (A)[9] op dDOT((B+8),(C+4)); \ - (A)[10] op dDOT((B+8),(C+8)); - -#ifdef __cplusplus - -inline void dMULTIPLY0_331(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP0_331(A,=,B,C) } -inline void dMULTIPLY1_331(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP1_331(A,=,B,C) } -inline void dMULTIPLY0_133(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP0_133(A,=,B,C) } -inline void dMULTIPLY0_333(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP0_333(A,=,B,C) } -inline void dMULTIPLY1_333(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP1_333(A,=,B,C) } -inline void dMULTIPLY2_333(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP2_333(A,=,B,C) } - -inline void dMULTIPLYADD0_331(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP0_331(A,+=,B,C) } -inline void dMULTIPLYADD1_331(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP1_331(A,+=,B,C) } -inline void dMULTIPLYADD0_133(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP0_133(A,+=,B,C) } -inline void dMULTIPLYADD0_333(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP0_333(A,+=,B,C) } -inline void dMULTIPLYADD1_333(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP1_333(A,+=,B,C) } -inline void dMULTIPLYADD2_333(dReal *A, const dReal *B, const dReal *C) - { dMULTIPLYOP2_333(A,+=,B,C) } - -#else - -#define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C) -#define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C) -#define dMULTIPLY0_133(A,B,C) dMULTIPLYOP0_133(A,=,B,C) -#define dMULTIPLY0_333(A,B,C) dMULTIPLYOP0_333(A,=,B,C) -#define dMULTIPLY1_333(A,B,C) dMULTIPLYOP1_333(A,=,B,C) -#define dMULTIPLY2_333(A,B,C) dMULTIPLYOP2_333(A,=,B,C) - -#define dMULTIPLYADD0_331(A,B,C) dMULTIPLYOP0_331(A,+=,B,C) -#define dMULTIPLYADD1_331(A,B,C) dMULTIPLYOP1_331(A,+=,B,C) -#define dMULTIPLYADD0_133(A,B,C) dMULTIPLYOP0_133(A,+=,B,C) -#define dMULTIPLYADD0_333(A,B,C) dMULTIPLYOP0_333(A,+=,B,C) -#define dMULTIPLYADD1_333(A,B,C) dMULTIPLYOP1_333(A,+=,B,C) -#define dMULTIPLYADD2_333(A,B,C) dMULTIPLYOP2_333(A,+=,B,C) - -#endif - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/rotation.h b/extern/ode/dist/include/ode/rotation.h deleted file mode 100644 index 19204c651f3..00000000000 --- a/extern/ode/dist/include/ode/rotation.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_ROTATION_H_ -#define _ODE_ROTATION_H_ - -#include <ode/common.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -void dRSetIdentity (dMatrix3 R); - -void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az, - dReal angle); - -void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi); - -void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az, - dReal bx, dReal by, dReal bz); - -void dQSetIdentity (dQuaternion q); - -void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az, - dReal angle); - -void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); -void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); -void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); -void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc); - -void dQtoR (const dQuaternion q, dMatrix3 R); - -void dRtoQ (const dMatrix3 R, dQuaternion q); - -void dWtoDQ (const dVector3 w, const dQuaternion q, dVector4 dq); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/space.h b/extern/ode/dist/include/ode/space.h deleted file mode 100644 index c540cd69d6e..00000000000 --- a/extern/ode/dist/include/ode/space.h +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_SPACE_H_ -#define _ODE_SPACE_H_ - -#include <ode/common.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct dContactGeom; - -typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2); - - -/* extra information the space needs in every geometry object */ - -typedef struct dGeomSpaceData { - dGeomID next; -} dGeomSpaceData; - - -dSpaceID dSimpleSpaceCreate(); -dSpaceID dHashSpaceCreate(); - -void dSpaceDestroy (dSpaceID); -void dSpaceAdd (dSpaceID, dGeomID); -void dSpaceRemove (dSpaceID, dGeomID); -void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback); -int dSpaceQuery (dSpaceID, dGeomID); - -void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel); - - -/* @@@ NOT FLEXIBLE ENOUGH - * - * generate contacts for those objects in the space that touch each other. - * an array of contacts is created on the alternative stack using - * StackAlloc(), and a pointer to the array is returned. the size of the - * array is returned by the function. - */ -/* int dSpaceCollide (dSpaceID space, dContactGeom **contact_array); */ - - -/* HMMMMM... i dont think so. - * tell the space that an object has moved, so its representation in the - * space should be changed. - */ -/* void dSpaceObjectMoved (dSpaceID, dGeomID); */ - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/include/ode/timer.h b/extern/ode/dist/include/ode/timer.h deleted file mode 100644 index fe2574feb3c..00000000000 --- a/extern/ode/dist/include/ode/timer.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_TIMER_H_ -#define _ODE_TIMER_H_ - -#include <ode/config.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -/* stop watch objects */ - -typedef struct dStopwatch { - double time; /* total clock count */ - unsigned long cc[2]; /* clock count since last `start' */ -} dStopwatch; - -void dStopwatchReset (dStopwatch *); -void dStopwatchStart (dStopwatch *); -void dStopwatchStop (dStopwatch *); -double dStopwatchTime (dStopwatch *); /* returns total time in secs */ - - -/* code timers */ - -void dTimerStart (const char *description); /* pass a static string here */ -void dTimerNow (const char *description); /* pass a static string here */ -void dTimerEnd(); - -/* print out a timer report. if `average' is nonzero, print out the average - * time for each slot (this is only meaningful if the same start-now-end - * calls are being made repeatedly. - */ -void dTimerReport (FILE *fout, int average); - - -/* resolution */ - -/* returns the timer ticks per second implied by the timing hardware or API. - * the actual timer resolution may not be this great. - */ -double dTimerTicksPerSecond(); - -/* returns an estimate of the actual timer resolution, in seconds. this may - * be greater than 1/ticks_per_second. - */ -double dTimerResolution(); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/extern/ode/dist/ode/README b/extern/ode/dist/ode/README deleted file mode 100644 index dd4596f9935..00000000000 --- a/extern/ode/dist/ode/README +++ /dev/null @@ -1,158 +0,0 @@ -Dynamics Library. -================= - -CONVENTIONS ------------ - -matrix storage --------------- - -matrix operations like factorization are expensive, so we must store the data -in a way that is most useful to the matrix code. we want the ability to update -the dynamics library without recompiling applications, e.g. so users can take -advantage of new floating point hardware. so we must settle on a single -format. because of the prevalence of 4-way SIMD, the format is this: store -the matrix by rows or columns, and each column is rounded up to a multiple of -4 elements. the extra "padding" elements at the end of each row/column are set -to 0. this is called the "standard format". to indicate if the data is stored -by rows or columns, we will say "standard row format" or "standard column -format". hopefully this decision will remain good in the future, as more and -more processors have 4-way SIMD, and 3D graphics always needs fast 4x4 -matrices. - -exception: matrices that have only one column or row (vectors), are always -stored as consecutive elements in standard row format, i.e. there is no -interior padding, only padding at the end. - -thus: all 3x1 floating point vectors are stored as 4x1 vectors: (x,x,x,0). -also: all 6x1 spatial velocities and accelerations are split into 3x1 position - and angular components, which are stored as contiguous 4x1 vectors. - -ALL matrices are stored by in standard row format. - - -arguments ---------- - -3x1 vector arguments to set() functions are supplied as x,y,z. -3x1 vector result arguments to get() function are pointers to arrays. -larger vectors are always supplied and returned as pointers. -all coordinates are in the global frame except where otherwise specified. -output-only arguments are usually supplied at the end. - - -memory allocation ------------------ - -with many C/C++ libraries memory allocation is a difficult problem to solve. -who allocates the memory? who frees it? must objects go on the heap or can -they go on the stack or in static storage? to provide the maximum flexibility, -the dynamics and collision libraries do not do their own memory allocation. -you must pass in pointers to externally allocated chunks of the right sizes. -the body, joint and colllision object structures are all exported, so you -can make instances of those structure and pass pointers to them. - -there are helper functions which allocate objects out of areans, in case you -need loots of dynamic creation and deletion. - -BUT!!! this ties us down to the body/joint/collision representation. - -a better approach is to supply custom memory allocation functions -(e.g. dlAlloc() etc). - - -C versus C++ ... ? ------------------- - -everything should be C linkable, and there should be C header files for -everything. but we want to develop in C++. so do this: - * all comments are "//". automatically convert to /**/ for distribution. - * structures derived from other structures --> automatically convert? - - -WORLDS ------- - -might want better terminology here. - -the dynamics world (DWorld) is a list of systems. each system corresponds to -one or more bodies, or perhaps some other kinds of physical object. -each system corresponds to one or more objects in the collision world -(there does not have to be a one-to-one correspondence between bodies and -collision objects). - -systems are simulated separately, perhaps using completely different -techniques. we must do something special when systems collide. -systems collide when collision objects belonging to system A touch -collision objects belonging to system B. - -for each collision point, the system must provide matrix equation data -that is used to compute collision forces. once those forces are computed, -the system must incorporate the forces into its timestep. -PROBLEM: what if we intertwine the LCP problems of the two systems - then -this simple approach wont work. - -the dynamics world contains two kinds of objects: bodies and joints. -joints connect two bodies together. - -the world contains one of more partitions. each partition is a collection of -bodies and joints such that each body is attached (through one or more joints) -to every other body. - -Joints ------- - -a joint can be connected to one or two bodies. -if the joint is only connected to one body, joint.node[1].body == 0. -joint.node[0].body is always valid. - - -Linkage -------- - -this library will always be statically linked with the app, for these reasons: - * collision space is selected at compile time, it adds data to the geom - objects. - - -Optimization ------------- - -doubles must be aligned on 8 byte boundaries! - - -MinGW on Windows issues ------------------------ - -* the .rc file for drawstuff needs a different include, try winresrc.h. - -* it seems we can't have both main() and WinMain() without the entry point - defaulting to main() and having resource loading problems. this screws up - what i was trying to do in the drawstuff library. perhaps main2() ? - -* remember to compile resources to COFF format RES files. - - - -Collision ---------- - -to plug in your own collision handling, replace (some of?) these functions -with your own. collision should be a separate library that you can link in -or not. your own library can call components in this collision library, e.g. -if you want polymorphic spaces instead of a single statically called space. - -creating an object will automatically register the appropriate -class (if necessary). how can we ensure that the minimum amount of code is -linked in? e.g. only one space handler, and sphere-sphere and sphere-box and -box-box collision code (if spheres and boxes instanced). - -the user creates a collision space, and for each dynamics object that is -created a collision object is inserted into the space. the collision -object's pos and R pointers are set to the corresponding dynamics -variables. - -there should be utility functions which create the dynamics and collision -objects at the same time, e.g. dMakeSphere(). - -collision objects and dynamics objects keep pointers to each other. diff --git a/extern/ode/dist/ode/fbuild/BuildDot b/extern/ode/dist/ode/fbuild/BuildDot deleted file mode 100644 index 09b49274da8..00000000000 --- a/extern/ode/dist/ode/fbuild/BuildDot +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# dot product code generator. -# -# code generation parameters, set in a parameters file: -# FNAME : name of source file to generate - a .c file will be made -# UNROLL1 : inner loop unrolling factor (1..) -# FETCH : max num of a[i]'s and b[i]'s to load ahead of muls -# LAT1 : load -> mul latency (>=1) -# LAT2 : mul -> add latency (>=1). if this is 1, use fused mul-add -# -############################################################################# - -require ("BuildUtil"); - -# get and check code generation parameters -error ("Usage: BuildDot <parameters-file>") if $#ARGV != 0; -do $ARGV[0]; - -if (!defined($FNAME) || !defined($UNROLL1) || !defined($FETCH) || - !defined($LAT1) || !defined($LAT2)) { - error ("code generation parameters not defined"); -} - -# check parameters -error ("bad UNROLL1") if $UNROLL1 < 1; -error ("bad FETCH") if $FETCH < 1; -error ("bad LAT1") if $LAT1 < 1; -error ("bad LAT2") if $LAT2 < 1; - -############################################################################# - -open (FOUT,">$FNAME.c") or die "can't open $FNAME.c for writing"; - -# file and function header -output (<<END); -/* generated code, do not edit. */ - -#include "ode/matrix.h" - - -dReal dDot (const dReal *a, const dReal *b, int n) -{ -END - -output ("dReal "); -for ($i=0; $i<$UNROLL1; $i++) { - output ("p$i,q$i,m$i,"); -} -output ("sum;\n"); - -output (<<END); -sum = 0; -n -= $UNROLL1; -while (n >= 0) { -END - -@load = (); # slot where a[i]'s and b[i]'s loaded -@mul = (); # slot where multiply i happened -@add = (); # slow where add i happened - -# in the future we may want to reduce the number of variables declared, -# so these arrays will be useful. -@pqused = (); # 1 if p/q[i] loaded with data, 0 once that data's used -@mused = (); # 1 if m[i] loaded with data, 0 once that data's used -@pqmap = (); # map virtual p/q variables to actual p/q variables -@mmap = (); # map virtual m variables to actual m variables - -output ("p0 = a[0]; q0 = b[0];\n"); -push (@load,0); - -$slot=0; # one slot for every load/mul/add/nop issued -for (;;) { - $startslot = $slot; - - # do next load - if (($#load - $#mul) < $FETCH && ($#load+1) < $UNROLL1) { - push (@load,$slot); - output ("p$#load = a[$#load]; q$#load = b[$#load];\n"); - $slot++; - } - # do next multiply - if ($#load > $#mul && $slot >= ($load[$#mul+1] + $LAT1) && - ($#mul+1) < $UNROLL1) { - push (@mul,$slot); - if ($LAT2 > 1) { - output ("m$#mul = p$#mul * q$#mul;\n"); - } - else { - output ("sum += p$#mul * q$#mul;\n"); - last if ($#mul+1) >= $UNROLL1; - } - $slot++; - } - # do next add - if ($LAT2 > 1) { - if ($#mul > $#add && $slot >= ($mul[$#add+1] + $LAT2)) { - push (@add,$slot); - output ("sum += m$#add;\n"); - $slot++; - last if ($#add+1) >= $UNROLL1; - } - } - - if ($slot == $startslot) { - # comment ("nop"); - $slot++; - } -} - -output ("a += $UNROLL1;\n"); -output ("b += $UNROLL1;\n"); -output ("n -= $UNROLL1;\n"); -output ("}\n"); - -output (<<END); -n += $UNROLL1; -while (n > 0) { -sum += (*a) * (*b); -a++; -b++; -n--; -} -return sum; -} -END diff --git a/extern/ode/dist/ode/fbuild/BuildLDLT b/extern/ode/dist/ode/fbuild/BuildLDLT deleted file mode 100644 index fd74faf18df..00000000000 --- a/extern/ode/dist/ode/fbuild/BuildLDLT +++ /dev/null @@ -1,654 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# -# triangular matrix solver and factorizer code generator. -# -# SOLVER -# ------ -# -# if L is an n x n lower triangular matrix (with ones on the diagonal), the -# solver solves L*X=B where X and B are n x m matrices. this is the core -# step in L*D*L' factorization. the algorithm is (in matlab): -# -# for i=1:n -# for j=1:m -# X(i,j) = B(i,j) - L(i,1:i-1)*X(1:i-1,j); -# end -# end -# -# note that the ordering of the (i,j) loop is somewhat arbitrary. the only -# prerequisite to calculating element (i,j) of X is that all X(1:i-1,j) have -# have already been calcuated. this gives us some flexibility. -# -# the code generated below calculates X in N1 x N1 blocks. to speed up the -# innermost dot product loop, the outer product trick is used. for instance, -# to calculate the value of the 2x2 matrix ABCD below we first iterate over -# the vectors (a,b,c,d) and (e,f,g,h), computing ABCD = a*e+b*f+c*g+d*h. -# then A and B contain the dot product values needed in the algorithm, and -# C and D have almost all of it. the outer product trick reduces the number -# of memory loads required. in this example 16 loads are required, but if -# the simple dot product in the above algorithm is used then 32 loads are -# required. increasing N1 decreases the total number of loads, but only as long -# as we have enough temporary registers to keep the matrix blocks and vectors. -# -# L * X = B -# -# [ . ] [ e e ] [ . . ] -# [ . . ] [ f f ] [ . . ] -# [ . . . ] [ g g ] [ . . ] -# [ . . . . ] [ h h ] [ . . ] -# [ a b c d . ] [ A B ] = [ . . ] -# [ a b c d . . ] [ C D ] [ . . ] -# [ . . . . . . . ] [ . . ] [ . . ] -# [ . . . . . . . . ] [ . . ] [ . . ] -# [ . . . . . . . . . ] [ . . ] [ . . ] -# -# note that L is stored by rows but X and B are stored by columns. -# the outer product loops are unrolled for extra speed. -# -# LDLT FACTORIZATION -# ------------------ -# -# the factorization algorithm builds L incrementally by repeatedly solving -# the following equation: -# -# [ L 0 ] [ D 0 ] [ L' l ] = [ A a ] <-- n rows -# [ l' e ] [ 0 d ] [ 0 e' ] [ a' b ] <-- m rows -# -# [ L*D*L' L*D*l ] = [ A a ] -# [ l'*D*L' l'*D*l+e*d*e' ] [ a' b ] -# -# L*D*L'=A is an existing solution, and a,b are new rows/columns to add to A. -# we compute: -# -# L * (Dl) = a -# l = inv(D) * Dl -# e*d*e' = b - l'*Dl (m*m LDLT factorization) -# -# -# L-transpose solver -# ------------------ -# -# the LT (L-transpose) solver uses the same logic as the standard L-solver, -# with a few tricks to make it work. to solve L^T*X=B we first remap: -# L to Lhat : Lhat(i,j) = L(n-j,n-i) -# X to Xhat : Xhat(i) = X(n-i) -# B to Bhat : Bhat(i) = B(n-i) -# and then solve Lhat*Xhat = Bhat. the current LT solver only supports one -# right hand side, but that's okay as it is not used in the factorizer. -# -############################################################################# -# -# code generation parameters, set in a parameters file: -# FNAME : name of source file to generate - a .c file will be made -# TYPE : 'f' to build factorizer, 's' to build solver, 't' to build the -# transpose solver. -# N1 : block size (size of outer product matrix) (1..9) -# UNROLL1 : solver inner loop unrolling factor (1..) -# UNROLL2 : factorizer inner loop unrolling factor (1..) -# MADD : if nonzero, generate code for fused multiply-add (0,1) -# FETCH : how to fetch data in the inner loop: -# 0 - load in a batch (the `normal way') -# 1 - delay inner loop loads until just before they're needed -# -############################################################################# -# -# TODO -# ---- -# -# * dFactorLDLT() is not so efficient for matrix sizes < block size, e.g. -# redundant calls, zero loads, adds etc -# -############################################################################# -# -# NOTES: -# -# * on the pentium we can prefetch like this: -# asm ("prefetcht0 %0" : : "m" (*Ai) ); -# but it doesn't seem to help much - -require ("BuildUtil"); - -# get and check code generation parameters -error ("Usage: BuildLDLT <parameters-file>") if $#ARGV != 0; -do $ARGV[0]; - -if (!defined($FNAME) || !defined($TYPE) || !defined($N1) || - !defined($UNROLL1) || !defined($UNROLL2) || !defined($MADD) || - !defined($FETCH)) { - error ("code generation parameters not defined"); -} - -# check parameters -error ("bad TYPE") if $TYPE ne 'f' && $TYPE ne 's' && $TYPE ne 't'; -error ("bad N1") if $N1 < 1 || $N1 > 9; -error ("bad UNROLL1") if $UNROLL1 < 1; -error ("bad UNROLL2") if $UNROLL2 < 1; -error ("bad MADD") if $MADD != 0 && $MADD != 1; -error ("bad FETCH") if $FETCH < 0 && $FETCH > 1; - -############################################################################# -# utility - -# functions to handle delayed loading of p and q values. -# bit in the the `ploaded' and `qloaded' numbers record what has been loaded, -# so we dont load it again. - -sub newLoads -{ - # bits in these numbers say what registers p and q have been loaded so far - $ploaded = 0; - $qloaded = 0; -} - -sub loadedEverything -{ - $ploaded = 0xffffffff; - $qloaded = 0xffffffff; -} - -sub loadP # (i,loadcmd) -{ - my $i = $_[0]; - my $loadcmd = $_[1]; - return if ($ploaded & (1 << $i)); - output ($loadcmd); - $ploaded |= (1 << $i); -} - -sub loadQ # (i,loadcmd) -{ - my $i = $_[0]; - my $loadcmd = $_[1]; - return if ($qloaded & (1 << $i)); - output ($loadcmd); - $qloaded |= (1 << $i); -} - -############################################################################# -# make a fast L solve function. -# this function has a restriction that the leading dimension of X and B must -# be a multiple of the block size. - -sub innerOuterProductLoop # (M,k,nrhs,increment) -{ - my $M=$_[0]; - my $k=$_[1]; - my $nrhs=$_[2]; - my $increment=$_[3]; - my ($i,$j); - newLoads; - if ($FETCH==0) { - comment ("load p and q values"); - for ($i=1; $i<=$M; $i++) { - if ($TYPE eq 't') { - output ("p$i=ell[".ofs2(-($i-1),0,'lskip')."];\n"); - output ("q$i=ex[".ofs2(-($k),$i-1,'lskip')."];\n") if $i <= $nrhs; - } - else { - output ("p$i=ell[".ofs2($k,$i-1,'lskip')."];\n"); - output ("q$i=ex[".ofs2($k,$i-1,'lskip')."];\n") if $i <= $nrhs; - } - } - loadedEverything; - } - - comment ("compute outer product and add it to the Z matrix"); - for ($i=1; $i<=$M; $i++) { - for ($j=1; $j<=$nrhs; $j++) { - if ($TYPE eq 't') { - loadP ($i,"p$i=ell[".ofs2(-($i-1),0,'lskip')."];\n"); - loadQ ($j,"q$j=ex[".ofs2(-($k),$j-1,'lskip')."];\n"); - } - else { - loadP ($i,"p$i=ell[".ofs2($k,$i-1,'lskip')."];\n"); - loadQ ($j,"q$j=ex[".ofs2($k,$j-1,'lskip')."];\n"); - } - my $var = $MADD ? "Z$i$j +=" : "m$i$j ="; - output ("$var p$i * q$j;\n"); - } - } - - if ($TYPE eq 't') { - if ($increment > 0) { - output ("ell += lskip1;\n"); - output ("ex -= $increment;\n"); - } - else { - output ("ell += lskip1;\n"); - } - } - else { - if ($increment > 0) { - comment ("advance pointers"); - output ("ell += $increment;\n"); - output ("ex += $increment;\n"); - } - } - - if ($MADD==0) { - for ($i=1; $i<=$M; $i++) { - for ($j=1; $j<=$nrhs; $j++) { - output ("Z$i$j += m$i$j;\n"); - } - } - } -} - - -sub computeRows # (nrhs,rows) -{ - my $nrhs = $_[0]; - my $rows = $_[1]; - my ($i,$j,$k); - - comment ("compute all $rows x $nrhs block of X, from rows i..i+$rows-1"); - - comment ("set the Z matrix to 0"); - for ($i=1; $i<=$rows; $i++) { - for ($j=1; $j<=$nrhs; $j++) { - output ("Z$i$j=0;\n"); - } - } - if ($TYPE eq 't') { - output ("ell = L - i;\n"); - } - else { - output ("ell = L + i*lskip1;\n"); - } - output ("ex = B;\n"); - - comment ("the inner loop that computes outer products and adds them to Z"); - output ("for (j=i-$UNROLL1; j >= 0; j -= $UNROLL1) {\n"); - for ($k=0; $k < $UNROLL1; $k++) { - innerOuterProductLoop ($rows,$k,$nrhs,($k==$UNROLL1-1) ? $UNROLL1 : 0); - } - - comment ("end of inner loop"); - output ("}\n"); - - if ($UNROLL1 > 1) { - comment ("compute left-over iterations"); - output ("j += $UNROLL1;\n"); - output ("for (; j > 0; j--) {\n"); - innerOuterProductLoop ($rows,'0',$nrhs,1); - output ("}\n"); - } - - comment ("finish computing the X(i) block"); - - for ($j=1; $j<=$nrhs; $j++) { - if ($TYPE eq 't') { - output ("Z1$j = ex[".ofs1(-($j-1),'lskip')."] - Z1$j;\n"); - output ("ex[".ofs1(-($j-1),'lskip')."] = Z1$j;\n"); - } - else { - output ("Z1$j = ex[".ofs1($j-1,'lskip')."] - Z1$j;\n"); - output ("ex[".ofs1($j-1,'lskip')."] = Z1$j;\n"); - } - } - - for ($i=2; $i<=$rows; $i++) { - for ($j=1; $j<$i; $j++) { - if ($TYPE eq 't') { - output ("p$j = ell[".ofs2(-($i-1),$j-1,'lskip')."];\n"); - } - else { - output ("p$j = ell[".ofs2($j-1,$i-1,'lskip')."];\n"); - } - } - for ($j=1; $j<=$nrhs; $j++) { - if ($TYPE eq 't') { - output ("Z$i$j = ex[".ofs2(-($i-1),$j-1,'lskip')."] - Z$i$j"); - } - else { - output ("Z$i$j = ex[".ofs2($i-1,$j-1,'lskip')."] - Z$i$j"); - } - for ($k=1; $k < $i; $k++) { - output (" - p$k*Z$k$j"); - } - output (";\n"); - if ($TYPE eq 't') { - output ("ex[".ofs2(-($i-1),$j-1,'lskip')."] = Z$i$j;\n"); - } - else { - output ("ex[".ofs2($i-1,$j-1,'lskip')."] = Z$i$j;\n"); - } - } - } -} - - -sub makeFastL1Solve # ( number-of-right-hand-sides ) -{ - my $nrhs = $_[0]; - my ($i,$j,$k); - my $funcsuffix = ($TYPE eq 'f') ? "_$nrhs" : ''; - my $staticvoid = ($TYPE eq 'f') ? 'static void' : 'void'; - - # function header - if ($TYPE eq 't') { - output (<<END); - -/* solve L^T * x=b, with b containing 1 right hand side. - * L is an n*n lower triangular matrix with ones on the diagonal. - * L is stored by rows and its leading dimension is lskip. - * b is an n*1 matrix that contains the right hand side. - * b is overwritten with x. - * this processes blocks of $N1. - */ - -void dSolveL1T (const dReal *L, dReal *B, int n, int lskip1) -{ -END - } - else { - output (<<END); - -/* solve L*X=B, with B containing $nrhs right hand sides. - * L is an n*n lower triangular matrix with ones on the diagonal. - * L is stored by rows and its leading dimension is lskip. - * B is an n*$nrhs matrix that contains the right hand sides. - * B is stored by columns and its leading dimension is also lskip. - * B is overwritten with X. - * this processes blocks of $N1*$N1. - * if this is in the factorizer source file, n must be a multiple of $N1. - */ - -$staticvoid dSolveL1$funcsuffix (const dReal *L, dReal *B, int n, int lskip1) -{ -END - } - - comment ("declare variables - Z matrix, p and q vectors, etc"); - output ("dReal "); - for ($i=1; $i<=$N1; $i++) { - for ($j=1; $j<=$nrhs; $j++) { - output ("Z$i$j,"); # Z matrix - output ("m$i$j,") if ! $MADD; # temporary vars where multiplies put - } - } - for ($i=1; $i<=$N1; $i++) { - output ("p$i,"); - output ("q$i,") if $i <= $nrhs; - } - output ("*ex;\nconst dReal *ell;\n"); - output ("int "); - for ($i=2; $i<$N1; $i++) { - output ("lskip$i,"); - } - output ("i,j;\n"); - - if ($TYPE eq 't') { - comment ("special handling for L and B because we're solving L1 *transpose*"); - output ("L = L + (n-1)*(lskip1+1);\n"); - output ("B = B + n-1;\n"); - output ("lskip1 = -lskip1;\n"); - } - - if ($N1 > 2) { - comment ("compute lskip values"); - for ($i=2; $i<$N1; $i++) { - output ("lskip$i = $i*lskip1;\n"); - } - } - - comment ("compute all $N1 x $nrhs blocks of X"); - if ($TYPE eq 's' or $TYPE eq 't') { - output ("for (i=0; i <= n-$N1; i+=$N1) {\n"); - } - else { - output ("for (i=0; i < n; i+=$N1) {\n"); - } - computeRows ($nrhs,$N1); - comment ("end of outer loop"); - output ("}\n"); - - if ($TYPE eq 's' or $TYPE eq 't') { - comment ("compute rows at end that are not a multiple of block size"); - output ("for (; i < n; i++) {\n"); - computeRows ($nrhs,1); - output ("}\n"); - } - - output ("}\n"); -} - -############################################################################# -# make a fast L*D*L' factorizer - -# code fragment: this factors an M x M block. if A_or_Z is 0 then it works -# on the $A matrix otherwise it works on the Z matrix. in either case it -# writes the diagonal entries into the `dee' vector. -# it is a simple implementation of the LDLT algorithm, with no tricks. - -sub getA # (i,j,A,A_or_Z) -{ - my $i = $_[0]; - my $j = $_[1]; - my $A = $_[2]; - return $_[3] ? ('Z'.($i+1).($j+1)) : ($A.'['.ofs2($j,$i,'nskip').']'); -} - -sub miniLDLT # (A,A_or_Z,M) -{ - my ($i,$j,$k); - my $A = $_[0]; - my $AZ = $_[1]; - my $M = $_[2]; - comment ("factorize $M x $M block " . ($AZ ? "Z,dee" : "$A,dee")); - comment ("factorize row 1"); - output ("dee[0] = dRecip(".getA(0,0,$A,$AZ).");\n"); - for ($i=1; $i<$M; $i++) { - comment ("factorize row ".($i+1)); - for ($j=1; $j<$i; $j++) { - output (getA($i,$j,$A,$AZ)." -= "); - for ($k=0; $k<$j; $k++) { - output (" + ") if $k > 0; - output (getA($i,$k,$A,$AZ)."*".getA($j,$k,$A,$AZ)); - } - output (";\n"); - } - output ("sum = 0;\n"); - for ($j=0; $j<$i; $j++) { - output ("q1 = ".getA($i,$j,$A,$AZ).";\n"); - output ("q2 = q1 * dee[$j];\n"); - output (getA($i,$j,$A,$AZ)." = q2;\n"); - output ("sum += q1*q2;\n"); - } - output ("dee[$i] = dRecip(".getA($i,$i,$A,$AZ)." - sum);\n"); - } - comment ("done factorizing $M x $M block"); -} - - -sub innerScaleAndOuterProductLoop # (M,k) -{ - my $M = $_[0]; - my $k = $_[1]; - my ($i,$j); - for ($i=1; $i<=$M; $i++) { - output ("p$i = ell[".ofs2($k,$i-1,'nskip')."];\n"); - } - output ("dd = dee[$k];\n"); - for ($i=1; $i<=$M; $i++) { - output ("q$i = p$i*dd;\n"); - } - for ($i=1; $i<=$M; $i++) { - output ("ell[".ofs2($k,$i-1,'nskip')."] = q$i;\n"); - } - for ($i=1; $i<=$M; $i++) { - for ($j=1; $j<=$i; $j++) { - my $var = $MADD ? "Z$i$j +=" : "m$i$j ="; - output ("$var p$i*q$j;\n"); - } - } - if ($MADD==0) { - for ($i=1; $i<=$M; $i++) { - for ($j=1; $j<=$i; $j++) { - output ("Z$i$j += m$i$j;\n"); - } - } - } -} - - -sub diagRows # (M) -{ - my $M=$_[0]; - comment ("scale the elements in a $M x i block at A(i,0), and also"); - comment ("compute Z = the outer product matrix that we'll need."); - for ($i=1; $i<=$M; $i++) { - for ($j=1; $j<=$i; $j++) { - output ("Z$i$j = 0;\n"); - } - } - output ("ell = A+i*nskip1;\n"); - output ("dee = d;\n"); - output ("for (j=i-$UNROLL2; j >= 0; j -= $UNROLL2) {\n"); - for ($i=0; $i < $UNROLL2; $i++) { - innerScaleAndOuterProductLoop ($M,$i); - } - output ("ell += $UNROLL2;\n"); - output ("dee += $UNROLL2;\n"); - output ("}\n"); - - if ($UNROLL2 > 1) { - comment ("compute left-over iterations"); - output ("j += $UNROLL2;\n"); - output ("for (; j > 0; j--) {\n"); - innerScaleAndOuterProductLoop ($M,0); - output ("ell++;\n"); - output ("dee++;\n"); - output ("}\n"); - } -} - - -sub diagBlock # (M) -{ - my $M = $_[0]; - comment ("solve for diagonal $M x $M block at A(i,i)"); - for ($i=1; $i<=$M; $i++) { - for ($j=1; $j<=$i; $j++) { - output ("Z$i$j = ell[".ofs2($j-1,$i-1,'nskip')."] - Z$i$j;\n"); - } - } - output ("dee = d + i;\n"); - miniLDLT ('',1,$M); - for ($i=2; $i<=$M; $i++) { - for ($j=1; $j<$i; $j++) { - output ("ell[".ofs2($j-1,$i-1,'nskip')."] = Z$i$j;\n"); - } - } -} - - -sub makeFastLDLT -{ - my ($i,$j,$k); - - # function header - output (<<END); - - -void dFactorLDLT (dReal *A, dReal *d, int n, int nskip1) -{ -END - output ("int i,j"); - for ($i=2; $i<$N1; $i++) { - output (",nskip$i"); - } - output (";\n"); - output ("dReal sum,*ell,*dee,dd,p1,p2"); - for ($i=3; $i<=$N1; $i++) { - output (",p$i"); - } - for ($i=1; $i<=$N1; $i++) { - output (",q$i"); - } - for ($i=1; $i<=$N1; $i++) { - for ($j=1; $j<=$i; $j++) { - output (",Z$i$j"); - output (",m$i$j") if ! $MADD; # temporary vars where multiplies put - } - } - output (";\n"); - output ("if (n < 1) return;\n"); - # output ("nskip1 = dPAD(n);\n"); ... not any more - for ($i=2; $i<$N1; $i++) { - output ("nskip$i = $i*nskip1;\n"); - } - - output ("\nfor (i=0; i<=n-$N1; i += $N1) {\n"); - comment ("solve L*(D*l)=a, l is scaled elements in $N1 x i block at A(i,0)"); - output ("dSolveL1_$N1 (A,A+i*nskip1,i,nskip1);\n"); - - diagRows ($N1); - diagBlock ($N1); - output ("}\n"); - - comment ("compute the (less than $N1) rows at the bottom"); - output ("switch (n-i) {\n"); - output ("case 0:\n"); - output ("break;\n\n"); - - for ($i=1; $i<$N1; $i++) { - output ("case $i:\n"); - output ("dSolveL1_$i (A,A+i*nskip1,i,nskip1);\n"); - diagRows ($i); - diagBlock ($i); - output ("break;\n\n"); - } - - output ("default: *((char*)0)=0; /* this should never happen! */\n"); - output ("}\n"); - - output ("}\n"); -} - -############################################################################# -# write source code - -open (FOUT,">$FNAME.c") or die "can't open $FNAME.c for writing"; - -# file and function header -output (<<END); -/* generated code, do not edit. */ - -#include "ode/matrix.h" -END - -if ($TYPE eq 'f') { - for ($i=1; $i <= $N1; $i++) { - makeFastL1Solve ($i); - } - makeFastLDLT; -} -else { - makeFastL1Solve (1); - makeRealFastL1Solve; -} -close FOUT; diff --git a/extern/ode/dist/ode/fbuild/BuildMultidot b/extern/ode/dist/ode/fbuild/BuildMultidot deleted file mode 100644 index f6b117708c5..00000000000 --- a/extern/ode/dist/ode/fbuild/BuildMultidot +++ /dev/null @@ -1,174 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# multi-dot-product code generator. this code generator is based on the -# dot-product code generator. -# -# code generation parameters, set in a parameters file: -# FNAME : name of source file to generate - a .c file will be made -# N1 : block size (number of `a' vectors to dot) -# UNROLL1 : inner loop unrolling factor (1..) -# FETCH : max num of a[i]'s and b[i]'s to load ahead of muls -# LAT1 : load -> mul latency (>=1) -# LAT2 : mul -> add latency (>=1). if this is 1, use fused mul-add -# -############################################################################# - -require ("BuildUtil"); - -# get and check code generation parameters -error ("Usage: BuildMultidot <parameters-file>") if $#ARGV != 0; -do $ARGV[0]; - -if (!defined($FNAME) || !defined($N1) || !defined($UNROLL1) || - !defined($FETCH) || !defined($LAT1) || !defined($LAT2)) { - error ("code generation parameters not defined"); -} - -# check parameters -error ("bad N1") if $N1 < 2; -error ("bad UNROLL1") if $UNROLL1 < 1; -error ("bad FETCH") if $FETCH < 1; -error ("bad LAT1") if $LAT1 < 1; -error ("bad LAT2") if $LAT2 < 1; - -############################################################################# - -open (FOUT,">$FNAME.c") or die "can't open $FNAME.c for writing"; - -# file and function header -output (<<END); -/* generated code, do not edit. */ - -#include "ode/matrix.h" - - -END -output ("void dMultidot$N1 ("); -for ($i=0; $i<$N1; $i++) { - output ("const dReal *a$i, "); -} -output ("const dReal *b, dReal *outsum, int n)\n{\n"); - -output ("dReal "); -for ($i=0; $i<$UNROLL1; $i++) { - for ($j=0; $j<$N1; $j++) { - output ("p$i$j,"); - output ("m$i$j,") if $LAT2 > 1; - } - output ("q$i,"); -} -for ($i=0; $i<$N1; $i++) { - output ("sum$i"); - output (",") if $i < ($N1-1); -} -output (";\n"); -for ($i=0; $i<$N1; $i++) { - output ("sum$i = 0;\n"); -} -output (<<END); -n -= $UNROLL1; -while (n >= 0) { -END - -@load = (); # slot where a[i]'s and b[i]'s loaded -@mul = (); # slot where multiply i happened -@add = (); # slow where add i happened - -for ($i=0; $i<$N1; $i++) { - output ("p0$i = a$i [0];\n"); -} -output ("q0 = b[0];\n"); -push (@load,0); - -$slot=0; # one slot for every load/mul/add/nop issued -for (;;) { - $startslot = $slot; - - # do next load - if (($#load - $#mul) < $FETCH && ($#load+1) < $UNROLL1) { - push (@load,$slot); - for ($j=0; $j<$N1; $j++) { - output ("p$#load$j = a$j [$#load];\n"); - } - output ("q$#load = b[$#load];\n"); - $slot++; - } - - # do next multiply - if ($#load > $#mul && $slot >= ($load[$#mul+1] + $LAT1) && - ($#mul+1) < $UNROLL1) { - push (@mul,$slot); - if ($LAT2 > 1) { - for ($j=0; $j<$N1; $j++) { - output ("m$#mul$j = p$#mul$j * q$#mul;\n"); - } - } - else { - for ($j=0; $j<$N1; $j++) { - output ("sum$j += p$#mul$j * q$#mul;\n"); - } - last if ($#mul+1) >= $UNROLL1; - } - $slot++; - } - # do next add - if ($LAT2 > 1) { - if ($#mul > $#add && $slot >= ($mul[$#add+1] + $LAT2)) { - push (@add,$slot); - for ($j=0; $j<$N1; $j++) { - output ("sum$j += m$#add$j;\n"); - } - $slot++; - last if ($#add+1) >= $UNROLL1; - } - } - - if ($slot == $startslot) { - # comment ("nop"); - $slot++; - } -} - -for ($j=0; $j<$N1; $j++) { - output ("a$j += $UNROLL1;\n"); -} -output ("b += $UNROLL1;\n"); -output ("n -= $UNROLL1;\n"); -output ("}\n"); - -output ("n += $UNROLL1;\n"); -output ("while (n > 0) {\n"); -output ("q0 = *b;\n"); -for ($j=0; $j<$N1; $j++) { - output ("sum$j += (*a$j) * q0;\n"); - output ("a$j++;\n"); -} -output ("b++;\n"); -output ("n--;\n"); -output ("}\n"); -for ($j=0; $j<$N1; $j++) { - output ("outsum[$j] = sum$j;\n"); -} -output ("}\n"); diff --git a/extern/ode/dist/ode/fbuild/BuildUtil b/extern/ode/dist/ode/fbuild/BuildUtil deleted file mode 100644 index b0828ff5ec1..00000000000 --- a/extern/ode/dist/ode/fbuild/BuildUtil +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/perl -w -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -package BuildUtil; - - -# print out code. after newlines, indent according to the number of curly -# brackets we've seen - -my $indent = 0; -my $startofline = 1; - - -sub main::output -{ - my $line = $_[0]; - my ($i,$j,$c); - for ($i=0; $i < length ($line); $i++) { - $c = substr ($line,$i,1); - print main::FOUT $c if $c eq '{'; - $indent++ if $c eq '{'; - $indent-- if $c eq '}'; - if ($startofline) { - for ($j=0; $j < $indent; $j++) { - print main::FOUT " "; - } - $startofline = 0; - } - print main::FOUT $c if $c ne '{'; - $startofline = 1 if $c eq "\n"; - } -} - - -# write a C comment with the correct indenting - -sub main::comment -{ - main::output ("/* $_[0] */\n"); -} - - -# return an offset: N*skip = skipN where N=0,1,2,... - -sub main::ofs1 # (N,skip) -{ - my $N = $_[0]; - my $skip = $_[1]; - return '0' if $N==0; - return $skip . $N; -} - - -# return an offset: M+N*skip = M+skipN where N=0,1,2,... - -sub main::ofs2 # (M,N,skip) -{ - my $M = $_[0]; - my $N = $_[1]; - my $skip = $_[2]; - $M = '0' if $M eq '-0'; - my $a = $M; - $a .= '+' . $skip . $N if ($N > 0); - substr ($a,0,2)='' if substr ($a,0,2) eq '0+'; - return $a; -} - - -# print an error message and exit - -sub main::error -{ - print "ERROR: $_[0]\n"; - exit 1; -} - - -1; diff --git a/extern/ode/dist/ode/fbuild/Dependencies b/extern/ode/dist/ode/fbuild/Dependencies deleted file mode 100644 index 86f5cd4417b..00000000000 --- a/extern/ode/dist/ode/fbuild/Dependencies +++ /dev/null @@ -1,16 +0,0 @@ -test_dot.o: test_dot.cpp ../../include/ode/ode.h \ - ../../include/ode/config.h ../../include/ode/contact.h \ - ../../include/ode/common.h ../../include/ode/error.h \ - ../../include/ode/memory.h ../../include/ode/odemath.h \ - ../../include/ode/matrix.h ../../include/ode/timer.h \ - ../../include/ode/rotation.h ../../include/ode/mass.h \ - ../../include/ode/space.h ../../include/ode/geom.h \ - ../../include/ode/misc.h -test_ldlt.o: test_ldlt.cpp ../../include/ode/ode.h \ - ../../include/ode/config.h ../../include/ode/contact.h \ - ../../include/ode/common.h ../../include/ode/error.h \ - ../../include/ode/memory.h ../../include/ode/odemath.h \ - ../../include/ode/matrix.h ../../include/ode/timer.h \ - ../../include/ode/rotation.h ../../include/ode/mass.h \ - ../../include/ode/space.h ../../include/ode/geom.h \ - ../../include/ode/misc.h diff --git a/extern/ode/dist/ode/fbuild/Makefile b/extern/ode/dist/ode/fbuild/Makefile deleted file mode 100644 index f988c3739af..00000000000 --- a/extern/ode/dist/ode/fbuild/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# currently this only works under linux, and it's a bit of a mess! - -MAKEFILE_INC=../../build/Makefile.inc -include $(MAKEFILE_INC) - -INCLUDE_PATHS=../../include -LIB_PATHS = ../../lib -DEFINES=dDOUBLE - -SOURCES_CPP=test_ldlt.cpp -SOURCES_C=fastldlt.c fastlsolve.c fastltsolve.c -APPS=$(call fEXENAME,test_ldlt) $(call fEXENAME,test_dot) $(call fEXENAME,test_multidot) -EXTRA_CLEAN=test_ldlt test_dot test_multidot fastldlt.c fastlsolve.c fastltsolve.c fastdot.c fastmultidot.c - - -all: $(APPS) - -$(call fEXENAME,test_ldlt): $(call fTARGETS,$(SOURCES_CPP) $(SOURCES_C)) - gcc -o $@ $^ -L $(LIB_PATHS) $(call fLIB,ode) -lm - -$(call fEXENAME,test_dot): test_dot.o fastdot.o - gcc -o $@ test_dot.o fastdot.o -L $(LIB_PATHS) $(call fLIB,ode) -lm - -$(call fEXENAME,test_multidot): test_multidot.o fastmultidot.o - gcc -o $@ test_multidot.o fastmultidot.o -L $(LIB_PATHS) $(call fLIB,ode) -lm - -fastldlt.o: fastldlt.c - gcc -O1 -I$(INCLUDE_PATHS) -ffast-math -fomit-frame-pointer -c -D$(DEFINES) $< - -fastlsolve.o: fastlsolve.c - gcc -O1 -I$(INCLUDE_PATHS) -ffast-math -fomit-frame-pointer -c -D$(DEFINES) $< - -fastltsolve.o: fastltsolve.c - gcc -O1 -I$(INCLUDE_PATHS) -ffast-math -fomit-frame-pointer -c -D$(DEFINES) $< - -fastdot.o: fastdot.c - gcc -O1 -I$(INCLUDE_PATHS) -ffast-math -fomit-frame-pointer -c -D$(DEFINES) $< - -fastmultidot.o: fastmultidot.c - gcc -O1 -I$(INCLUDE_PATHS) -ffast-math -fomit-frame-pointer -c -D$(DEFINES) $< - -fastldlt.c: BuildLDLT BuildUtil ParametersF - ./BuildLDLT ParametersF - -fastlsolve.c: BuildLDLT BuildUtil ParametersS - ./BuildLDLT ParametersS - -fastltsolve.c: BuildLDLT BuildUtil ParametersT - ./BuildLDLT ParametersT - -fastdot.c: BuildDot BuildUtil ParametersD - ./BuildDot ParametersD - -fastmultidot.c: BuildMultidot BuildUtil ParametersM - ./BuildMultidot ParametersM diff --git a/extern/ode/dist/ode/fbuild/OptimizeDot b/extern/ode/dist/ode/fbuild/OptimizeDot deleted file mode 100644 index 1dc178262aa..00000000000 --- a/extern/ode/dist/ode/fbuild/OptimizeDot +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# optimize the dot product built by BuildDot - -############################################################################## - -require ("OptimizeUtil"); - -# unused standard parameters -$TYPE='unused'; -$N1=0; # unused -$UNROLL2=0; # unused -$MADD=0; # unused - -############################################################################## - -sub testDot # (filename) -{ - my $filename = $_[0]; - createParametersFile ('ParametersD'); - $params = "$N1 $UNROLL1 $UNROLL2 $MADD $FETCH $LAT1 $LAT2"; - print "***** TESTING $params\n"; - doit ("rm -f fastdot.c fastdot.o test_dot"); - doit ("make test_dot"); - doit ("./test_dot >> $filename"); - open (FILE,">>$filename"); - print FILE " $params\n"; - close FILE; -} - -# find optimal parameters. write results to data4.txt - -open (FILE,">data4.txt"); -print FILE "# dot product data from OptimizeDot\n"; -close FILE; -$FNAME='fastdot'; - -for ($UNROLL1=1; $UNROLL1 <= 10; $UNROLL1++) { - for ($LAT1=1; $LAT1 <= 5; $LAT1++) { - for ($LAT2=1; $LAT2 <= 5; $LAT2++) { - for ($FETCH=1; $FETCH<=5; $FETCH++) { - testDot ('data4.txt'); - } - } - } -} - -readBackDataFile ('data4.txt'); -createParametersFile ('ParametersD'); diff --git a/extern/ode/dist/ode/fbuild/OptimizeLDLT b/extern/ode/dist/ode/fbuild/OptimizeLDLT deleted file mode 100644 index 612633e00c2..00000000000 --- a/extern/ode/dist/ode/fbuild/OptimizeLDLT +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# optimize the factorizer built by BuildLDLT -# -# FNAME : name of source file to generate - .h and .c files will be made -# N1 : block size (size of outer product matrix) (1..9) -# UNROLL1 : solver inner loop unrolling factor (1..) -# UNROLL2 : factorizer inner loop unrolling factor (1..) -# MADD : if nonzero, generate code for fused multiply-add (0,1) -# FETCH : how to fetch data in the inner loop: -# 0 - load in a batch (the `normal way') -# 1 - delay inner loop loads until just before they're needed - -############################################################################## - -require ("OptimizeUtil"); - -############################################################################## -# optimize factorizer - -sub testFactorizer # (filename) -{ - my $filename = $_[0]; - createParametersFile ('ParametersF'); - $params = "$N1 $UNROLL1 $UNROLL2 $MADD $FETCH"; - print "***** TESTING $params\n"; - doit ("rm -f fastldlt.c fastldlt.o test_ldlt"); - doit ("make test_ldlt"); - doit ("./test_ldlt f >> $filename"); - open (FILE,">>$filename"); - print FILE " $params\n"; - close FILE; -} - - -# first find optimal parameters ignoring UNROLL1 and UNROLL2, write results -# to data1.txt - -open (FILE,">data1.txt"); -print FILE "# factorizer data from OptimizeLDLT\n"; -close FILE; -$FNAME='fastldlt'; -$TYPE='f'; -$UNROLL1=4; -$UNROLL2=4; -for ($N1=1; $N1 <= 4; $N1++) { - for ($MADD=0; $MADD<=1; $MADD++) { - for ($FETCH=0; $FETCH<=1; $FETCH++) { - testFactorizer ('data1.txt'); - } - } -} - -readBackDataFile ('data1.txt'); -createParametersFile ('ParametersF'); - -# now find optimal UNROLL1 and UNROLL2 values, write results to data2.txt - -open (FILE,">data2.txt"); -print FILE "# factorizer data from OptimizeLDLT\n"; -close FILE; -for ($UNROLL1=1; $UNROLL1 <= 10; $UNROLL1++) { - for ($UNROLL2=1; $UNROLL2 <= 10; $UNROLL2++) { - testFactorizer ('data2.txt'); - } -} - -readBackDataFile ('data2.txt'); -createParametersFile ('ParametersF'); diff --git a/extern/ode/dist/ode/fbuild/OptimizeLSolve b/extern/ode/dist/ode/fbuild/OptimizeLSolve deleted file mode 100644 index bba6b495f2c..00000000000 --- a/extern/ode/dist/ode/fbuild/OptimizeLSolve +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# optimize the solver built by BuildLDLT -# -# FNAME : name of source file to generate - .h and .c files will be made -# N1 : block size (size of outer product matrix) (1..9) -# UNROLL1 : solver inner loop unrolling factor (1..) -# UNROLL2 : factorizer inner loop unrolling factor (1..) -# MADD : if nonzero, generate code for fused multiply-add (0,1) -# FETCH : how to fetch data in the inner loop: -# 0 - load in a batch (the `normal way') -# 1 - delay inner loop loads until just before they're needed - -############################################################################## - -require ("OptimizeUtil"); - -############################################################################## -# optimize solver - -sub testSolver # (filename) -{ - my $filename = $_[0]; - createParametersFile ('ParametersS'); - $params = "$N1 $UNROLL1 $UNROLL2 $MADD $FETCH"; - print "***** TESTING $params\n"; - doit ("rm -f fastlsolve.c fastlsolve.o test_ldlt"); - doit ("make test_ldlt"); - doit ("./test_ldlt s >> $filename"); - open (FILE,">>$filename"); - print FILE " $params\n"; - close FILE; -} - -# find optimal parameters. UNROLL2 has no effect. write results to data3.txt - -open (FILE,">data3.txt"); -print FILE "# solver data from OptimizeLDLT\n"; -close FILE; -$FNAME='fastlsolve'; -$TYPE='s'; -$UNROLL2=1; -for ($N1=1; $N1 <= 5; $N1++) { - for ($UNROLL1=1; $UNROLL1 <= 15; $UNROLL1++) { - for ($MADD=0; $MADD<=1; $MADD++) { - for ($FETCH=0; $FETCH<=1; $FETCH++) { - testSolver ('data3.txt'); - } - } - } -} - -readBackDataFile ('data3.txt'); -createParametersFile ('ParametersS'); diff --git a/extern/ode/dist/ode/fbuild/OptimizeLTSolve b/extern/ode/dist/ode/fbuild/OptimizeLTSolve deleted file mode 100644 index a10109e2d2c..00000000000 --- a/extern/ode/dist/ode/fbuild/OptimizeLTSolve +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# optimize the transpose solver built by BuildLDLT -# -# FNAME : name of source file to generate - .h and .c files will be made -# N1 : block size (size of outer product matrix) (1..9) -# UNROLL1 : solver inner loop unrolling factor (1..) -# UNROLL2 : factorizer inner loop unrolling factor (1..) -# MADD : if nonzero, generate code for fused multiply-add (0,1) -# FETCH : how to fetch data in the inner loop: -# 0 - load in a batch (the `normal way') -# 1 - delay inner loop loads until just before they're needed - -############################################################################## - -require ("OptimizeUtil"); - -############################################################################## -# optimize solver - -sub testSolver # (filename) -{ - my $filename = $_[0]; - createParametersFile ('ParametersT'); - $params = "$N1 $UNROLL1 $UNROLL2 $MADD $FETCH"; - print "***** TESTING $params\n"; - doit ("rm -f fastltsolve.c fastltsolve.o test_ldlt"); - doit ("make test_ldlt"); - doit ("./test_ldlt t >> $filename"); - open (FILE,">>$filename"); - print FILE " $params\n"; - close FILE; -} - -# find optimal parameters. UNROLL2 has no effect. write results to data5.txt - -open (FILE,">data5.txt"); -print FILE "# solver data from OptimizeLDLT\n"; -close FILE; -$FNAME='fastltsolve'; -$TYPE='t'; -$UNROLL2=1; -for ($N1=1; $N1 <= 5; $N1++) { - for ($UNROLL1=1; $UNROLL1 <= 15; $UNROLL1++) { - for ($MADD=0; $MADD<=1; $MADD++) { - for ($FETCH=0; $FETCH<=1; $FETCH++) { - testSolver ('data5.txt'); - } - } - } -} - -readBackDataFile ('data5.txt'); -createParametersFile ('ParametersT'); diff --git a/extern/ode/dist/ode/fbuild/OptimizeMultidot b/extern/ode/dist/ode/fbuild/OptimizeMultidot deleted file mode 100644 index f2b54383312..00000000000 --- a/extern/ode/dist/ode/fbuild/OptimizeMultidot +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/perl -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# optimize the dot product built by BuildMultidot - -############################################################################## - -require ("OptimizeUtil"); - -# multiple -$N1=2; - -# unused standard parameters -$TYPE='unused'; -$UNROLL2=0; # unused -$MADD=0; # unused - -############################################################################## - -sub testMultidot # (filename) -{ - my $filename = $_[0]; - createParametersFile ('ParametersM'); - $params = "$N1 $UNROLL1 $UNROLL2 $MADD $FETCH $LAT1 $LAT2"; - print "***** TESTING $params\n"; - doit ("rm -f fastmultidot.c fastmultidot.o test_multidot"); - doit ("make test_multidot"); - doit ("./test_multidot >> $filename"); - open (FILE,">>$filename"); - print FILE " $params\n"; - close FILE; -} - -# find optimal parameters. write results to data6.txt - -open (FILE,">data6.txt"); -print FILE "# multi-dot product data from OptimizeMultidot\n"; -close FILE; -$FNAME='fastmultidot'; - -for ($UNROLL1=1; $UNROLL1 <= 10; $UNROLL1++) { - for ($LAT1=1; $LAT1 <= 5; $LAT1++) { - for ($LAT2=1; $LAT2 <= 5; $LAT2++) { - for ($FETCH=1; $FETCH<=5; $FETCH++) { - testMultidot ('data6.txt'); - } - } - } -} - -readBackDataFile ('data6.txt'); -createParametersFile ('ParametersM'); diff --git a/extern/ode/dist/ode/fbuild/OptimizeUtil b/extern/ode/dist/ode/fbuild/OptimizeUtil deleted file mode 100644 index 2b882fcba65..00000000000 --- a/extern/ode/dist/ode/fbuild/OptimizeUtil +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl -w -# -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -package BuildUtil; - - -sub main::doit -{ - my $cmd = $_[0]; - print "$cmd\n"; - system ($cmd)==0 or die "FAILED"; -} - - -sub main::createParametersFile # (filename) -{ - open (PARAM,">$_[0]"); - print PARAM "# perl script to set parameters required by the code generator\n"; - print PARAM "\$FNAME=\"$main::FNAME\";\n" if defined($main::FNAME); - print PARAM "\$TYPE=\"$main::TYPE\";\n" if defined($main::TYPE); - print PARAM "\$N1=$main::N1;\n" if defined($main::N1); - print PARAM "\$UNROLL1=$main::UNROLL1;\n" if defined($main::UNROLL1); - print PARAM "\$UNROLL2=$main::UNROLL2;\n" if defined($main::UNROLL2); - print PARAM "\$MADD=$main::MADD;\n" if defined($main::MADD); - print PARAM "\$FETCH=$main::FETCH;\n" if defined($main::FETCH); - print PARAM "\$LAT1=$main::LAT1;\n" if defined($main::LAT1); - print PARAM "\$LAT2=$main::LAT2;\n" if defined($main::LAT2); - close PARAM; -} - - -# read back a data file and find best parameters - -sub main::readBackDataFile # (filename) -{ - my $filename = $_[0]; - my $maxtime = 1e10; - open (FILE,$filename); - while (<FILE>) { - next if /^\#/; - my $line = lc $_; - if ($line =~ /error/) { - print "ERRORS FOUND IN $filename\n"; - exit 1; - } - $line =~ s/^\s*//; - $line =~ s/\s*$//; - my @nums = split (/\s+/,$line); - $time = $nums[0]; - if ($time < $maxtime) { - $main::N1 = $nums[1]; - $main::UNROLL1 = $nums[2]; - $main::UNROLL2 = $nums[3]; - $main::MADD = $nums[4]; - $main::FETCH = $nums[5]; - $main::LAT1 = $nums[6]; - $main::LAT2 = $nums[7]; - $maxtime = $time; - } - } - close FILE; -} - - -1; diff --git a/extern/ode/dist/ode/fbuild/ParametersD.example b/extern/ode/dist/ode/fbuild/ParametersD.example deleted file mode 100644 index e58f279f7d7..00000000000 --- a/extern/ode/dist/ode/fbuild/ParametersD.example +++ /dev/null @@ -1,32 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# perl script to set parameters required by the code generator -$FNAME="fastdot"; -$TYPE="unused"; -$N1=0; -$UNROLL1=2; -$UNROLL2=0; -$MADD=0; -$FETCH=1; -$LAT1=1; -$LAT2=2; diff --git a/extern/ode/dist/ode/fbuild/ParametersF.example b/extern/ode/dist/ode/fbuild/ParametersF.example deleted file mode 100644 index 9881b09ad81..00000000000 --- a/extern/ode/dist/ode/fbuild/ParametersF.example +++ /dev/null @@ -1,30 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# perl script to set parameters required by the code generator -$FNAME="fastldlt"; -$TYPE="f"; -$N1=2; -$UNROLL1=2; -$UNROLL2=6; -$MADD=0; -$FETCH=1; diff --git a/extern/ode/dist/ode/fbuild/ParametersM.example b/extern/ode/dist/ode/fbuild/ParametersM.example deleted file mode 100644 index bb81d6b83f1..00000000000 --- a/extern/ode/dist/ode/fbuild/ParametersM.example +++ /dev/null @@ -1,32 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# perl script to set parameters required by the code generator -$FNAME="fastmultidot"; -$TYPE="unused"; -$N1=2; -$UNROLL1=1; -$UNROLL2=0; -$MADD=0; -$FETCH=5; -$LAT1=1; -$LAT2=1; diff --git a/extern/ode/dist/ode/fbuild/ParametersS.example b/extern/ode/dist/ode/fbuild/ParametersS.example deleted file mode 100644 index 29c9a91fc16..00000000000 --- a/extern/ode/dist/ode/fbuild/ParametersS.example +++ /dev/null @@ -1,30 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# perl script to set parameters required by the code generator -$FNAME="fastlsolve"; -$TYPE="s"; -$N1=4; -$UNROLL1=12; -$UNROLL2=1; -$MADD=1; -$FETCH=0; diff --git a/extern/ode/dist/ode/fbuild/ParametersT.example b/extern/ode/dist/ode/fbuild/ParametersT.example deleted file mode 100644 index 3aa92a31dd2..00000000000 --- a/extern/ode/dist/ode/fbuild/ParametersT.example +++ /dev/null @@ -1,30 +0,0 @@ -######################################################################### -# # -# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. # -# All rights reserved. Email: russ@q12.org Web: www.q12.org # -# # -# This library is free software; you can redistribute it and/or # -# modify it under the terms of EITHER: # -# (1) The GNU Lesser General Public License as published by the Free # -# Software Foundation; either version 2.1 of the License, or (at # -# your option) any later version. The text of the GNU Lesser # -# General Public License is included with this library in the # -# file LICENSE.TXT. # -# (2) The BSD-style license that is included with this library in # -# the file LICENSE-BSD.TXT. # -# # -# This library is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # -# LICENSE.TXT and LICENSE-BSD.TXT for more details. # -# # -######################################################################### - -# perl script to set parameters required by the code generator -$FNAME="fastltsolve"; -$TYPE="t"; -$N1=4; -$UNROLL1=12; -$UNROLL2=1; -$MADD=1; -$FETCH=0; diff --git a/extern/ode/dist/ode/fbuild/README b/extern/ode/dist/ode/fbuild/README deleted file mode 100644 index bcf7f5aa8b5..00000000000 --- a/extern/ode/dist/ode/fbuild/README +++ /dev/null @@ -1,41 +0,0 @@ - -factorizer/solver builder - -before running `make', copy the following files: - ParametersD.example --> ParametersD - ParametersF.example --> ParametersF - ParametersS.example --> ParametersS - -the files Parameters[D|F|S] don't exist in the CVS archive because -they are changable. - - - -STATS - for chol ------ - -* all with -O1 - -128x128 matrix -atlas = 1724779 clocks -my chol = 1164629 clocks (parameters: 2 2 2 1) with Ai++, Aj++ -my chol = 1140786 clocks (parameters: 2 6 8 0) with Ai++, Aj++ -my chol = 1118968 clocks (parameters: 2 6 8 0) with +ofs - -64x64 matrix -atlas = 374020 clocks -my chol = 157076 clocks (parameters = 2 2 2 1) - -32x32 matrix (12961 flops) -atlas = 83827 clocks -my chol = 25945 clocks (parameters: 2 2 2 1) - - - - -TODO ----- - -* doc! - -* iterate blocks by partial rows to try and keep more data in cache diff --git a/extern/ode/dist/ode/fbuild/ldlt.m b/extern/ode/dist/ode/fbuild/ldlt.m deleted file mode 100644 index 19ae2d1c94e..00000000000 --- a/extern/ode/dist/ode/fbuild/ldlt.m +++ /dev/null @@ -1,26 +0,0 @@ -function [L,d] = ldlt(A) - -n=length(A); -d=zeros(n,1); - -d(1) = 1/A(1,1); -for i=2:n - for j=2:i-1 - A(i,j) = A(i,j) - A(j,1:j-1) * A(i,1:j-1)'; - end - sum = 0; - for j=1:i-1 - q1 = A(i,j); - q2 = q1 * d(j); - A(i,j) = q2; - sum = sum + q1*q2; - end - d(i) = 1/(A(i,i) - sum); -end - -L=A; -for i=1:n - L(i,i:n)=zeros(1,n+1-i); - L(i,i)=1; -end -d = d .\ 1; diff --git a/extern/ode/dist/ode/fbuild/test_dot.cpp b/extern/ode/dist/ode/fbuild/test_dot.cpp deleted file mode 100644 index 62aec32e509..00000000000 --- a/extern/ode/dist/ode/fbuild/test_dot.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <stdio.h> -#include "ode/ode.h" - -#define ALLOCA dALLOCA16 -#define SIZE 1000 - - -// correct dot product, for accuracy testing - -dReal goodDot (dReal *a, dReal *b, int n) -{ - dReal sum=0; - while (n > 0) { - sum += (*a) * (*b); - a++; - b++; - n--; - } - return sum; -} - - -// test dot product accuracy - -void testAccuracy() -{ - // allocate vectors a and b and fill them with random data - dReal *a = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - dReal *b = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - dMakeRandomMatrix (a,1,SIZE,1.0); - dMakeRandomMatrix (b,1,SIZE,1.0); - - for (int n=1; n<100; n++) { - dReal good = goodDot (a,b,n); - dReal test = dDot (a,b,n); - dReal diff = fabs(good-test); - //printf ("diff = %e\n",diff); - if (diff > 1e-10) printf ("ERROR: accuracy test failed\n"); - } -} - - -// test dot product factorizer speed. - -void testSpeed() -{ - // allocate vectors a and b and fill them with random data - dReal *a = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - dReal *b = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - dMakeRandomMatrix (a,1,SIZE,1.0); - dMakeRandomMatrix (b,1,SIZE,1.0); - - // time several dot products, return the minimum timing - double mintime = 1e100; - dStopwatch sw; - for (int i=0; i<1000; i++) { - dStopwatchReset (&sw); - dStopwatchStart (&sw); - - // try a bunch of prime sizes up to 101 - dDot (a,b,2); - dDot (a,b,3); - dDot (a,b,5); - dDot (a,b,7); - dDot (a,b,11); - dDot (a,b,13); - dDot (a,b,17); - dDot (a,b,19); - dDot (a,b,23); - dDot (a,b,29); - dDot (a,b,31); - dDot (a,b,37); - dDot (a,b,41); - dDot (a,b,43); - dDot (a,b,47); - dDot (a,b,53); - dDot (a,b,59); - dDot (a,b,61); - dDot (a,b,67); - dDot (a,b,71); - dDot (a,b,73); - dDot (a,b,79); - dDot (a,b,83); - dDot (a,b,89); - dDot (a,b,97); - dDot (a,b,101); - - dStopwatchStop (&sw); - double time = dStopwatchTime (&sw); - if (time < mintime) mintime = time; - } - - printf ("%.0f",mintime * dTimerTicksPerSecond()); -} - - -int main() -{ - testAccuracy(); - testSpeed(); - return 0; -} diff --git a/extern/ode/dist/ode/fbuild/test_ldlt.cpp b/extern/ode/dist/ode/fbuild/test_ldlt.cpp deleted file mode 100644 index 3b795b9ee7f..00000000000 --- a/extern/ode/dist/ode/fbuild/test_ldlt.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <stdio.h> -#include <malloc.h> -#include "ode/ode.h" - -#define ALLOCA dALLOCA16 - -//**************************************************************************** -// constants - -#ifdef dSINGLE -#define TOL (1e-4) -#else -#define TOL (1e-10) -#endif - -//**************************************************************************** -// test L*X=B solver accuracy. - -void testSolverAccuracy (int n) -{ - int i; - int npad = dPAD(n); - dReal *L = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dReal *B = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *B2 = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *X = (dReal*) ALLOCA (n*sizeof(dReal)); - - // L is a random lower triangular matrix with 1's on the diagonal - dMakeRandomMatrix (L,n,n,1.0); - dClearUpperTriangle (L,n); - for (i=0; i<n; i++) L[i*npad+i] = 1; - - // B is the right hand side - dMakeRandomMatrix (B,n,1,1.0); - memcpy (X,B,n*sizeof(dReal)); // copy B to X - - dSolveL1 (L,X,n,npad); - - /* - dPrintMatrix (L,n,n); - printf ("\n"); - dPrintMatrix (B,n,1); - printf ("\n"); - dPrintMatrix (X,n,1); - printf ("\n"); - */ - - dSetZero (B2,n); - dMultiply0 (B2,L,X,n,n,1); - dReal error = dMaxDifference (B,B2,1,n); - if (error > TOL) { - printf ("error = %e, size = %d\n",error,n); - } -} - -//**************************************************************************** -// test L^T*X=B solver accuracy. - -void testTransposeSolverAccuracy (int n) -{ - int i; - int npad = dPAD(n); - dReal *L = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dReal *B = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *B2 = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *X = (dReal*) ALLOCA (n*sizeof(dReal)); - - // L is a random lower triangular matrix with 1's on the diagonal - dMakeRandomMatrix (L,n,n,1.0); - dClearUpperTriangle (L,n); - for (i=0; i<n; i++) L[i*npad+i] = 1; - - // B is the right hand side - dMakeRandomMatrix (B,n,1,1.0); - memcpy (X,B,n*sizeof(dReal)); // copy B to X - - dSolveL1T (L,X,n,npad); - - dSetZero (B2,n); - dMultiply1 (B2,L,X,n,n,1); - dReal error = dMaxDifference (B,B2,1,n); - if (error > TOL) { - printf ("error = %e, size = %d\n",error,n); - } -} - -//**************************************************************************** -// test L*D*L' factorizer accuracy. - -void testLDLTAccuracy (int n) -{ - int i,j; - int npad = dPAD(n); - dReal *A = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dReal *L = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dReal *d = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *Atest = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dReal *DL = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - - dMakeRandomMatrix (A,n,n,1.0); - dMultiply2 (L,A,A,n,n,n); - memcpy (A,L,n*npad*sizeof(dReal)); - dSetZero (d,n); - - dFactorLDLT (L,d,n,npad); - - // make L lower triangular, and convert d into diagonal of D - dClearUpperTriangle (L,n); - for (i=0; i<n; i++) L[i*npad+i] = 1; - for (i=0; i<n; i++) d[i] = 1.0/d[i]; - - // form Atest = L*D*L' - dSetZero (Atest,n*npad); - dSetZero (DL,n*npad); - for (i=0; i<n; i++) { - for (j=0; j<n; j++) DL[i*npad+j] = L[i*npad+j] * d[j]; - } - dMultiply2 (Atest,L,DL,n,n,n); - dReal error = dMaxDifference (A,Atest,n,n); - if (error > TOL) { - printf ("error = %e, size = %d\n",error,n); - } - - /* - printf ("\n"); - dPrintMatrix (A,n,n); - printf ("\n"); - dPrintMatrix (L,n,n); - printf ("\n"); - dPrintMatrix (d,1,n); - */ -} - -//**************************************************************************** -// test L*D*L' factorizer speed. - -void testLDLTSpeed (int n) -{ - int npad = dPAD(n); - - // allocate A - dReal *A = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - - // make B a symmetric positive definite matrix - dMakeRandomMatrix (A,n,n,1.0); - dReal *B = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dSetZero (B,n*npad); - dMultiply2 (B,A,A,n,n,n); - - // make d - dReal *d = (dReal*) ALLOCA (n*sizeof(dReal)); - dSetZero (d,n); - - // time several factorizations, return the minimum timing - double mintime = 1e100; - dStopwatch sw; - for (int i=0; i<100; i++) { - memcpy (A,B,n*npad*sizeof(dReal)); - dStopwatchReset (&sw); - dStopwatchStart (&sw); - - dFactorLDLT (A,d,n,npad); - - dStopwatchStop (&sw); - double time = dStopwatchTime (&sw); - if (time < mintime) mintime = time; - } - - printf ("%.0f",mintime * dTimerTicksPerSecond()); -} - -//**************************************************************************** -// test solver speed. - -void testSolverSpeed (int n, int transpose) -{ - int i; - int npad = dPAD(n); - - // allocate L,B,X - dReal *L = (dReal*) ALLOCA (n*npad*sizeof(dReal)); - dReal *B = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *X = (dReal*) ALLOCA (n*sizeof(dReal)); - - // L is a random lower triangular matrix with 1's on the diagonal - dMakeRandomMatrix (L,n,n,1.0); - dClearUpperTriangle (L,n); - for (i=0; i<n; i++) L[i*npad+i] = 1; - - // B is the right hand side - dMakeRandomMatrix (B,n,1,1.0); - - // time several factorizations, return the minimum timing - double mintime = 1e100; - dStopwatch sw; - for (int i=0; i<100; i++) { - memcpy (X,B,n*sizeof(dReal)); // copy B to X - - if (transpose) { - dStopwatchReset (&sw); - dStopwatchStart (&sw); - dSolveL1T (L,X,n,npad); - dStopwatchStop (&sw); - } - else { - dStopwatchReset (&sw); - dStopwatchStart (&sw); - dSolveL1 (L,X,n,npad); - dStopwatchStop (&sw); - } - - double time = dStopwatchTime (&sw); - if (time < mintime) mintime = time; - } - - printf ("%.0f",mintime * dTimerTicksPerSecond()); -} - -//**************************************************************************** -// the single command line argument is 'f' to test and time the factorizer, -// or 's' to test and time the solver. - - -void testAccuracy (int n, char type) -{ - if (type == 'f') testLDLTAccuracy (n); - if (type == 's') testSolverAccuracy (n); - if (type == 't') testTransposeSolverAccuracy (n); -} - - -void testSpeed (int n, char type) -{ - if (type == 'f') testLDLTSpeed (n); - if (type == 's') testSolverSpeed (n,0); - if (type == 't') testSolverSpeed (n,1); -} - - -int main (int argc, char **argv) -{ - if (argc != 2 || argv[1][0] == 0 || argv[1][1] != 0 || - (argv[1][0] != 'f' && argv[1][0] != 's' && argv[1][0] != 't')) { - fprintf (stderr,"Usage: test_ldlt [f|s|t]\n"); - exit (1); - } - char type = argv[1][0]; - - // accuracy test: test all sizes up to 20 then all prime sizes up to 101 - int i; - for (i=1; i<20; i++) { - testAccuracy (i,type); - } - testAccuracy (23,type); - testAccuracy (29,type); - testAccuracy (31,type); - testAccuracy (37,type); - testAccuracy (41,type); - testAccuracy (43,type); - testAccuracy (47,type); - testAccuracy (53,type); - testAccuracy (59,type); - testAccuracy (61,type); - testAccuracy (67,type); - testAccuracy (71,type); - testAccuracy (73,type); - testAccuracy (79,type); - testAccuracy (83,type); - testAccuracy (89,type); - testAccuracy (97,type); - testAccuracy (101,type); - - // test speed on a 127x127 matrix - testSpeed (127,type); - - return 0; -} diff --git a/extern/ode/dist/ode/fbuild/test_multidot.cpp b/extern/ode/dist/ode/fbuild/test_multidot.cpp deleted file mode 100644 index 0e961152fed..00000000000 --- a/extern/ode/dist/ode/fbuild/test_multidot.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <stdio.h> -#include "ode/ode.h" - -#define NUM_A 2 -#define ALLOCA dALLOCA16 -#define SIZE 1000 - - -extern "C" void dMultidot2 (const dReal *a0, const dReal *a1, - const dReal *b, dReal *outsum, int n); -/* -extern "C" void dMultidot4 (const dReal *a0, const dReal *a1, - const dReal *a2, const dReal *a3, - const dReal *b, dReal *outsum, int n); -*/ - - -// correct dot product, for accuracy testing - -dReal goodDot (dReal *a, dReal *b, int n) -{ - dReal sum=0; - while (n > 0) { - sum += (*a) * (*b); - a++; - b++; - n--; - } - return sum; -} - - -// test multi-dot product accuracy - -void testAccuracy() -{ - int j; - - // allocate vectors a and b and fill them with random data - dReal *a[NUM_A]; - for (j=0; j<NUM_A; j++) a[j] = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - dReal *b = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - for (j=0; j<NUM_A; j++) dMakeRandomMatrix (a[j],1,SIZE,1.0); - dMakeRandomMatrix (b,1,SIZE,1.0); - - for (int n=1; n<100; n++) { - dReal good[NUM_A]; - for (j=0; j<NUM_A; j++) good[j] = goodDot (a[j],b,n); - dReal test[4]; - dMultidot2 (a[0],a[1],b,test,n); - dReal diff = 0; - for (j=0; j<NUM_A; j++) diff += fabs(good[j]-test[j]); - // printf ("diff = %e\n",diff); - if (diff > 1e-10) printf ("ERROR: accuracy test failed\n"); - } -} - - -// test multi-dot product factorizer speed. - -void testSpeed() -{ - int j; - dReal sum[NUM_A]; - - // allocate vectors a and b and fill them with random data - dReal *a[NUM_A]; - for (j=0; j<NUM_A; j++) a[j] = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - dReal *b = (dReal*) ALLOCA (SIZE*sizeof(dReal)); - for (j=0; j<NUM_A; j++) dMakeRandomMatrix (a[j],1,SIZE,1.0); - dMakeRandomMatrix (b,1,SIZE,1.0); - - // time several dot products, return the minimum timing - double mintime = 1e100; - dStopwatch sw; - for (int i=0; i<1000; i++) { - dStopwatchReset (&sw); - dStopwatchStart (&sw); - - // try a bunch of prime sizes up to 101 - dMultidot2 (a[0],a[1],b,sum,2); - dMultidot2 (a[0],a[1],b,sum,3); - dMultidot2 (a[0],a[1],b,sum,5); - dMultidot2 (a[0],a[1],b,sum,7); - dMultidot2 (a[0],a[1],b,sum,11); - dMultidot2 (a[0],a[1],b,sum,13); - dMultidot2 (a[0],a[1],b,sum,17); - dMultidot2 (a[0],a[1],b,sum,19); - dMultidot2 (a[0],a[1],b,sum,23); - dMultidot2 (a[0],a[1],b,sum,29); - dMultidot2 (a[0],a[1],b,sum,31); - dMultidot2 (a[0],a[1],b,sum,37); - dMultidot2 (a[0],a[1],b,sum,41); - dMultidot2 (a[0],a[1],b,sum,43); - dMultidot2 (a[0],a[1],b,sum,47); - dMultidot2 (a[0],a[1],b,sum,53); - dMultidot2 (a[0],a[1],b,sum,59); - dMultidot2 (a[0],a[1],b,sum,61); - dMultidot2 (a[0],a[1],b,sum,67); - dMultidot2 (a[0],a[1],b,sum,71); - dMultidot2 (a[0],a[1],b,sum,73); - dMultidot2 (a[0],a[1],b,sum,79); - dMultidot2 (a[0],a[1],b,sum,83); - dMultidot2 (a[0],a[1],b,sum,89); - dMultidot2 (a[0],a[1],b,sum,97); - dMultidot2 (a[0],a[1],b,sum,101); - - dStopwatchStop (&sw); - double time = dStopwatchTime (&sw); - if (time < mintime) mintime = time; - } - - printf ("%.0f",mintime * dTimerTicksPerSecond()); -} - - -int main() -{ - testAccuracy(); - testSpeed(); - return 0; -} diff --git a/extern/ode/dist/ode/src/array.cpp b/extern/ode/dist/ode/src/array.cpp deleted file mode 100644 index cbb1a6ed557..00000000000 --- a/extern/ode/dist/ode/src/array.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/config.h> -#include <ode/memory.h> -#include <ode/error.h> -#include "array.h" - - -static inline int roundUpToPowerOfTwo (int x) -{ - int i = 1; - while (i < x) i <<= 1; - return i; -} - - -void dArrayBase::_freeAll (int sizeofT) -{ - if (_data) { - if (_data == this+1) return; // if constructLocalArray() was called - dFree (_data,_anum * sizeofT); - } -} - - -void dArrayBase::_setSize (int newsize, int sizeofT) -{ - if (newsize < 0) return; - if (newsize > _anum) { - if (_data == this+1) { - // this is a no-no, because constructLocalArray() was called - dDebug (0,"setSize() out of space in LOCAL array"); - } - int newanum = roundUpToPowerOfTwo (newsize); - if (_data) _data = dRealloc (_data, _anum*sizeofT, newanum*sizeofT); - else _data = dAlloc (newanum*sizeofT); - _anum = newanum; - } - _size = newsize; -} - - -void * dArrayBase::operator new (size_t size) -{ - return dAlloc (size); -} - - -void dArrayBase::operator delete (void *ptr, size_t size) -{ - dFree (ptr,size); -} - - -void dArrayBase::constructLocalArray (int __anum) -{ - _size = 0; - _anum = __anum; - _data = this+1; -} diff --git a/extern/ode/dist/ode/src/array.h b/extern/ode/dist/ode/src/array.h deleted file mode 100644 index 97c2cebc2f4..00000000000 --- a/extern/ode/dist/ode/src/array.h +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* this comes from the `reuse' library. copy any changes back to the source. - * - * Variable sized array template. The array is always stored in a contiguous - * chunk. The array can be resized. A size increase will cause more memory - * to be allocated, and may result in relocation of the array memory. - * A size decrease has no effect on the memory allocation. - * - * Array elements with constructors or destructors are not supported! - * But if you must have such elements, here's what to know/do: - * - Bitwise copy is used when copying whole arrays. - * - When copying individual items (via push(), insert() etc) the `=' - * (equals) operator is used. Thus you should define this operator to do - * a bitwise copy. You should probably also define the copy constructor. - */ - - -#ifndef _ODE_ARRAY_H_ -#define _ODE_ARRAY_H_ - -#include <ode/config.h> - - -// this base class has no constructors or destructor, for your convenience. - -class dArrayBase { -protected: - int _size; // number of elements in `data' - int _anum; // allocated number of elements in `data' - void *_data; // array data - - void _freeAll (int sizeofT); - void _setSize (int newsize, int sizeofT); - // set the array size to `newsize', allocating more memory if necessary. - // if newsize>_anum and is a power of two then this is guaranteed to - // set _size and _anum to newsize. - -public: - // not: dArrayBase () { _size=0; _anum=0; _data=0; } - - int size() const { return _size; } - int allocatedSize() const { return _anum; } - void * operator new (size_t size); - void operator delete (void *ptr, size_t size); - - void constructor() { _size=0; _anum=0; _data=0; } - // if this structure is allocated with malloc() instead of new, you can - // call this to set it up. - - void constructLocalArray (int __anum); - // this helper function allows non-reallocating arrays to be constructed - // on the stack (or in the heap if necessary). this is something of a - // kludge and should be used with extreme care. this function acts like - // a constructor - it is called on uninitialized memory that will hold the - // Array structure and the data. __anum is the number of elements that - // are allocated. the memory MUST be allocated with size: - // sizeof(ArrayBase) + __anum*sizeof(T) - // arrays allocated this way will never try to reallocate or free the - // memory - that's your job. -}; - - -template <class T> class dArray : public dArrayBase { -public: - void equals (const dArray<T> &x) { - setSize (x.size()); - memcpy (_data,x._data,x._size * sizeof(T)); - } - - dArray () { constructor(); } - dArray (const dArray<T> &x) { constructor(); equals (x); } - ~dArray () { _freeAll(sizeof(T)); } - void setSize (int newsize) { _setSize (newsize,sizeof(T)); } - T *data() const { return (T*) _data; } - T & operator[] (int i) const { return ((T*)_data)[i]; } - void operator = (const dArray<T> &x) { equals (x); } - - void push (const T item) { - if (_size < _anum) _size++; else _setSize (_size+1,sizeof(T)); - ((T*)_data)[_size-1] = item; - } - - void swap (dArray<T> &x) { - int tmp1; - void *tmp2; - tmp1=_size; _size=x._size; x._size=tmp1; - tmp1=_anum; _anum=x._anum; x._anum=tmp1; - tmp2=_data; _data=x._data; x._data=tmp2; - } - - // insert the item at the position `i'. if i<0 then add the item to the - // start, if i >= size then add the item to the end of the array. - void insert (int i, const T item) { - if (_size < _anum) _size++; else _setSize (_size+1,sizeof(T)); - if (i >= (_size-1)) i = _size-1; // add to end - else { - if (i < 0) i=0; // add to start - int n = _size-1-i; - if (n>0) memmove (((T*)_data) + i+1, ((T*)_data) + i, n*sizeof(T)); - } - ((T*)_data)[i] = item; - } - - void remove (int i) { - if (i >= 0 && i < _size) { // passing this test guarantees size>0 - int n = _size-1-i; - if (n>0) memmove (((T*)_data) + i, ((T*)_data) + i+1, n*sizeof(T)); - _size--; - } - } -}; - -#endif - diff --git a/extern/ode/dist/ode/src/error.cpp b/extern/ode/dist/ode/src/error.cpp deleted file mode 100644 index 9b33db55f0c..00000000000 --- a/extern/ode/dist/ode/src/error.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/config.h> -#include <ode/error.h> - - -static dMessageFunction *error_function = 0; -static dMessageFunction *debug_function = 0; -static dMessageFunction *message_function = 0; - - -extern "C" void dSetErrorHandler (dMessageFunction *fn) -{ - error_function = fn; -} - - -extern "C" void dSetDebugHandler (dMessageFunction *fn) -{ - debug_function = fn; -} - - -extern "C" void dSetMessageHandler (dMessageFunction *fn) -{ - message_function = fn; -} - - -extern "C" dMessageFunction *dGetErrorHandler() -{ - return error_function; -} - - -extern "C" dMessageFunction *dGetDebugHandler() -{ - return debug_function; -} - - -extern "C" dMessageFunction *dGetMessageHandler() -{ - return message_function; -} - - -static void printMessage (int num, const char *msg1, const char *msg2, - va_list ap) -{ - fflush (stderr); - fflush (stdout); - if (num) fprintf (stderr,"\n%s %d: ",msg1,num); - else fprintf (stderr,"\n%s: ",msg1); - vfprintf (stderr,msg2,ap); - fprintf (stderr,"\n"); - fflush (stderr); -} - -//**************************************************************************** -// unix - -#ifndef WIN32 - -extern "C" void dError (int num, const char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - if (error_function) error_function (num,msg,ap); - else printMessage (num,"ODE Error",msg,ap); - exit (1); -} - - -extern "C" void dDebug (int num, const char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - if (debug_function) debug_function (num,msg,ap); - else printMessage (num,"ODE INTERNAL ERROR",msg,ap); - // *((char *)0) = 0; ... commit SEGVicide - abort(); -} - - -extern "C" void dMessage (int num, const char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - if (message_function) message_function (num,msg,ap); - else printMessage (num,"ODE Message",msg,ap); -} - -#endif - -//**************************************************************************** -// windows - -#ifdef WIN32 - -// isn't cygwin annoying! -#ifdef CYGWIN -#define _snprintf snprintf -#define _vsnprintf vsnprintf -#endif - - -#include "windows.h" - - -extern "C" void dError (int num, const char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - if (error_function) error_function (num,msg,ap); - else { - char s[1000],title[100]; - _snprintf (title,sizeof(title),"ODE Error %d",num); - _vsnprintf (s,sizeof(s),msg,ap); - s[sizeof(s)-1] = 0; - MessageBox(0,s,title,MB_OK | MB_ICONWARNING); - } - exit (1); -} - - -extern "C" void dDebug (int num, const char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - if (debug_function) debug_function (num,msg,ap); - else { - char s[1000],title[100]; - _snprintf (title,sizeof(title),"ODE INTERNAL ERROR %d",num); - _vsnprintf (s,sizeof(s),msg,ap); - s[sizeof(s)-1] = 0; - MessageBox(0,s,title,MB_OK | MB_ICONSTOP); - } - abort(); -} - - -extern "C" void dMessage (int num, const char *msg, ...) -{ - va_list ap; - va_start (ap,msg); - if (message_function) message_function (num,msg,ap); - else printMessage (num,"ODE Message",msg,ap); -} - - -#endif diff --git a/extern/ode/dist/ode/src/fastdot.c b/extern/ode/dist/ode/src/fastdot.c deleted file mode 100644 index 148d2dd9e17..00000000000 --- a/extern/ode/dist/ode/src/fastdot.c +++ /dev/null @@ -1,30 +0,0 @@ -/* generated code, do not edit. */ - -#include "ode/matrix.h" - - -dReal dDot (const dReal *a, const dReal *b, int n) -{ - dReal p0,q0,m0,p1,q1,m1,sum; - sum = 0; - n -= 2; - while (n >= 0) { - p0 = a[0]; q0 = b[0]; - m0 = p0 * q0; - p1 = a[1]; q1 = b[1]; - m1 = p1 * q1; - sum += m0; - sum += m1; - a += 2; - b += 2; - n -= 2; - } - n += 2; - while (n > 0) { - sum += (*a) * (*b); - a++; - b++; - n--; - } - return sum; -} diff --git a/extern/ode/dist/ode/src/fastldlt.c b/extern/ode/dist/ode/src/fastldlt.c deleted file mode 100644 index df2ea6ec229..00000000000 --- a/extern/ode/dist/ode/src/fastldlt.c +++ /dev/null @@ -1,381 +0,0 @@ -/* generated code, do not edit. */ - -#include "ode/matrix.h" - -/* solve L*X=B, with B containing 1 right hand sides. - * L is an n*n lower triangular matrix with ones on the diagonal. - * L is stored by rows and its leading dimension is lskip. - * B is an n*1 matrix that contains the right hand sides. - * B is stored by columns and its leading dimension is also lskip. - * B is overwritten with X. - * this processes blocks of 2*2. - * if this is in the factorizer source file, n must be a multiple of 2. - */ - -static void dSolveL1_1 (const dReal *L, dReal *B, int n, int lskip1) -{ - /* declare variables - Z matrix, p and q vectors, etc */ - dReal Z11,m11,Z21,m21,p1,q1,p2,*ex; - const dReal *ell; - int i,j; - /* compute all 2 x 1 blocks of X */ - for (i=0; i < n; i+=2) { - /* compute all 2 x 1 block of X, from rows i..i+2-1 */ - /* set the Z matrix to 0 */ - Z11=0; - Z21=0; - ell = L + i*lskip1; - ex = B; - /* the inner loop that computes outer products and adds them to Z */ - for (j=i-2; j >= 0; j -= 2) { - /* compute outer product and add it to the Z matrix */ - p1=ell[0]; - q1=ex[0]; - m11 = p1 * q1; - p2=ell[lskip1]; - m21 = p2 * q1; - Z11 += m11; - Z21 += m21; - /* compute outer product and add it to the Z matrix */ - p1=ell[1]; - q1=ex[1]; - m11 = p1 * q1; - p2=ell[1+lskip1]; - m21 = p2 * q1; - /* advance pointers */ - ell += 2; - ex += 2; - Z11 += m11; - Z21 += m21; - /* end of inner loop */ - } - /* compute left-over iterations */ - j += 2; - for (; j > 0; j--) { - /* compute outer product and add it to the Z matrix */ - p1=ell[0]; - q1=ex[0]; - m11 = p1 * q1; - p2=ell[lskip1]; - m21 = p2 * q1; - /* advance pointers */ - ell += 1; - ex += 1; - Z11 += m11; - Z21 += m21; - } - /* finish computing the X(i) block */ - Z11 = ex[0] - Z11; - ex[0] = Z11; - p1 = ell[lskip1]; - Z21 = ex[1] - Z21 - p1*Z11; - ex[1] = Z21; - /* end of outer loop */ - } -} - -/* solve L*X=B, with B containing 2 right hand sides. - * L is an n*n lower triangular matrix with ones on the diagonal. - * L is stored by rows and its leading dimension is lskip. - * B is an n*2 matrix that contains the right hand sides. - * B is stored by columns and its leading dimension is also lskip. - * B is overwritten with X. - * this processes blocks of 2*2. - * if this is in the factorizer source file, n must be a multiple of 2. - */ - -static void dSolveL1_2 (const dReal *L, dReal *B, int n, int lskip1) -{ - /* declare variables - Z matrix, p and q vectors, etc */ - dReal Z11,m11,Z12,m12,Z21,m21,Z22,m22,p1,q1,p2,q2,*ex; - const dReal *ell; - int i,j; - /* compute all 2 x 2 blocks of X */ - for (i=0; i < n; i+=2) { - /* compute all 2 x 2 block of X, from rows i..i+2-1 */ - /* set the Z matrix to 0 */ - Z11=0; - Z12=0; - Z21=0; - Z22=0; - ell = L + i*lskip1; - ex = B; - /* the inner loop that computes outer products and adds them to Z */ - for (j=i-2; j >= 0; j -= 2) { - /* compute outer product and add it to the Z matrix */ - p1=ell[0]; - q1=ex[0]; - m11 = p1 * q1; - q2=ex[lskip1]; - m12 = p1 * q2; - p2=ell[lskip1]; - m21 = p2 * q1; - m22 = p2 * q2; - Z11 += m11; - Z12 += m12; - Z21 += m21; - Z22 += m22; - /* compute outer product and add it to the Z matrix */ - p1=ell[1]; - q1=ex[1]; - m11 = p1 * q1; - q2=ex[1+lskip1]; - m12 = p1 * q2; - p2=ell[1+lskip1]; - m21 = p2 * q1; - m22 = p2 * q2; - /* advance pointers */ - ell += 2; - ex += 2; - Z11 += m11; - Z12 += m12; - Z21 += m21; - Z22 += m22; - /* end of inner loop */ - } - /* compute left-over iterations */ - j += 2; - for (; j > 0; j--) { - /* compute outer product and add it to the Z matrix */ - p1=ell[0]; - q1=ex[0]; - m11 = p1 * q1; - q2=ex[lskip1]; - m12 = p1 * q2; - p2=ell[lskip1]; - m21 = p2 * q1; - m22 = p2 * q2; - /* advance pointers */ - ell += 1; - ex += 1; - Z11 += m11; - Z12 += m12; - Z21 += m21; - Z22 += m22; - } - /* finish computing the X(i) block */ - Z11 = ex[0] - Z11; - ex[0] = Z11; - Z12 = ex[lskip1] - Z12; - ex[lskip1] = Z12; - p1 = ell[lskip1]; - Z21 = ex[1] - Z21 - p1*Z11; - ex[1] = Z21; - Z22 = ex[1+lskip1] - Z22 - p1*Z12; - ex[1+lskip1] = Z22; - /* end of outer loop */ - } -} - - -void dFactorLDLT (dReal *A, dReal *d, int n, int nskip1) -{ - int i,j; - dReal sum,*ell,*dee,dd,p1,p2,q1,q2,Z11,m11,Z21,m21,Z22,m22; - if (n < 1) return; - - for (i=0; i<=n-2; i += 2) { - /* solve L*(D*l)=a, l is scaled elements in 2 x i block at A(i,0) */ - dSolveL1_2 (A,A+i*nskip1,i,nskip1); - /* scale the elements in a 2 x i block at A(i,0), and also */ - /* compute Z = the outer product matrix that we'll need. */ - Z11 = 0; - Z21 = 0; - Z22 = 0; - ell = A+i*nskip1; - dee = d; - for (j=i-6; j >= 0; j -= 6) { - p1 = ell[0]; - p2 = ell[nskip1]; - dd = dee[0]; - q1 = p1*dd; - q2 = p2*dd; - ell[0] = q1; - ell[nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - p1 = ell[1]; - p2 = ell[1+nskip1]; - dd = dee[1]; - q1 = p1*dd; - q2 = p2*dd; - ell[1] = q1; - ell[1+nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - p1 = ell[2]; - p2 = ell[2+nskip1]; - dd = dee[2]; - q1 = p1*dd; - q2 = p2*dd; - ell[2] = q1; - ell[2+nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - p1 = ell[3]; - p2 = ell[3+nskip1]; - dd = dee[3]; - q1 = p1*dd; - q2 = p2*dd; - ell[3] = q1; - ell[3+nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - p1 = ell[4]; - p2 = ell[4+nskip1]; - dd = dee[4]; - q1 = p1*dd; - q2 = p2*dd; - ell[4] = q1; - ell[4+nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - p1 = ell[5]; - p2 = ell[5+nskip1]; - dd = dee[5]; - q1 = p1*dd; - q2 = p2*dd; - ell[5] = q1; - ell[5+nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - ell += 6; - dee += 6; - } - /* compute left-over iterations */ - j += 6; - for (; j > 0; j--) { - p1 = ell[0]; - p2 = ell[nskip1]; - dd = dee[0]; - q1 = p1*dd; - q2 = p2*dd; - ell[0] = q1; - ell[nskip1] = q2; - m11 = p1*q1; - m21 = p2*q1; - m22 = p2*q2; - Z11 += m11; - Z21 += m21; - Z22 += m22; - ell++; - dee++; - } - /* solve for diagonal 2 x 2 block at A(i,i) */ - Z11 = ell[0] - Z11; - Z21 = ell[nskip1] - Z21; - Z22 = ell[1+nskip1] - Z22; - dee = d + i; - /* factorize 2 x 2 block Z,dee */ - /* factorize row 1 */ - dee[0] = dRecip(Z11); - /* factorize row 2 */ - sum = 0; - q1 = Z21; - q2 = q1 * dee[0]; - Z21 = q2; - sum += q1*q2; - dee[1] = dRecip(Z22 - sum); - /* done factorizing 2 x 2 block */ - ell[nskip1] = Z21; - } - /* compute the (less than 2) rows at the bottom */ - switch (n-i) { - case 0: - break; - - case 1: - dSolveL1_1 (A,A+i*nskip1,i,nskip1); - /* scale the elements in a 1 x i block at A(i,0), and also */ - /* compute Z = the outer product matrix that we'll need. */ - Z11 = 0; - ell = A+i*nskip1; - dee = d; - for (j=i-6; j >= 0; j -= 6) { - p1 = ell[0]; - dd = dee[0]; - q1 = p1*dd; - ell[0] = q1; - m11 = p1*q1; - Z11 += m11; - p1 = ell[1]; - dd = dee[1]; - q1 = p1*dd; - ell[1] = q1; - m11 = p1*q1; - Z11 += m11; - p1 = ell[2]; - dd = dee[2]; - q1 = p1*dd; - ell[2] = q1; - m11 = p1*q1; - Z11 += m11; - p1 = ell[3]; - dd = dee[3]; - q1 = p1*dd; - ell[3] = q1; - m11 = p1*q1; - Z11 += m11; - p1 = ell[4]; - dd = dee[4]; - q1 = p1*dd; - ell[4] = q1; - m11 = p1*q1; - Z11 += m11; - p1 = ell[5]; - dd = dee[5]; - q1 = p1*dd; - ell[5] = q1; - m11 = p1*q1; - Z11 += m11; - ell += 6; - dee += 6; - } - /* compute left-over iterations */ - j += 6; - for (; j > 0; j--) { - p1 = ell[0]; - dd = dee[0]; - q1 = p1*dd; - ell[0] = q1; - m11 = p1*q1; - Z11 += m11; - ell++; - dee++; - } - /* solve for diagonal 1 x 1 block at A(i,i) */ - Z11 = ell[0] - Z11; - dee = d + i; - /* factorize 1 x 1 block Z,dee */ - /* factorize row 1 */ - dee[0] = dRecip(Z11); - /* done factorizing 1 x 1 block */ - break; - - default: *((char*)0)=0; /* this should never happen! */ - } -} diff --git a/extern/ode/dist/ode/src/fastlsolve.c b/extern/ode/dist/ode/src/fastlsolve.c deleted file mode 100644 index 0ae99d62d0b..00000000000 --- a/extern/ode/dist/ode/src/fastlsolve.c +++ /dev/null @@ -1,298 +0,0 @@ -/* generated code, do not edit. */ - -#include "ode/matrix.h" - -/* solve L*X=B, with B containing 1 right hand sides. - * L is an n*n lower triangular matrix with ones on the diagonal. - * L is stored by rows and its leading dimension is lskip. - * B is an n*1 matrix that contains the right hand sides. - * B is stored by columns and its leading dimension is also lskip. - * B is overwritten with X. - * this processes blocks of 4*4. - * if this is in the factorizer source file, n must be a multiple of 4. - */ - -void dSolveL1 (const dReal *L, dReal *B, int n, int lskip1) -{ - /* declare variables - Z matrix, p and q vectors, etc */ - dReal Z11,Z21,Z31,Z41,p1,q1,p2,p3,p4,*ex; - const dReal *ell; - int lskip2,lskip3,i,j; - /* compute lskip values */ - lskip2 = 2*lskip1; - lskip3 = 3*lskip1; - /* compute all 4 x 1 blocks of X */ - for (i=0; i <= n-4; i+=4) { - /* compute all 4 x 1 block of X, from rows i..i+4-1 */ - /* set the Z matrix to 0 */ - Z11=0; - Z21=0; - Z31=0; - Z41=0; - ell = L + i*lskip1; - ex = B; - /* the inner loop that computes outer products and adds them to Z */ - for (j=i-12; j >= 0; j -= 12) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - p2=ell[lskip1]; - p3=ell[lskip2]; - p4=ell[lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[1]; - q1=ex[1]; - p2=ell[1+lskip1]; - p3=ell[1+lskip2]; - p4=ell[1+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[2]; - q1=ex[2]; - p2=ell[2+lskip1]; - p3=ell[2+lskip2]; - p4=ell[2+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[3]; - q1=ex[3]; - p2=ell[3+lskip1]; - p3=ell[3+lskip2]; - p4=ell[3+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[4]; - q1=ex[4]; - p2=ell[4+lskip1]; - p3=ell[4+lskip2]; - p4=ell[4+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[5]; - q1=ex[5]; - p2=ell[5+lskip1]; - p3=ell[5+lskip2]; - p4=ell[5+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[6]; - q1=ex[6]; - p2=ell[6+lskip1]; - p3=ell[6+lskip2]; - p4=ell[6+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[7]; - q1=ex[7]; - p2=ell[7+lskip1]; - p3=ell[7+lskip2]; - p4=ell[7+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[8]; - q1=ex[8]; - p2=ell[8+lskip1]; - p3=ell[8+lskip2]; - p4=ell[8+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[9]; - q1=ex[9]; - p2=ell[9+lskip1]; - p3=ell[9+lskip2]; - p4=ell[9+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[10]; - q1=ex[10]; - p2=ell[10+lskip1]; - p3=ell[10+lskip2]; - p4=ell[10+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* load p and q values */ - p1=ell[11]; - q1=ex[11]; - p2=ell[11+lskip1]; - p3=ell[11+lskip2]; - p4=ell[11+lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* advance pointers */ - ell += 12; - ex += 12; - /* end of inner loop */ - } - /* compute left-over iterations */ - j += 12; - for (; j > 0; j--) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - p2=ell[lskip1]; - p3=ell[lskip2]; - p4=ell[lskip3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - Z21 += p2 * q1; - Z31 += p3 * q1; - Z41 += p4 * q1; - /* advance pointers */ - ell += 1; - ex += 1; - } - /* finish computing the X(i) block */ - Z11 = ex[0] - Z11; - ex[0] = Z11; - p1 = ell[lskip1]; - Z21 = ex[1] - Z21 - p1*Z11; - ex[1] = Z21; - p1 = ell[lskip2]; - p2 = ell[1+lskip2]; - Z31 = ex[2] - Z31 - p1*Z11 - p2*Z21; - ex[2] = Z31; - p1 = ell[lskip3]; - p2 = ell[1+lskip3]; - p3 = ell[2+lskip3]; - Z41 = ex[3] - Z41 - p1*Z11 - p2*Z21 - p3*Z31; - ex[3] = Z41; - /* end of outer loop */ - } - /* compute rows at end that are not a multiple of block size */ - for (; i < n; i++) { - /* compute all 1 x 1 block of X, from rows i..i+1-1 */ - /* set the Z matrix to 0 */ - Z11=0; - ell = L + i*lskip1; - ex = B; - /* the inner loop that computes outer products and adds them to Z */ - for (j=i-12; j >= 0; j -= 12) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[1]; - q1=ex[1]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[2]; - q1=ex[2]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[3]; - q1=ex[3]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[4]; - q1=ex[4]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[5]; - q1=ex[5]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[6]; - q1=ex[6]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[7]; - q1=ex[7]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[8]; - q1=ex[8]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[9]; - q1=ex[9]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[10]; - q1=ex[10]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* load p and q values */ - p1=ell[11]; - q1=ex[11]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* advance pointers */ - ell += 12; - ex += 12; - /* end of inner loop */ - } - /* compute left-over iterations */ - j += 12; - for (; j > 0; j--) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - /* compute outer product and add it to the Z matrix */ - Z11 += p1 * q1; - /* advance pointers */ - ell += 1; - ex += 1; - } - /* finish computing the X(i) block */ - Z11 = ex[0] - Z11; - ex[0] = Z11; - } -} diff --git a/extern/ode/dist/ode/src/fastltsolve.c b/extern/ode/dist/ode/src/fastltsolve.c deleted file mode 100644 index eb950f6076a..00000000000 --- a/extern/ode/dist/ode/src/fastltsolve.c +++ /dev/null @@ -1,199 +0,0 @@ -/* generated code, do not edit. */ - -#include "ode/matrix.h" - -/* solve L^T * x=b, with b containing 1 right hand side. - * L is an n*n lower triangular matrix with ones on the diagonal. - * L is stored by rows and its leading dimension is lskip. - * b is an n*1 matrix that contains the right hand side. - * b is overwritten with x. - * this processes blocks of 4. - */ - -void dSolveL1T (const dReal *L, dReal *B, int n, int lskip1) -{ - /* declare variables - Z matrix, p and q vectors, etc */ - dReal Z11,m11,Z21,m21,Z31,m31,Z41,m41,p1,q1,p2,p3,p4,*ex; - const dReal *ell; - int lskip2,lskip3,i,j; - /* special handling for L and B because we're solving L1 *transpose* */ - L = L + (n-1)*(lskip1+1); - B = B + n-1; - lskip1 = -lskip1; - /* compute lskip values */ - lskip2 = 2*lskip1; - lskip3 = 3*lskip1; - /* compute all 4 x 1 blocks of X */ - for (i=0; i <= n-4; i+=4) { - /* compute all 4 x 1 block of X, from rows i..i+4-1 */ - /* set the Z matrix to 0 */ - Z11=0; - Z21=0; - Z31=0; - Z41=0; - ell = L - i; - ex = B; - /* the inner loop that computes outer products and adds them to Z */ - for (j=i-4; j >= 0; j -= 4) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - p2=ell[-1]; - p3=ell[-2]; - p4=ell[-3]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - m21 = p2 * q1; - m31 = p3 * q1; - m41 = p4 * q1; - ell += lskip1; - Z11 += m11; - Z21 += m21; - Z31 += m31; - Z41 += m41; - /* load p and q values */ - p1=ell[0]; - q1=ex[-1]; - p2=ell[-1]; - p3=ell[-2]; - p4=ell[-3]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - m21 = p2 * q1; - m31 = p3 * q1; - m41 = p4 * q1; - ell += lskip1; - Z11 += m11; - Z21 += m21; - Z31 += m31; - Z41 += m41; - /* load p and q values */ - p1=ell[0]; - q1=ex[-2]; - p2=ell[-1]; - p3=ell[-2]; - p4=ell[-3]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - m21 = p2 * q1; - m31 = p3 * q1; - m41 = p4 * q1; - ell += lskip1; - Z11 += m11; - Z21 += m21; - Z31 += m31; - Z41 += m41; - /* load p and q values */ - p1=ell[0]; - q1=ex[-3]; - p2=ell[-1]; - p3=ell[-2]; - p4=ell[-3]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - m21 = p2 * q1; - m31 = p3 * q1; - m41 = p4 * q1; - ell += lskip1; - ex -= 4; - Z11 += m11; - Z21 += m21; - Z31 += m31; - Z41 += m41; - /* end of inner loop */ - } - /* compute left-over iterations */ - j += 4; - for (; j > 0; j--) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - p2=ell[-1]; - p3=ell[-2]; - p4=ell[-3]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - m21 = p2 * q1; - m31 = p3 * q1; - m41 = p4 * q1; - ell += lskip1; - ex -= 1; - Z11 += m11; - Z21 += m21; - Z31 += m31; - Z41 += m41; - } - /* finish computing the X(i) block */ - Z11 = ex[0] - Z11; - ex[0] = Z11; - p1 = ell[-1]; - Z21 = ex[-1] - Z21 - p1*Z11; - ex[-1] = Z21; - p1 = ell[-2]; - p2 = ell[-2+lskip1]; - Z31 = ex[-2] - Z31 - p1*Z11 - p2*Z21; - ex[-2] = Z31; - p1 = ell[-3]; - p2 = ell[-3+lskip1]; - p3 = ell[-3+lskip2]; - Z41 = ex[-3] - Z41 - p1*Z11 - p2*Z21 - p3*Z31; - ex[-3] = Z41; - /* end of outer loop */ - } - /* compute rows at end that are not a multiple of block size */ - for (; i < n; i++) { - /* compute all 1 x 1 block of X, from rows i..i+1-1 */ - /* set the Z matrix to 0 */ - Z11=0; - ell = L - i; - ex = B; - /* the inner loop that computes outer products and adds them to Z */ - for (j=i-4; j >= 0; j -= 4) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - ell += lskip1; - Z11 += m11; - /* load p and q values */ - p1=ell[0]; - q1=ex[-1]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - ell += lskip1; - Z11 += m11; - /* load p and q values */ - p1=ell[0]; - q1=ex[-2]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - ell += lskip1; - Z11 += m11; - /* load p and q values */ - p1=ell[0]; - q1=ex[-3]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - ell += lskip1; - ex -= 4; - Z11 += m11; - /* end of inner loop */ - } - /* compute left-over iterations */ - j += 4; - for (; j > 0; j--) { - /* load p and q values */ - p1=ell[0]; - q1=ex[0]; - /* compute outer product and add it to the Z matrix */ - m11 = p1 * q1; - ell += lskip1; - ex -= 1; - Z11 += m11; - } - /* finish computing the X(i) block */ - Z11 = ex[0] - Z11; - ex[0] = Z11; - } -} diff --git a/extern/ode/dist/ode/src/geom.cpp b/extern/ode/dist/ode/src/geom.cpp deleted file mode 100644 index 1818814a791..00000000000 --- a/extern/ode/dist/ode/src/geom.cpp +++ /dev/null @@ -1,2207 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -the rule is that only the low level primitive collision functions should set -dContactGeom::g1 and dContactGeom::g2. - -*/ - -#define SHARED_GEOM_H_INCLUDED_FROM_DEFINING_FILE 1 -#include <ode/common.h> -#include <ode/geom.h> -#include <ode/rotation.h> -#include <ode/odemath.h> -#include <ode/memory.h> -#include <ode/misc.h> -#include <ode/objects.h> -#include <ode/matrix.h> -#include "objects.h" -#include "array.h" -#include "geom_internal.h" - -//**************************************************************************** -// collision utilities. - -// given a pointer `p' to a dContactGeom, return the dContactGeom at -// p + skip bytes. - -#define CONTACT(p,skip) ((dContactGeom*) (((char*)p) + (skip))) - - -// if the spheres (p1,r1) and (p2,r2) collide, set the contact `c' and -// return 1, else return 0. - -static int dCollideSpheres (dVector3 p1, dReal r1, - dVector3 p2, dReal r2, dContactGeom *c) -{ - // printf ("d=%.2f (%.2f %.2f %.2f) (%.2f %.2f %.2f) r1=%.2f r2=%.2f\n", - // d,p1[0],p1[1],p1[2],p2[0],p2[1],p2[2],r1,r2); - - dReal d = dDISTANCE (p1,p2); - if (d > (r1 + r2)) return 0; - if (d <= 0) { - c->pos[0] = p1[0]; - c->pos[1] = p1[1]; - c->pos[2] = p1[2]; - c->normal[0] = 1; - c->normal[1] = 0; - c->normal[2] = 0; - c->depth = r1 + r2; - } - else { - dReal d1 = dRecip (d); - c->normal[0] = (p1[0]-p2[0])*d1; - c->normal[1] = (p1[1]-p2[1])*d1; - c->normal[2] = (p1[2]-p2[2])*d1; - dReal k = REAL(0.5) * (r2 - r1 - d); - c->pos[0] = p1[0] + c->normal[0]*k; - c->pos[1] = p1[1] + c->normal[1]*k; - c->pos[2] = p1[2] + c->normal[2]*k; - c->depth = r1 + r2 - d; - } - return 1; -} - - -// given two lines -// qa = pa + alpha* ua -// qb = pb + beta * ub -// where pa,pb are two points, ua,ub are two unit length vectors, and alpha, -// beta go from [-inf,inf], return alpha and beta such that qa and qb are -// as close as possible - -static void lineClosestApproach (const dVector3 pa, const dVector3 ua, - const dVector3 pb, const dVector3 ub, - dReal *alpha, dReal *beta) -{ - dVector3 p; - p[0] = pb[0] - pa[0]; - p[1] = pb[1] - pa[1]; - p[2] = pb[2] - pa[2]; - dReal uaub = dDOT(ua,ub); - dReal q1 = dDOT(ua,p); - dReal q2 = -dDOT(ub,p); - dReal d = 1-uaub*uaub; - if (d <= 0) { - // @@@ this needs to be made more robust - *alpha = 0; - *beta = 0; - } - else { - d = dRecip(d); - *alpha = (q1 + uaub*q2)*d; - *beta = (uaub*q1 + q2)*d; - } -} - - -// given two line segments A and B with endpoints a1-a2 and b1-b2, return the -// points on A and B that are closest to each other (in cp1 and cp2). -// in the case of parallel lines where there are multiple solutions, a -// solution involving the endpoint of at least one line will be returned. -// this will work correctly for zero length lines, e.g. if a1==a2 and/or -// b1==b2. -// -// the algorithm works by applying the voronoi clipping rule to the features -// of the line segments. the three features of each line segment are the two -// endpoints and the line between them. the voronoi clipping rule states that, -// for feature X on line A and feature Y on line B, the closest points PA and -// PB between X and Y are globally the closest points if PA is in V(Y) and -// PB is in V(X), where V(X) is the voronoi region of X. - - -void dClosestLineSegmentPoints (dVector3 const a1, dVector3 const a2, - dVector3 const b1, dVector3 const b2, - dVector3 cp1, dVector3 cp2) -{ - dVector3 a1a2,b1b2,a1b1,a1b2,a2b1,a2b2,n; - dReal la,lb,k,da1,da2,da3,da4,db1,db2,db3,db4,det; - -#define SET2(a,b) a[0]=b[0]; a[1]=b[1]; a[2]=b[2]; -#define SET3(a,b,op,c) a[0]=b[0] op c[0]; a[1]=b[1] op c[1]; a[2]=b[2] op c[2]; - - // check vertex-vertex features - - SET3 (a1a2,a2,-,a1); - SET3 (b1b2,b2,-,b1); - SET3 (a1b1,b1,-,a1); - da1 = dDOT(a1a2,a1b1); - db1 = dDOT(b1b2,a1b1); - if (da1 <= 0 && db1 >= 0) { - SET2 (cp1,a1); - SET2 (cp2,b1); - return; - } - - SET3 (a1b2,b2,-,a1); - da2 = dDOT(a1a2,a1b2); - db2 = dDOT(b1b2,a1b2); - if (da2 <= 0 && db2 <= 0) { - SET2 (cp1,a1); - SET2 (cp2,b2); - return; - } - - SET3 (a2b1,b1,-,a2); - da3 = dDOT(a1a2,a2b1); - db3 = dDOT(b1b2,a2b1); - if (da3 >= 0 && db3 >= 0) { - SET2 (cp1,a2); - SET2 (cp2,b1); - return; - } - - SET3 (a2b2,b2,-,a2); - da4 = dDOT(a1a2,a2b2); - db4 = dDOT(b1b2,a2b2); - if (da4 >= 0 && db4 <= 0) { - SET2 (cp1,a2); - SET2 (cp2,b2); - return; - } - - // check edge-vertex features. - // if one or both of the lines has zero length, we will never get to here, - // so we do not have to worry about the following divisions by zero. - - la = dDOT(a1a2,a1a2); - if (da1 >= 0 && da3 <= 0) { - k = da1 / la; - SET3 (n,a1b1,-,k*a1a2); - if (dDOT(b1b2,n) >= 0) { - SET3 (cp1,a1,+,k*a1a2); - SET2 (cp2,b1); - return; - } - } - - if (da2 >= 0 && da4 <= 0) { - k = da2 / la; - SET3 (n,a1b2,-,k*a1a2); - if (dDOT(b1b2,n) <= 0) { - SET3 (cp1,a1,+,k*a1a2); - SET2 (cp2,b2); - return; - } - } - - lb = dDOT(b1b2,b1b2); - if (db1 <= 0 && db2 >= 0) { - k = -db1 / lb; - SET3 (n,-a1b1,-,k*b1b2); - if (dDOT(a1a2,n) >= 0) { - SET2 (cp1,a1); - SET3 (cp2,b1,+,k*b1b2); - return; - } - } - - if (db3 <= 0 && db4 >= 0) { - k = -db3 / lb; - SET3 (n,-a2b1,-,k*b1b2); - if (dDOT(a1a2,n) <= 0) { - SET2 (cp1,a2); - SET3 (cp2,b1,+,k*b1b2); - return; - } - } - - // it must be edge-edge - - k = dDOT(a1a2,b1b2); - det = la*lb - k*k; - if (det <= 0) { - // this should never happen, but just in case... - SET2(cp1,a1); - SET2(cp2,b1); - return; - } - det = dRecip (det); - dReal alpha = (lb*da1 - k*db1) * det; - dReal beta = ( k*da1 - la*db1) * det; - SET3 (cp1,a1,+,alpha*a1a2); - SET3 (cp2,b1,+,beta*b1b2); - -# undef SET2 -# undef SET3 -} - - -// given a line segment p1-p2 and a box (center 'c', rotation 'R', side length -// vector 'side'), compute the points of closest approach between the box -// and the line. return these points in 'lret' (the point on the line) and -// 'bret' (the point on the box). if the line actually penetrates the box -// then the solution is not unique, but only one solution will be returned. -// in this case the solution points will coincide. -// -// a simple root finding algorithm is used to find the value of 't' that -// satisfies: -// d|D(t)|^2/dt = 0 -// where: -// |D(t)| = |p(t)-b(t)| -// where p(t) is a point on the line parameterized by t: -// p(t) = p1 + t*(p2-p1) -// and b(t) is that same point clipped to the boundary of the box. in box- -// relative coordinates d|D(t)|^2/dt is the sum of three x,y,z components -// each of which looks like this: -// -// t_lo / -// ______/ -->t -// / t_hi -// / -// -// t_lo and t_hi are the t values where the line passes through the planes -// corresponding to the sides of the box. the algorithm computes d|D(t)|^2/dt -// in a piecewise fashion from t=0 to t=1, stopping at the point where -// d|D(t)|^2/dt crosses from negative to positive. - -static void dClosestLineBoxPoints (const dVector3 p1, const dVector3 p2, - const dVector3 c, const dMatrix3 R, - const dVector3 side, - dVector3 lret, dVector3 bret) -{ - int i; - - // compute the start and delta of the line p1-p2 relative to the box. - // we will do all subsequent computations in this box-relative coordinate - // system. we have to do a translation and rotation for each point. - dVector3 tmp,s,v; - tmp[0] = p1[0] - c[0]; - tmp[1] = p1[1] - c[1]; - tmp[2] = p1[2] - c[2]; - dMULTIPLY1_331 (s,R,tmp); - tmp[0] = p2[0] - p1[0]; - tmp[1] = p2[1] - p1[1]; - tmp[2] = p2[2] - p1[2]; - dMULTIPLY1_331 (v,R,tmp); - - // mirror the line so that v has all components >= 0 - dVector3 sign; - for (i=0; i<3; i++) { - if (v[i] < 0) { - s[i] = -s[i]; - v[i] = -v[i]; - sign[i] = -1; - } - else sign[i] = 1; - } - - // compute v^2 - dVector3 v2; - v2[0] = v[0]*v[0]; - v2[1] = v[1]*v[1]; - v2[2] = v[2]*v[2]; - - // compute the half-sides of the box - dReal h[3]; - h[0] = REAL(0.5) * side[0]; - h[1] = REAL(0.5) * side[1]; - h[2] = REAL(0.5) * side[2]; - - // region is -1,0,+1 depending on which side of the box planes each - // coordinate is on. tanchor in the next t value at which there is a - // transition, or the last one if there are no more. - int region[3]; - dReal tanchor[3]; - - // find the region and tanchor values for p1 - for (i=0; i<3; i++) { - if (v[i] > 0) { - if (s[i] < -h[i]) { - region[i] = -1; - tanchor[i] = (-h[i]-s[i])/v[i]; - } - else { - region[i] = (s[i] > h[i]); - tanchor[i] = (h[i]-s[i])/v[i]; - } - } - else { - region[i] = 0; - tanchor[i] = 2; // this will never be a valid tanchor - } - } - - // compute d|d|^2/dt for t=0. if it's >= 0 then p1 is the closest point - dReal t=0; - dReal dd2dt = 0; - for (i=0; i<3; i++) dd2dt -= (region[i] ? v2[i] : 0) * tanchor[i]; - if (dd2dt >= 0) goto got_answer; - - do { - // find the point on the line that is at the next clip plane boundary - dReal next_t = 1; - for (i=0; i<3; i++) { - if (tanchor[i] > t && tanchor[i] < 1 && tanchor[i] < next_t) - next_t = tanchor[i]; - } - - // compute d|d|^2/dt for the next t - dReal next_dd2dt = 0; - for (i=0; i<3; i++) { - next_dd2dt += (region[i] ? v2[i] : 0) * (next_t - tanchor[i]); - } - - // if the sign of d|d|^2/dt has changed, solution = the crossover point - if (next_dd2dt >= 0) { - dReal m = (next_dd2dt-dd2dt)/(next_t - t); - t -= dd2dt/m; - goto got_answer; - } - - // advance to the next anchor point / region - for (i=0; i<3; i++) { - if (tanchor[i] == next_t) { - tanchor[i] = (h[i]-s[i])/v[i]; - region[i]++; - } - } - t = next_t; - dd2dt = next_dd2dt; - } - while (t < 1); - t = 1; - - got_answer: - - // compute closest point on the line - for (i=0; i<3; i++) lret[i] = p1[i] + t*tmp[i]; // note: tmp=p2-p1 - - // compute closest point on the box - for (i=0; i<3; i++) { - tmp[i] = sign[i] * (s[i] + t*v[i]); - if (tmp[i] < -h[i]) tmp[i] = -h[i]; - else if (tmp[i] > h[i]) tmp[i] = h[i]; - } - dMULTIPLY0_331 (s,R,tmp); - for (i=0; i<3; i++) bret[i] = s[i] + c[i]; -} - - -// given a box (R,side), `R' is the rotation matrix for the box, and `side' -// is a vector of x/y/z side lengths, return the size of the interval of the -// box projected along the given axis. if the axis has unit length then the -// return value will be the actual diameter, otherwise the result will be -// scaled by the axis length. - -static inline dReal boxDiameter (const dMatrix3 R, const dVector3 side, - const dVector3 axis) -{ - dVector3 q; - dMULTIPLY1_331 (q,R,axis); // transform axis to body-relative - return dFabs(q[0])*side[0] + dFabs(q[1])*side[1] + dFabs(q[2])*side[2]; -} - - -// given boxes (p1,R1,side1) and (p1,R1,side1), return 1 if they intersect -// or 0 if not. - -int dBoxTouchesBox (const dVector3 p1, const dMatrix3 R1, - const dVector3 side1, const dVector3 p2, - const dMatrix3 R2, const dVector3 side2) -{ - // two boxes are disjoint if (and only if) there is a separating axis - // perpendicular to a face from one box or perpendicular to an edge from - // either box. the following tests are derived from: - // "OBB Tree: A Hierarchical Structure for Rapid Interference Detection", - // S.Gottschalk, M.C.Lin, D.Manocha., Proc of ACM Siggraph 1996. - - // Rij is R1'*R2, i.e. the relative rotation between R1 and R2. - // Qij is abs(Rij) - dVector3 p,pp; - dReal A1,A2,A3,B1,B2,B3,R11,R12,R13,R21,R22,R23,R31,R32,R33, - Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33; - - // get vector from centers of box 1 to box 2, relative to box 1 - p[0] = p2[0] - p1[0]; - p[1] = p2[1] - p1[1]; - p[2] = p2[2] - p1[2]; - dMULTIPLY1_331 (pp,R1,p); // get pp = p relative to body 1 - - // get side lengths / 2 - A1 = side1[0]*REAL(0.5); A2 = side1[1]*REAL(0.5); A3 = side1[2]*REAL(0.5); - B1 = side2[0]*REAL(0.5); B2 = side2[1]*REAL(0.5); B3 = side2[2]*REAL(0.5); - - // for the following tests, excluding computation of Rij, in the worst case, - // 15 compares, 60 adds, 81 multiplies, and 24 absolutes. - // notation: R1=[u1 u2 u3], R2=[v1 v2 v3] - - // separating axis = u1,u2,u3 - R11 = dDOT44(R1+0,R2+0); R12 = dDOT44(R1+0,R2+1); R13 = dDOT44(R1+0,R2+2); - Q11 = dFabs(R11); Q12 = dFabs(R12); Q13 = dFabs(R13); - if (dFabs(pp[0]) > (A1 + B1*Q11 + B2*Q12 + B3*Q13)) return 0; - R21 = dDOT44(R1+1,R2+0); R22 = dDOT44(R1+1,R2+1); R23 = dDOT44(R1+1,R2+2); - Q21 = dFabs(R21); Q22 = dFabs(R22); Q23 = dFabs(R23); - if (dFabs(pp[1]) > (A2 + B1*Q21 + B2*Q22 + B3*Q23)) return 0; - R31 = dDOT44(R1+2,R2+0); R32 = dDOT44(R1+2,R2+1); R33 = dDOT44(R1+2,R2+2); - Q31 = dFabs(R31); Q32 = dFabs(R32); Q33 = dFabs(R33); - if (dFabs(pp[2]) > (A3 + B1*Q31 + B2*Q32 + B3*Q33)) return 0; - - // separating axis = v1,v2,v3 - if (dFabs(dDOT41(R2+0,p)) > (A1*Q11 + A2*Q21 + A3*Q31 + B1)) return 0; - if (dFabs(dDOT41(R2+1,p)) > (A1*Q12 + A2*Q22 + A3*Q32 + B2)) return 0; - if (dFabs(dDOT41(R2+2,p)) > (A1*Q13 + A2*Q23 + A3*Q33 + B3)) return 0; - - // separating axis = u1 x (v1,v2,v3) - if (dFabs(pp[2]*R21-pp[1]*R31) > A2*Q31 + A3*Q21 + B2*Q13 + B3*Q12) return 0; - if (dFabs(pp[2]*R22-pp[1]*R32) > A2*Q32 + A3*Q22 + B1*Q13 + B3*Q11) return 0; - if (dFabs(pp[2]*R23-pp[1]*R33) > A2*Q33 + A3*Q23 + B1*Q12 + B2*Q11) return 0; - - // separating axis = u2 x (v1,v2,v3) - if (dFabs(pp[0]*R31-pp[2]*R11) > A1*Q31 + A3*Q11 + B2*Q23 + B3*Q22) return 0; - if (dFabs(pp[0]*R32-pp[2]*R12) > A1*Q32 + A3*Q12 + B1*Q23 + B3*Q21) return 0; - if (dFabs(pp[0]*R33-pp[2]*R13) > A1*Q33 + A3*Q13 + B1*Q22 + B2*Q21) return 0; - - // separating axis = u3 x (v1,v2,v3) - if (dFabs(pp[1]*R11-pp[0]*R21) > A1*Q21 + A2*Q11 + B2*Q33 + B3*Q32) return 0; - if (dFabs(pp[1]*R12-pp[0]*R22) > A1*Q22 + A2*Q12 + B1*Q33 + B3*Q31) return 0; - if (dFabs(pp[1]*R13-pp[0]*R23) > A1*Q23 + A2*Q13 + B1*Q32 + B2*Q31) return 0; - - return 1; -} - - -// given two boxes (p1,R1,side1) and (p2,R2,side2), collide them together and -// generate contact points. this returns 0 if there is no contact otherwise -// it returns the number of contacts generated. -// `normal' returns the contact normal. -// `depth' returns the maximum penetration depth along that normal. -// `code' returns a number indicating the type of contact that was detected: -// 1,2,3 = box 2 intersects with a face of box 1 -// 4,5,6 = box 1 intersects with a face of box 2 -// 7..15 = edge-edge contact -// `maxc' is the maximum number of contacts allowed to be generated, i.e. -// the size of the `contact' array. -// `contact' and `skip' are the contact array information provided to the -// collision functions. this function only fills in the position and depth -// fields. -// -// @@@ some stuff to optimize here, reuse code in contact point calculations. - -extern "C" int dBoxBox (const dVector3 p1, const dMatrix3 R1, - const dVector3 side1, const dVector3 p2, - const dMatrix3 R2, const dVector3 side2, - dVector3 normal, dReal *depth, int *code, - int maxc, dContactGeom *contact, int skip) -{ - dVector3 p,pp,normalC; - const dReal *normalR = 0; - dReal A1,A2,A3,B1,B2,B3,R11,R12,R13,R21,R22,R23,R31,R32,R33, - Q11,Q12,Q13,Q21,Q22,Q23,Q31,Q32,Q33,s,s2,l; - int i,invert_normal; - - // get vector from centers of box 1 to box 2, relative to box 1 - p[0] = p2[0] - p1[0]; - p[1] = p2[1] - p1[1]; - p[2] = p2[2] - p1[2]; - dMULTIPLY1_331 (pp,R1,p); // get pp = p relative to body 1 - - // get side lengths / 2 - A1 = side1[0]*REAL(0.5); A2 = side1[1]*REAL(0.5); A3 = side1[2]*REAL(0.5); - B1 = side2[0]*REAL(0.5); B2 = side2[1]*REAL(0.5); B3 = side2[2]*REAL(0.5); - - // Rij is R1'*R2, i.e. the relative rotation between R1 and R2 - R11 = dDOT44(R1+0,R2+0); R12 = dDOT44(R1+0,R2+1); R13 = dDOT44(R1+0,R2+2); - R21 = dDOT44(R1+1,R2+0); R22 = dDOT44(R1+1,R2+1); R23 = dDOT44(R1+1,R2+2); - R31 = dDOT44(R1+2,R2+0); R32 = dDOT44(R1+2,R2+1); R33 = dDOT44(R1+2,R2+2); - - Q11 = dFabs(R11); Q12 = dFabs(R12); Q13 = dFabs(R13); - Q21 = dFabs(R21); Q22 = dFabs(R22); Q23 = dFabs(R23); - Q31 = dFabs(R31); Q32 = dFabs(R32); Q33 = dFabs(R33); - - // for all 15 possible separating axes: - // * see if the axis separates the boxes. if so, return 0. - // * find the depth of the penetration along the separating axis (s2) - // * if this is the largest depth so far, record it. - // the normal vector will be set to the separating axis with the smallest - // depth. note: normalR is set to point to a column of R1 or R2 if that is - // the smallest depth normal so far. otherwise normalR is 0 and normalC is - // set to a vector relative to body 1. invert_normal is 1 if the sign of - // the normal should be flipped. - -#define TEST(expr1,expr2,norm,cc) \ - s2 = dFabs(expr1) - (expr2); \ - if (s2 > 0) return 0; \ - if (s2 > s) { \ - s = s2; \ - normalR = norm; \ - invert_normal = ((expr1) < 0); \ - *code = (cc); \ - } - - s = -dInfinity; - invert_normal = 0; - *code = 0; - - // separating axis = u1,u2,u3 - TEST (pp[0],(A1 + B1*Q11 + B2*Q12 + B3*Q13),R1+0,1); - TEST (pp[1],(A2 + B1*Q21 + B2*Q22 + B3*Q23),R1+1,2); - TEST (pp[2],(A3 + B1*Q31 + B2*Q32 + B3*Q33),R1+2,3); - - // separating axis = v1,v2,v3 - TEST (dDOT41(R2+0,p),(A1*Q11 + A2*Q21 + A3*Q31 + B1),R2+0,4); - TEST (dDOT41(R2+1,p),(A1*Q12 + A2*Q22 + A3*Q32 + B2),R2+1,5); - TEST (dDOT41(R2+2,p),(A1*Q13 + A2*Q23 + A3*Q33 + B3),R2+2,6); - - // note: cross product axes need to be scaled when s is computed. - // normal (n1,n2,n3) is relative to box 1. -#undef TEST -#define TEST(expr1,expr2,n1,n2,n3,cc) \ - s2 = dFabs(expr1) - (expr2); \ - if (s2 > 0) return 0; \ - l = dSqrt ((n1)*(n1) + (n2)*(n2) + (n3)*(n3)); \ - if (l > 0) { \ - s2 /= l; \ - if (s2 > s) { \ - s = s2; \ - normalR = 0; \ - normalC[0] = (n1)/l; normalC[1] = (n2)/l; normalC[2] = (n3)/l; \ - invert_normal = ((expr1) < 0); \ - *code = (cc); \ - } \ - } - - // separating axis = u1 x (v1,v2,v3) - TEST(pp[2]*R21-pp[1]*R31,(A2*Q31+A3*Q21+B2*Q13+B3*Q12),0,-R31,R21,7); - TEST(pp[2]*R22-pp[1]*R32,(A2*Q32+A3*Q22+B1*Q13+B3*Q11),0,-R32,R22,8); - TEST(pp[2]*R23-pp[1]*R33,(A2*Q33+A3*Q23+B1*Q12+B2*Q11),0,-R33,R23,9); - - // separating axis = u2 x (v1,v2,v3) - TEST(pp[0]*R31-pp[2]*R11,(A1*Q31+A3*Q11+B2*Q23+B3*Q22),R31,0,-R11,10); - TEST(pp[0]*R32-pp[2]*R12,(A1*Q32+A3*Q12+B1*Q23+B3*Q21),R32,0,-R12,11); - TEST(pp[0]*R33-pp[2]*R13,(A1*Q33+A3*Q13+B1*Q22+B2*Q21),R33,0,-R13,12); - - // separating axis = u3 x (v1,v2,v3) - TEST(pp[1]*R11-pp[0]*R21,(A1*Q21+A2*Q11+B2*Q33+B3*Q32),-R21,R11,0,13); - TEST(pp[1]*R12-pp[0]*R22,(A1*Q22+A2*Q12+B1*Q33+B3*Q31),-R22,R12,0,14); - TEST(pp[1]*R13-pp[0]*R23,(A1*Q23+A2*Q13+B1*Q32+B2*Q31),-R23,R13,0,15); - -#undef TEST - - // if we get to this point, the boxes interpenetrate. compute the normal - // in global coordinates. - if (normalR) { - normal[0] = normalR[0]; - normal[1] = normalR[4]; - normal[2] = normalR[8]; - } - else { - dMULTIPLY0_331 (normal,R1,normalC); - } - if (invert_normal) { - normal[0] = -normal[0]; - normal[1] = -normal[1]; - normal[2] = -normal[2]; - } - *depth = -s; - - // compute contact point(s) - - if (*code > 6) { - // an edge from box 1 touches an edge from box 2. - // find a point pa on the intersecting edge of box 1 - dVector3 pa; - dReal sign; - for (i=0; i<3; i++) pa[i] = p1[i]; - sign = (dDOT14(normal,R1+0) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) pa[i] += sign * A1 * R1[i*4]; - sign = (dDOT14(normal,R1+1) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) pa[i] += sign * A2 * R1[i*4+1]; - sign = (dDOT14(normal,R1+2) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) pa[i] += sign * A3 * R1[i*4+2]; - - // find a point pb on the intersecting edge of box 2 - dVector3 pb; - for (i=0; i<3; i++) pb[i] = p2[i]; - sign = (dDOT14(normal,R2+0) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) pb[i] += sign * B1 * R2[i*4]; - sign = (dDOT14(normal,R2+1) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) pb[i] += sign * B2 * R2[i*4+1]; - sign = (dDOT14(normal,R2+2) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) pb[i] += sign * B3 * R2[i*4+2]; - - dReal alpha,beta; - dVector3 ua,ub; - for (i=0; i<3; i++) ua[i] = R1[((*code)-7)/3 + i*4]; - for (i=0; i<3; i++) ub[i] = R2[((*code)-7)%3 + i*4]; - - lineClosestApproach (pa,ua,pb,ub,&alpha,&beta); - for (i=0; i<3; i++) pa[i] += ua[i]*alpha; - for (i=0; i<3; i++) pb[i] += ub[i]*beta; - - for (i=0; i<3; i++) contact[0].pos[i] = REAL(0.5)*(pa[i]+pb[i]); - contact[0].depth = *depth; - return 1; - } - - // okay, we have a face-something intersection (because the separating - // axis is perpendicular to a face). - - // @@@ temporary: make deepest vertex on the "other" box the contact point. - // @@@ this kind of works, but we need multiple contact points for stability, - // @@@ especially for face-face contact. - - dVector3 vertex; - if (*code <= 3) { - // face from box 1 touches a vertex/edge/face from box 2. - dReal sign; - for (i=0; i<3; i++) vertex[i] = p2[i]; - sign = (dDOT14(normal,R2+0) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) vertex[i] += sign * B1 * R2[i*4]; - sign = (dDOT14(normal,R2+1) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) vertex[i] += sign * B2 * R2[i*4+1]; - sign = (dDOT14(normal,R2+2) > 0) ? REAL(-1.0) : REAL(1.0); - for (i=0; i<3; i++) vertex[i] += sign * B3 * R2[i*4+2]; - } - else { - // face from box 2 touches a vertex/edge/face from box 1. - dReal sign; - for (i=0; i<3; i++) vertex[i] = p1[i]; - sign = (dDOT14(normal,R1+0) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) vertex[i] += sign * A1 * R1[i*4]; - sign = (dDOT14(normal,R1+1) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) vertex[i] += sign * A2 * R1[i*4+1]; - sign = (dDOT14(normal,R1+2) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) vertex[i] += sign * A3 * R1[i*4+2]; - } - for (i=0; i<3; i++) contact[0].pos[i] = vertex[i]; - contact[0].depth = *depth; - return 1; -} - -//**************************************************************************** -// general support for geometry objects and classes - -struct dColliderEntry { - dColliderFn *fn; // collider function - int mode; // 1 = reverse o1 and o2, 2 = no function available -}; - -static dArray<dxGeomClass*> *classes=0; - -// function pointers and modes for n^2 class collider functions. this is an -// n*n matrix stored by row. the functions pointers are extracted from the -// class get-collider-function function. -static dArray<dColliderEntry> *colliders=0; - - -static inline void initCollisionArrays() -{ - if (classes==0) { - // old way: - // classes = (dArray<dxGeomClass*> *) dAllocNoFree (sizeof(dArrayBase)); - // classes->constructor(); - classes = new dArray<dxGeomClass*>; - classes->setSize (1); // force allocation of array data memory - dAllocDontReport (classes); - dAllocDontReport (classes->data()); - classes->setSize (0); - } - if (colliders==0) { - // old way: - // colliders=(dArray<dColliderEntry> *)dAllocNoFree (sizeof(dArrayBase)); - // colliders->constructor(); - colliders = new dArray<dColliderEntry>; - colliders->setSize (1); // force allocation of array data memory - dAllocDontReport (colliders); - dAllocDontReport (colliders->data()); - colliders->setSize (0); - } -} - - -int dCreateGeomClass (const dGeomClass *c) -{ - dUASSERT(c && c->bytes >= 0 && c->collider && c->aabb,"bad geom class"); - initCollisionArrays(); - - int n = classes->size(); - dxGeomClass *gc = (dxGeomClass*) dAlloc (sizeof(dxGeomClass)); - dAllocDontReport (gc); - gc->collider = c->collider; - gc->aabb = c->aabb; - gc->aabb_test = c->aabb_test; - gc->dtor = c->dtor; - gc->num = n; - gc->size = SIZEOF_DXGEOM + c->bytes; - classes->push (gc); - - // make room for n^2 class collider function pointers - these entries will - // be filled as dCollide() is called. - colliders->setSize ((n+1)*(n+1)); - memset (colliders->data(),0,(n+1)*(n+1)*sizeof(dColliderEntry)); - - return n; -} - - -int dCollide (dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, - int skip) -{ - int i,c1,c2,a1,a2,count,swap; - dColliderFn *fn; - dAASSERT(o1 && o2 && contact); - dUASSERT(classes && colliders,"no registered geometry classes"); - - // no contacts if both geoms on the same body, and the body is not 0 - if (o1->body == o2->body && o1->body) return 0; - - dColliderEntry *colliders2 = colliders->data(); - c1 = o1->_class->num; - c2 = o2->_class->num; - a1 = c1 * classes->size() + c2; // address 1 in collider array - a2 = c2 * classes->size() + c1; // address 2 in collider array - swap = 0; // set to 1 to swap normals before returning - - // return if there are no collider functions available - if ((colliders2[a1].mode==2) || (colliders2[a2].mode==2)) return 0; - - if ((fn = colliders2[a1].fn)) { - swap = colliders2[a1].mode; - if (swap) count = (*fn) (o2,o1,flags,contact,skip); - else count = (*fn) (o1,o2,flags,contact,skip); - } - else if ((fn = (*classes)[c1]->collider (c2))) { - colliders2 [a2].fn = fn; - colliders2 [a2].mode = 1; - colliders2 [a1].fn = fn; // do mode=0 assignment second so that - colliders2 [a1].mode = 0; // diagonal entries will have mode 0 - count = (*fn) (o1,o2,flags,contact,skip); - swap = 0; - } - else if ((fn = (*classes)[c2]->collider (c1))) { - colliders2 [a1].fn = fn; - colliders2 [a1].mode = 1; - colliders2 [a2].fn = fn; // do mode=0 assignment second so that - colliders2 [a2].mode = 0; // diagonal entries will have mode 0 - count = (*fn) (o2,o1,flags,contact,skip); - swap = 1; - } - else { - colliders2[a1].mode = 2; - colliders2[a2].mode = 2; - return 0; - } - - if (swap) { - for (i=0; i<count; i++) { - dContactGeom *c = CONTACT(contact,skip*i); - c->normal[0] = -c->normal[0]; - c->normal[1] = -c->normal[1]; - c->normal[2] = -c->normal[2]; - dxGeom *tmp = c->g1; - c->g1 = c->g2; - c->g2 = tmp; - } - } - - return count; -} - - -int dGeomGetClass (dxGeom *g) -{ - dAASSERT (g); - return g->_class->num; -} - - -void dGeomSetData (dxGeom *g, void *data) -{ - dAASSERT (g); - g->data = data; -} - - -void *dGeomGetData (dxGeom *g) -{ - dAASSERT (g); - return g->data; -} - - -void dGeomSetBody (dxGeom *g, dBodyID b) -{ - dAASSERT (g); - if (b) { - if (!g->body) dFree (g->pos,sizeof(dxPosR)); - g->body = b; - g->pos = b->pos; - g->R = b->R; - } - else { - if (g->body) { - dxPosR *pr = (dxPosR*) dAlloc (sizeof(dxPosR)); - g->pos = pr->pos; - g->R = pr->R; - memcpy (g->pos,g->body->pos,sizeof(g->pos)); - memcpy (g->R,g->body->R,sizeof(g->R)); - g->body = 0; - } - } -} - - -dBodyID dGeomGetBody (dxGeom *g) -{ - dAASSERT (g); - return g->body; -} - - -void dGeomSetPosition (dxGeom *g, dReal x, dReal y, dReal z) -{ - dAASSERT (g); - if (g->body) dBodySetPosition (g->body,x,y,z); - else { - g->pos[0] = x; - g->pos[1] = y; - g->pos[2] = z; - } -} - - -void dGeomSetRotation (dxGeom *g, const dMatrix3 R) -{ - dAASSERT (g); - if (g->body) dBodySetRotation (g->body,R); - else memcpy (g->R,R,sizeof(dMatrix3)); -} - - -const dReal * dGeomGetPosition (dxGeom *g) -{ - dAASSERT (g); - return g->pos; -} - - -const dReal * dGeomGetRotation (dxGeom *g) -{ - dAASSERT (g); - return g->R; -} - - -// for external use only. use the CLASSDATA macro inside ODE. - -void * dGeomGetClassData (dxGeom *g) -{ - dAASSERT (g); - return (void*) CLASSDATA(g); -} - - -dxGeom * dCreateGeom (int classnum) -{ - dUASSERT (classes && colliders && classnum >= 0 && - classnum < classes->size(),"bad class number"); - int size = (*classes)[classnum]->size; - dxGeom *geom = (dxGeom*) dAlloc (size); - memset (geom,0,size); // everything is initially zeroed - - geom->_class = (*classes)[classnum]; - geom->data = 0; - geom->body = 0; - - dxPosR *pr = (dxPosR*) dAlloc (sizeof(dxPosR)); - geom->pos = pr->pos; - geom->R = pr->R; - dSetZero (geom->pos,4); - dRSetIdentity (geom->R); - - return geom; -} - - -void dGeomDestroy (dxGeom *g) -{ - dAASSERT (g); - if (g->spaceid) dSpaceRemove (g->spaceid,g); - if (g->_class->dtor) g->_class->dtor (g); - if (!g->body) dFree (g->pos,sizeof(dxPosR)); - dFree (g,g->_class->size); -} - - -void dGeomGetAABB (dxGeom *g, dReal aabb[6]) -{ - dAASSERT (g); - g->_class->aabb (g,aabb); -} - - -dReal *dGeomGetSpaceAABB (dxGeom *g) -{ - dAASSERT (g); - return g->space_aabb; -} - -//**************************************************************************** -// data for the standard classes - -struct dxSphere { - dReal radius; // sphere radius -}; - -struct dxBox { - dVector3 side; // side lengths (x,y,z) -}; - -struct dxCCylinder { // capped cylinder - dReal radius,lz; // radius, length along z axis */ -}; - -struct dxPlane { - dReal p[4]; -}; - -struct dxGeomGroup { - dArray<dxGeom*> parts; // all the geoms that make up the group -}; - -//**************************************************************************** -// primitive collision functions -// same interface as dCollide(). -// S=sphere, B=box, C=capped cylinder, P=plane, G=group, T=transform - -int dCollideSS (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dSphereClass); - dIASSERT (o2->_class->num == dSphereClass); - dxSphere *s1 = (dxSphere*) CLASSDATA(o1); - dxSphere *s2 = (dxSphere*) CLASSDATA(o2); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - return dCollideSpheres (o1->pos,s1->radius, - o2->pos,s2->radius,contact); -} - - -int dCollideSB (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - // this is easy. get the sphere center `p' relative to the box, and then clip - // that to the boundary of the box (call that point `q'). if q is on the - // boundary of the box and |p-q| is <= sphere radius, they touch. - // if q is inside the box, the sphere is inside the box, so set a contact - // normal to push the sphere to the closest box edge. - - dVector3 l,t,p,q,r; - dReal depth; - int onborder = 0; - - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dSphereClass); - dIASSERT (o2->_class->num == dBoxClass); - dxSphere *sphere = (dxSphere*) CLASSDATA(o1); - dxBox *box = (dxBox*) CLASSDATA(o2); - - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - - p[0] = o1->pos[0] - o2->pos[0]; - p[1] = o1->pos[1] - o2->pos[1]; - p[2] = o1->pos[2] - o2->pos[2]; - - l[0] = box->side[0]*REAL(0.5); - t[0] = dDOT14(p,o2->R); - if (t[0] < -l[0]) { t[0] = -l[0]; onborder = 1; } - if (t[0] > l[0]) { t[0] = l[0]; onborder = 1; } - - l[1] = box->side[1]*REAL(0.5); - t[1] = dDOT14(p,o2->R+1); - if (t[1] < -l[1]) { t[1] = -l[1]; onborder = 1; } - if (t[1] > l[1]) { t[1] = l[1]; onborder = 1; } - - t[2] = dDOT14(p,o2->R+2); - l[2] = box->side[2]*REAL(0.5); - if (t[2] < -l[2]) { t[2] = -l[2]; onborder = 1; } - if (t[2] > l[2]) { t[2] = l[2]; onborder = 1; } - - if (!onborder) { - // sphere center inside box. find largest `t' value - dReal max = dFabs(t[0]); - int maxi = 0; - for (int i=1; i<3; i++) { - dReal tt = dFabs(t[i]); - if (tt > max) { - max = tt; - maxi = i; - } - } - // contact position = sphere center - contact->pos[0] = o1->pos[0]; - contact->pos[1] = o1->pos[1]; - contact->pos[2] = o1->pos[2]; - // contact normal aligned with box edge along largest `t' value - dVector3 tmp; - tmp[0] = 0; - tmp[1] = 0; - tmp[2] = 0; - tmp[maxi] = (t[maxi] > 0) ? REAL(1.0) : REAL(-1.0); - dMULTIPLY0_331 (contact->normal,o2->R,tmp); - // contact depth = distance to wall along normal plus radius - contact->depth = l[maxi] - max + sphere->radius; - return 1; - } - - t[3] = 0; //@@@ hmmm - dMULTIPLY0_331 (q,o2->R,t); - r[0] = p[0] - q[0]; - r[1] = p[1] - q[1]; - r[2] = p[2] - q[2]; - depth = sphere->radius - dSqrt(dDOT(r,r)); - if (depth < 0) return 0; - contact->pos[0] = q[0] + o2->pos[0]; - contact->pos[1] = q[1] + o2->pos[1]; - contact->pos[2] = q[2] + o2->pos[2]; - contact->normal[0] = r[0]; - contact->normal[1] = r[1]; - contact->normal[2] = r[2]; - dNormalize3 (contact->normal); - contact->depth = depth; - return 1; -} - - -int dCollideSP (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dSphereClass); - dIASSERT (o2->_class->num == dPlaneClass); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - dxSphere *sphere = (dxSphere*) CLASSDATA(o1); - dxPlane *plane = (dxPlane*) CLASSDATA(o2); - dReal k = dDOT (o1->pos,plane->p); - dReal depth = plane->p[3] - k + sphere->radius; - if (depth >= 0) { - contact->normal[0] = plane->p[0]; - contact->normal[1] = plane->p[1]; - contact->normal[2] = plane->p[2]; - contact->pos[0] = o1->pos[0] - plane->p[0] * sphere->radius; - contact->pos[1] = o1->pos[1] - plane->p[1] * sphere->radius; - contact->pos[2] = o1->pos[2] - plane->p[2] * sphere->radius; - contact->depth = depth; - return 1; - } - else return 0; -} - - -int dCollideBB (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dVector3 normal; - dReal depth; - int code; - dxBox *b1 = (dxBox*) CLASSDATA(o1); - dxBox *b2 = (dxBox*) CLASSDATA(o2); - int num = dBoxBox (o1->pos,o1->R,b1->side, o2->pos,o2->R,b2->side, - normal,&depth,&code,flags & NUMC_MASK,contact,skip); - for (int i=0; i<num; i++) { - CONTACT(contact,i*skip)->normal[0] = -normal[0]; - CONTACT(contact,i*skip)->normal[1] = -normal[1]; - CONTACT(contact,i*skip)->normal[2] = -normal[2]; - CONTACT(contact,i*skip)->g1 = const_cast<dxGeom*> (o1); - CONTACT(contact,i*skip)->g2 = const_cast<dxGeom*> (o2); - } - return num; -} - - -int dCollideBP (const dxGeom *o1, const dxGeom *o2, - int flags, dContactGeom *contact, int skip) -{ - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dBoxClass); - dIASSERT (o2->_class->num == dPlaneClass); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - dxBox *box = (dxBox*) CLASSDATA(o1); - dxPlane *plane = (dxPlane*) CLASSDATA(o2); - int ret = 0; - - //@@@ problem: using 4-vector (plane->p) as 3-vector (normal). - const dReal *R = o1->R; // rotation of box - const dReal *n = plane->p; // normal vector - - // project sides lengths along normal vector, get absolute values - dReal Q1 = dDOT14(n,R+0); - dReal Q2 = dDOT14(n,R+1); - dReal Q3 = dDOT14(n,R+2); - dReal A1 = box->side[0] * Q1; - dReal A2 = box->side[1] * Q2; - dReal A3 = box->side[2] * Q3; - dReal B1 = dFabs(A1); - dReal B2 = dFabs(A2); - dReal B3 = dFabs(A3); - - // early exit test - dReal depth = plane->p[3] + REAL(0.5)*(B1+B2+B3) - dDOT(n,o1->pos); - if (depth < 0) return 0; - - // find number of contacts requested - int maxc = flags & NUMC_MASK; - if (maxc < 1) maxc = 1; - if (maxc > 3) maxc = 3; // no more than 3 contacts per box allowed - - // find deepest point - dVector3 p; - p[0] = o1->pos[0]; - p[1] = o1->pos[1]; - p[2] = o1->pos[2]; -#define FOO(i,op) \ - p[0] op REAL(0.5)*box->side[i] * R[0+i]; \ - p[1] op REAL(0.5)*box->side[i] * R[4+i]; \ - p[2] op REAL(0.5)*box->side[i] * R[8+i]; -#define BAR(i,iinc) if (A ## iinc > 0) { FOO(i,-=) } else { FOO(i,+=) } - BAR(0,1); - BAR(1,2); - BAR(2,3); -#undef FOO -#undef BAR - - // the deepest point is the first contact point - contact->pos[0] = p[0]; - contact->pos[1] = p[1]; - contact->pos[2] = p[2]; - contact->normal[0] = n[0]; - contact->normal[1] = n[1]; - contact->normal[2] = n[2]; - contact->depth = depth; - ret = 1; // ret is number of contact points found so far - if (maxc == 1) goto done; - - // get the second and third contact points by starting from `p' and going - // along the two sides with the smallest projected length. - -#define FOO(i,j,op) \ - CONTACT(contact,i*skip)->pos[0] = p[0] op box->side[j] * R[0+j]; \ - CONTACT(contact,i*skip)->pos[1] = p[1] op box->side[j] * R[4+j]; \ - CONTACT(contact,i*skip)->pos[2] = p[2] op box->side[j] * R[8+j]; -#define BAR(ctact,side,sideinc) \ - depth -= B ## sideinc; \ - if (depth < 0) goto done; \ - if (A ## sideinc > 0) { FOO(ctact,side,+) } else { FOO(ctact,side,-) } \ - CONTACT(contact,ctact*skip)->depth = depth; \ - ret++; - - CONTACT(contact,skip)->normal[0] = n[0]; - CONTACT(contact,skip)->normal[1] = n[1]; - CONTACT(contact,skip)->normal[2] = n[2]; - if (maxc == 3) { - CONTACT(contact,2*skip)->normal[0] = n[0]; - CONTACT(contact,2*skip)->normal[1] = n[1]; - CONTACT(contact,2*skip)->normal[2] = n[2]; - } - - if (B1 < B2) { - if (B3 < B1) goto use_side_3; else { - BAR(1,0,1); // use side 1 - if (maxc == 2) goto done; - if (B2 < B3) goto contact2_2; else goto contact2_3; - } - } - else { - if (B3 < B2) { - use_side_3: // use side 3 - BAR(1,2,3); - if (maxc == 2) goto done; - if (B1 < B2) goto contact2_1; else goto contact2_2; - } - else { - BAR(1,1,2); // use side 2 - if (maxc == 2) goto done; - if (B1 < B3) goto contact2_1; else goto contact2_3; - } - } - - contact2_1: BAR(2,0,1); goto done; - contact2_2: BAR(2,1,2); goto done; - contact2_3: BAR(2,2,3); goto done; -#undef FOO -#undef BAR - - done: - for (int i=0; i<ret; i++) { - CONTACT(contact,i*skip)->g1 = const_cast<dxGeom*> (o1); - CONTACT(contact,i*skip)->g2 = const_cast<dxGeom*> (o2); - } - return ret; -} - - -int dCollideCS (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dCCylinderClass); - dIASSERT (o2->_class->num == dSphereClass); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - dxCCylinder *ccyl = (dxCCylinder*) CLASSDATA(o1); - dxSphere *sphere = (dxSphere*) CLASSDATA(o2); - - // find the point on the cylinder axis that is closest to the sphere - dReal alpha = - o1->R[2] * (o2->pos[0] - o1->pos[0]) + - o1->R[6] * (o2->pos[1] - o1->pos[1]) + - o1->R[10] * (o2->pos[2] - o1->pos[2]); - dReal lz2 = ccyl->lz * REAL(0.5); - if (alpha > lz2) alpha = lz2; - if (alpha < -lz2) alpha = -lz2; - - // collide the spheres - dVector3 p; - p[0] = o1->pos[0] + alpha * o1->R[2]; - p[1] = o1->pos[1] + alpha * o1->R[6]; - p[2] = o1->pos[2] + alpha * o1->R[10]; - return dCollideSpheres (p,ccyl->radius,o2->pos,sphere->radius,contact); -} - - -int dCollideCB (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dCCylinderClass); - dIASSERT (o2->_class->num == dBoxClass); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - dxCCylinder *cyl = (dxCCylinder*) CLASSDATA(o1); - dxBox *box = (dxBox*) CLASSDATA(o2); - - // get p1,p2 = cylinder axis endpoints, get radius - dVector3 p1,p2; - dReal clen = cyl->lz * REAL(0.5); - p1[0] = o1->pos[0] + clen * o1->R[2]; - p1[1] = o1->pos[1] + clen * o1->R[6]; - p1[2] = o1->pos[2] + clen * o1->R[10]; - p2[0] = o1->pos[0] - clen * o1->R[2]; - p2[1] = o1->pos[1] - clen * o1->R[6]; - p2[2] = o1->pos[2] - clen * o1->R[10]; - dReal radius = cyl->radius; - - // copy out box center, rotation matrix, and side array - dReal *c = o2->pos; - dReal *R = o2->R; - dReal *side = box->side; - - // get the closest point between the cylinder axis and the box - dVector3 pl,pb; - dClosestLineBoxPoints (p1,p2,c,R,side,pl,pb); - - // generate contact point - return dCollideSpheres (pl,radius,pb,0,contact); -} - - -// this returns at most one contact point when the two cylinder's axes are not -// aligned, and at most two (for stability) when they are aligned. -// the algorithm minimizes the distance between two "sample spheres" that are -// positioned along the cylinder axes according to: -// sphere1 = pos1 + alpha1 * axis1 -// sphere2 = pos2 + alpha2 * axis2 -// alpha1 and alpha2 are limited to +/- half the length of the cylinders. -// the algorithm works by finding a solution that has both alphas free, or -// a solution that has one or both alphas fixed to the ends of the cylinder. - -int dCollideCC (const dxGeom *o1, const dxGeom *o2, - int flags, dContactGeom *contact, int skip) -{ - int i; - const dReal tolerance = REAL(1e-5); - - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dCCylinderClass); - dIASSERT (o2->_class->num == dCCylinderClass); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - dxCCylinder *cyl1 = (dxCCylinder*) CLASSDATA(o1); - dxCCylinder *cyl2 = (dxCCylinder*) CLASSDATA(o2); - - // copy out some variables, for convenience - dReal lz1 = cyl1->lz * REAL(0.5); - dReal lz2 = cyl2->lz * REAL(0.5); - dReal *pos1 = o1->pos; - dReal *pos2 = o2->pos; - dReal axis1[3],axis2[3]; - axis1[0] = o1->R[2]; - axis1[1] = o1->R[6]; - axis1[2] = o1->R[10]; - axis2[0] = o2->R[2]; - axis2[1] = o2->R[6]; - axis2[2] = o2->R[10]; - - dReal alpha1,alpha2,sphere1[3],sphere2[3]; - int fix1 = 0; // 0 if alpha1 is free, +/-1 to fix at +/- lz1 - int fix2 = 0; // 0 if alpha2 is free, +/-1 to fix at +/- lz2 - - for (int count=0; count<9; count++) { - // find a trial solution by fixing or not fixing the alphas - if (fix1) { - if (fix2) { - // alpha1 and alpha2 are fixed, so the solution is easy - if (fix1 > 0) alpha1 = lz1; else alpha1 = -lz1; - if (fix2 > 0) alpha2 = lz2; else alpha2 = -lz2; - for (i=0; i<3; i++) sphere1[i] = pos1[i] + alpha1*axis1[i]; - for (i=0; i<3; i++) sphere2[i] = pos2[i] + alpha2*axis2[i]; - } - else { - // fix alpha1 but let alpha2 be free - if (fix1 > 0) alpha1 = lz1; else alpha1 = -lz1; - for (i=0; i<3; i++) sphere1[i] = pos1[i] + alpha1*axis1[i]; - alpha2 = (axis2[0]*(sphere1[0]-pos2[0]) + - axis2[1]*(sphere1[1]-pos2[1]) + - axis2[2]*(sphere1[2]-pos2[2])); - for (i=0; i<3; i++) sphere2[i] = pos2[i] + alpha2*axis2[i]; - } - } - else { - if (fix2) { - // fix alpha2 but let alpha1 be free - if (fix2 > 0) alpha2 = lz2; else alpha2 = -lz2; - for (i=0; i<3; i++) sphere2[i] = pos2[i] + alpha2*axis2[i]; - alpha1 = (axis1[0]*(sphere2[0]-pos1[0]) + - axis1[1]*(sphere2[1]-pos1[1]) + - axis1[2]*(sphere2[2]-pos1[2])); - for (i=0; i<3; i++) sphere1[i] = pos1[i] + alpha1*axis1[i]; - } - else { - // let alpha1 and alpha2 be free - // compute determinant of d(d^2)\d(alpha) jacobian - dReal a1a2 = dDOT (axis1,axis2); - dReal det = REAL(1.0)-a1a2*a1a2; - if (det < tolerance) { - // the cylinder axes (almost) parallel, so we will generate up to two - // contacts. the solution matrix is rank deficient so alpha1 and - // alpha2 are related by: - // alpha2 = alpha1 + (pos1-pos2)'*axis1 (if axis1==axis2) - // or alpha2 = -(alpha1 + (pos1-pos2)'*axis1) (if axis1==-axis2) - // first compute where the two cylinders overlap in alpha1 space: - if (a1a2 < 0) { - axis2[0] = -axis2[0]; - axis2[1] = -axis2[1]; - axis2[2] = -axis2[2]; - } - dReal q[3]; - for (i=0; i<3; i++) q[i] = pos1[i]-pos2[i]; - dReal k = dDOT (axis1,q); - dReal a1lo = -lz1; - dReal a1hi = lz1; - dReal a2lo = -lz2 - k; - dReal a2hi = lz2 - k; - dReal lo = (a1lo > a2lo) ? a1lo : a2lo; - dReal hi = (a1hi < a2hi) ? a1hi : a2hi; - if (lo <= hi) { - int num_contacts = flags & NUMC_MASK; - if (num_contacts >= 2 && lo < hi) { - // generate up to two contacts. if one of those contacts is - // not made, fall back on the one-contact strategy. - for (i=0; i<3; i++) sphere1[i] = pos1[i] + lo*axis1[i]; - for (i=0; i<3; i++) sphere2[i] = pos2[i] + (lo+k)*axis2[i]; - int n1 = dCollideSpheres (sphere1,cyl1->radius, - sphere2,cyl2->radius,contact); - if (n1) { - for (i=0; i<3; i++) sphere1[i] = pos1[i] + hi*axis1[i]; - for (i=0; i<3; i++) sphere2[i] = pos2[i] + (hi+k)*axis2[i]; - dContactGeom *c2 = CONTACT(contact,skip); - int n2 = dCollideSpheres (sphere1,cyl1->radius, - sphere2,cyl2->radius, c2); - if (n2) { - c2->g1 = const_cast<dxGeom*> (o1); - c2->g2 = const_cast<dxGeom*> (o2); - return 2; - } - } - } - - // just one contact to generate, so put it in the middle of - // the range - alpha1 = (lo + hi) * REAL(0.5); - alpha2 = alpha1 + k; - for (i=0; i<3; i++) sphere1[i] = pos1[i] + alpha1*axis1[i]; - for (i=0; i<3; i++) sphere2[i] = pos2[i] + alpha2*axis2[i]; - return dCollideSpheres (sphere1,cyl1->radius, - sphere2,cyl2->radius,contact); - } - else return 0; - } - det = REAL(1.0)/det; - dReal delta[3]; - for (i=0; i<3; i++) delta[i] = pos1[i] - pos2[i]; - dReal q1 = dDOT (delta,axis1); - dReal q2 = dDOT (delta,axis2); - alpha1 = det*(a1a2*q2-q1); - alpha2 = det*(q2-a1a2*q1); - for (i=0; i<3; i++) sphere1[i] = pos1[i] + alpha1*axis1[i]; - for (i=0; i<3; i++) sphere2[i] = pos2[i] + alpha2*axis2[i]; - } - } - - // if the alphas are outside their allowed ranges then fix them and - // try again - if (fix1==0) { - if (alpha1 < -lz1) { - fix1 = -1; - continue; - } - if (alpha1 > lz1) { - fix1 = 1; - continue; - } - } - if (fix2==0) { - if (alpha2 < -lz2) { - fix2 = -1; - continue; - } - if (alpha2 > lz2) { - fix2 = 1; - continue; - } - } - - // unfix the alpha variables if the local distance gradient indicates - // that we are not yet at the minimum - dReal tmp[3]; - for (i=0; i<3; i++) tmp[i] = sphere1[i] - sphere2[i]; - if (fix1) { - dReal gradient = dDOT (tmp,axis1); - if ((fix1 > 0 && gradient > 0) || (fix1 < 0 && gradient < 0)) { - fix1 = 0; - continue; - } - } - if (fix2) { - dReal gradient = -dDOT (tmp,axis2); - if ((fix2 > 0 && gradient > 0) || (fix2 < 0 && gradient < 0)) { - fix2 = 0; - continue; - } - } - return dCollideSpheres (sphere1,cyl1->radius,sphere2,cyl2->radius,contact); - } - // if we go through the loop too much, then give up. we should NEVER get to - // this point (i hope). - dMessage (0,"dCollideCC(): too many iterations"); - return 0; -} - - -int dCollideCP (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dCCylinderClass); - dIASSERT (o2->_class->num == dPlaneClass); - dxCCylinder *ccyl = (dxCCylinder*) CLASSDATA(o1); - dxPlane *plane = (dxPlane*) CLASSDATA(o2); - - // collide the deepest capping sphere with the plane - dReal sign = (dDOT14 (plane->p,o1->R+2) > 0) ? REAL(-1.0) : REAL(1.0); - dVector3 p; - p[0] = o1->pos[0] + o1->R[2] * ccyl->lz * REAL(0.5) * sign; - p[1] = o1->pos[1] + o1->R[6] * ccyl->lz * REAL(0.5) * sign; - p[2] = o1->pos[2] + o1->R[10] * ccyl->lz * REAL(0.5) * sign; - - dReal k = dDOT (p,plane->p); - dReal depth = plane->p[3] - k + ccyl->radius; - if (depth < 0) return 0; - contact->normal[0] = plane->p[0]; - contact->normal[1] = plane->p[1]; - contact->normal[2] = plane->p[2]; - contact->pos[0] = p[0] - plane->p[0] * ccyl->radius; - contact->pos[1] = p[1] - plane->p[1] * ccyl->radius; - contact->pos[2] = p[2] - plane->p[2] * ccyl->radius; - contact->depth = depth; - - int ncontacts = 1; - if ((flags & NUMC_MASK) >= 2) { - // collide the other capping sphere with the plane - p[0] = o1->pos[0] - o1->R[2] * ccyl->lz * REAL(0.5) * sign; - p[1] = o1->pos[1] - o1->R[6] * ccyl->lz * REAL(0.5) * sign; - p[2] = o1->pos[2] - o1->R[10] * ccyl->lz * REAL(0.5) * sign; - - k = dDOT (p,plane->p); - depth = plane->p[3] - k + ccyl->radius; - if (depth >= 0) { - dContactGeom *c2 = CONTACT(contact,skip); - c2->normal[0] = plane->p[0]; - c2->normal[1] = plane->p[1]; - c2->normal[2] = plane->p[2]; - c2->pos[0] = p[0] - plane->p[0] * ccyl->radius; - c2->pos[1] = p[1] - plane->p[1] * ccyl->radius; - c2->pos[2] = p[2] - plane->p[2] * ccyl->radius; - c2->depth = depth; - ncontacts = 2; - } - } - - for (int i=0; i < ncontacts; i++) { - CONTACT(contact,i*skip)->g1 = const_cast<dxGeom*> (o1); - CONTACT(contact,i*skip)->g2 = const_cast<dxGeom*> (o2); - } - return ncontacts; -} - - -// this collides a group with another geom. the other geom can also be a -// group, but this case is not handled specially. - -int dCollideG (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(o1); - int numleft = flags & NUMC_MASK; - if (numleft == 0) numleft = 1; - flags &= ~NUMC_MASK; - int num=0,i=0; - while (i < gr->parts.size() && numleft > 0) { - int n = dCollide (gr->parts[i],const_cast<dxGeom*>(o2), - flags | numleft,contact,skip); - contact = CONTACT (contact,skip*n); - numleft -= n; - num += n; - i++; - } - return num; -} - -//**************************************************************************** -// standard classes - -SHAREDLIBEXPORT int dSphereClass = -1; -SHAREDLIBEXPORT int dBoxClass = -1; -SHAREDLIBEXPORT int dCCylinderClass = -1; -SHAREDLIBEXPORT int dPlaneClass = -1; - - -static dColliderFn * dSphereColliderFn (int num) -{ - if (num == dSphereClass) return (dColliderFn *) &dCollideSS; - if (num == dBoxClass) return (dColliderFn *) &dCollideSB; - if (num == dPlaneClass) return (dColliderFn *) &dCollideSP; - return 0; -} - - -static void dSphereAABB (dxGeom *geom, dReal aabb[6]) -{ - dxSphere *s = (dxSphere*) CLASSDATA(geom); - aabb[0] = geom->pos[0] - s->radius; - aabb[1] = geom->pos[0] + s->radius; - aabb[2] = geom->pos[1] - s->radius; - aabb[3] = geom->pos[1] + s->radius; - aabb[4] = geom->pos[2] - s->radius; - aabb[5] = geom->pos[2] + s->radius; -} - - -static dColliderFn * dBoxColliderFn (int num) -{ - if (num == dBoxClass) return (dColliderFn *) &dCollideBB; - if (num == dPlaneClass) return (dColliderFn *) &dCollideBP; - return 0; -} - - -static void dBoxAABB (dxGeom *geom, dReal aabb[6]) -{ - dxBox *b = (dxBox*) CLASSDATA(geom); - dReal xrange = REAL(0.5) * (dFabs (geom->R[0] * b->side[0]) + - dFabs (geom->R[1] * b->side[1]) + dFabs (geom->R[2] * b->side[2])); - dReal yrange = REAL(0.5) * (dFabs (geom->R[4] * b->side[0]) + - dFabs (geom->R[5] * b->side[1]) + dFabs (geom->R[6] * b->side[2])); - dReal zrange = REAL(0.5) * (dFabs (geom->R[8] * b->side[0]) + - dFabs (geom->R[9] * b->side[1]) + dFabs (geom->R[10] * b->side[2])); - aabb[0] = geom->pos[0] - xrange; - aabb[1] = geom->pos[0] + xrange; - aabb[2] = geom->pos[1] - yrange; - aabb[3] = geom->pos[1] + yrange; - aabb[4] = geom->pos[2] - zrange; - aabb[5] = geom->pos[2] + zrange; -} - - -static dColliderFn * dCCylinderColliderFn (int num) -{ - if (num == dSphereClass) return (dColliderFn *) &dCollideCS; - if (num == dPlaneClass) return (dColliderFn *) &dCollideCP; - if (num == dCCylinderClass) return (dColliderFn *) &dCollideCC; - if (num == dBoxClass) return (dColliderFn *) &dCollideCB; - return 0; -} - - -static void dCCylinderAABB (dxGeom *geom, dReal aabb[6]) -{ - dxCCylinder *c = (dxCCylinder*) CLASSDATA(geom); - dReal xrange = dFabs(geom->R[2] * c->lz) * REAL(0.5) + c->radius; - dReal yrange = dFabs(geom->R[6] * c->lz) * REAL(0.5) + c->radius; - dReal zrange = dFabs(geom->R[10] * c->lz) * REAL(0.5) + c->radius; - aabb[0] = geom->pos[0] - xrange; - aabb[1] = geom->pos[0] + xrange; - aabb[2] = geom->pos[1] - yrange; - aabb[3] = geom->pos[1] + yrange; - aabb[4] = geom->pos[2] - zrange; - aabb[5] = geom->pos[2] + zrange; -} - - -dColliderFn * dPlaneColliderFn (int num) -{ - return 0; -} - - -static void dPlaneAABB (dxGeom *geom, dReal aabb[6]) -{ - // @@@ planes that have normal vectors aligned along an axis can use a - // @@@ less comprehensive bounding box. - aabb[0] = -dInfinity; - aabb[1] = dInfinity; - aabb[2] = -dInfinity; - aabb[3] = dInfinity; - aabb[4] = -dInfinity; - aabb[5] = dInfinity; -} - - -dxGeom *dCreateSphere (dSpaceID space, dReal radius) -{ - dAASSERT (radius > 0); - if (dSphereClass == -1) { - dGeomClass c; - c.bytes = sizeof (dxSphere); - c.collider = &dSphereColliderFn; - c.aabb = &dSphereAABB; - c.aabb_test = 0; - c.dtor = 0; - dSphereClass = dCreateGeomClass (&c); - } - - dxGeom *g = dCreateGeom (dSphereClass); - if (space) dSpaceAdd (space,g); - dxSphere *s = (dxSphere*) CLASSDATA(g); - s->radius = radius; - return g; -} - - -dxGeom *dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz) -{ - dAASSERT (lx > 0 && ly > 0 && lz > 0); - if (dBoxClass == -1) { - dGeomClass c; - c.bytes = sizeof (dxBox); - c.collider = &dBoxColliderFn; - c.aabb = &dBoxAABB; - c.aabb_test = 0; - c.dtor = 0; - dBoxClass = dCreateGeomClass (&c); - } - - dxGeom *g = dCreateGeom (dBoxClass); - if (space) dSpaceAdd (space,g); - dxBox *b = (dxBox*) CLASSDATA(g); - b->side[0] = lx; - b->side[1] = ly; - b->side[2] = lz; - return g; -} - - -dxGeom * dCreateCCylinder (dSpaceID space, dReal radius, dReal length) -{ - dAASSERT (radius > 0 && length > 0); - if (dCCylinderClass == -1) { - dGeomClass c; - c.bytes = sizeof (dxCCylinder); - c.collider = &dCCylinderColliderFn; - c.aabb = &dCCylinderAABB; - c.aabb_test = 0; - c.dtor = 0; - dCCylinderClass = dCreateGeomClass (&c); - } - - dxGeom *g = dCreateGeom (dCCylinderClass); - if (space) dSpaceAdd (space,g); - dxCCylinder *c = (dxCCylinder*) CLASSDATA(g); - c->radius = radius; - c->lz = length; - return g; -} - - -dxGeom *dCreatePlane (dSpaceID space, - dReal a, dReal b, dReal c, dReal d) -{ - if (dPlaneClass == -1) { - dGeomClass c; - c.bytes = sizeof (dxPlane); - c.collider = &dPlaneColliderFn; - c.aabb = &dPlaneAABB; - c.aabb_test = 0; - c.dtor = 0; - dPlaneClass = dCreateGeomClass (&c); - } - - dxGeom *g = dCreateGeom (dPlaneClass); - if (space) dSpaceAdd (space,g); - dxPlane *p = (dxPlane*) CLASSDATA(g); - - // make sure plane normal has unit length - dReal l = a*a + b*b + c*c; - if (l > 0) { - l = dRecipSqrt(l); - p->p[0] = a*l; - p->p[1] = b*l; - p->p[2] = c*l; - p->p[3] = d*l; - } - else { - p->p[0] = 1; - p->p[1] = 0; - p->p[2] = 0; - p->p[3] = 0; - } - return g; -} - - -void dGeomSphereSetRadius (dGeomID g, dReal radius) -{ - dUASSERT (g && g->_class->num == dSphereClass,"argument not a sphere"); - dAASSERT (radius > 0); - dxSphere *s = (dxSphere*) CLASSDATA(g); - s->radius = radius; -} - - -void dGeomBoxSetLengths (dGeomID g, dReal lx, dReal ly, dReal lz) -{ - dUASSERT (g && g->_class->num == dBoxClass,"argument not a box"); - dAASSERT (lx > 0 && ly > 0 && lz > 0); - dxBox *b = (dxBox*) CLASSDATA(g); - b->side[0] = lx; - b->side[1] = ly; - b->side[2] = lz; -} - - -void dGeomPlaneSetParams (dGeomID g, dReal a, dReal b, dReal c, dReal d) -{ - dUASSERT (g && g->_class->num == dPlaneClass,"argument not a plane"); - dxPlane *p = (dxPlane*) CLASSDATA(g); - p->p[0] = a; - p->p[1] = b; - p->p[2] = c; - p->p[3] = d; -} - - -void dGeomCCylinderSetParams (dGeomID g, dReal radius, dReal length) -{ - dUASSERT (g && g->_class->num == dCCylinderClass,"argument not a ccylinder"); - dAASSERT (radius > 0 && length > 0); - dxCCylinder *c = (dxCCylinder*) CLASSDATA(g); - c->radius = radius; - c->lz = length; -} - - -dReal dGeomSphereGetRadius (dGeomID g) -{ - dUASSERT (g && g->_class->num == dSphereClass,"argument not a sphere"); - dxSphere *s = (dxSphere*) CLASSDATA(g); - return s->radius; -} - - -void dGeomBoxGetLengths (dGeomID g, dVector3 result) -{ - dUASSERT (g && g->_class->num == dBoxClass,"argument not a box"); - dxBox *b = (dxBox*) CLASSDATA(g); - result[0] = b->side[0]; - result[1] = b->side[1]; - result[2] = b->side[2]; -} - - -void dGeomPlaneGetParams (dGeomID g, dVector4 result) -{ - dUASSERT (g && g->_class->num == dPlaneClass,"argument not a plane"); - dxPlane *p = (dxPlane*) CLASSDATA(g); - result[0] = p->p[0]; - result[1] = p->p[1]; - result[2] = p->p[2]; - result[3] = p->p[3]; -} - - -void dGeomCCylinderGetParams (dGeomID g, dReal *radius, dReal *length) -{ - dUASSERT (g && g->_class->num == dCCylinderClass,"argument not a ccylinder"); - dxCCylinder *c = (dxCCylinder*) CLASSDATA(g); - *radius = c->radius; - *length = c->lz; -} - -//**************************************************************************** -// geom group - -int dGeomGroupClass = -1; - -static dColliderFn * dGeomGroupColliderFn (int num) -{ - return (dColliderFn *) &dCollideG; -} - - -static void dGeomGroupAABB (dxGeom *geom, dReal aabb[6]) -{ - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(geom); - aabb[0] = dInfinity; - aabb[1] = -dInfinity; - aabb[2] = dInfinity; - aabb[3] = -dInfinity; - aabb[4] = dInfinity; - aabb[5] = -dInfinity; - int i,j; - for (i=0; i < gr->parts.size(); i++) { - dReal aabb2[6]; - gr->parts[i]->_class->aabb (gr->parts[i],aabb2); - for (j=0; j<6; j += 2) if (aabb2[j] < aabb[j]) aabb[j] = aabb2[j]; - for (j=1; j<6; j += 2) if (aabb2[j] > aabb[j]) aabb[j] = aabb2[j]; - } -} - - -static void dGeomGroupDtor (dxGeom *geom) -{ - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(geom); - gr->parts.~dArray(); -} - - -dxGeom *dCreateGeomGroup (dSpaceID space) -{ - if (dGeomGroupClass == -1) { - dGeomClass c; - c.bytes = sizeof (dxGeomGroup); - c.collider = &dGeomGroupColliderFn; - c.aabb = &dGeomGroupAABB; - c.aabb_test = 0; - c.dtor = &dGeomGroupDtor; - dGeomGroupClass = dCreateGeomClass (&c); - } - - dxGeom *g = dCreateGeom (dGeomGroupClass); - if (space) dSpaceAdd (space,g); - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(g); - gr->parts.constructor(); - return g; -} - - -void dGeomGroupAdd (dxGeom *g, dxGeom *x) -{ - dUASSERT (g && g->_class->num == dGeomGroupClass,"argument not a geomgroup"); - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(g); - gr->parts.push (x); -} - - -void dGeomGroupRemove (dxGeom *g, dxGeom *x) -{ - dUASSERT (g && g->_class->num == dGeomGroupClass,"argument not a geomgroup"); - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(g); - for (int i=0; i < gr->parts.size(); i++) { - if (gr->parts[i] == x) { - gr->parts.remove (i); - return; - } - } -} - - -int dGeomGroupGetNumGeoms (dxGeom *g) -{ - dUASSERT (g && g->_class->num == dGeomGroupClass,"argument not a geomgroup"); - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(g); - return gr->parts.size(); -} - - -dxGeom * dGeomGroupGetGeom (dxGeom *g, int i) -{ - dUASSERT (g && g->_class->num == dGeomGroupClass,"argument not a geomgroup"); - dxGeomGroup *gr = (dxGeomGroup*) CLASSDATA(g); - dAASSERT (i >= 0 && i < gr->parts.size()); - return gr->parts[i]; -} - -//**************************************************************************** -// transformed geom - -int dGeomTransformClass = -1; - -struct dxGeomTransform { - dxGeom *obj; // object that is being transformed - int cleanup; // 1 to destroy obj when destroyed - int infomode; // 1 to put Tx geom in dContactGeom g1 - dVector3 final_pos; // final tx (body tx + relative tx) of the object. - dMatrix3 final_R; // this is only set if the AABB function is called -}; // by space collision before the collide fn is called - - -// compute final pos and R for the encapsulated geom object - -static void compute_final_tx (const dxGeom *g) -{ - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - dMULTIPLY0_331 (tr->final_pos,g->R,tr->obj->pos); - tr->final_pos[0] += g->pos[0]; - tr->final_pos[1] += g->pos[1]; - tr->final_pos[2] += g->pos[2]; - dMULTIPLY0_333 (tr->final_R,g->R,tr->obj->R); -} - - - -// this collides a transformed geom with another geom. the other geom can -// also be a transformed geom, but this case is not handled specially. - -int dCollideT (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(o1); - if (!tr->obj) return 0; - dUASSERT (tr->obj->spaceid==0, - "GeomTransform encapsulated object must not be in a space"); - dUASSERT (tr->obj->body==0, - "GeomTransform encapsulated object must not be attach to a body"); - - // backup the relative pos and R pointers of the encapsulated geom object, - // and the body pointer - dReal *posbak = tr->obj->pos; - dReal *Rbak = tr->obj->R; - dxBody *bodybak = tr->obj->body; - - // compute temporary pos and R for the encapsulated geom object - if (!o1->space_aabb) compute_final_tx (o1); - tr->obj->pos = tr->final_pos; - tr->obj->R = tr->final_R; - tr->obj->body = o1->body; - - // do the collision - int n = dCollide (tr->obj,const_cast<dxGeom*>(o2),flags,contact,skip); - - // if required, adjust the 'g1' values in the generated contacts so that - // thay indicated the GeomTransform object instead of the encapsulated - // object. - if (tr->infomode) { - for (int i=0; i<n; i++) { - dContactGeom *c = CONTACT(contact,skip*i); - c->g1 = const_cast<dxGeom*> (o1); - } - } - - // restore the pos, R and body - tr->obj->pos = posbak; - tr->obj->R = Rbak; - tr->obj->body = bodybak; - return n; -} - - -static dColliderFn * dGeomTransformColliderFn (int num) -{ - return (dColliderFn *) &dCollideT; -} - - -static void dGeomTransformAABB (dxGeom *geom, dReal aabb[6]) -{ - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(geom); - if (!tr->obj) { - dSetZero (aabb,6); - return; - } - - // backup the relative pos and R pointers of the encapsulated geom object - dReal *posbak = tr->obj->pos; - dReal *Rbak = tr->obj->R; - - // compute temporary pos and R for the encapsulated geom object - compute_final_tx (geom); - tr->obj->pos = tr->final_pos; - tr->obj->R = tr->final_R; - - // compute the AABB - tr->obj->_class->aabb (tr->obj,aabb); - - // restore the pos and R - tr->obj->pos = posbak; - tr->obj->R = Rbak; -} - - -static void dGeomTransformDtor (dxGeom *geom) -{ - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(geom); - if (tr->obj && tr->cleanup) { - dGeomDestroy (tr->obj); - } -} - - -dxGeom *dCreateGeomTransform (dSpaceID space) -{ - if (dGeomTransformClass == -1) { - dGeomClass c; - c.bytes = sizeof (dxGeomTransform); - c.collider = &dGeomTransformColliderFn; - c.aabb = &dGeomTransformAABB; - c.aabb_test = 0; - c.dtor = dGeomTransformDtor; - dGeomTransformClass = dCreateGeomClass (&c); - } - - dxGeom *g = dCreateGeom (dGeomTransformClass); - if (space) dSpaceAdd (space,g); - - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - tr->obj = 0; - tr->cleanup = 0; - tr->infomode = 0; - dSetZero (tr->final_pos,4); - dRSetIdentity (tr->final_R); - - return g; -} - - -void dGeomTransformSetGeom (dxGeom *g, dxGeom *obj) -{ - dUASSERT (g && g->_class->num == dGeomTransformClass, - "argument not a geom transform"); - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - if (tr->obj && tr->cleanup) { - dGeomDestroy (tr->obj); - } - tr->obj = obj; -} - - -dxGeom * dGeomTransformGetGeom (dxGeom *g) -{ - dUASSERT (g && g->_class->num == dGeomTransformClass, - "argument not a geom transform"); - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - return tr->obj; -} - - -void dGeomTransformSetCleanup (dGeomID g, int mode) -{ - dUASSERT (g && g->_class->num == dGeomTransformClass, - "argument not a geom transform"); - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - tr->cleanup = mode; -} - - -int dGeomTransformGetCleanup (dGeomID g) -{ - dUASSERT (g && g->_class->num == dGeomTransformClass, - "argument not a geom transform"); - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - return tr->cleanup; -} - - -void dGeomTransformSetInfo (dGeomID g, int mode) -{ - dUASSERT (g && g->_class->num == dGeomTransformClass, - "argument not a geom transform"); - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - tr->infomode = mode; -} - - -int dGeomTransformGetInfo (dGeomID g) -{ - dUASSERT (g && g->_class->num == dGeomTransformClass, - "argument not a geom transform"); - dxGeomTransform *tr = (dxGeomTransform*) CLASSDATA(g); - return tr->infomode; -} - -//**************************************************************************** -// other utility functions - -void dInfiniteAABB (dxGeom *geom, dReal aabb[6]) -{ - aabb[0] = -dInfinity; - aabb[1] = dInfinity; - aabb[2] = -dInfinity; - aabb[3] = dInfinity; - aabb[4] = -dInfinity; - aabb[5] = dInfinity; -} - - -void dCloseODE() -{ - if (colliders) { - delete colliders; - colliders = 0; - } - if (classes) { - for (int i=0; i < classes->size(); i++) { - dFree ((*classes)[i], sizeof (dxGeomClass)); - } - delete classes; - classes = 0; - } - - // reset geom class vars - dSphereClass = -1; - dBoxClass = -1; - dCCylinderClass = -1; - dPlaneClass = -1; - dGeomGroupClass = -1; - dGeomTransformClass = -1; - - // if you're using contrib code you may want to uncomment the following: - // dTriListClass = -1; - // dRayClass = -1; -} diff --git a/extern/ode/dist/ode/src/geom_internal.h b/extern/ode/dist/ode/src/geom_internal.h deleted file mode 100644 index 63be589ffe0..00000000000 --- a/extern/ode/dist/ode/src/geom_internal.h +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_GEOM_INTERNAL_H_ -#define _ODE_GEOM_INTERNAL_H_ - - -// mask for the number-of-contacts field in the dCollide() flags parameter -#define NUMC_MASK (0xffff) - - -// internal info for geometry class - -struct dxGeomClass { - dGetColliderFnFn *collider; - dGetAABBFn *aabb; - dAABBTestFn *aabb_test; - dGeomDtorFn *dtor; - int num; // class number - int size; // total size of object, including extra data area -}; - - -// position vector and rotation matrix for geometry objects that are not -// connected to bodies. - -struct dxPosR { - dVector3 pos; - dMatrix3 R; -}; - - -// common data for all geometry objects. the class-specific data area follows -// this structure. pos and R will either point to a separately allocated -// buffer (if body is 0 - pos points to the dxPosR object) or to the pos and -// R of the body (if body nonzero). - -struct dxGeom { // a dGeomID is a pointer to this - dxGeomClass *_class; // class of this object - void *data; // user data pointer - dBodyID body; // dynamics body associated with this object (if any) - dReal *pos; // pointer to object's position vector - dReal *R; // pointer to object's rotation matrix - dSpaceID spaceid; // the space this object is in - dGeomSpaceData space; // reserved for use by space this object is in - dReal *space_aabb; // ptr to aabb array held by dSpaceCollide() fn - // class-specific data follows here, with proper alignment. -}; - - -// this is the size of the dxGeom structure rounded up to a multiple of 16 -// bytes. any class specific data that comes after this will have the correct -// alignment. - -#define SIZEOF_DXGEOM dEFFICIENT_SIZE(sizeof(dxGeom)) - - -// given a pointer to a dxGeom, return a pointer to the class data that -// follows it. - -#define CLASSDATA(geomptr) (((char*)geomptr) + SIZEOF_DXGEOM) - -#endif - diff --git a/extern/ode/dist/ode/src/joint.cpp b/extern/ode/dist/ode/src/joint.cpp deleted file mode 100644 index 74e4c34cc71..00000000000 --- a/extern/ode/dist/ode/src/joint.cpp +++ /dev/null @@ -1,2160 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -design note: the general principle for giving a joint the option of connecting -to the static environment (i.e. the absolute frame) is to check the second -body (joint->node[1].body), and if it is zero then behave as if its body -transform is the identity. - -*/ - -#include <ode/odemath.h> -#include <ode/rotation.h> -#include <ode/matrix.h> -#include "joint.h" - -//**************************************************************************** -// externs - -extern "C" void dBodyAddTorque (dBodyID, dReal fx, dReal fy, dReal fz); -extern "C" void dBodyAddForce (dBodyID, dReal fx, dReal fy, dReal fz); - -//**************************************************************************** -// utility - -// set three "ball-and-socket" rows in the constraint equation, and the -// corresponding right hand side. - -static inline void setBall (dxJoint *joint, dxJoint::Info2 *info, - dVector3 anchor1, dVector3 anchor2) -{ - // anchor points in global coordinates with respect to body PORs. - dVector3 a1,a2; - - int s = info->rowskip; - - // set jacobian - info->J1l[0] = 1; - info->J1l[s+1] = 1; - info->J1l[2*s+2] = 1; - dMULTIPLY0_331 (a1,joint->node[0].body->R,anchor1); - dCROSSMAT (info->J1a,a1,s,-,+); - if (joint->node[1].body) { - info->J2l[0] = -1; - info->J2l[s+1] = -1; - info->J2l[2*s+2] = -1; - dMULTIPLY0_331 (a2,joint->node[1].body->R,anchor2); - dCROSSMAT (info->J2a,a2,s,+,-); - } - - // set right hand side - dReal k = info->fps * info->erp; - if (joint->node[1].body) { - for (int j=0; j<3; j++) { - info->c[j] = k * (a2[j] + joint->node[1].body->pos[j] - - a1[j] - joint->node[0].body->pos[j]); - } - } - else { - for (int j=0; j<3; j++) { - info->c[j] = k * (anchor2[j] - a1[j] - - joint->node[0].body->pos[j]); - } - } -} - - -// this is like setBall(), except that `axis' is a unit length vector -// (in global coordinates) that should be used for the first jacobian -// position row (the other two row vectors will be derived from this). -// `erp1' is the erp value to use along the axis. - -static inline void setBall2 (dxJoint *joint, dxJoint::Info2 *info, - dVector3 anchor1, dVector3 anchor2, - dVector3 axis, dReal erp1) -{ - // anchor points in global coordinates with respect to body PORs. - dVector3 a1,a2; - - int i,s = info->rowskip; - - // get vectors normal to the axis. in setBall() axis,q1,q2 is [1 0 0], - // [0 1 0] and [0 0 1], which makes everything much easier. - dVector3 q1,q2; - dPlaneSpace (axis,q1,q2); - - // set jacobian - for (i=0; i<3; i++) info->J1l[i] = axis[i]; - for (i=0; i<3; i++) info->J1l[s+i] = q1[i]; - for (i=0; i<3; i++) info->J1l[2*s+i] = q2[i]; - dMULTIPLY0_331 (a1,joint->node[0].body->R,anchor1); - dCROSS (info->J1a,=,a1,axis); - dCROSS (info->J1a+s,=,a1,q1); - dCROSS (info->J1a+2*s,=,a1,q2); - if (joint->node[1].body) { - for (i=0; i<3; i++) info->J2l[i] = -axis[i]; - for (i=0; i<3; i++) info->J2l[s+i] = -q1[i]; - for (i=0; i<3; i++) info->J2l[2*s+i] = -q2[i]; - dMULTIPLY0_331 (a2,joint->node[1].body->R,anchor2); - dCROSS (info->J2a,= -,a2,axis); - dCROSS (info->J2a+s,= -,a2,q1); - dCROSS (info->J2a+2*s,= -,a2,q2); - } - - // set right hand side - measure error along (axis,q1,q2) - dReal k1 = info->fps * erp1; - dReal k = info->fps * info->erp; - - for (i=0; i<3; i++) a1[i] += joint->node[0].body->pos[i]; - if (joint->node[1].body) { - for (i=0; i<3; i++) a2[i] += joint->node[1].body->pos[i]; - info->c[0] = k1 * (dDOT(axis,a2) - dDOT(axis,a1)); - info->c[1] = k * (dDOT(q1,a2) - dDOT(q1,a1)); - info->c[2] = k * (dDOT(q2,a2) - dDOT(q2,a1)); - } - else { - info->c[0] = k1 * (dDOT(axis,anchor2) - dDOT(axis,a1)); - info->c[1] = k * (dDOT(q1,anchor2) - dDOT(q1,a1)); - info->c[2] = k * (dDOT(q2,anchor2) - dDOT(q2,a1)); - } -} - - -// compute anchor points relative to bodies - -static void setAnchors (dxJoint *j, dReal x, dReal y, dReal z, - dVector3 anchor1, dVector3 anchor2) -{ - if (j->node[0].body) { - dReal q[4]; - q[0] = x - j->node[0].body->pos[0]; - q[1] = y - j->node[0].body->pos[1]; - q[2] = z - j->node[0].body->pos[2]; - q[3] = 0; - dMULTIPLY1_331 (anchor1,j->node[0].body->R,q); - if (j->node[1].body) { - q[0] = x - j->node[1].body->pos[0]; - q[1] = y - j->node[1].body->pos[1]; - q[2] = z - j->node[1].body->pos[2]; - q[3] = 0; - dMULTIPLY1_331 (anchor2,j->node[1].body->R,q); - } - else { - anchor2[0] = x; - anchor2[1] = y; - anchor2[2] = z; - } - } - anchor1[3] = 0; - anchor2[3] = 0; -} - - -// compute axes relative to bodies. axis2 can be 0 - -static void setAxes (dxJoint *j, dReal x, dReal y, dReal z, - dVector3 axis1, dVector3 axis2) -{ - if (j->node[0].body) { - dReal q[4]; - q[0] = x; - q[1] = y; - q[2] = z; - q[3] = 0; - dNormalize3 (q); - dMULTIPLY1_331 (axis1,j->node[0].body->R,q); - if (axis2) { - if (j->node[1].body) { - dMULTIPLY1_331 (axis2,j->node[1].body->R,q); - } - else { - axis2[0] = x; - axis2[1] = y; - axis2[2] = z; - } - axis2[3] = 0; - } - } - axis1[3] = 0; -} - - -static void getAnchor (dxJoint *j, dVector3 result, dVector3 anchor1) -{ - if (j->node[0].body) { - dMULTIPLY0_331 (result,j->node[0].body->R,anchor1); - result[0] += j->node[0].body->pos[0]; - result[1] += j->node[0].body->pos[1]; - result[2] += j->node[0].body->pos[2]; - } -} - - -static void getAxis (dxJoint *j, dVector3 result, dVector3 axis1) -{ - if (j->node[0].body) { - dMULTIPLY0_331 (result,j->node[0].body->R,axis1); - } -} - - -// given two bodies (body1,body2), the hinge axis that they are connected by -// w.r.t. body1 (axis), and the initial relative orientation between them -// (q_initial), return the relative rotation angle. the initial relative -// orientation corresponds to an angle of zero. if body2 is 0 then measure the -// angle between body1 and the static frame. -// -// this will not return the correct angle if the bodies rotate along any axis -// other than the given hinge axis. - -static dReal getHingeAngle (dxBody *body1, dxBody *body2, dVector3 axis, - dQuaternion q_initial) -{ - // the angle between the two bodies is extracted from the quaternion that - // represents the relative rotation between them. recall that a quaternion - // q is: - // [s,v] = [ cos(theta/2) , sin(theta/2) * u ] - // where s is a scalar and v is a 3-vector. u is a unit length axis and - // theta is a rotation along that axis. we can get theta/2 by: - // theta/2 = atan2 ( sin(theta/2) , cos(theta/2) ) - // but we can't get sin(theta/2) directly, only its absolute value, i.e.: - // |v| = |sin(theta/2)| * |u| - // = |sin(theta/2)| - // using this value will have a strange effect. recall that there are two - // quaternion representations of a given rotation, q and -q. typically as - // a body rotates along the axis it will go through a complete cycle using - // one representation and then the next cycle will use the other - // representation. this corresponds to u pointing in the direction of the - // hinge axis and then in the opposite direction. the result is that theta - // will appear to go "backwards" every other cycle. here is a fix: if u - // points "away" from the direction of the hinge (motor) axis (i.e. more - // than 90 degrees) then use -q instead of q. this represents the same - // rotation, but results in the cos(theta/2) value being sign inverted. - - // get qrel = relative rotation between the two bodies - dQuaternion qrel; - if (body2) { - dQuaternion qq; - dQMultiply1 (qq,body1->q,body2->q); - dQMultiply2 (qrel,qq,q_initial); - } - else { - // pretend body2->q is the identity - dQMultiply3 (qrel,body1->q,q_initial); - } - - // extract the angle from the quaternion. cost2 = cos(theta/2), - // sint2 = |sin(theta/2)| - dReal cost2 = qrel[0]; - dReal sint2 = dSqrt (qrel[1]*qrel[1]+qrel[2]*qrel[2]+qrel[3]*qrel[3]); - dReal theta = (dDOT(qrel+1,axis) >= 0) ? // @@@ padding assumptions - (2 * dAtan2(sint2,cost2)) : // if u points in direction of axis - (2 * dAtan2(sint2,-cost2)); // if u points in opposite direction - - // the angle we get will be between 0..2*pi, but we want to return angles - // between -pi..pi - if (theta > M_PI) theta -= 2*M_PI; - - // the angle we've just extracted has the wrong sign - theta = -theta; - - return theta; -} - -//**************************************************************************** -// dxJointLimitMotor - -void dxJointLimitMotor::init (dxWorld *world) -{ - vel = 0; - fmax = 0; - lostop = -dInfinity; - histop = dInfinity; - fudge_factor = 1; - normal_cfm = world->global_cfm; - stop_erp = world->global_erp; - stop_cfm = world->global_cfm; - bounce = 0; - limit = 0; - limit_err = 0; -} - - -void dxJointLimitMotor::set (int num, dReal value) -{ - switch (num) { - case dParamLoStop: - if (value <= histop) lostop = value; - break; - case dParamHiStop: - if (value >= lostop) histop = value; - break; - case dParamVel: - vel = value; - break; - case dParamFMax: - if (value >= 0) fmax = value; - break; - case dParamFudgeFactor: - if (value >= 0 && value <= 1) fudge_factor = value; - break; - case dParamBounce: - bounce = value; - break; - case dParamCFM: - normal_cfm = value; - break; - case dParamStopERP: - stop_erp = value; - break; - case dParamStopCFM: - stop_cfm = value; - break; - } -} - - -dReal dxJointLimitMotor::get (int num) -{ - switch (num) { - case dParamLoStop: return lostop; - case dParamHiStop: return histop; - case dParamVel: return vel; - case dParamFMax: return fmax; - case dParamFudgeFactor: return fudge_factor; - case dParamBounce: return bounce; - case dParamCFM: return normal_cfm; - case dParamStopERP: return stop_erp; - case dParamStopCFM: return stop_cfm; - default: return 0; - } -} - - -int dxJointLimitMotor::testRotationalLimit (dReal angle) -{ - if (angle <= lostop) { - limit = 1; - limit_err = angle - lostop; - return 1; - } - else if (angle >= histop) { - limit = 2; - limit_err = angle - histop; - return 1; - } - else { - limit = 0; - return 0; - } -} - - -int dxJointLimitMotor::addLimot (dxJoint *joint, - dxJoint::Info2 *info, int row, - dVector3 ax1, int rotational) -{ - int srow = row * info->rowskip; - - // if the joint is powered, or has joint limits, add in the extra row - int powered = fmax > 0; - if (powered || limit) { - dReal *J1 = rotational ? info->J1a : info->J1l; - dReal *J2 = rotational ? info->J2a : info->J2l; - - J1[srow+0] = ax1[0]; - J1[srow+1] = ax1[1]; - J1[srow+2] = ax1[2]; - if (joint->node[1].body) { - J2[srow+0] = -ax1[0]; - J2[srow+1] = -ax1[1]; - J2[srow+2] = -ax1[2]; - } - - // if we're limited low and high simultaneously, the joint motor is - // ineffective - if (limit && (lostop == histop)) powered = 0; - - if (powered) { - info->cfm[row] = normal_cfm; - if (! limit) { - info->c[row] = vel; - info->lo[row] = -fmax; - info->hi[row] = fmax; - } - else { - // the joint is at a limit, AND is being powered. if the joint is - // being powered into the limit then we apply the maximum motor force - // in that direction, because the motor is working against the - // immovable limit. if the joint is being powered away from the limit - // then we have problems because actually we need *two* lcp - // constraints to handle this case. so we fake it and apply some - // fraction of the maximum force. the fraction to use can be set as - // a fudge factor. - - dReal fm = fmax; - if (vel > 0) fm = -fm; - - // if we're powering away from the limit, apply the fudge factor - if ((limit==1 && vel > 0) || (limit==2 && vel < 0)) fm *= fudge_factor; - - if (rotational) { - dBodyAddTorque (joint->node[0].body,-fm*ax1[0],-fm*ax1[1], - -fm*ax1[2]); - if (joint->node[1].body) - dBodyAddTorque (joint->node[1].body,fm*ax1[0],fm*ax1[1],fm*ax1[2]); - } - else { - dBodyAddForce (joint->node[0].body,-fm*ax1[0],-fm*ax1[1],-fm*ax1[2]); - if (joint->node[1].body) - dBodyAddForce (joint->node[1].body,fm*ax1[0],fm*ax1[1],fm*ax1[2]); - } - } - } - - if (limit) { - dReal k = info->fps * stop_erp; - info->c[row] = -k * limit_err; - info->cfm[row] = stop_cfm; - - if (lostop == histop) { - // limited low and high simultaneously - info->lo[row] = -dInfinity; - info->hi[row] = dInfinity; - } - else { - if (limit == 1) { - // low limit - info->lo[row] = 0; - info->hi[row] = dInfinity; - } - else { - // high limit - info->lo[row] = -dInfinity; - info->hi[row] = 0; - } - - // deal with bounce - if (bounce > 0) { - // calculate joint velocity - dReal vel; - if (rotational) { - vel = dDOT(joint->node[0].body->avel,ax1); - if (joint->node[1].body) - vel -= dDOT(joint->node[1].body->avel,ax1); - } - else { - vel = dDOT(joint->node[0].body->lvel,ax1); - if (joint->node[1].body) - vel -= dDOT(joint->node[1].body->lvel,ax1); - } - - // only apply bounce if the velocity is incoming, and if the - // resulting c[] exceeds what we already have. - if (limit == 1) { - // low limit - if (vel < 0) { - dReal newc = -bounce * vel; - if (newc > info->c[row]) info->c[row] = newc; - } - } - else { - // high limit - all those computations are reversed - if (vel > 0) { - dReal newc = -bounce * vel; - if (newc < info->c[row]) info->c[row] = newc; - } - } - } - } - } - return 1; - } - else return 0; -} - -//**************************************************************************** -// ball and socket - -static void ballInit (dxJointBall *j) -{ - dSetZero (j->anchor1,4); - dSetZero (j->anchor2,4); -} - - -static void ballGetInfo1 (dxJointBall *j, dxJoint::Info1 *info) -{ - info->m = 3; - info->nub = 3; -} - - -static void ballGetInfo2 (dxJointBall *joint, dxJoint::Info2 *info) -{ - setBall (joint,info,joint->anchor1,joint->anchor2); -} - - -extern "C" void dJointSetBallAnchor (dxJointBall *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dball_vtable,"joint is not a ball"); - setAnchors (joint,x,y,z,joint->anchor1,joint->anchor2); -} - - -extern "C" void dJointGetBallAnchor (dxJointBall *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dball_vtable,"joint is not a ball"); - getAnchor (joint,result,joint->anchor1); -} - - -dxJoint::Vtable __dball_vtable = { - sizeof(dxJointBall), - (dxJoint::init_fn*) ballInit, - (dxJoint::getInfo1_fn*) ballGetInfo1, - (dxJoint::getInfo2_fn*) ballGetInfo2, - dJointTypeBall}; - -//**************************************************************************** -// hinge - -static void hingeInit (dxJointHinge *j) -{ - dSetZero (j->anchor1,4); - dSetZero (j->anchor2,4); - dSetZero (j->axis1,4); - j->axis1[0] = 1; - dSetZero (j->axis2,4); - j->axis2[0] = 1; - dSetZero (j->qrel,4); - j->limot.init (j->world); -} - - -static void hingeGetInfo1 (dxJointHinge *j, dxJoint::Info1 *info) -{ - info->nub = 5; - - // see if joint is powered - if (j->limot.fmax > 0) - info->m = 6; // powered hinge needs an extra constraint row - else info->m = 5; - - // see if we're at a joint limit. - if ((j->limot.lostop >= -M_PI || j->limot.histop <= M_PI) && - j->limot.lostop <= j->limot.histop) { - dReal angle = getHingeAngle (j->node[0].body,j->node[1].body,j->axis1, - j->qrel); - if (j->limot.testRotationalLimit (angle)) info->m = 6; - } -} - - -static void hingeGetInfo2 (dxJointHinge *joint, dxJoint::Info2 *info) -{ - // set the three ball-and-socket rows - setBall (joint,info,joint->anchor1,joint->anchor2); - - // set the two hinge rows. the hinge axis should be the only unconstrained - // rotational axis, the angular velocity of the two bodies perpendicular to - // the hinge axis should be equal. thus the constraint equations are - // p*w1 - p*w2 = 0 - // q*w1 - q*w2 = 0 - // where p and q are unit vectors normal to the hinge axis, and w1 and w2 - // are the angular velocity vectors of the two bodies. - - dVector3 ax1; // length 1 joint axis in global coordinates, from 1st body - dVector3 p,q; // plane space vectors for ax1 - dMULTIPLY0_331 (ax1,joint->node[0].body->R,joint->axis1); - dPlaneSpace (ax1,p,q); - - int s3=3*info->rowskip; - int s4=4*info->rowskip; - - info->J1a[s3+0] = p[0]; - info->J1a[s3+1] = p[1]; - info->J1a[s3+2] = p[2]; - info->J1a[s4+0] = q[0]; - info->J1a[s4+1] = q[1]; - info->J1a[s4+2] = q[2]; - - if (joint->node[1].body) { - info->J2a[s3+0] = -p[0]; - info->J2a[s3+1] = -p[1]; - info->J2a[s3+2] = -p[2]; - info->J2a[s4+0] = -q[0]; - info->J2a[s4+1] = -q[1]; - info->J2a[s4+2] = -q[2]; - } - - // compute the right hand side of the constraint equation. set relative - // body velocities along p and q to bring the hinge back into alignment. - // if ax1,ax2 are the unit length hinge axes as computed from body1 and - // body2, we need to rotate both bodies along the axis u = (ax1 x ax2). - // if `theta' is the angle between ax1 and ax2, we need an angular velocity - // along u to cover angle erp*theta in one step : - // |angular_velocity| = angle/time = erp*theta / stepsize - // = (erp*fps) * theta - // angular_velocity = |angular_velocity| * (ax1 x ax2) / |ax1 x ax2| - // = (erp*fps) * theta * (ax1 x ax2) / sin(theta) - // ...as ax1 and ax2 are unit length. if theta is smallish, - // theta ~= sin(theta), so - // angular_velocity = (erp*fps) * (ax1 x ax2) - // ax1 x ax2 is in the plane space of ax1, so we project the angular - // velocity to p and q to find the right hand side. - - dVector3 ax2,b; - if (joint->node[1].body) { - dMULTIPLY0_331 (ax2,joint->node[1].body->R,joint->axis2); - } - else { - ax2[0] = joint->axis2[0]; - ax2[1] = joint->axis2[1]; - ax2[2] = joint->axis2[2]; - } - dCROSS (b,=,ax1,ax2); - dReal k = info->fps * info->erp; - info->c[3] = k * dDOT(b,p); - info->c[4] = k * dDOT(b,q); - - // if the hinge is powered, or has joint limits, add in the stuff - joint->limot.addLimot (joint,info,5,ax1,1); -} - - -// compute initial relative rotation body1 -> body2, or env -> body1 - -static void hingeComputeInitialRelativeRotation (dxJointHinge *joint) -{ - if (joint->node[0].body) { - if (joint->node[1].body) { - dQMultiply1 (joint->qrel,joint->node[0].body->q,joint->node[1].body->q); - } - else { - // set joint->qrel to the transpose of the first body q - joint->qrel[0] = joint->node[0].body->q[0]; - for (int i=1; i<4; i++) joint->qrel[i] = -joint->node[0].body->q[i]; - } - } -} - - -extern "C" void dJointSetHingeAnchor (dxJointHinge *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - setAnchors (joint,x,y,z,joint->anchor1,joint->anchor2); - hingeComputeInitialRelativeRotation (joint); -} - - -extern "C" void dJointSetHingeAxis (dxJointHinge *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - setAxes (joint,x,y,z,joint->axis1,joint->axis2); - hingeComputeInitialRelativeRotation (joint); -} - - -extern "C" void dJointGetHingeAnchor (dxJointHinge *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - getAnchor (joint,result,joint->anchor1); -} - - -extern "C" void dJointGetHingeAxis (dxJointHinge *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - getAxis (joint,result,joint->axis1); -} - - -extern "C" void dJointSetHingeParam (dxJointHinge *joint, - int parameter, dReal value) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - joint->limot.set (parameter,value); -} - - -extern "C" dReal dJointGetHingeParam (dxJointHinge *joint, int parameter) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - return joint->limot.get (parameter); -} - - -extern "C" dReal dJointGetHingeAngle (dxJointHinge *joint) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a hinge"); - if (joint->node[0].body) { - return getHingeAngle (joint->node[0].body,joint->node[1].body,joint->axis1, - joint->qrel); - } - else return 0; -} - - -extern "C" dReal dJointGetHingeAngleRate (dxJointHinge *joint) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__dhinge_vtable,"joint is not a Hinge"); - if (joint->node[0].body) { - dVector3 axis; - dMULTIPLY0_331 (axis,joint->node[0].body->R,joint->axis1); - dReal rate = dDOT(axis,joint->node[0].body->avel); - if (joint->node[1].body) rate -= dDOT(axis,joint->node[1].body->avel); - return rate; - } - else return 0; -} - - -dxJoint::Vtable __dhinge_vtable = { - sizeof(dxJointHinge), - (dxJoint::init_fn*) hingeInit, - (dxJoint::getInfo1_fn*) hingeGetInfo1, - (dxJoint::getInfo2_fn*) hingeGetInfo2, - dJointTypeHinge}; - -//**************************************************************************** -// slider - -static void sliderInit (dxJointSlider *j) -{ - dSetZero (j->axis1,4); - j->axis1[0] = 1; - dSetZero (j->qrel,4); - dSetZero (j->offset,4); - j->limot.init (j->world); -} - - -extern "C" dReal dJointGetSliderPosition (dxJointSlider *joint) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dslider_vtable,"joint is not a slider"); - - // get axis1 in global coordinates - dVector3 ax1,q; - dMULTIPLY0_331 (ax1,joint->node[0].body->R,joint->axis1); - - if (joint->node[1].body) { - // get body2 + offset point in global coordinates - dMULTIPLY0_331 (q,joint->node[1].body->R,joint->offset); - for (int i=0; i<3; i++) q[i] = joint->node[0].body->pos[i] - q[i] - - joint->node[1].body->pos[i]; - } - else { - for (int i=0; i<3; i++) q[i] = joint->node[0].body->pos[i] - - joint->offset[i]; - - } - return dDOT(ax1,q); -} - - -extern "C" dReal dJointGetSliderPositionRate (dxJointSlider *joint) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dslider_vtable,"joint is not a slider"); - - // get axis1 in global coordinates - dVector3 ax1; - dMULTIPLY0_331 (ax1,joint->node[0].body->R,joint->axis1); - - if (joint->node[1].body) { - return dDOT(ax1,joint->node[0].body->lvel) - - dDOT(ax1,joint->node[1].body->lvel); - } - else { - return dDOT(ax1,joint->node[0].body->lvel); - } -} - - -static void sliderGetInfo1 (dxJointSlider *j, dxJoint::Info1 *info) -{ - info->nub = 5; - - // see if joint is powered - if (j->limot.fmax > 0) - info->m = 6; // powered slider needs an extra constraint row - else info->m = 5; - - // see if we're at a joint limit. - j->limot.limit = 0; - if ((j->limot.lostop > -dInfinity || j->limot.histop < dInfinity) && - j->limot.lostop <= j->limot.histop) { - // measure joint position - dReal pos = dJointGetSliderPosition (j); - if (pos <= j->limot.lostop) { - j->limot.limit = 1; - j->limot.limit_err = pos - j->limot.lostop; - info->m = 6; - } - else if (pos >= j->limot.histop) { - j->limot.limit = 2; - j->limot.limit_err = pos - j->limot.histop; - info->m = 6; - } - } -} - - -static void sliderGetInfo2 (dxJointSlider *joint, dxJoint::Info2 *info) -{ - int i,s = info->rowskip; - int s2=2*s,s3=3*s,s4=4*s; - - // pull out pos and R for both bodies. also get the `connection' - // vector pos2-pos1. - - dReal *pos1,*pos2,*R1,*R2; - dVector3 c; - pos1 = joint->node[0].body->pos; - R1 = joint->node[0].body->R; - if (joint->node[1].body) { - pos2 = joint->node[1].body->pos; - R2 = joint->node[1].body->R; - for (i=0; i<3; i++) c[i] = pos2[i] - pos1[i]; - } - else { - pos2 = 0; - R2 = 0; - } - - // 3 rows to make body rotations equal - info->J1a[0] = 1; - info->J1a[s+1] = 1; - info->J1a[s2+2] = 1; - if (joint->node[1].body) { - info->J2a[0] = -1; - info->J2a[s+1] = -1; - info->J2a[s2+2] = -1; - } - - // remaining two rows. we want: vel2 = vel1 + w1 x c ... but this would - // result in three equations, so we project along the planespace vectors - // so that sliding along the slider axis is disregarded. for symmetry we - // also substitute (w1+w2)/2 for w1, as w1 is supposed to equal w2. - - dVector3 ax1; // joint axis in global coordinates (unit length) - dVector3 p,q; // plane space of ax1 - dMULTIPLY0_331 (ax1,R1,joint->axis1); - dPlaneSpace (ax1,p,q); - if (joint->node[1].body) { - dVector3 tmp; - dCROSS (tmp, = REAL(0.5) * ,c,p); - for (i=0; i<3; i++) info->J2a[s3+i] = tmp[i]; - for (i=0; i<3; i++) info->J2a[s3+i] = tmp[i]; - dCROSS (tmp, = REAL(0.5) * ,c,q); - for (i=0; i<3; i++) info->J2a[s4+i] = tmp[i]; - for (i=0; i<3; i++) info->J2a[s4+i] = tmp[i]; - for (i=0; i<3; i++) info->J2l[s3+i] = -p[i]; - for (i=0; i<3; i++) info->J2l[s4+i] = -q[i]; - } - for (i=0; i<3; i++) info->J1l[s3+i] = p[i]; - for (i=0; i<3; i++) info->J1l[s4+i] = q[i]; - - // compute the right hand side. the first three elements will result in - // relative angular velocity of the two bodies - this is set to bring them - // back into alignment. the correcting angular velocity is - // |angular_velocity| = angle/time = erp*theta / stepsize - // = (erp*fps) * theta - // angular_velocity = |angular_velocity| * u - // = (erp*fps) * theta * u - // where rotation along unit length axis u by theta brings body 2's frame - // to qrel with respect to body 1's frame. using a small angle approximation - // for sin(), this gives - // angular_velocity = (erp*fps) * 2 * v - // where the quaternion of the relative rotation between the two bodies is - // q = [cos(theta/2) sin(theta/2)*u] = [s v] - - // get qerr = relative rotation (rotation error) between two bodies - dQuaternion qerr,e; - if (joint->node[1].body) { - dQuaternion qq; - dQMultiply1 (qq,joint->node[0].body->q,joint->node[1].body->q); - dQMultiply2 (qerr,qq,joint->qrel); - } - else { - dQMultiply3 (qerr,joint->node[0].body->q,joint->qrel); - } - if (qerr[0] < 0) { - qerr[1] = -qerr[1]; // adjust sign of qerr to make theta small - qerr[2] = -qerr[2]; - qerr[3] = -qerr[3]; - } - dMULTIPLY0_331 (e,joint->node[0].body->R,qerr+1); // @@@ bad SIMD padding! - dReal k = info->fps * info->erp; - info->c[0] = 2*k * e[0]; - info->c[1] = 2*k * e[1]; - info->c[2] = 2*k * e[2]; - - // compute last two elements of right hand side. we want to align the offset - // point (in body 2's frame) with the center of body 1. - if (joint->node[1].body) { - dVector3 ofs; // offset point in global coordinates - dMULTIPLY0_331 (ofs,R2,joint->offset); - for (i=0; i<3; i++) c[i] += ofs[i]; - info->c[3] = k * dDOT(p,c); - info->c[4] = k * dDOT(q,c); - } - else { - dVector3 ofs; // offset point in global coordinates - for (i=0; i<3; i++) ofs[i] = joint->offset[i] - pos1[i]; - info->c[3] = k * dDOT(p,ofs); - info->c[4] = k * dDOT(q,ofs); - } - - // if the slider is powered, or has joint limits, add in the extra row - joint->limot.addLimot (joint,info,5,ax1,0); -} - - -extern "C" void dJointSetSliderAxis (dxJointSlider *joint, - dReal x, dReal y, dReal z) -{ - int i; - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dslider_vtable,"joint is not a slider"); - setAxes (joint,x,y,z,joint->axis1,0); - - // compute initial relative rotation body1 -> body2, or env -> body1 - // also compute center of body1 w.r.t body 2 - if (joint->node[1].body) { - dQMultiply1 (joint->qrel,joint->node[0].body->q,joint->node[1].body->q); - dVector3 c; - for (i=0; i<3; i++) - c[i] = joint->node[0].body->pos[i] - joint->node[1].body->pos[i]; - dMULTIPLY1_331 (joint->offset,joint->node[1].body->R,c); - } - else { - // set joint->qrel to the transpose of the first body's q - joint->qrel[0] = joint->node[0].body->q[0]; - for (i=1; i<4; i++) joint->qrel[i] = -joint->node[0].body->q[i]; - for (i=0; i<3; i++) joint->offset[i] = joint->node[0].body->pos[i]; - } -} - - -extern "C" void dJointGetSliderAxis (dxJointSlider *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dslider_vtable,"joint is not a slider"); - getAxis (joint,result,joint->axis1); -} - - -extern "C" void dJointSetSliderParam (dxJointSlider *joint, - int parameter, dReal value) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dslider_vtable,"joint is not a slider"); - joint->limot.set (parameter,value); -} - - -extern "C" dReal dJointGetSliderParam (dxJointSlider *joint, int parameter) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dslider_vtable,"joint is not a slider"); - return joint->limot.get (parameter); -} - - -dxJoint::Vtable __dslider_vtable = { - sizeof(dxJointSlider), - (dxJoint::init_fn*) sliderInit, - (dxJoint::getInfo1_fn*) sliderGetInfo1, - (dxJoint::getInfo2_fn*) sliderGetInfo2, - dJointTypeSlider}; - -//**************************************************************************** -// contact - -static void contactInit (dxJointContact *j) -{ - // default frictionless contact. hmmm, this info gets overwritten straight - // away anyway, so why bother? - j->contact.surface.mode = 0; - j->contact.surface.mu = 0; - dSetZero (j->contact.geom.pos,4); - dSetZero (j->contact.geom.normal,4); - j->contact.geom.depth = 0; -} - - -static void contactGetInfo1 (dxJointContact *j, dxJoint::Info1 *info) -{ - // make sure mu's >= 0, then calculate number of constraint rows and number - // of unbounded rows. - int m = 1, nub=0; - if (j->contact.surface.mu < 0) j->contact.surface.mu = 0; - if (j->contact.surface.mode & dContactMu2) { - if (j->contact.surface.mu > 0) m++; - if (j->contact.surface.mu2 < 0) j->contact.surface.mu2 = 0; - if (j->contact.surface.mu2 > 0) m++; - if (j->contact.surface.mu == dInfinity) nub ++; - if (j->contact.surface.mu2 == dInfinity) nub ++; - } - else { - if (j->contact.surface.mu > 0) m += 2; - if (j->contact.surface.mu == dInfinity) nub += 2; - } - - j->the_m = m; - info->m = m; - info->nub = nub; -} - - -static void contactGetInfo2 (dxJointContact *j, dxJoint::Info2 *info) -{ - int i,s = info->rowskip; - int s2 = 2*s; - - // get normal, with sign adjusted for body1/body2 polarity - dVector3 normal; - if (j->flags & dJOINT_REVERSE) { - normal[0] = j->contact.geom.normal[0]; - normal[1] = j->contact.geom.normal[1]; - normal[2] = j->contact.geom.normal[2]; - } - else { - normal[0] = - j->contact.geom.normal[0]; - normal[1] = - j->contact.geom.normal[1]; - normal[2] = - j->contact.geom.normal[2]; - } - normal[3] = 0; // @@@ hmmm - - // c1,c2 = contact points with respect to body PORs - dVector3 c1,c2; - for (i=0; i<3; i++) c1[i] = j->contact.geom.pos[i] - j->node[0].body->pos[i]; - - // set jacobian for normal - info->J1l[0] = normal[0]; - info->J1l[1] = normal[1]; - info->J1l[2] = normal[2]; - dCROSS (info->J1a,=,c1,normal); - if (j->node[1].body) { - for (i=0; i<3; i++) c2[i] = j->contact.geom.pos[i] - - j->node[1].body->pos[i]; - info->J2l[0] = -normal[0]; - info->J2l[1] = -normal[1]; - info->J2l[2] = -normal[2]; - dCROSS (info->J2a,= -,c2,normal); - } - - // set right hand side and cfm value for normal - dReal erp = info->erp; - if (j->contact.surface.mode & dContactSoftERP) - erp = j->contact.surface.soft_erp; - dReal k = info->fps * erp; - info->c[0] = k*j->contact.geom.depth; - if (j->contact.surface.mode & dContactSoftCFM) - info->cfm[0] = j->contact.surface.soft_cfm; - - // deal with bounce - if (j->contact.surface.mode & dContactBounce) { - // calculate outgoing velocity (-ve for incoming contact) - dReal outgoing = dDOT(info->J1l,j->node[0].body->lvel) + - dDOT(info->J1a,j->node[0].body->avel); - if (j->node[1].body) { - outgoing += dDOT(info->J2l,j->node[1].body->lvel) + - dDOT(info->J2a,j->node[1].body->avel); - } - // only apply bounce if the outgoing velocity is greater than the - // threshold, and if the resulting c[0] exceeds what we already have. - if (j->contact.surface.bounce_vel >= 0 && - (-outgoing) > j->contact.surface.bounce_vel) { - dReal newc = - j->contact.surface.bounce * outgoing; - if (newc > info->c[0]) info->c[0] = newc; - } - } - - // set LCP limits for normal - info->lo[0] = 0; - info->hi[0] = dInfinity; - - // now do jacobian for tangential forces - dVector3 t1,t2; // two vectors tangential to normal - - // first friction direction - if (j->the_m >= 2) { - if (j->contact.surface.mode & dContactFDir1) { // use fdir1 ? - t1[0] = j->contact.fdir1[0]; - t1[1] = j->contact.fdir1[1]; - t1[2] = j->contact.fdir1[2]; - dCROSS (t2,=,normal,t1); - } - else { - dPlaneSpace (normal,t1,t2); - } - info->J1l[s+0] = t1[0]; - info->J1l[s+1] = t1[1]; - info->J1l[s+2] = t1[2]; - dCROSS (info->J1a+s,=,c1,t1); - if (j->node[1].body) { - info->J2l[s+0] = -t1[0]; - info->J2l[s+1] = -t1[1]; - info->J2l[s+2] = -t1[2]; - dCROSS (info->J2a+s,= -,c2,t1); - } - // set right hand side - if (j->contact.surface.mode & dContactMotion1) { - info->c[1] = j->contact.surface.motion1; - } - // set LCP bounds and friction index. this depends on the approximation - // mode - info->lo[1] = -j->contact.surface.mu; - info->hi[1] = j->contact.surface.mu; - if (j->contact.surface.mode & dContactApprox1_1) info->findex[1] = 0; - - // set slip (constraint force mixing) - if (j->contact.surface.mode & dContactSlip1) - info->cfm[1] = j->contact.surface.slip1; - } - - // second friction direction - if (j->the_m >= 3) { - info->J1l[s2+0] = t2[0]; - info->J1l[s2+1] = t2[1]; - info->J1l[s2+2] = t2[2]; - dCROSS (info->J1a+s2,=,c1,t2); - if (j->node[1].body) { - info->J2l[s2+0] = -t2[0]; - info->J2l[s2+1] = -t2[1]; - info->J2l[s2+2] = -t2[2]; - dCROSS (info->J2a+s2,= -,c2,t2); - } - // set right hand side - if (j->contact.surface.mode & dContactMotion2) { - info->c[2] = j->contact.surface.motion2; - } - // set LCP bounds and friction index. this depends on the approximation - // mode - if (j->contact.surface.mode & dContactMu2) { - info->lo[2] = -j->contact.surface.mu2; - info->hi[2] = j->contact.surface.mu2; - } - else { - info->lo[2] = -j->contact.surface.mu; - info->hi[2] = j->contact.surface.mu; - } - if (j->contact.surface.mode & dContactApprox1_2) info->findex[2] = 0; - - // set slip (constraint force mixing) - if (j->contact.surface.mode & dContactSlip2) - info->cfm[2] = j->contact.surface.slip2; - } -} - - -dxJoint::Vtable __dcontact_vtable = { - sizeof(dxJointContact), - (dxJoint::init_fn*) contactInit, - (dxJoint::getInfo1_fn*) contactGetInfo1, - (dxJoint::getInfo2_fn*) contactGetInfo2, - dJointTypeContact}; - -//**************************************************************************** -// hinge 2. note that this joint must be attached to two bodies for it to work - -static dReal measureHinge2Angle (dxJointHinge2 *joint) -{ - dVector3 a1,a2; - dMULTIPLY0_331 (a1,joint->node[1].body->R,joint->axis2); - dMULTIPLY1_331 (a2,joint->node[0].body->R,a1); - dReal x = dDOT(joint->v1,a2); - dReal y = dDOT(joint->v2,a2); - return -dAtan2 (y,x); -} - - -static void hinge2Init (dxJointHinge2 *j) -{ - dSetZero (j->anchor1,4); - dSetZero (j->anchor2,4); - dSetZero (j->axis1,4); - j->axis1[0] = 1; - dSetZero (j->axis2,4); - j->axis2[1] = 1; - j->c0 = 0; - j->s0 = 0; - - dSetZero (j->v1,4); - j->v1[0] = 1; - dSetZero (j->v2,4); - j->v2[1] = 1; - - j->limot1.init (j->world); - j->limot2.init (j->world); - - j->susp_erp = j->world->global_erp; - j->susp_cfm = j->world->global_cfm; - - j->flags |= dJOINT_TWOBODIES; -} - - -static void hinge2GetInfo1 (dxJointHinge2 *j, dxJoint::Info1 *info) -{ - info->m = 4; - info->nub = 4; - - // see if we're powered or at a joint limit for axis 1 - int atlimit=0; - if ((j->limot1.lostop >= -M_PI || j->limot1.histop <= M_PI) && - j->limot1.lostop <= j->limot1.histop) { - dReal angle = measureHinge2Angle (j); - if (j->limot1.testRotationalLimit (angle)) atlimit = 1; - } - if (atlimit || j->limot1.fmax > 0) info->m++; - - // see if we're powering axis 2 (we currently never limit this axis) - j->limot2.limit = 0; - if (j->limot2.fmax > 0) info->m++; -} - - -// macro that computes ax1,ax2 = axis 1 and 2 in global coordinates (they are -// relative to body 1 and 2 initially) and then computes the constrained -// rotational axis as the cross product of ax1 and ax2. -// the sin and cos of the angle between axis 1 and 2 is computed, this comes -// from dot and cross product rules. - -#define HINGE2_GET_AXIS_INFO(axis,sin_angle,cos_angle) \ - dVector3 ax1,ax2; \ - dMULTIPLY0_331 (ax1,joint->node[0].body->R,joint->axis1); \ - dMULTIPLY0_331 (ax2,joint->node[1].body->R,joint->axis2); \ - dCROSS (axis,=,ax1,ax2); \ - sin_angle = dSqrt (axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2]); \ - cos_angle = dDOT (ax1,ax2); - - -static void hinge2GetInfo2 (dxJointHinge2 *joint, dxJoint::Info2 *info) -{ - // get information we need to set the hinge row - dReal s,c; - dVector3 q; - HINGE2_GET_AXIS_INFO (q,s,c); - dNormalize3 (q); // @@@ quicker: divide q by s ? - - // set the three ball-and-socket rows (aligned to the suspension axis ax1) - setBall2 (joint,info,joint->anchor1,joint->anchor2,ax1,joint->susp_erp); - - // set the hinge row - int s3=3*info->rowskip; - info->J1a[s3+0] = q[0]; - info->J1a[s3+1] = q[1]; - info->J1a[s3+2] = q[2]; - if (joint->node[1].body) { - info->J2a[s3+0] = -q[0]; - info->J2a[s3+1] = -q[1]; - info->J2a[s3+2] = -q[2]; - } - - // compute the right hand side for the constrained rotational DOF. - // axis 1 and axis 2 are separated by an angle `theta'. the desired - // separation angle is theta0. sin(theta0) and cos(theta0) are recorded - // in the joint structure. the correcting angular velocity is: - // |angular_velocity| = angle/time = erp*(theta0-theta) / stepsize - // = (erp*fps) * (theta0-theta) - // (theta0-theta) can be computed using the following small-angle-difference - // approximation: - // theta0-theta ~= tan(theta0-theta) - // = sin(theta0-theta)/cos(theta0-theta) - // = (c*s0 - s*c0) / (c*c0 + s*s0) - // = c*s0 - s*c0 assuming c*c0 + s*s0 ~= 1 - // where c = cos(theta), s = sin(theta) - // c0 = cos(theta0), s0 = sin(theta0) - - dReal k = info->fps * info->erp; - info->c[3] = k * (joint->c0 * s - joint->s0 * c); - - // if the axis1 hinge is powered, or has joint limits, add in more stuff - int row = 4 + joint->limot1.addLimot (joint,info,4,ax1,1); - - // if the axis2 hinge is powered, add in more stuff - joint->limot2.addLimot (joint,info,row,ax2,1); - - // set parameter for the suspension - info->cfm[0] = joint->susp_cfm; -} - - -// compute vectors v1 and v2 (embedded in body1), used to measure angle -// between body 1 and body 2 - -static void makeHinge2V1andV2 (dxJointHinge2 *joint) -{ - if (joint->node[0].body) { - // get axis 1 and 2 in global coords - dVector3 ax1,ax2,v; - dMULTIPLY0_331 (ax1,joint->node[0].body->R,joint->axis1); - dMULTIPLY0_331 (ax2,joint->node[1].body->R,joint->axis2); - - // don't do anything if the axis1 or axis2 vectors are zero or the same - if ((ax1[0]==0 && ax1[1]==0 && ax1[2]==0) || - (ax2[0]==0 && ax2[1]==0 && ax2[2]==0) || - (ax1[0]==ax2[0] && ax1[1]==ax2[1] && ax1[2]==ax2[2])) return; - - // modify axis 2 so it's perpendicular to axis 1 - dReal k = dDOT(ax1,ax2); - for (int i=0; i<3; i++) ax2[i] -= k*ax1[i]; - dNormalize3 (ax2); - - // make v1 = modified axis2, v2 = axis1 x (modified axis2) - dCROSS (v,=,ax1,ax2); - dMULTIPLY1_331 (joint->v1,joint->node[0].body->R,ax2); - dMULTIPLY1_331 (joint->v2,joint->node[0].body->R,v); - } -} - - -extern "C" void dJointSetHinge2Anchor (dxJointHinge2 *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - setAnchors (joint,x,y,z,joint->anchor1,joint->anchor2); - makeHinge2V1andV2 (joint); -} - - -extern "C" void dJointSetHinge2Axis1 (dxJointHinge2 *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[0].body) { - dReal q[4]; - q[0] = x; - q[1] = y; - q[2] = z; - q[3] = 0; - dNormalize3 (q); - dMULTIPLY1_331 (joint->axis1,joint->node[0].body->R,q); - joint->axis1[3] = 0; - - // compute the sin and cos of the angle between axis 1 and axis 2 - dVector3 ax; - HINGE2_GET_AXIS_INFO(ax,joint->s0,joint->c0); - } - makeHinge2V1andV2 (joint); -} - - -extern "C" void dJointSetHinge2Axis2 (dxJointHinge2 *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[1].body) { - dReal q[4]; - q[0] = x; - q[1] = y; - q[2] = z; - q[3] = 0; - dNormalize3 (q); - dMULTIPLY1_331 (joint->axis2,joint->node[1].body->R,q); - joint->axis1[3] = 0; - - // compute the sin and cos of the angle between axis 1 and axis 2 - dVector3 ax; - HINGE2_GET_AXIS_INFO(ax,joint->s0,joint->c0); - } - makeHinge2V1andV2 (joint); -} - - -extern "C" void dJointSetHinge2Param (dxJointHinge2 *joint, - int parameter, dReal value) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if ((parameter & 0xff00) == 0x100) { - joint->limot2.set (parameter & 0xff,value); - } - else { - if (parameter == dParamSuspensionERP) joint->susp_erp = value; - else if (parameter == dParamSuspensionCFM) joint->susp_cfm = value; - else joint->limot1.set (parameter,value); - } -} - - -extern "C" void dJointGetHinge2Anchor (dxJointHinge2 *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - getAnchor (joint,result,joint->anchor1); -} - - -extern "C" void dJointGetHinge2Axis1 (dxJointHinge2 *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[0].body) { - dMULTIPLY0_331 (result,joint->node[0].body->R,joint->axis1); - } -} - - -extern "C" void dJointGetHinge2Axis2 (dxJointHinge2 *joint, dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[1].body) { - dMULTIPLY0_331 (result,joint->node[1].body->R,joint->axis2); - } -} - - -extern "C" dReal dJointGetHinge2Param (dxJointHinge2 *joint, int parameter) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if ((parameter & 0xff00) == 0x100) { - return joint->limot2.get (parameter & 0xff); - } - else { - if (parameter == dParamSuspensionERP) return joint->susp_erp; - else if (parameter == dParamSuspensionCFM) return joint->susp_cfm; - else return joint->limot1.get (parameter); - } -} - - -extern "C" dReal dJointGetHinge2Angle1 (dxJointHinge2 *joint) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[0].body) return measureHinge2Angle (joint); - else return 0; -} - - -extern "C" dReal dJointGetHinge2Angle1Rate (dxJointHinge2 *joint) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[0].body) { - dVector3 axis; - dMULTIPLY0_331 (axis,joint->node[0].body->R,joint->axis1); - dReal rate = dDOT(axis,joint->node[0].body->avel); - if (joint->node[1].body) rate -= dDOT(axis,joint->node[1].body->avel); - return rate; - } - else return 0; -} - - -extern "C" dReal dJointGetHinge2Angle2Rate (dxJointHinge2 *joint) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dhinge2_vtable,"joint is not a hinge2"); - if (joint->node[0].body && joint->node[1].body) { - dVector3 axis; - dMULTIPLY0_331 (axis,joint->node[1].body->R,joint->axis2); - dReal rate = dDOT(axis,joint->node[0].body->avel); - if (joint->node[1].body) rate -= dDOT(axis,joint->node[1].body->avel); - return rate; - } - else return 0; -} - - -dxJoint::Vtable __dhinge2_vtable = { - sizeof(dxJointHinge2), - (dxJoint::init_fn*) hinge2Init, - (dxJoint::getInfo1_fn*) hinge2GetInfo1, - (dxJoint::getInfo2_fn*) hinge2GetInfo2, - dJointTypeHinge2}; - -//**************************************************************************** -// universal - -static void universalInit (dxJointUniversal *j) -{ - dSetZero (j->anchor1,4); - dSetZero (j->anchor2,4); - dSetZero (j->axis1,4); - j->axis1[0] = 1; - dSetZero (j->axis2,4); - j->axis2[1] = 1; -} - - -static void universalGetInfo1 (dxJointUniversal *j, dxJoint::Info1 *info) -{ - info->nub = 4; - info->m = 4; -} - - -static void universalGetInfo2 (dxJointUniversal *joint, dxJoint::Info2 *info) -{ - // set the three ball-and-socket rows - setBall (joint,info,joint->anchor1,joint->anchor2); - - // set the universal joint row. the angular velocity about an axis - // perpendicular to both joint axes should be equal. thus the constraint - // equation is - // p*w1 - p*w2 = 0 - // where p is a vector normal to both joint axes, and w1 and w2 - // are the angular velocity vectors of the two bodies. - - // length 1 joint axis in global coordinates, from each body - dVector3 ax1, ax2; - // length 1 vector perpendicular to ax1 and ax2. Neither body can rotate - // about this. - dVector3 p; - - // This says "ax1 = joint->node[0].body->R * joint->axis1" - dMULTIPLY0_331 (ax1,joint->node[0].body->R,joint->axis1); - if (joint->node[1].body) { - dMULTIPLY0_331 (ax2,joint->node[1].body->R,joint->axis2); - } - else { - ax2[0] = joint->axis2[0]; - ax2[1] = joint->axis2[1]; - ax2[2] = joint->axis2[2]; - } - - // if ax1 and ax2 are almost parallel, p won't be perpendicular to them. - // Is there some more robust way to do this? - dCROSS(p, =, ax1, ax2); - dNormalize3(p); - - int s3=3*info->rowskip; - - info->J1a[s3+0] = p[0]; - info->J1a[s3+1] = p[1]; - info->J1a[s3+2] = p[2]; - - if (joint->node[1].body) { - info->J2a[s3+0] = -p[0]; - info->J2a[s3+1] = -p[1]; - info->J2a[s3+2] = -p[2]; - } - - // compute the right hand side of the constraint equation. set relative - // body velocities along p to bring the axes back to perpendicular. - // If ax1, ax2 are unit length joint axes as computed from body1 and - // body2, we need to rotate both bodies along the axis p. If theta - // is the angle between ax1 and ax2, we need an angular velocity - // along p to cover the angle erp * (theta - Pi/2) in one step: - // - // |angular_velocity| = angle/time = erp*(theta - Pi/2) / stepsize - // = (erp*fps) * (theta - Pi/2) - // - // if theta is close to Pi/2, - // theta - Pi/2 ~= cos(theta), so - // |angular_velocity| = (erp*fps) * (ax1 dot ax2) - - info->c[3] = info->fps * info->erp * - dDOT(ax1, ax2); -} - - -extern "C" void dJointSetUniversalAnchor (dxJointUniversal *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__duniversal_vtable,"joint is not a universal"); - setAnchors (joint,x,y,z,joint->anchor1,joint->anchor2); -} - - -extern "C" void dJointSetUniversalAxis1 (dxJointUniversal *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__duniversal_vtable,"joint is not a universal"); - if (joint->node[0].body) { - dReal q[4]; - q[0] = x; - q[1] = y; - q[2] = z; - q[3] = 0; - dNormalize3 (q); - dMULTIPLY1_331 (joint->axis1,joint->node[0].body->R,q); - } - joint->axis1[3] = 0; -} - - -extern "C" void dJointSetUniversalAxis2 (dxJointUniversal *joint, - dReal x, dReal y, dReal z) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__duniversal_vtable,"joint is not a universal"); - if (joint->node[1].body) { - dReal q[4]; - q[0] = x; - q[1] = y; - q[2] = z; - q[3] = 0; - dNormalize3 (q); - dMULTIPLY1_331 (joint->axis2,joint->node[1].body->R,q); - } - joint->axis2[3] = 0; -} - - -extern "C" void dJointGetUniversalAnchor (dxJointUniversal *joint, - dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__duniversal_vtable,"joint is not a universal"); - getAnchor (joint,result,joint->anchor1); -} - - -extern "C" void dJointGetUniversalAxis1 (dxJointUniversal *joint, - dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__duniversal_vtable,"joint is not a universal"); - if (joint->node[0].body) { - dMULTIPLY0_331 (result, joint->node[0].body->R, joint->axis1); - } -} - - -extern "C" void dJointGetUniversalAxis2 (dxJointUniversal *joint, - dVector3 result) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(result,"bad result argument"); - dUASSERT(joint->vtable == &__duniversal_vtable,"joint is not a universal"); - if (joint->node[1].body) { - dMULTIPLY0_331 (result, joint->node[1].body->R, joint->axis2); - } -} - - -dxJoint::Vtable __duniversal_vtable = { - sizeof(dxJointUniversal), - (dxJoint::init_fn*) universalInit, - (dxJoint::getInfo1_fn*) universalGetInfo1, - (dxJoint::getInfo2_fn*) universalGetInfo2, - dJointTypeUniversal}; - -//**************************************************************************** -// angular motor - -static void amotorInit (dxJointAMotor *j) -{ - int i; - j->num = 0; - j->mode = dAMotorUser; - for (i=0; i<3; i++) { - j->rel[i] = 0; - dSetZero (j->axis[i],4); - j->limot[i].init (j->world); - j->angle[i] = 0; - } - dSetZero (j->reference1,4); - dSetZero (j->reference2,4); - - j->flags |= dJOINT_TWOBODIES; -} - - -// compute the 3 axes in global coordinates - -static void amotorComputeGlobalAxes (dxJointAMotor *joint, dVector3 ax[3]) -{ - if (joint->mode == dAMotorEuler) { - // special handling for euler mode - dMULTIPLY0_331 (ax[0],joint->node[0].body->R,joint->axis[0]); - dMULTIPLY0_331 (ax[2],joint->node[1].body->R,joint->axis[2]); - dCROSS (ax[1],=,ax[2],ax[0]); - dNormalize3 (ax[1]); - } - else { - for (int i=0; i < joint->num; i++) { - if (joint->rel[i] == 1) { - // relative to b1 - dMULTIPLY0_331 (ax[i],joint->node[0].body->R,joint->axis[i]); - } - if (joint->rel[i] == 2) { - // relative to b2 - dMULTIPLY0_331 (ax[i],joint->node[1].body->R,joint->axis[i]); - } - else { - // global - just copy it - ax[i][0] = joint->axis[i][0]; - ax[i][1] = joint->axis[i][1]; - ax[i][2] = joint->axis[i][2]; - } - } - } -} - - -static void amotorComputeEulerAngles (dxJointAMotor *joint, dVector3 ax[3]) -{ - // assumptions: - // global axes already calculated --> ax - // axis[0] is relative to body 1 --> global ax[0] - // axis[2] is relative to body 2 --> global ax[2] - // ax[1] = ax[2] x ax[0] - // original ax[0] and ax[2] are perpendicular - // reference1 is perpendicular to ax[0] (in body 1 frame) - // reference2 is perpendicular to ax[2] (in body 2 frame) - // all ax[] and reference vectors are unit length - - // calculate references in global frame - dVector3 ref1,ref2; - dMULTIPLY0_331 (ref1,joint->node[0].body->R,joint->reference1); - dMULTIPLY0_331 (ref2,joint->node[1].body->R,joint->reference2); - - // get q perpendicular to both ax[0] and ref1, get first euler angle - dVector3 q; - dCROSS (q,=,ax[0],ref1); - joint->angle[0] = -dAtan2 (dDOT(ax[2],q),dDOT(ax[2],ref1)); - - // get q perpendicular to both ax[0] and ax[1], get second euler angle - dCROSS (q,=,ax[0],ax[1]); - joint->angle[1] = -dAtan2 (dDOT(ax[2],ax[0]),dDOT(ax[2],q)); - - // get q perpendicular to both ax[1] and ax[2], get third euler angle - dCROSS (q,=,ax[1],ax[2]); - joint->angle[2] = -dAtan2 (dDOT(ref2,ax[1]), dDOT(ref2,q)); -} - - -// set the reference vectors as follows: -// * reference1 = current axis[2] relative to body 1 -// * reference2 = current axis[0] relative to body 2 -// this assumes that: -// * axis[0] is relative to body 1 -// * axis[2] is relative to body 2 - -static void amotorSetEulerReferenceVectors (dxJointAMotor *j) -{ - if (j->node[0].body && j->node[1].body) { - dVector3 r; // axis[2] and axis[0] in global coordinates - dMULTIPLY0_331 (r,j->node[1].body->R,j->axis[2]); - dMULTIPLY1_331 (j->reference1,j->node[0].body->R,r); - dMULTIPLY0_331 (r,j->node[0].body->R,j->axis[0]); - dMULTIPLY1_331 (j->reference2,j->node[1].body->R,r); - } -} - - -static void amotorGetInfo1 (dxJointAMotor *j, dxJoint::Info1 *info) -{ - info->m = 0; - info->nub = 0; - - // compute the axes and angles, if in euler mode - if (j->mode == dAMotorEuler) { - dVector3 ax[3]; - amotorComputeGlobalAxes (j,ax); - amotorComputeEulerAngles (j,ax); - } - - // see if we're powered or at a joint limit for each axis - for (int i=0; i < j->num; i++) { - if (j->limot[i].testRotationalLimit (j->angle[i]) || - j->limot[i].fmax > 0) { - info->m++; - } - } -} - - -static void amotorGetInfo2 (dxJointAMotor *joint, dxJoint::Info2 *info) -{ - int i; - - // compute the axes (if not global) - dVector3 ax[3]; - amotorComputeGlobalAxes (joint,ax); - - // in euler angle mode we do not actually constrain the angular velocity - // along the axes axis[0] and axis[2] (although we do use axis[1]) : - // - // to get constrain w2-w1 along ...not - // ------ --------------------- ------ - // d(angle[0])/dt = 0 ax[1] x ax[2] ax[0] - // d(angle[1])/dt = 0 ax[1] - // d(angle[2])/dt = 0 ax[0] x ax[1] ax[2] - // - // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0. - // to prove the result for angle[0], write the expression for angle[0] from - // GetInfo1 then take the derivative. to prove this for angle[2] it is - // easier to take the euler rate expression for d(angle[2])/dt with respect - // to the components of w and set that to 0. - - dVector3 *axptr[3]; - axptr[0] = &ax[0]; - axptr[1] = &ax[1]; - axptr[2] = &ax[2]; - - dVector3 ax0_cross_ax1; - dVector3 ax1_cross_ax2; - if (joint->mode == dAMotorEuler) { - dCROSS (ax0_cross_ax1,=,ax[0],ax[1]); - axptr[2] = &ax0_cross_ax1; - dCROSS (ax1_cross_ax2,=,ax[1],ax[2]); - axptr[0] = &ax1_cross_ax2; - } - - int row=0; - for (i=0; i < joint->num; i++) { - row += joint->limot[i].addLimot (joint,info,row,*(axptr[i]),1); - } -} - - -extern "C" void dJointSetAMotorNumAxes (dxJointAMotor *joint, int num) -{ - dAASSERT(joint && num >= 0 && num <= 3); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - if (joint->mode == dAMotorEuler) { - joint->num = 3; - } - else { - if (num < 0) num = 0; - if (num > 3) num = 3; - joint->num = num; - } -} - - -extern "C" void dJointSetAMotorAxis (dxJointAMotor *joint, int anum, int rel, - dReal x, dReal y, dReal z) -{ - dAASSERT(joint && anum >= 0 && anum <= 2 && rel >= 0 && rel <= 2); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - if (anum < 0) anum = 0; - if (anum > 2) anum = 2; - joint->rel[anum] = rel; - - // x,y,z is always in global coordinates regardless of rel, so we may have - // to convert it to be relative to a body - dVector3 r; - r[0] = x; - r[1] = y; - r[2] = z; - r[3] = 0; - if (rel > 0) { - if (rel==1) { - dMULTIPLY1_331 (joint->axis[anum],joint->node[0].body->R,r); - } - else { - dMULTIPLY1_331 (joint->axis[anum],joint->node[1].body->R,r); - } - } - else { - joint->axis[anum][0] = r[0]; - joint->axis[anum][1] = r[1]; - joint->axis[anum][2] = r[2]; - } - dNormalize3 (joint->axis[anum]); - if (joint->mode == dAMotorEuler) amotorSetEulerReferenceVectors (joint); -} - - -extern "C" void dJointSetAMotorAngle (dxJointAMotor *joint, int anum, - dReal angle) -{ - dAASSERT(joint && anum >= 0 && anum < 3); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - if (joint->mode == dAMotorUser) { - if (anum < 0) anum = 0; - if (anum > 3) anum = 3; - joint->angle[anum] = angle; - } -} - - -extern "C" void dJointSetAMotorParam (dxJointAMotor *joint, int parameter, - dReal value) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - int anum = parameter >> 8; - if (anum < 0) anum = 0; - if (anum > 2) anum = 2; - parameter &= 0xff; - joint->limot[anum].set (parameter, value); -} - - -extern "C" void dJointSetAMotorMode (dxJointAMotor *joint, int mode) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - joint->mode = mode; - if (joint->mode == dAMotorEuler) { - joint->num = 3; - amotorSetEulerReferenceVectors (joint); - } -} - - -extern "C" int dJointGetAMotorNumAxes (dxJointAMotor *joint) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - return joint->num; -} - - -extern "C" void dJointGetAMotorAxis (dxJointAMotor *joint, int anum, - dVector3 result) -{ - dAASSERT(joint && anum >= 0 && anum < 3); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - if (anum < 0) anum = 0; - if (anum > 2) anum = 2; - if (joint->rel[anum] > 0) { - if (joint->rel[anum]==1) { - dMULTIPLY0_331 (result,joint->node[0].body->R,joint->axis[anum]); - } - else { - dMULTIPLY0_331 (result,joint->node[1].body->R,joint->axis[anum]); - } - } - else { - result[0] = joint->axis[anum][0]; - result[1] = joint->axis[anum][1]; - result[2] = joint->axis[anum][2]; - } -} - - -extern "C" int dJointGetAMotorAxisRel (dxJointAMotor *joint, int anum) -{ - dAASSERT(joint && anum >= 0 && anum < 3); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - if (anum < 0) anum = 0; - if (anum > 2) anum = 2; - return joint->rel[anum]; -} - - -extern "C" dReal dJointGetAMotorAngle (dxJointAMotor *joint, int anum) -{ - dAASSERT(joint && anum >= 0 && anum < 3); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - if (anum < 0) anum = 0; - if (anum > 3) anum = 3; - return joint->angle[anum]; -} - - -extern "C" dReal dJointGetAMotorAngleRate (dxJointAMotor *joint, int anum) -{ - // @@@ - dDebug (0,"not yet implemented"); - return 0; -} - - -extern "C" dReal dJointGetAMotorParam (dxJointAMotor *joint, int parameter) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - int anum = parameter >> 8; - if (anum < 0) anum = 0; - if (anum > 2) anum = 2; - parameter &= 0xff; - return joint->limot[anum].get (parameter); -} - - -extern "C" int dJointGetAMotorMode (dxJointAMotor *joint) -{ - dAASSERT(joint); - dUASSERT(joint->vtable == &__damotor_vtable,"joint is not an amotor"); - return joint->mode; -} - - -dxJoint::Vtable __damotor_vtable = { - sizeof(dxJointAMotor), - (dxJoint::init_fn*) amotorInit, - (dxJoint::getInfo1_fn*) amotorGetInfo1, - (dxJoint::getInfo2_fn*) amotorGetInfo2, - dJointTypeAMotor}; - -//**************************************************************************** -// fixed joint - -static void fixedInit (dxJointFixed *j) -{ - dSetZero (j->offset,4); -} - - -static void fixedGetInfo1 (dxJointFixed *j, dxJoint::Info1 *info) -{ - info->m = 6; - info->nub = 6; -} - - -static void fixedGetInfo2 (dxJointFixed *joint, dxJoint::Info2 *info) -{ - int s = info->rowskip; - - // set jacobian - info->J1l[0] = 1; - info->J1l[s+1] = 1; - info->J1l[2*s+2] = 1; - info->J1a[3*s] = 1; - info->J1a[4*s+1] = 1; - info->J1a[5*s+2] = 1; - - dVector3 ofs; - if (joint->node[1].body) { - dMULTIPLY0_331 (ofs,joint->node[0].body->R,joint->offset); - dCROSSMAT (info->J1a,ofs,s,+,-); - info->J2l[0] = -1; - info->J2l[s+1] = -1; - info->J2l[2*s+2] = -1; - info->J2a[3*s] = -1; - info->J2a[4*s+1] = -1; - info->J2a[5*s+2] = -1; - } - - // set right hand side for the first three rows (linear) - dReal k = info->fps * info->erp; - if (joint->node[1].body) { - for (int j=0; j<3; j++) - info->c[j] = k * (joint->node[1].body->pos[j] - - joint->node[0].body->pos[j] + ofs[j]); - } - else { - for (int j=0; j<3; j++) - info->c[j] = k * (joint->offset[j] - joint->node[0].body->pos[j]); - } - - // set right hand side for the next three rows (angular). this code is - // borrowed from the slider, so look at the comments there. - // @@@ make a function common to both the slider and this joint !!! - - // get qerr = relative rotation (rotation error) between two bodies - dQuaternion qerr,e; - if (joint->node[1].body) { - dQMultiply1 (qerr,joint->node[0].body->q,joint->node[1].body->q); - } - else { - qerr[0] = joint->node[0].body->q[0]; - for (int i=1; i<4; i++) qerr[i] = -joint->node[0].body->q[i]; - } - if (qerr[0] < 0) { - qerr[1] = -qerr[1]; // adjust sign of qerr to make theta small - qerr[2] = -qerr[2]; - qerr[3] = -qerr[3]; - } - dMULTIPLY0_331 (e,joint->node[0].body->R,qerr+1); // @@@ bad SIMD padding! - info->c[3] = 2*k * e[0]; - info->c[4] = 2*k * e[1]; - info->c[5] = 2*k * e[2]; -} - - -extern "C" void dJointSetFixed (dxJointFixed *joint) -{ - dUASSERT(joint,"bad joint argument"); - dUASSERT(joint->vtable == &__dfixed_vtable,"joint is not fixed"); - int i; - - // compute the offset between the bodies - if (joint->node[0].body) { - if (joint->node[1].body) { - dReal ofs[4]; - for (i=0; i<4; i++) ofs[i] = joint->node[0].body->pos[i]; - for (i=0; i<4; i++) ofs[i] -= joint->node[1].body->pos[i]; - dMULTIPLY1_331 (joint->offset,joint->node[0].body->R,ofs); - } - else { - for (i=0; i<4; i++) joint->offset[i] = joint->node[0].body->pos[i]; - } - } -} - - -dxJoint::Vtable __dfixed_vtable = { - sizeof(dxJointFixed), - (dxJoint::init_fn*) fixedInit, - (dxJoint::getInfo1_fn*) fixedGetInfo1, - (dxJoint::getInfo2_fn*) fixedGetInfo2, - dJointTypeFixed}; - -//**************************************************************************** -// null joint - -static void nullGetInfo1 (dxJointNull *j, dxJoint::Info1 *info) -{ - info->m = 0; - info->nub = 0; -} - - -static void nullGetInfo2 (dxJointNull *joint, dxJoint::Info2 *info) -{ - dDebug (0,"this should never get called"); -} - - -dxJoint::Vtable __dnull_vtable = { - sizeof(dxJointNull), - (dxJoint::init_fn*) 0, - (dxJoint::getInfo1_fn*) nullGetInfo1, - (dxJoint::getInfo2_fn*) nullGetInfo2, - dJointTypeNull}; diff --git a/extern/ode/dist/ode/src/joint.h b/extern/ode/dist/ode/src/joint.h deleted file mode 100644 index e0362ffa829..00000000000 --- a/extern/ode/dist/ode/src/joint.h +++ /dev/null @@ -1,260 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_JOINT_H_ -#define _ODE_JOINT_H_ - - -#include "objects.h" -#include <ode/contact.h> -#include "obstack.h" - - -// joint flags -enum { - // if this flag is set, the joint was allocated in a joint group - dJOINT_INGROUP = 1, - - // if this flag is set, the joint was attached with arguments (0,body). - // our convention is to treat all attaches as (body,0), i.e. so node[0].body - // is always nonzero, so this flag records the fact that the arguments were - // swapped. - dJOINT_REVERSE = 2, - - // if this flag is set, the joint can not have just one body attached to it, - // it must have either zero or two bodies attached. - dJOINT_TWOBODIES = 4 -}; - - -// there are two of these nodes in the joint, one for each connection to a -// body. these are node of a linked list kept by each body of it's connecting -// joints. but note that the body pointer in each node points to the body that -// makes use of the *other* node, not this node. this trick makes it a bit -// easier to traverse the body/joint graph. - -struct dxJointNode { - dxJoint *joint; // pointer to enclosing dxJoint object - dxBody *body; // *other* body this joint is connected to - dxJointNode *next; // next node in body's list of connected joints -}; - - -struct dxJoint : public dObject { - // naming convention: the "first" body this is connected to is node[0].body, - // and the "second" body is node[1].body. if this joint is only connected - // to one body then the second body is 0. - - // info returned by getInfo1 function. the constraint dimension is m (<=6). - // i.e. that is the total number of rows in the jacobian. `nub' is the - // number of unbounded variables (which have lo,hi = -/+ infinity). - - struct Info1 { - int m,nub; - }; - - // info returned by getInfo2 function - - struct Info2 { - // integrator parameters: frames per second (1/stepsize), default error - // reduction parameter (0..1). - dReal fps,erp; - - // for the first and second body, pointers to two (linear and angular) - // n*3 jacobian sub matrices, stored by rows. these matrices will have - // been initialized to 0 on entry. if the second body is zero then the - // J2xx pointers may be 0. - dReal *J1l,*J1a,*J2l,*J2a; - - // elements to jump from one row to the next in J's - int rowskip; - - // right hand sides of the equation J*v = c + cfm * lambda. cfm is the - // "constraint force mixing" vector. c is set to zero on entry, cfm is - // set to a constant value (typically very small or zero) value on entry. - dReal *c,*cfm; - - // lo and hi limits for variables (set to -/+ infinity on entry). - dReal *lo,*hi; - - // findex vector for variables. see the LCP solver interface for a - // description of what this does. this is set to -1 on entry. - // note that the returned indexes are relative to the first index of - // the constraint. - int *findex; - }; - - // virtual function table: size of the joint structure, function pointers. - // we do it this way instead of using C++ virtual functions because - // sometimes we need to allocate joints ourself within a memory pool. - - typedef void init_fn (dxJoint *joint); - typedef void getInfo1_fn (dxJoint *joint, Info1 *info); - typedef void getInfo2_fn (dxJoint *joint, Info2 *info); - struct Vtable { - int size; - init_fn *init; - getInfo1_fn *getInfo1; - getInfo2_fn *getInfo2; - int typenum; // a dJointTypeXXX type number - }; - - Vtable *vtable; // virtual function table - int flags; // dJOINT_xxx flags - dxJointNode node[2]; // connections to bodies. node[1].body can be 0 - dJointFeedback *feedback; // optional feedback structure -}; - - -// joint group. NOTE: any joints in the group that have their world destroyed -// will have their world pointer set to 0. - -struct dxJointGroup : public dBase { - int num; // number of joints on the stack - dObStack stack; // a stack of (possibly differently sized) dxJoint -}; // objects. - - -// common limit and motor information for a single joint axis of movement -struct dxJointLimitMotor { - dReal vel,fmax; // powered joint: velocity, max force - dReal lostop,histop; // joint limits, relative to initial position - dReal fudge_factor; // when powering away from joint limits - dReal normal_cfm; // cfm to use when not at a stop - dReal stop_erp,stop_cfm; // erp and cfm for when at joint limit - dReal bounce; // restitution factor - // variables used between getInfo1() and getInfo2() - int limit; // 0=free, 1=at lo limit, 2=at hi limit - dReal limit_err; // if at limit, amount over limit - - void init (dxWorld *); - void set (int num, dReal value); - dReal get (int num); - int testRotationalLimit (dReal angle); - int addLimot (dxJoint *joint, dxJoint::Info2 *info, int row, - dVector3 ax1, int rotational); -}; - - -// ball and socket - -struct dxJointBall : public dxJoint { - dVector3 anchor1; // anchor w.r.t first body - dVector3 anchor2; // anchor w.r.t second body -}; -extern struct dxJoint::Vtable __dball_vtable; - - -// hinge - -struct dxJointHinge : public dxJoint { - dVector3 anchor1; // anchor w.r.t first body - dVector3 anchor2; // anchor w.r.t second body - dVector3 axis1; // axis w.r.t first body - dVector3 axis2; // axis w.r.t second body - dQuaternion qrel; // initial relative rotation body1 -> body2 - dxJointLimitMotor limot; // limit and motor information -}; -extern struct dxJoint::Vtable __dhinge_vtable; - - -// universal - -struct dxJointUniversal : public dxJoint { - dVector3 anchor1; // anchor w.r.t first body - dVector3 anchor2; // anchor w.r.t second body - dVector3 axis1; // axis w.r.t first body - dVector3 axis2; // axis w.r.t second body -}; -extern struct dxJoint::Vtable __duniversal_vtable; - - -// slider. if body2 is 0 then qrel is the absolute rotation of body1 and -// offset is the position of body1 center along axis1. - -struct dxJointSlider : public dxJoint { - dVector3 axis1; // axis w.r.t first body - dQuaternion qrel; // initial relative rotation body1 -> body2 - dVector3 offset; // point relative to body2 that should be - // aligned with body1 center along axis1 - dxJointLimitMotor limot; // limit and motor information -}; -extern struct dxJoint::Vtable __dslider_vtable; - - -// contact - -struct dxJointContact : public dxJoint { - int the_m; // number of rows computed by getInfo1 - dContact contact; -}; -extern struct dxJoint::Vtable __dcontact_vtable; - - -// hinge 2 - -struct dxJointHinge2 : public dxJoint { - dVector3 anchor1; // anchor w.r.t first body - dVector3 anchor2; // anchor w.r.t second body - dVector3 axis1; // axis 1 w.r.t first body - dVector3 axis2; // axis 2 w.r.t second body - dReal c0,s0; // cos,sin of desired angle between axis 1,2 - dVector3 v1,v2; // angle ref vectors embedded in first body - dxJointLimitMotor limot1; // limit+motor info for axis 1 - dxJointLimitMotor limot2; // limit+motor info for axis 2 - dReal susp_erp,susp_cfm; // suspension parameters (erp,cfm) -}; -extern struct dxJoint::Vtable __dhinge2_vtable; - - -// angular motor - -struct dxJointAMotor : public dxJoint { - int num; // number of axes (0..3) - int mode; // a dAMotorXXX constant - int rel[3]; // what the axes are relative to (global,b1,b2) - dVector3 axis[3]; // three axes - dxJointLimitMotor limot[3]; // limit+motor info for axes - dReal angle[3]; // user-supplied angles for axes - // these vectors are used for calculating euler angles - dVector3 reference1; // original axis[2], relative to body 1 - dVector3 reference2; // original axis[0], relative to body 2 -}; -extern struct dxJoint::Vtable __damotor_vtable; - - -// fixed - -struct dxJointFixed : public dxJoint { - dVector3 offset; // relative offset between the bodies -}; -extern struct dxJoint::Vtable __dfixed_vtable; - - -// null joint, for testing only - -struct dxJointNull : public dxJoint { -}; -extern struct dxJoint::Vtable __dnull_vtable; - -#endif - diff --git a/extern/ode/dist/ode/src/lcp.cpp b/extern/ode/dist/ode/src/lcp.cpp deleted file mode 100644 index dba2d3b949b..00000000000 --- a/extern/ode/dist/ode/src/lcp.cpp +++ /dev/null @@ -1,1455 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - - -THE ALGORITHM -------------- - -solve A*x = b+w, with x and w subject to certain LCP conditions. -each x(i),w(i) must lie on one of the three line segments in the following -diagram. each line segment corresponds to one index set : - - w(i) - /|\ | : - | | : - | |i in N : - w>0 | |state[i]=0 : - | | : - | | : i in C - w=0 + +-----------------------+ - | : | - | : | - w<0 | : |i in N - | : |state[i]=1 - | : | - | : | - +-------|-----------|-----------|----------> x(i) - lo 0 hi - -the Dantzig algorithm proceeds as follows: - for i=1:n - * if (x(i),w(i)) is not on the line, push x(i) and w(i) positive or - negative towards the line. as this is done, the other (x(j),w(j)) - for j<i are constrained to be on the line. if any (x,w) reaches the - end of a line segment then it is switched between index sets. - * i is added to the appropriate index set depending on what line segment - it hits. - -we restrict lo(i) <= 0 and hi(i) >= 0. this makes the algorithm a bit -simpler, because the starting point for x(i),w(i) is always on the dotted -line x=0 and x will only ever increase in one direction, so it can only hit -two out of the three line segments. - - -NOTES ------ - -this is an implementation of "lcp_dantzig2_ldlt.m" and "lcp_dantzig_lohi.m". -the implementation is split into an LCP problem object (dLCP) and an LCP -driver function. most optimization occurs in the dLCP object. - -a naive implementation of the algorithm requires either a lot of data motion -or a lot of permutation-array lookup, because we are constantly re-ordering -rows and columns. to avoid this and make a more optimized algorithm, a -non-trivial data structure is used to represent the matrix A (this is -implemented in the fast version of the dLCP object). - -during execution of this algorithm, some indexes in A are clamped (set C), -some are non-clamped (set N), and some are "don't care" (where x=0). -A,x,b,w (and other problem vectors) are permuted such that the clamped -indexes are first, the unclamped indexes are next, and the don't-care -indexes are last. this permutation is recorded in the array `p'. -initially p = 0..n-1, and as the rows and columns of A,x,b,w are swapped, -the corresponding elements of p are swapped. - -because the C and N elements are grouped together in the rows of A, we can do -lots of work with a fast dot product function. if A,x,etc were not permuted -and we only had a permutation array, then those dot products would be much -slower as we would have a permutation array lookup in some inner loops. - -A is accessed through an array of row pointers, so that element (i,j) of the -permuted matrix is A[i][j]. this makes row swapping fast. for column swapping -we still have to actually move the data. - -during execution of this algorithm we maintain an L*D*L' factorization of -the clamped submatrix of A (call it `AC') which is the top left nC*nC -submatrix of A. there are two ways we could arrange the rows/columns in AC. - -(1) AC is always permuted such that L*D*L' = AC. this causes a problem - when a row/column is removed from C, because then all the rows/columns of A - between the deleted index and the end of C need to be rotated downward. - this results in a lot of data motion and slows things down. -(2) L*D*L' is actually a factorization of a *permutation* of AC (which is - itself a permutation of the underlying A). this is what we do - the - permutation is recorded in the vector C. call this permutation A[C,C]. - when a row/column is removed from C, all we have to do is swap two - rows/columns and manipulate C. - -*/ - -#include <ode/common.h> -#include "lcp.h" -#include <ode/matrix.h> -#include <ode/misc.h> -#include "mat.h" // for testing -#include <ode/timer.h> // for testing - -//*************************************************************************** -// code generation parameters - -// LCP debugging (mosty for fast dLCP) - this slows things down a lot -//#define DEBUG_LCP - -//#define dLCP_SLOW // use slow dLCP object -#define dLCP_FAST // use fast dLCP object - -// option 1 : matrix row pointers (less data copying) -#define ROWPTRS -#define ATYPE dReal ** -#define AROW(i) (A[i]) - -// option 2 : no matrix row pointers (slightly faster inner loops) -//#define NOROWPTRS -//#define ATYPE dReal * -//#define AROW(i) (A+(i)*nskip) - -// misc defines -#define ALLOCA dALLOCA16 -//#define dDot myDot -#define NUB_OPTIMIZATIONS - -//*************************************************************************** - -// an alternative inline dot product, for speed comparisons - -static inline dReal myDot (dReal *a, dReal *b, int n) -{ - dReal sum=0; - while (n > 0) { - sum += (*a) * (*b); - a++; - b++; - n--; - } - return sum; -} - - -// swap row/column i1 with i2 in the n*n matrix A. the leading dimension of -// A is nskip. this only references and swaps the lower triangle. -// if `do_fast_row_swaps' is nonzero and row pointers are being used, then -// rows will be swapped by exchanging row pointers. otherwise the data will -// be copied. - -static void swapRowsAndCols (ATYPE A, int n, int i1, int i2, int nskip, - int do_fast_row_swaps) -{ - int i; - dIASSERT (A && n > 0 && i1 >= 0 && i2 >= 0 && i1 < n && i2 < n && - nskip >= n && i1 < i2); - -# ifdef ROWPTRS - for (i=i1+1; i<i2; i++) A[i1][i] = A[i][i1]; - for (i=i1+1; i<i2; i++) A[i][i1] = A[i2][i]; - A[i1][i2] = A[i1][i1]; - A[i1][i1] = A[i2][i1]; - A[i2][i1] = A[i2][i2]; - // swap rows, by swapping row pointers - if (do_fast_row_swaps) { - dReal *tmpp; - tmpp = A[i1]; - A[i1] = A[i2]; - A[i2] = tmpp; - } - else { - dReal *tmprow = (dReal*) ALLOCA (n * sizeof(dReal)); - memcpy (tmprow,A[i1],n * sizeof(dReal)); - memcpy (A[i1],A[i2],n * sizeof(dReal)); - memcpy (A[i2],tmprow,n * sizeof(dReal)); - } - // swap columns the hard way - for (i=i2+1; i<n; i++) { - dReal tmp = A[i][i1]; - A[i][i1] = A[i][i2]; - A[i][i2] = tmp; - } -# else - dReal tmp,*tmprow = (dReal*) ALLOCA (n * sizeof(dReal)); - if (i1 > 0) { - memcpy (tmprow,A+i1*nskip,i1*sizeof(dReal)); - memcpy (A+i1*nskip,A+i2*nskip,i1*sizeof(dReal)); - memcpy (A+i2*nskip,tmprow,i1*sizeof(dReal)); - } - for (i=i1+1; i<i2; i++) { - tmp = A[i2*nskip+i]; - A[i2*nskip+i] = A[i*nskip+i1]; - A[i*nskip+i1] = tmp; - } - tmp = A[i1*nskip+i1]; - A[i1*nskip+i1] = A[i2*nskip+i2]; - A[i2*nskip+i2] = tmp; - for (i=i2+1; i<n; i++) { - tmp = A[i*nskip+i1]; - A[i*nskip+i1] = A[i*nskip+i2]; - A[i*nskip+i2] = tmp; - } -# endif -} - - -// swap two indexes in the n*n LCP problem. i1 must be <= i2. - -static void swapProblem (ATYPE A, dReal *x, dReal *b, dReal *w, dReal *lo, - dReal *hi, int *p, int *state, int *findex, - int n, int i1, int i2, int nskip, - int do_fast_row_swaps) -{ - dReal tmp; - int tmpi; - dIASSERT (n>0 && i1 >=0 && i2 >= 0 && i1 < n && i2 < n && nskip >= n && - i1 <= i2); - if (i1==i2) return; - swapRowsAndCols (A,n,i1,i2,nskip,do_fast_row_swaps); - tmp = x[i1]; - x[i1] = x[i2]; - x[i2] = tmp; - tmp = b[i1]; - b[i1] = b[i2]; - b[i2] = tmp; - tmp = w[i1]; - w[i1] = w[i2]; - w[i2] = tmp; - tmp = lo[i1]; - lo[i1] = lo[i2]; - lo[i2] = tmp; - tmp = hi[i1]; - hi[i1] = hi[i2]; - hi[i2] = tmp; - tmpi = p[i1]; - p[i1] = p[i2]; - p[i2] = tmpi; - tmpi = state[i1]; - state[i1] = state[i2]; - state[i2] = tmpi; - if (findex) { - tmpi = findex[i1]; - findex[i1] = findex[i2]; - findex[i2] = tmpi; - } -} - - -// for debugging - check that L,d is the factorization of A[C,C]. -// A[C,C] has size nC*nC and leading dimension nskip. -// L has size nC*nC and leading dimension nskip. -// d has size nC. - -#ifdef DEBUG_LCP - -static void checkFactorization (ATYPE A, dReal *_L, dReal *_d, - int nC, int *C, int nskip) -{ - int i,j; - if (nC==0) return; - - // get A1=A, copy the lower triangle to the upper triangle, get A2=A[C,C] - dMatrix A1 (nC,nC); - for (i=0; i<nC; i++) { - for (j=0; j<=i; j++) A1(i,j) = A1(j,i) = AROW(i)[j]; - } - dMatrix A2 = A1.select (nC,C,nC,C); - - // printf ("A1=\n"); A1.print(); printf ("\n"); - // printf ("A2=\n"); A2.print(); printf ("\n"); - - // compute A3 = L*D*L' - dMatrix L (nC,nC,_L,nskip,1); - dMatrix D (nC,nC); - for (i=0; i<nC; i++) D(i,i) = 1/_d[i]; - L.clearUpperTriangle(); - for (i=0; i<nC; i++) L(i,i) = 1; - dMatrix A3 = L * D * L.transpose(); - - // printf ("L=\n"); L.print(); printf ("\n"); - // printf ("D=\n"); D.print(); printf ("\n"); - // printf ("A3=\n"); A2.print(); printf ("\n"); - - // compare A2 and A3 - dReal diff = A2.maxDifference (A3); - if (diff > 1e-8) - dDebug (0,"L*D*L' check, maximum difference = %.6e\n",diff); -} - -#endif - - -// for debugging - -#ifdef DEBUG_LCP - -static void checkPermutations (int i, int n, int nC, int nN, int *p, int *C) -{ - int j,k; - dIASSERT (nC>=0 && nN>=0 && (nC+nN)==i && i < n); - for (k=0; k<i; k++) dIASSERT (p[k] >= 0 && p[k] < i); - for (k=i; k<n; k++) dIASSERT (p[k] == k); - for (j=0; j<nC; j++) { - int C_is_bad = 1; - for (k=0; k<nC; k++) if (C[k]==j) C_is_bad = 0; - dIASSERT (C_is_bad==0); - } -} - -#endif - -//*************************************************************************** -// dLCP manipulator object. this represents an n*n LCP problem. -// -// two index sets C and N are kept. each set holds a subset of -// the variable indexes 0..n-1. an index can only be in one set. -// initially both sets are empty. -// -// the index set C is special: solutions to A(C,C)\A(C,i) can be generated. - -#ifdef dLCP_SLOW - -// simple but slow implementation of dLCP, for testing the LCP drivers. - -#include "array.h" - -struct dLCP { - int n,nub,nskip; - dReal *Adata,*x,*b,*w,*lo,*hi; // LCP problem data - ATYPE A; // A rows - dArray<int> C,N; // index sets - int last_i_for_solve1; // last i value given to solve1 - - dLCP (int _n, int _nub, dReal *_Adata, dReal *_x, dReal *_b, dReal *_w, - dReal *_lo, dReal *_hi, dReal *_L, dReal *_d, - dReal *_Dell, dReal *_ell, dReal *_tmp, - int *_state, int *_findex, int *_p, int *_C, dReal **Arows); - // the constructor is given an initial problem description (A,x,b,w) and - // space for other working data (which the caller may allocate on the stack). - // some of this data is specific to the fast dLCP implementation. - // the matrices A and L have size n*n, vectors have size n*1. - // A represents a symmetric matrix but only the lower triangle is valid. - // `nub' is the number of unbounded indexes at the start. all the indexes - // 0..nub-1 will be put into C. - - ~dLCP(); - - int getNub() { return nub; } - // return the value of `nub'. the constructor may want to change it, - // so the caller should find out its new value. - - // transfer functions: transfer index i to the given set (C or N). indexes - // less than `nub' can never be given. A,x,b,w,etc may be permuted by these - // functions, the caller must be robust to this. - - void transfer_i_to_C (int i); - // this assumes C and N span 1:i-1. this also assumes that solve1() has - // been recently called for the same i without any other transfer - // functions in between (thereby allowing some data reuse for the fast - // implementation). - void transfer_i_to_N (int i); - // this assumes C and N span 1:i-1. - void transfer_i_from_N_to_C (int i); - void transfer_i_from_C_to_N (int i); - - int numC(); - int numN(); - // return the number of indexes in set C/N - - int indexC (int i); - int indexN (int i); - // return index i in set C/N. - - // accessor and arithmetic functions. Aij translates as A(i,j), etc. - // make sure that only the lower triangle of A is ever referenced. - - dReal Aii (int i); - dReal AiC_times_qC (int i, dReal *q); - dReal AiN_times_qN (int i, dReal *q); // for all Nj - void pN_equals_ANC_times_qC (dReal *p, dReal *q); // for all Nj - void pN_plusequals_ANi (dReal *p, int i, int sign=1); - // for all Nj. sign = +1,-1. assumes i > maximum index in N. - void pC_plusequals_s_times_qC (dReal *p, dReal s, dReal *q); - void pN_plusequals_s_times_qN (dReal *p, dReal s, dReal *q); // for all Nj - void solve1 (dReal *a, int i, int dir=1, int only_transfer=0); - // get a(C) = - dir * A(C,C) \ A(C,i). dir must be +/- 1. - // the fast version of this function computes some data that is needed by - // transfer_i_to_C(). if only_transfer is nonzero then this function - // *only* computes that data, it does not set a(C). - - void unpermute(); - // call this at the end of the LCP function. if the x/w values have been - // permuted then this will unscramble them. -}; - - -dLCP::dLCP (int _n, int _nub, dReal *_Adata, dReal *_x, dReal *_b, dReal *_w, - dReal *_lo, dReal *_hi, dReal *_L, dReal *_d, - dReal *_Dell, dReal *_ell, dReal *_tmp, - int *_state, int *_findex, int *_p, int *_C, dReal **Arows) -{ - dUASSERT (_findex==0,"slow dLCP object does not support findex array"); - - n = _n; - nub = _nub; - Adata = _Adata; - A = 0; - x = _x; - b = _b; - w = _w; - lo = _lo; - hi = _hi; - nskip = dPAD(n); - dSetZero (x,n); - last_i_for_solve1 = -1; - - int i,j; - C.setSize (n); - N.setSize (n); - for (int i=0; i<n; i++) { - C[i] = 0; - N[i] = 0; - } - -# ifdef ROWPTRS - // make matrix row pointers - A = Arows; - for (i=0; i<n; i++) A[i] = Adata + i*nskip; -# else - A = Adata; -# endif - - // lets make A symmetric - for (i=0; i<n; i++) { - for (j=i+1; j<n; j++) AROW(i)[j] = AROW(j)[i]; - } - - // if nub>0, put all indexes 0..nub-1 into C and solve for x - if (nub > 0) { - for (i=0; i<nub; i++) memcpy (_L+i*nskip,AROW(i),(i+1)*sizeof(dReal)); - dFactorLDLT (_L,_d,nub,nskip); - memcpy (x,b,nub*sizeof(dReal)); - dSolveLDLT (_L,_d,x,nub,nskip); - dSetZero (_w,nub); - for (i=0; i<nub; i++) C[i] = 1; - } -} - - -dLCP::~dLCP() -{ -} - - -void dLCP::transfer_i_to_C (int i) -{ - if (i < nub) dDebug (0,"bad i"); - if (C[i]) dDebug (0,"i already in C"); - if (N[i]) dDebug (0,"i already in N"); - for (int k=0; k<i; k++) { - if (!(C[k] ^ N[k])) dDebug (0,"assumptions for C and N violated"); - } - for (int k=i; k<n; k++) - if (C[k] || N[k]) dDebug (0,"assumptions for C and N violated"); - if (i != last_i_for_solve1) dDebug (0,"assumptions for i violated"); - last_i_for_solve1 = -1; - C[i] = 1; -} - - -void dLCP::transfer_i_to_N (int i) -{ - if (i < nub) dDebug (0,"bad i"); - if (C[i]) dDebug (0,"i already in C"); - if (N[i]) dDebug (0,"i already in N"); - for (int k=0; k<i; k++) - if (!C[k] && !N[k]) dDebug (0,"assumptions for C and N violated"); - for (int k=i; k<n; k++) - if (C[k] || N[k]) dDebug (0,"assumptions for C and N violated"); - last_i_for_solve1 = -1; - N[i] = 1; -} - - -void dLCP::transfer_i_from_N_to_C (int i) -{ - if (i < nub) dDebug (0,"bad i"); - if (C[i]) dDebug (0,"i already in C"); - if (!N[i]) dDebug (0,"i not in N"); - last_i_for_solve1 = -1; - N[i] = 0; - C[i] = 1; -} - - -void dLCP::transfer_i_from_C_to_N (int i) -{ - if (i < nub) dDebug (0,"bad i"); - if (N[i]) dDebug (0,"i already in N"); - if (!C[i]) dDebug (0,"i not in C"); - last_i_for_solve1 = -1; - C[i] = 0; - N[i] = 1; -} - - -int dLCP::numC() -{ - int i,count=0; - for (i=0; i<n; i++) if (C[i]) count++; - return count; -} - - -int dLCP::numN() -{ - int i,count=0; - for (i=0; i<n; i++) if (N[i]) count++; - return count; -} - - -int dLCP::indexC (int i) -{ - int k,count=0; - for (k=0; k<n; k++) { - if (C[k]) { - if (count==i) return k; - count++; - } - } - dDebug (0,"bad index C (%d)",i); - return 0; -} - - -int dLCP::indexN (int i) -{ - int k,count=0; - for (k=0; k<n; k++) { - if (N[k]) { - if (count==i) return k; - count++; - } - } - dDebug (0,"bad index into N"); - return 0; -} - - -dReal dLCP::Aii (int i) -{ - return AROW(i)[i]; -} - - -dReal dLCP::AiC_times_qC (int i, dReal *q) -{ - dReal sum = 0; - for (int k=0; k<n; k++) if (C[k]) sum += AROW(i)[k] * q[k]; - return sum; -} - - -dReal dLCP::AiN_times_qN (int i, dReal *q) -{ - dReal sum = 0; - for (int k=0; k<n; k++) if (N[k]) sum += AROW(i)[k] * q[k]; - return sum; -} - - -void dLCP::pN_equals_ANC_times_qC (dReal *p, dReal *q) -{ - dReal sum; - for (int ii=0; ii<n; ii++) if (N[ii]) { - sum = 0; - for (int jj=0; jj<n; jj++) if (C[jj]) sum += AROW(ii)[jj] * q[jj]; - p[ii] = sum; - } -} - - -void dLCP::pN_plusequals_ANi (dReal *p, int i, int sign) -{ - int k; - for (k=0; k<n; k++) if (N[k] && k >= i) dDebug (0,"N assumption violated"); - if (sign > 0) { - for (k=0; k<n; k++) if (N[k]) p[k] += AROW(i)[k]; - } - else { - for (k=0; k<n; k++) if (N[k]) p[k] -= AROW(i)[k]; - } -} - - -void dLCP::pC_plusequals_s_times_qC (dReal *p, dReal s, dReal *q) -{ - for (int k=0; k<n; k++) if (C[k]) p[k] += s*q[k]; -} - - -void dLCP::pN_plusequals_s_times_qN (dReal *p, dReal s, dReal *q) -{ - for (int k=0; k<n; k++) if (N[k]) p[k] += s*q[k]; -} - - -void dLCP::solve1 (dReal *a, int i, int dir, int only_transfer) -{ - dReal *AA = (dReal*) ALLOCA (n*nskip*sizeof(dReal)); - dReal *dd = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *bb = (dReal*) ALLOCA (n*sizeof(dReal)); - int ii,jj,AAi,AAj; - - last_i_for_solve1 = i; - AAi = 0; - for (ii=0; ii<n; ii++) if (C[ii]) { - AAj = 0; - for (jj=0; jj<n; jj++) if (C[jj]) { - AA[AAi*nskip+AAj] = AROW(ii)[jj]; - AAj++; - } - bb[AAi] = AROW(i)[ii]; - AAi++; - } - if (AAi==0) return; - - dFactorLDLT (AA,dd,AAi,nskip); - dSolveLDLT (AA,dd,bb,AAi,nskip); - - AAi=0; - if (dir > 0) { - for (ii=0; ii<n; ii++) if (C[ii]) a[ii] = -bb[AAi++]; - } - else { - for (ii=0; ii<n; ii++) if (C[ii]) a[ii] = bb[AAi++]; - } -} - - -void dLCP::unpermute() -{ -} - -#endif // dLCP_SLOW - -//*************************************************************************** -// fast implementation of dLCP. see the above definition of dLCP for -// interface comments. -// -// `p' records the permutation of A,x,b,w,etc. p is initially 1:n and is -// permuted as the other vectors/matrices are permuted. -// -// A,x,b,w,lo,hi,state,findex,p,c are permuted such that sets C,N have -// contiguous indexes. the don't-care indexes follow N. -// -// an L*D*L' factorization is maintained of A(C,C), and whenever indexes are -// added or removed from the set C the factorization is updated. -// thus L*D*L'=A[C,C], i.e. a permuted top left nC*nC submatrix of A. -// the leading dimension of the matrix L is always `nskip'. -// -// at the start there may be other indexes that are unbounded but are not -// included in `nub'. dLCP will permute the matrix so that absolutely all -// unbounded vectors are at the start. thus there may be some initial -// permutation. -// -// the algorithms here assume certain patterns, particularly with respect to -// index transfer. - -#ifdef dLCP_FAST - -struct dLCP { - int n,nskip,nub; - ATYPE A; // A rows - dReal *Adata,*x,*b,*w,*lo,*hi; // permuted LCP problem data - dReal *L,*d; // L*D*L' factorization of set C - dReal *Dell,*ell,*tmp; - int *state,*findex,*p,*C; - int nC,nN; // size of each index set - - dLCP (int _n, int _nub, dReal *_Adata, dReal *_x, dReal *_b, dReal *_w, - dReal *_lo, dReal *_hi, dReal *_L, dReal *_d, - dReal *_Dell, dReal *_ell, dReal *_tmp, - int *_state, int *_findex, int *_p, int *_C, dReal **Arows); - int getNub() { return nub; } - void transfer_i_to_C (int i); - void transfer_i_to_N (int i) - { nN++; } // because we can assume C and N span 1:i-1 - void transfer_i_from_N_to_C (int i); - void transfer_i_from_C_to_N (int i); - int numC() { return nC; } - int numN() { return nN; } - int indexC (int i) { return i; } - int indexN (int i) { return i+nC; } - dReal Aii (int i) { return AROW(i)[i]; } - dReal AiC_times_qC (int i, dReal *q) { return dDot (AROW(i),q,nC); } - dReal AiN_times_qN (int i, dReal *q) { return dDot (AROW(i)+nC,q+nC,nN); } - void pN_equals_ANC_times_qC (dReal *p, dReal *q); - void pN_plusequals_ANi (dReal *p, int i, int sign=1); - void pC_plusequals_s_times_qC (dReal *p, dReal s, dReal *q) - { for (int i=0; i<nC; i++) p[i] += s*q[i]; } - void pN_plusequals_s_times_qN (dReal *p, dReal s, dReal *q) - { for (int i=0; i<nN; i++) p[i+nC] += s*q[i+nC]; } - void solve1 (dReal *a, int i, int dir=1, int only_transfer=0); - void unpermute(); -}; - - -dLCP::dLCP (int _n, int _nub, dReal *_Adata, dReal *_x, dReal *_b, dReal *_w, - dReal *_lo, dReal *_hi, dReal *_L, dReal *_d, - dReal *_Dell, dReal *_ell, dReal *_tmp, - int *_state, int *_findex, int *_p, int *_C, dReal **Arows) -{ - n = _n; - nub = _nub; - Adata = _Adata; - A = 0; - x = _x; - b = _b; - w = _w; - lo = _lo; - hi = _hi; - L = _L; - d = _d; - Dell = _Dell; - ell = _ell; - tmp = _tmp; - state = _state; - findex = _findex; - p = _p; - C = _C; - nskip = dPAD(n); - dSetZero (x,n); - - int k; - -# ifdef ROWPTRS - // make matrix row pointers - A = Arows; - for (k=0; k<n; k++) A[k] = Adata + k*nskip; -# else - A = Adata; -# endif - - nC = 0; - nN = 0; - for (k=0; k<n; k++) p[k]=k; // initially unpermuted - - /* - // for testing, we can do some random swaps in the area i > nub - if (nub < n) { - for (k=0; k<100; k++) { - int i1,i2; - do { - i1 = dRandInt(n-nub)+nub; - i2 = dRandInt(n-nub)+nub; - } - while (i1 > i2); - //printf ("--> %d %d\n",i1,i2); - swapProblem (A,x,b,w,lo,hi,p,state,findex,n,i1,i2,nskip,0); - } - } - */ - - // permute the problem so that *all* the unbounded variables are at the - // start, i.e. look for unbounded variables not included in `nub'. we can - // potentially push up `nub' this way and get a bigger initial factorization. - // note that when we swap rows/cols here we must not just swap row pointers, - // as the initial factorization relies on the data being all in one chunk. - for (k=nub; k<n; k++) { - if (lo[k]==-dInfinity && hi[k]==dInfinity) { - swapProblem (A,x,b,w,lo,hi,p,state,findex,n,nub,k,nskip,0); - nub++; - } - } - - // if there are unbounded variables at the start, factorize A up to that - // point and solve for x. this puts all indexes 0..nub-1 into C. - if (nub > 0) { - for (k=0; k<nub; k++) memcpy (L+k*nskip,AROW(k),(k+1)*sizeof(dReal)); - dFactorLDLT (L,d,nub,nskip); - memcpy (x,b,nub*sizeof(dReal)); - dSolveLDLT (L,d,x,nub,nskip); - dSetZero (w,nub); - for (k=0; k<nub; k++) C[k] = k; - nC = nub; - } - - // permute the indexes > nub such that all findex variables are at the end - if (findex) { - int num_at_end = 0; - for (k=n-1; k >= nub; k--) { - if (findex[k] >= 0) { - swapProblem (A,x,b,w,lo,hi,p,state,findex,n,k,n-1-num_at_end,nskip,1); - num_at_end++; - } - } - } - - // print info about indexes - /* - for (k=0; k<n; k++) { - if (k<nub) printf ("C"); - else if (lo[k]==-dInfinity && hi[k]==dInfinity) printf ("c"); - else printf ("."); - } - printf ("\n"); - */ -} - - -void dLCP::transfer_i_to_C (int i) -{ - int j; - if (nC > 0) { - // ell,Dell were computed by solve1(). note, ell = D \ L1solve (L,A(i,C)) - for (j=0; j<nC; j++) L[nC*nskip+j] = ell[j]; - d[nC] = dRecip (AROW(i)[i] - dDot(ell,Dell,nC)); - } - else { - d[0] = dRecip (AROW(i)[i]); - } - swapProblem (A,x,b,w,lo,hi,p,state,findex,n,nC,i,nskip,1); - C[nC] = nC; - nC++; - -# ifdef DEBUG_LCP - checkFactorization (A,L,d,nC,C,nskip); - if (i < (n-1)) checkPermutations (i+1,n,nC,nN,p,C); -# endif -} - - -void dLCP::transfer_i_from_N_to_C (int i) -{ - int j; - if (nC > 0) { - dReal *aptr = AROW(i); -# ifdef NUB_OPTIMIZATIONS - // if nub>0, initial part of aptr unpermuted - for (j=0; j<nub; j++) Dell[j] = aptr[j]; - for (j=nub; j<nC; j++) Dell[j] = aptr[C[j]]; -# else - for (j=0; j<nC; j++) Dell[j] = aptr[C[j]]; -# endif - dSolveL1 (L,Dell,nC,nskip); - for (j=0; j<nC; j++) ell[j] = Dell[j] * d[j]; - for (j=0; j<nC; j++) L[nC*nskip+j] = ell[j]; - d[nC] = dRecip (AROW(i)[i] - dDot(ell,Dell,nC)); - } - else { - d[0] = dRecip (AROW(i)[i]); - } - swapProblem (A,x,b,w,lo,hi,p,state,findex,n,nC,i,nskip,1); - C[nC] = nC; - nN--; - nC++; - - // @@@ TO DO LATER - // if we just finish here then we'll go back and re-solve for - // delta_x. but actually we can be more efficient and incrementally - // update delta_x here. but if we do this, we wont have ell and Dell - // to use in updating the factorization later. - -# ifdef DEBUG_LCP - checkFactorization (A,L,d,nC,C,nskip); -# endif -} - - -void dLCP::transfer_i_from_C_to_N (int i) -{ - // remove a row/column from the factorization, and adjust the - // indexes (black magic!) - int j,k; - for (j=0; j<nC; j++) if (C[j]==i) { - dLDLTRemove (A,C,L,d,n,nC,j,nskip); - for (k=0; k<nC; k++) if (C[k]==nC-1) { - C[k] = C[j]; - if (j < (nC-1)) memmove (C+j,C+j+1,(nC-j-1)*sizeof(int)); - break; - } - dIASSERT (k < nC); - break; - } - dIASSERT (j < nC); - swapProblem (A,x,b,w,lo,hi,p,state,findex,n,i,nC-1,nskip,1); - nC--; - nN++; - -# ifdef DEBUG_LCP - checkFactorization (A,L,d,nC,C,nskip); -# endif -} - - -void dLCP::pN_equals_ANC_times_qC (dReal *p, dReal *q) -{ - // we could try to make this matrix-vector multiplication faster using - // outer product matrix tricks, e.g. with the dMultidotX() functions. - // but i tried it and it actually made things slower on random 100x100 - // problems because of the overhead involved. so we'll stick with the - // simple method for now. - for (int i=0; i<nN; i++) p[i+nC] = dDot (AROW(i+nC),q,nC); -} - - -void dLCP::pN_plusequals_ANi (dReal *p, int i, int sign) -{ - dReal *aptr = AROW(i)+nC; - if (sign > 0) { - for (int i=0; i<nN; i++) p[i+nC] += aptr[i]; - } - else { - for (int i=0; i<nN; i++) p[i+nC] -= aptr[i]; - } -} - - -void dLCP::solve1 (dReal *a, int i, int dir, int only_transfer) -{ - // the `Dell' and `ell' that are computed here are saved. if index i is - // later added to the factorization then they can be reused. - // - // @@@ question: do we need to solve for entire delta_x??? yes, but - // only if an x goes below 0 during the step. - - int j; - if (nC > 0) { - dReal *aptr = AROW(i); -# ifdef NUB_OPTIMIZATIONS - // if nub>0, initial part of aptr[] is guaranteed unpermuted - for (j=0; j<nub; j++) Dell[j] = aptr[j]; - for (j=nub; j<nC; j++) Dell[j] = aptr[C[j]]; -# else - for (j=0; j<nC; j++) Dell[j] = aptr[C[j]]; -# endif - dSolveL1 (L,Dell,nC,nskip); - for (j=0; j<nC; j++) ell[j] = Dell[j] * d[j]; - - if (!only_transfer) { - for (j=0; j<nC; j++) tmp[j] = ell[j]; - dSolveL1T (L,tmp,nC,nskip); - if (dir > 0) { - for (j=0; j<nC; j++) a[C[j]] = -tmp[j]; - } - else { - for (j=0; j<nC; j++) a[C[j]] = tmp[j]; - } - } - } -} - - -void dLCP::unpermute() -{ - // now we have to un-permute x and w - int j; - dReal *tmp = (dReal*) ALLOCA (n*sizeof(dReal)); - memcpy (tmp,x,n*sizeof(dReal)); - for (j=0; j<n; j++) x[p[j]] = tmp[j]; - memcpy (tmp,w,n*sizeof(dReal)); - for (j=0; j<n; j++) w[p[j]] = tmp[j]; -} - -#endif // dLCP_FAST - -//*************************************************************************** -// an unoptimized Dantzig LCP driver routine for the basic LCP problem. -// must have lo=0, hi=dInfinity, and nub=0. - -void dSolveLCPBasic (int n, dReal *A, dReal *x, dReal *b, - dReal *w, int nub, dReal *lo, dReal *hi) -{ - dAASSERT (n>0 && A && x && b && w && nub == 0); - - int i,k; - int nskip = dPAD(n); - dReal *L = (dReal*) ALLOCA (n*nskip*sizeof(dReal)); - dReal *d = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *delta_x = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *delta_w = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *Dell = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *ell = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *tmp = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal **Arows = (dReal**) ALLOCA (n*sizeof(dReal*)); - int *p = (int*) ALLOCA (n*sizeof(int)); - int *C = (int*) ALLOCA (n*sizeof(int)); - int *dummy = (int*) ALLOCA (n*sizeof(int)); - - dLCP lcp (n,0,A,x,b,w,tmp,tmp,L,d,Dell,ell,tmp,dummy,dummy,p,C,Arows); - nub = lcp.getNub(); - - for (i=0; i<n; i++) { - w[i] = lcp.AiC_times_qC (i,x) - b[i]; - if (w[i] >= 0) { - lcp.transfer_i_to_N (i); - } - else { - for (;;) { - // compute: delta_x(C) = -A(C,C)\A(C,i) - dSetZero (delta_x,n); - lcp.solve1 (delta_x,i); - delta_x[i] = 1; - - // compute: delta_w = A*delta_x - dSetZero (delta_w,n); - lcp.pN_equals_ANC_times_qC (delta_w,delta_x); - lcp.pN_plusequals_ANi (delta_w,i); - delta_w[i] = lcp.AiC_times_qC (i,delta_x) + lcp.Aii(i); - - // find index to switch - int si = i; // si = switch index - int si_in_N = 0; // set to 1 if si in N - dReal s = -w[i]/delta_w[i]; - - if (s <= 0) { - dMessage (d_ERR_LCP, "LCP internal error, s <= 0 (s=%.4e)",s); - if (i < (n-1)) { - dSetZero (x+i,n-i); - dSetZero (w+i,n-i); - } - goto done; - } - - for (k=0; k < lcp.numN(); k++) { - if (delta_w[lcp.indexN(k)] < 0) { - dReal s2 = -w[lcp.indexN(k)] / delta_w[lcp.indexN(k)]; - if (s2 < s) { - s = s2; - si = lcp.indexN(k); - si_in_N = 1; - } - } - } - for (k=0; k < lcp.numC(); k++) { - if (delta_x[lcp.indexC(k)] < 0) { - dReal s2 = -x[lcp.indexC(k)] / delta_x[lcp.indexC(k)]; - if (s2 < s) { - s = s2; - si = lcp.indexC(k); - si_in_N = 0; - } - } - } - - // apply x = x + s * delta_x - lcp.pC_plusequals_s_times_qC (x,s,delta_x); - x[i] += s; - lcp.pN_plusequals_s_times_qN (w,s,delta_w); - w[i] += s * delta_w[i]; - - // switch indexes between sets if necessary - if (si==i) { - w[i] = 0; - lcp.transfer_i_to_C (i); - break; - } - if (si_in_N) { - w[si] = 0; - lcp.transfer_i_from_N_to_C (si); - } - else { - x[si] = 0; - lcp.transfer_i_from_C_to_N (si); - } - } - } - } - - done: - lcp.unpermute(); -} - -//*************************************************************************** -// an optimized Dantzig LCP driver routine for the lo-hi LCP problem. - -void dSolveLCP (int n, dReal *A, dReal *x, dReal *b, - dReal *w, int nub, dReal *lo, dReal *hi, int *findex) -{ - dAASSERT (n>0 && A && x && b && w && lo && hi && nub >= 0 && nub <= n); - int i,k,hit_first_friction_index = 0; - int nskip = dPAD(n); - - // if all the variables are unbounded then we can just factor, solve, - // and return - if (nub >= n) { - dFactorLDLT (A,w,n,nskip); // use w for d - dSolveLDLT (A,w,b,n,nskip); - memcpy (x,b,n*sizeof(dReal)); - dSetZero (w,n); - return; - } - -# ifndef dNODEBUG - // check restrictions on lo and hi - for (k=0; k<n; k++) dIASSERT (lo[k] <= 0 && hi[k] >= 0); -# endif - - dReal *L = (dReal*) ALLOCA (n*nskip*sizeof(dReal)); - dReal *d = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *delta_x = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *delta_w = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *Dell = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *ell = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal **Arows = (dReal**) ALLOCA (n*sizeof(dReal*)); - int *p = (int*) ALLOCA (n*sizeof(int)); - int *C = (int*) ALLOCA (n*sizeof(int)); - int dir; - dReal dirf; - - // for i in N, state[i] is 0 if x(i)==lo(i) or 1 if x(i)==hi(i) - int *state = (int*) ALLOCA (n*sizeof(int)); - - // create LCP object. note that tmp is set to delta_w to save space, this - // optimization relies on knowledge of how tmp is used, so be careful! - dLCP lcp (n,nub,A,x,b,w,lo,hi,L,d,Dell,ell,delta_w,state,findex,p,C,Arows); - nub = lcp.getNub(); - - // loop over all indexes nub..n-1. for index i, if x(i),w(i) satisfy the - // LCP conditions then i is added to the appropriate index set. otherwise - // x(i),w(i) is driven either +ve or -ve to force it to the valid region. - // as we drive x(i), x(C) is also adjusted to keep w(C) at zero. - // while driving x(i) we maintain the LCP conditions on the other variables - // 0..i-1. we do this by watching out for other x(i),w(i) values going - // outside the valid region, and then switching them between index sets - // when that happens. - - for (i=nub; i<n; i++) { - // the index i is the driving index and indexes i+1..n-1 are "dont care", - // i.e. when we make changes to the system those x's will be zero and we - // don't care what happens to those w's. in other words, we only consider - // an (i+1)*(i+1) sub-problem of A*x=b+w. - - // if we've hit the first friction index, we have to compute the lo and - // hi values based on the values of x already computed. we have been - // permuting the indexes, so the values stored in the findex vector are - // no longer valid. thus we have to temporarily unpermute the x vector. - if (hit_first_friction_index == 0 && findex && findex[i] >= 0) { - // un-permute x into delta_w, which is not being used at the moment - for (k=0; k<n; k++) delta_w[p[k]] = x[k]; - // set lo and hi values - for (k=i; k<n; k++) { - hi[k] = dFabs (hi[k] * delta_w[findex[k]]); - lo[k] = -hi[k]; - } - hit_first_friction_index = 1; - } - - // thus far we have not even been computing the w values for indexes - // greater than i, so compute w[i] now. - w[i] = lcp.AiC_times_qC (i,x) + lcp.AiN_times_qN (i,x) - b[i]; - - // if lo=hi=0 (which can happen for tangential friction when normals are - // 0) then the index will be assigned to set N with some state. however, - // set C's line has zero size, so the index will always remain in set N. - // with the "normal" switching logic, if w changed sign then the index - // would have to switch to set C and then back to set N with an inverted - // state. this is pointless, and also computationally expensive. to - // prevent this from happening, we use the rule that indexes with lo=hi=0 - // will never be checked for set changes. this means that the state for - // these indexes may be incorrect, but that doesn't matter. - - // see if x(i),w(i) is in a valid region - if (lo[i]==0 && w[i] >= 0) { - lcp.transfer_i_to_N (i); - state[i] = 0; - } - else if (hi[i]==0 && w[i] <= 0) { - lcp.transfer_i_to_N (i); - state[i] = 1; - } - else if (w[i]==0) { - // this is a degenerate case. by the time we get to this test we know - // that lo != 0, which means that lo < 0 as lo is not allowed to be +ve, - // and similarly that hi > 0. this means that the line segment - // corresponding to set C is at least finite in extent, and we are on it. - // NOTE: we must call lcp.solve1() before lcp.transfer_i_to_C() - lcp.solve1 (delta_x,i,0,1); - lcp.transfer_i_to_C (i); - } - else { - // we must push x(i) and w(i) - for (;;) { - // find direction to push on x(i) - if (w[i] <= 0) { - dir = 1; - dirf = REAL(1.0); - } - else { - dir = -1; - dirf = REAL(-1.0); - } - - // compute: delta_x(C) = -dir*A(C,C)\A(C,i) - lcp.solve1 (delta_x,i,dir); - // note that delta_x[i] = dirf, but we wont bother to set it - - // compute: delta_w = A*delta_x ... note we only care about - // delta_w(N) and delta_w(i), the rest is ignored - lcp.pN_equals_ANC_times_qC (delta_w,delta_x); - lcp.pN_plusequals_ANi (delta_w,i,dir); - delta_w[i] = lcp.AiC_times_qC (i,delta_x) + lcp.Aii(i)*dirf; - - // find largest step we can take (size=s), either to drive x(i),w(i) - // to the valid LCP region or to drive an already-valid variable - // outside the valid region. - - int cmd = 1; // index switching command - int si = 0; // si = index to switch if cmd>3 - dReal s = -w[i]/delta_w[i]; - if (dir > 0) { - if (hi[i] < dInfinity) { - dReal s2 = (hi[i]-x[i])/dirf; // step to x(i)=hi(i) - if (s2 < s) { - s = s2; - cmd = 3; - } - } - } - else { - if (lo[i] > -dInfinity) { - dReal s2 = (lo[i]-x[i])/dirf; // step to x(i)=lo(i) - if (s2 < s) { - s = s2; - cmd = 2; - } - } - } - - for (k=0; k < lcp.numN(); k++) { - if ((state[lcp.indexN(k)]==0 && delta_w[lcp.indexN(k)] < 0) || - (state[lcp.indexN(k)]!=0 && delta_w[lcp.indexN(k)] > 0)) { - // don't bother checking if lo=hi=0 - if (lo[lcp.indexN(k)] == 0 && hi[lcp.indexN(k)] == 0) continue; - dReal s2 = -w[lcp.indexN(k)] / delta_w[lcp.indexN(k)]; - if (s2 < s) { - s = s2; - cmd = 4; - si = lcp.indexN(k); - } - } - } - - for (k=nub; k < lcp.numC(); k++) { - if (delta_x[lcp.indexC(k)] < 0 && lo[lcp.indexC(k)] > -dInfinity) { - dReal s2 = (lo[lcp.indexC(k)]-x[lcp.indexC(k)]) / - delta_x[lcp.indexC(k)]; - if (s2 < s) { - s = s2; - cmd = 5; - si = lcp.indexC(k); - } - } - if (delta_x[lcp.indexC(k)] > 0 && hi[lcp.indexC(k)] < dInfinity) { - dReal s2 = (hi[lcp.indexC(k)]-x[lcp.indexC(k)]) / - delta_x[lcp.indexC(k)]; - if (s2 < s) { - s = s2; - cmd = 6; - si = lcp.indexC(k); - } - } - } - - //static char* cmdstring[8] = {0,"->C","->NL","->NH","N->C", - // "C->NL","C->NH"}; - //printf ("cmd=%d (%s), si=%d\n",cmd,cmdstring[cmd],(cmd>3) ? si : i); - - // if s <= 0 then we've got a problem. if we just keep going then - // we're going to get stuck in an infinite loop. instead, just cross - // our fingers and exit with the current solution. - if (s <= 0) { - dMessage (d_ERR_LCP, "LCP internal error, s <= 0 (s=%.4e)",s); - if (i < (n-1)) { - dSetZero (x+i,n-i); - dSetZero (w+i,n-i); - } - goto done; - } - - // apply x = x + s * delta_x - lcp.pC_plusequals_s_times_qC (x,s,delta_x); - x[i] += s * dirf; - - // apply w = w + s * delta_w - lcp.pN_plusequals_s_times_qN (w,s,delta_w); - w[i] += s * delta_w[i]; - - // switch indexes between sets if necessary - switch (cmd) { - case 1: // done - w[i] = 0; - lcp.transfer_i_to_C (i); - break; - case 2: // done - x[i] = lo[i]; - state[i] = 0; - lcp.transfer_i_to_N (i); - break; - case 3: // done - x[i] = hi[i]; - state[i] = 1; - lcp.transfer_i_to_N (i); - break; - case 4: // keep going - w[si] = 0; - lcp.transfer_i_from_N_to_C (si); - break; - case 5: // keep going - x[si] = lo[si]; - state[si] = 0; - lcp.transfer_i_from_C_to_N (si); - break; - case 6: // keep going - x[si] = hi[si]; - state[si] = 1; - lcp.transfer_i_from_C_to_N (si); - break; - } - - if (cmd <= 3) break; - } - } - } - - done: - lcp.unpermute(); -} - -//*************************************************************************** -// accuracy and timing test - -extern "C" void dTestSolveLCP() -{ - int n = 100; - int i,nskip = dPAD(n); - const dReal tol = REAL(1e-9); - printf ("dTestSolveLCP()\n"); - - dReal *A = (dReal*) ALLOCA (n*nskip*sizeof(dReal)); - dReal *x = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *b = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *w = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *lo = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *hi = (dReal*) ALLOCA (n*sizeof(dReal)); - - dReal *A2 = (dReal*) ALLOCA (n*nskip*sizeof(dReal)); - dReal *b2 = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *lo2 = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *hi2 = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *tmp1 = (dReal*) ALLOCA (n*sizeof(dReal)); - dReal *tmp2 = (dReal*) ALLOCA (n*sizeof(dReal)); - - double total_time = 0; - for (int count=0; count < 1000; count++) { - - // form (A,b) = a random positive definite LCP problem - dMakeRandomMatrix (A2,n,n,1.0); - dMultiply2 (A,A2,A2,n,n,n); - dMakeRandomMatrix (x,n,1,1.0); - dMultiply0 (b,A,x,n,n,1); - for (i=0; i<n; i++) b[i] += (dRandReal()*REAL(0.2))-REAL(0.1); - - // choose `nub' in the range 0..n-1 - int nub = 50; //dRandInt (n); - - // make limits - for (i=0; i<nub; i++) lo[i] = -dInfinity; - for (i=0; i<nub; i++) hi[i] = dInfinity; - //for (i=nub; i<n; i++) lo[i] = 0; - //for (i=nub; i<n; i++) hi[i] = dInfinity; - //for (i=nub; i<n; i++) lo[i] = -dInfinity; - //for (i=nub; i<n; i++) hi[i] = 0; - for (i=nub; i<n; i++) lo[i] = -(dRandReal()*REAL(1.0))-REAL(0.01); - for (i=nub; i<n; i++) hi[i] = (dRandReal()*REAL(1.0))+REAL(0.01); - - // set a few limits to lo=hi=0 - /* - for (i=0; i<10; i++) { - int j = dRandInt (n-nub) + nub; - lo[j] = 0; - hi[j] = 0; - } - */ - - // solve the LCP. we must make copy of A,b,lo,hi (A2,b2,lo2,hi2) for - // SolveLCP() to permute. also, we'll clear the upper triangle of A2 to - // ensure that it doesn't get referenced (if it does, the answer will be - // wrong). - - memcpy (A2,A,n*nskip*sizeof(dReal)); - dClearUpperTriangle (A2,n); - memcpy (b2,b,n*sizeof(dReal)); - memcpy (lo2,lo,n*sizeof(dReal)); - memcpy (hi2,hi,n*sizeof(dReal)); - dSetZero (x,n); - dSetZero (w,n); - - dStopwatch sw; - dStopwatchReset (&sw); - dStopwatchStart (&sw); - - dSolveLCP (n,A2,x,b2,w,nub,lo2,hi2,0); - - dStopwatchStop (&sw); - double time = dStopwatchTime(&sw); - total_time += time; - double average = total_time / double(count+1) * 1000.0; - - // check the solution - - dMultiply0 (tmp1,A,x,n,n,1); - for (i=0; i<n; i++) tmp2[i] = b[i] + w[i]; - dReal diff = dMaxDifference (tmp1,tmp2,n,1); - // printf ("\tA*x = b+w, maximum difference = %.6e - %s (1)\n",diff, - // diff > tol ? "FAILED" : "passed"); - if (diff > tol) dDebug (0,"A*x = b+w, maximum difference = %.6e",diff); - int n1=0,n2=0,n3=0; - for (i=0; i<n; i++) { - if (x[i]==lo[i] && w[i] >= 0) { - n1++; // ok - } - else if (x[i]==hi[i] && w[i] <= 0) { - n2++; // ok - } - else if (x[i] >= lo[i] && x[i] <= hi[i] && w[i] == 0) { - n3++; // ok - } - else { - dDebug (0,"FAILED: i=%d x=%.4e w=%.4e lo=%.4e hi=%.4e",i, - x[i],w[i],lo[i],hi[i]); - } - } - - // pacifier - printf ("passed: NL=%3d NH=%3d C=%3d ",n1,n2,n3); - printf ("time=%10.3f ms avg=%10.4f\n",time * 1000.0,average); - } -} diff --git a/extern/ode/dist/ode/src/lcp.h b/extern/ode/dist/ode/src/lcp.h deleted file mode 100644 index 86cbd6319eb..00000000000 --- a/extern/ode/dist/ode/src/lcp.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -given (A,b,lo,hi), solve the LCP problem: A*x = b+w, where each x(i),w(i) -satisfies one of - (1) x = lo, w >= 0 - (2) x = hi, w <= 0 - (3) lo < x < hi, w = 0 -A is a matrix of dimension n*n, everything else is a vector of size n*1. -lo and hi can be +/- dInfinity as needed. the first `nub' variables are -unbounded, i.e. hi and lo are assumed to be +/- dInfinity. - -we restrict lo(i) <= 0 and hi(i) >= 0. - -the original data (A,b) may be modified by this function. - -if the `findex' (friction index) parameter is nonzero, it points to an array -of index values. in this case constraints that have findex[i] >= 0 are -special. all non-special constraints are solved for, then the lo and hi values -for the special constraints are set: - hi[i] = abs( hi[i] * x[findex[i]] ) - lo[i] = -hi[i] -and the solution continues. this mechanism allows a friction approximation -to be implemented. - -*/ - - -#ifndef _ODE_LCP_H_ -#define _ODE_LCP_H_ - - -void dSolveLCP (int n, dReal *A, dReal *x, dReal *b, dReal *w, - int nub, dReal *lo, dReal *hi, int *findex); - - -#endif - diff --git a/extern/ode/dist/ode/src/mass.cpp b/extern/ode/dist/ode/src/mass.cpp deleted file mode 100644 index 9c1aae2033f..00000000000 --- a/extern/ode/dist/ode/src/mass.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/config.h> -#include <ode/mass.h> -#include <ode/odemath.h> -#include <ode/matrix.h> - - -#define _I(i,j) I[(i)*4+(j)] - - -// return 1 if ok, 0 if bad - -static int checkMass (dMass *m) -{ - if (m->mass <= 0) { - dDEBUGMSG ("mass must be > 0"); - return 0; - } - if (!dIsPositiveDefinite (m->I,3)) { - dDEBUGMSG ("inertia must be positive definite"); - return 0; - } - - // verify that the center of mass position is consistent with the mass - // and inertia matrix. this is done by checking that the inertia around - // the center of mass is also positive definite. from the comment in - // dMassTranslate(), if the body is translated so that its center of mass - // is at the point of reference, then the new inertia is: - // I + mass*crossmat(c)^2 - // note that requiring this to be positive definite is exactly equivalent - // to requiring that the spatial inertia matrix - // [ mass*eye(3,3) M*crossmat(c)^T ] - // [ M*crossmat(c) I ] - // is positive definite, given that I is PD and mass>0. see the theorem - // about partitioned PD matrices for proof. - - dMatrix3 I2,chat; - dSetZero (chat,12); - dCROSSMAT (chat,m->c,4,+,-); - dMULTIPLY0_333 (I2,chat,chat); - for (int i=0; i<12; i++) I2[i] = m->I[i] + m->mass*I2[i]; - if (!dIsPositiveDefinite (I2,3)) { - dDEBUGMSG ("center of mass inconsistent with mass parameters"); - return 0; - } - return 1; -} - - -void dMassSetZero (dMass *m) -{ - dAASSERT (m); - m->mass = REAL(0.0); - dSetZero (m->c,sizeof(m->c) / sizeof(dReal)); - dSetZero (m->I,sizeof(m->I) / sizeof(dReal)); -} - - -void dMassSetParameters (dMass *m, dReal themass, - dReal cgx, dReal cgy, dReal cgz, - dReal I11, dReal I22, dReal I33, - dReal I12, dReal I13, dReal I23) -{ - dAASSERT (m); - dMassSetZero (m); - m->mass = themass; - m->c[0] = cgx; - m->c[1] = cgy; - m->c[2] = cgz; - m->_I(0,0) = I11; - m->_I(1,1) = I22; - m->_I(2,2) = I33; - m->_I(0,1) = I12; - m->_I(0,2) = I13; - m->_I(1,2) = I23; - m->_I(1,0) = I12; - m->_I(2,0) = I13; - m->_I(2,1) = I23; - checkMass (m); -} - - -void dMassSetSphere (dMass *m, dReal density, dReal radius) -{ - dAASSERT (m); - dMassSetZero (m); - m->mass = (REAL(4.0)/REAL(3.0)) * M_PI * radius*radius*radius * density; - dReal II = REAL(0.4) * m->mass * radius*radius; - m->_I(0,0) = II; - m->_I(1,1) = II; - m->_I(2,2) = II; - -# ifndef dNODEBUG - checkMass (m); -# endif -} - - -void dMassSetCappedCylinder (dMass *m, dReal density, int direction, - dReal a, dReal b) -{ - dReal M1,M2,Ia,Ib; - dAASSERT (m); - dUASSERT (direction >= 1 && direction <= 3,"bad direction number"); - dMassSetZero (m); - M1 = M_PI*a*a*b*density; // cylinder mass - M2 = (REAL(4.0)/REAL(3.0))*M_PI*a*a*a*density; // total cap mass - m->mass = M1+M2; - Ia = M1*(REAL(0.25)*a*a + (REAL(1.0)/REAL(12.0))*b*b) + - M2*(REAL(0.4)*a*a + REAL(0.5)*b*b); - Ib = (M1*REAL(0.5) + M2*REAL(0.4))*a*a; - m->_I(0,0) = Ia; - m->_I(1,1) = Ia; - m->_I(2,2) = Ia; - m->_I(direction-1,direction-1) = Ib; - -# ifndef dNODEBUG - checkMass (m); -# endif -} - - -void dMassSetBox (dMass *m, dReal density, - dReal lx, dReal ly, dReal lz) -{ - dAASSERT (m); - dMassSetZero (m); - dReal M = lx*ly*lz*density; - m->mass = M; - m->_I(0,0) = M/REAL(12.0) * (ly*ly + lz*lz); - m->_I(1,1) = M/REAL(12.0) * (lx*lx + lz*lz); - m->_I(2,2) = M/REAL(12.0) * (lx*lx + ly*ly); - -# ifndef dNODEBUG - checkMass (m); -# endif -} - - -void dMassAdjust (dMass *m, dReal newmass) -{ - dAASSERT (m); - dReal scale = newmass / m->mass; - m->mass = newmass; - for (int i=0; i<3; i++) for (int j=0; j<3; j++) m->_I(i,j) *= scale; - -# ifndef dNODEBUG - checkMass (m); -# endif -} - - -void dMassTranslate (dMass *m, dReal x, dReal y, dReal z) -{ - // if the body is translated by `a' relative to its point of reference, - // the new inertia about the point of reference is: - // - // I + mass*(crossmat(c)^2 - crossmat(c+a)^2) - // - // where c is the existing center of mass and I is the old inertia. - - int i,j; - dMatrix3 ahat,chat,t1,t2; - dReal a[3]; - - dAASSERT (m); - - // adjust inertia matrix - dSetZero (chat,12); - dCROSSMAT (chat,m->c,4,+,-); - a[0] = x + m->c[0]; - a[1] = y + m->c[1]; - a[2] = z + m->c[2]; - dSetZero (ahat,12); - dCROSSMAT (ahat,a,4,+,-); - dMULTIPLY0_333 (t1,ahat,ahat); - dMULTIPLY0_333 (t2,chat,chat); - for (i=0; i<3; i++) for (j=0; j<3; j++) - m->_I(i,j) += m->mass * (t2[i*4+j]-t1[i*4+j]); - - // ensure perfect symmetry - m->_I(1,0) = m->_I(0,1); - m->_I(2,0) = m->_I(0,2); - m->_I(2,1) = m->_I(1,2); - - // adjust center of mass - m->c[0] += x; - m->c[1] += y; - m->c[2] += z; - -# ifndef dNODEBUG - checkMass (m); -# endif -} - - -void dMassRotate (dMass *m, const dMatrix3 R) -{ - // if the body is rotated by `R' relative to its point of reference, - // the new inertia about the point of reference is: - // - // R * I * R' - // - // where I is the old inertia. - - dMatrix3 t1; - dReal t2[3]; - - dAASSERT (m); - - // rotate inertia matrix - dMULTIPLY2_333 (t1,m->I,R); - dMULTIPLY0_333 (m->I,R,t1); - - // ensure perfect symmetry - m->_I(1,0) = m->_I(0,1); - m->_I(2,0) = m->_I(0,2); - m->_I(2,1) = m->_I(1,2); - - // rotate center of mass - dMULTIPLY0_331 (t2,R,m->c); - m->c[0] = t2[0]; - m->c[1] = t2[1]; - m->c[2] = t2[2]; - -# ifndef dNODEBUG - checkMass (m); -# endif -} - - -void dMassAdd (dMass *a, const dMass *b) -{ - int i; - dAASSERT (a && b); - dReal denom = dRecip (a->mass + b->mass); - for (i=0; i<3; i++) a->c[i] = (a->c[i]*a->mass + b->c[i]*b->mass)*denom; - a->mass += b->mass; - for (i=0; i<12; i++) a->I[i] += b->I[i]; -} diff --git a/extern/ode/dist/ode/src/mat.cpp b/extern/ode/dist/ode/src/mat.cpp deleted file mode 100644 index 6e635dcc994..00000000000 --- a/extern/ode/dist/ode/src/mat.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/config.h> -#include <ode/misc.h> -#include <ode/matrix.h> -#include <ode/error.h> -#include <ode/memory.h> -#include "mat.h" - - -dMatrix::dMatrix() -{ - n = 0; - m = 0; - data = 0; -} - - -dMatrix::dMatrix (int rows, int cols) -{ - if (rows < 1 || cols < 1) dDebug (0,"bad matrix size"); - n = rows; - m = cols; - data = (dReal*) dAlloc (n*m*sizeof(dReal)); - dSetZero (data,n*m); -} - - -dMatrix::dMatrix (const dMatrix &a) -{ - n = a.n; - m = a.m; - data = (dReal*) dAlloc (n*m*sizeof(dReal)); - memcpy (data,a.data,n*m*sizeof(dReal)); -} - - -dMatrix::dMatrix (int rows, int cols, - dReal *_data, int rowskip, int colskip) -{ - if (rows < 1 || cols < 1) dDebug (0,"bad matrix size"); - n = rows; - m = cols; - data = (dReal*) dAlloc (n*m*sizeof(dReal)); - for (int i=0; i<n; i++) { - for (int j=0; j<m; j++) data[i*m+j] = _data[i*rowskip + j*colskip]; - } -} - - -dMatrix::~dMatrix() -{ - if (data) dFree (data,n*m*sizeof(dReal)); -} - - -dReal & dMatrix::operator () (int i, int j) -{ - if (i < 0 || i >= n || j < 0 || j >= m) dDebug (0,"bad matrix (i,j)"); - return data [i*m+j]; -} - - -void dMatrix::operator= (const dMatrix &a) -{ - if (data) dFree (data,n*m*sizeof(dReal)); - n = a.n; - m = a.m; - if (n > 0 && m > 0) { - data = (dReal*) dAlloc (n*m*sizeof(dReal)); - memcpy (data,a.data,n*m*sizeof(dReal)); - } - else data = 0; -} - - -void dMatrix::operator= (dReal a) -{ - for (int i=0; i<n*m; i++) data[i] = a; -} - - -dMatrix dMatrix::transpose() -{ - dMatrix r (m,n); - for (int i=0; i<n; i++) { - for (int j=0; j<m; j++) r.data[j*n+i] = data[i*m+j]; - } - return r; -} - - -dMatrix dMatrix::select (int np, int *p, int nq, int *q) -{ - if (np < 1 || nq < 1) dDebug (0,"Matrix select, bad index array sizes"); - dMatrix r (np,nq); - for (int i=0; i<np; i++) { - for (int j=0; j<nq; j++) { - if (p[i] < 0 || p[i] >= n || q[i] < 0 || q[i] >= m) - dDebug (0,"Matrix select, bad index arrays"); - r.data[i*nq+j] = data[p[i]*m+q[j]]; - } - } - return r; -} - - -dMatrix dMatrix::operator + (const dMatrix &a) -{ - if (n != a.n || m != a.m) dDebug (0,"matrix +, mismatched sizes"); - dMatrix r (n,m); - for (int i=0; i<n*m; i++) r.data[i] = data[i] + a.data[i]; - return r; -} - - -dMatrix dMatrix::operator - (const dMatrix &a) -{ - if (n != a.n || m != a.m) dDebug (0,"matrix -, mismatched sizes"); - dMatrix r (n,m); - for (int i=0; i<n*m; i++) r.data[i] = data[i] - a.data[i]; - return r; -} - - -dMatrix dMatrix::operator - () -{ - dMatrix r (n,m); - for (int i=0; i<n*m; i++) r.data[i] = -data[i]; - return r; -} - - -dMatrix dMatrix::operator * (const dMatrix &a) -{ - if (m != a.n) dDebug (0,"matrix *, mismatched sizes"); - dMatrix r (n,a.m); - for (int i=0; i<n; i++) { - for (int j=0; j<a.m; j++) { - dReal sum = 0; - for (int k=0; k<m; k++) sum += data[i*m+k] * a.data[k*a.m+j]; - r.data [i*a.m+j] = sum; - } - } - return r; -} - - -void dMatrix::operator += (const dMatrix &a) -{ - if (n != a.n || m != a.m) dDebug (0,"matrix +=, mismatched sizes"); - for (int i=0; i<n*m; i++) data[i] += a.data[i]; -} - - -void dMatrix::operator -= (const dMatrix &a) -{ - if (n != a.n || m != a.m) dDebug (0,"matrix -=, mismatched sizes"); - for (int i=0; i<n*m; i++) data[i] -= a.data[i]; -} - - -void dMatrix::clearUpperTriangle() -{ - if (n != m) dDebug (0,"clearUpperTriangle() only works on square matrices"); - for (int i=0; i<n; i++) { - for (int j=i+1; j<m; j++) data[i*m+j] = 0; - } -} - - -void dMatrix::clearLowerTriangle() -{ - if (n != m) dDebug (0,"clearLowerTriangle() only works on square matrices"); - for (int i=0; i<n; i++) { - for (int j=0; j<i; j++) data[i*m+j] = 0; - } -} - - -void dMatrix::makeRandom (dReal range) -{ - for (int i=0; i<n; i++) { - for (int j=0; j<m; j++) - data[i*m+j] = (dRandReal()*REAL(2.0)-REAL(1.0))*range; - } -} - - -void dMatrix::print (char *fmt, FILE *f) -{ - for (int i=0; i<n; i++) { - for (int j=0; j<m; j++) fprintf (f,fmt,data[i*m+j]); - fprintf (f,"\n"); - } -} - - -dReal dMatrix::maxDifference (const dMatrix &a) -{ - if (n != a.n || m != a.m) dDebug (0,"maxDifference(), mismatched sizes"); - dReal max = 0; - for (int i=0; i<n; i++) { - for (int j=0; j<m; j++) { - dReal diff = dFabs(data[i*m+j] - a.data[i*m+j]); - if (diff > max) max = diff; - } - } - return max; -} diff --git a/extern/ode/dist/ode/src/mat.h b/extern/ode/dist/ode/src/mat.h deleted file mode 100644 index 26f6bd1093a..00000000000 --- a/extern/ode/dist/ode/src/mat.h +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -// matrix class. this is mostly for convenience in the testing code, it is -// not optimized at all. correctness is much more importance here. - -#ifndef _ODE_MAT_H_ -#define _ODE_MAT_H_ - -#include <ode/common.h> - - -class dMatrix { - int n,m; // matrix dimension, n,m >= 0 - dReal *data; // if nonzero, n*m elements allocated on the heap - -public: - // constructors, destructors - dMatrix(); // make default 0x0 matrix - dMatrix (int rows, int cols); // construct zero matrix of given size - dMatrix (const dMatrix &); // construct copy of given matrix - // create copy of given data - element (i,j) is data[i*rowskip+j*colskip] - dMatrix (int rows, int cols, dReal *_data, int rowskip, int colskip); - ~dMatrix(); // destructor - - // data movement - dReal & operator () (int i, int j); // reference an element - void operator= (const dMatrix &); // matrix = matrix - void operator= (dReal); // matrix = scalar - dMatrix transpose(); // return transposed matrix - // return a permuted submatrix of this matrix, made up of the rows in p - // and the columns in q. p has np elements, q has nq elements. - dMatrix select (int np, int *p, int nq, int *q); - - // operators - dMatrix operator + (const dMatrix &); - dMatrix operator - (const dMatrix &); - dMatrix operator - (); - dMatrix operator * (const dMatrix &); - void operator += (const dMatrix &); - void operator -= (const dMatrix &); - - // utility - void clearUpperTriangle(); - void clearLowerTriangle(); - void makeRandom (dReal range); - void print (char *fmt = "%10.4f ", FILE *f=stdout); - dReal maxDifference (const dMatrix &); -}; - - -#endif - diff --git a/extern/ode/dist/ode/src/matrix.cpp b/extern/ode/dist/ode/src/matrix.cpp deleted file mode 100644 index 16afe915dd6..00000000000 --- a/extern/ode/dist/ode/src/matrix.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/common.h> -#include <ode/matrix.h> - -// misc defines -#define ALLOCA dALLOCA16 - - -void dSetZero (dReal *a, int n) -{ - dAASSERT (a && n >= 0); - while (n > 0) { - *(a++) = 0; - n--; - } -} - - -void dSetValue (dReal *a, int n, dReal value) -{ - dAASSERT (a && n >= 0); - while (n > 0) { - *(a++) = value; - n--; - } -} - - -void dMultiply0 (dReal *A, const dReal *B, const dReal *C, int p, int q, int r) -{ - int i,j,k,qskip,rskip,rpad; - dAASSERT (A && B && C && p>0 && q>0 && r>0); - qskip = dPAD(q); - rskip = dPAD(r); - rpad = rskip - r; - dReal sum; - const dReal *b,*c,*bb; - bb = B; - for (i=p; i; i--) { - for (j=0 ; j<r; j++) { - c = C + j; - b = bb; - sum = 0; - for (k=q; k; k--, c+=rskip) sum += (*(b++))*(*c); - *(A++) = sum; - } - A += rpad; - bb += qskip; - } -} - - -void dMultiply1 (dReal *A, const dReal *B, const dReal *C, int p, int q, int r) -{ - int i,j,k,pskip,rskip; - dReal sum; - dAASSERT (A && B && C && p>0 && q>0 && r>0); - pskip = dPAD(p); - rskip = dPAD(r); - for (i=0; i<p; i++) { - for (j=0; j<r; j++) { - sum = 0; - for (k=0; k<q; k++) sum += B[i+k*pskip] * C[j+k*rskip]; - A[i*rskip+j] = sum; - } - } -} - - -void dMultiply2 (dReal *A, const dReal *B, const dReal *C, int p, int q, int r) -{ - int i,j,k,z,rpad,qskip; - dReal sum; - const dReal *bb,*cc; - dAASSERT (A && B && C && p>0 && q>0 && r>0); - rpad = dPAD(r) - r; - qskip = dPAD(q); - bb = B; - for (i=p; i; i--) { - cc = C; - for (j=r; j; j--) { - z = 0; - sum = 0; - for (k=q; k; k--,z++) sum += bb[z] * cc[z]; - *(A++) = sum; - cc += qskip; - } - A += rpad; - bb += qskip; - } -} - - -int dFactorCholesky (dReal *A, int n) -{ - int i,j,k,nskip; - dReal sum,*a,*b,*aa,*bb,*cc,*recip; - dAASSERT (n > 0 && A); - nskip = dPAD (n); - recip = (dReal*) ALLOCA (n * sizeof(dReal)); - aa = A; - for (i=0; i<n; i++) { - bb = A; - cc = A + i*nskip; - for (j=0; j<i; j++) { - sum = *cc; - a = aa; - b = bb; - for (k=j; k; k--) sum -= (*(a++))*(*(b++)); - *cc = sum * recip[j]; - bb += nskip; - cc++; - } - sum = *cc; - a = aa; - for (k=i; k; k--, a++) sum -= (*a)*(*a); - if (sum <= REAL(0.0)) return 0; - *cc = dSqrt(sum); - recip[i] = dRecip (*cc); - aa += nskip; - } - return 1; -} - - -void dSolveCholesky (const dReal *L, dReal *b, int n) -{ - int i,k,nskip; - dReal sum,*y; - dAASSERT (n > 0 && L && b); - nskip = dPAD (n); - y = (dReal*) ALLOCA (n*sizeof(dReal)); - for (i=0; i<n; i++) { - sum = 0; - for (k=0; k < i; k++) sum += L[i*nskip+k]*y[k]; - y[i] = (b[i]-sum)/L[i*nskip+i]; - } - for (i=n-1; i >= 0; i--) { - sum = 0; - for (k=i+1; k < n; k++) sum += L[k*nskip+i]*b[k]; - b[i] = (y[i]-sum)/L[i*nskip+i]; - } -} - - -int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n) -{ - int i,j,nskip; - dReal *L,*x; - dAASSERT (n > 0 && A && Ainv); - nskip = dPAD (n); - L = (dReal*) ALLOCA (nskip*n*sizeof(dReal)); - memcpy (L,A,nskip*n*sizeof(dReal)); - x = (dReal*) ALLOCA (n*sizeof(dReal)); - if (dFactorCholesky (L,n)==0) return 0; - dSetZero (Ainv,n*nskip); // make sure all padding elements set to 0 - for (i=0; i<n; i++) { - for (j=0; j<n; j++) x[j] = 0; - x[i] = 1; - dSolveCholesky (L,x,n); - for (j=0; j<n; j++) Ainv[j*nskip+i] = x[j]; - } - return 1; -} - - -int dIsPositiveDefinite (const dReal *A, int n) -{ - dReal *Acopy; - dAASSERT (n > 0 && A); - int nskip = dPAD (n); - Acopy = (dReal*) ALLOCA (nskip*n * sizeof(dReal)); - memcpy (Acopy,A,nskip*n * sizeof(dReal)); - return dFactorCholesky (Acopy,n); -} - - -/***** this has been replaced by a faster version -void dSolveL1T (const dReal *L, dReal *b, int n, int nskip) -{ - int i,j; - dAASSERT (L && b && n >= 0 && nskip >= n); - dReal sum; - for (i=n-2; i>=0; i--) { - sum = 0; - for (j=i+1; j<n; j++) sum += L[j*nskip+i]*b[j]; - b[i] -= sum; - } -} -*/ - - -void dVectorScale (dReal *a, const dReal *d, int n) -{ - dAASSERT (a && d && n >= 0); - for (int i=0; i<n; i++) a[i] *= d[i]; -} - - -void dSolveLDLT (const dReal *L, const dReal *d, dReal *b, int n, int nskip) -{ - dAASSERT (L && d && b && n > 0 && nskip >= n); - dSolveL1 (L,b,n,nskip); - dVectorScale (b,d,n); - dSolveL1T (L,b,n,nskip); -} - - -void dLDLTAddTL (dReal *L, dReal *d, const dReal *a, int n, int nskip) -{ - int j,p; - dReal *W1,*W2,W11,W21,alpha1,alpha2,alphanew,gamma1,gamma2,k1,k2,Wp,ell,dee; - dAASSERT (L && d && a && n > 0 && nskip >= n); - - if (n < 2) return; - W1 = (dReal*) ALLOCA (n*sizeof(dReal)); - W2 = (dReal*) ALLOCA (n*sizeof(dReal)); - - W1[0] = 0; - W2[0] = 0; - for (j=1; j<n; j++) W1[j] = W2[j] = a[j] * M_SQRT1_2; - W11 = (REAL(0.5)*a[0]+1)*M_SQRT1_2; - W21 = (REAL(0.5)*a[0]-1)*M_SQRT1_2; - - alpha1=1; - alpha2=1; - - dee = d[0]; - alphanew = alpha1 + (W11*W11)*dee; - dee /= alphanew; - gamma1 = W11 * dee; - dee *= alpha1; - alpha1 = alphanew; - alphanew = alpha2 - (W21*W21)*dee; - dee /= alphanew; - gamma2 = W21 * dee; - alpha2 = alphanew; - k1 = REAL(1.0) - W21*gamma1; - k2 = W21*gamma1*W11 - W21; - for (p=1; p<n; p++) { - Wp = W1[p]; - ell = L[p*nskip]; - W1[p] = Wp - W11*ell; - W2[p] = k1*Wp + k2*ell; - } - - for (j=1; j<n; j++) { - dee = d[j]; - alphanew = alpha1 + (W1[j]*W1[j])*dee; - dee /= alphanew; - gamma1 = W1[j] * dee; - dee *= alpha1; - alpha1 = alphanew; - alphanew = alpha2 - (W2[j]*W2[j])*dee; - dee /= alphanew; - gamma2 = W2[j] * dee; - dee *= alpha2; - d[j] = dee; - alpha2 = alphanew; - - k1 = W1[j]; - k2 = W2[j]; - for (p=j+1; p<n; p++) { - ell = L[p*nskip+j]; - Wp = W1[p] - k1 * ell; - ell += gamma1 * Wp; - W1[p] = Wp; - Wp = W2[p] - k2 * ell; - ell -= gamma2 * Wp; - W2[p] = Wp; - L[p*nskip+j] = ell; - } - } -} - - -// macros for dLDLTRemove() for accessing A - either access the matrix -// directly or access it via row pointers. we are only supposed to reference -// the lower triangle of A (it is symmetric), but indexes i and j come from -// permutation vectors so they are not predictable. so do a test on the -// indexes - this should not slow things down too much, as we don't do this -// in an inner loop. - -#define _GETA(i,j) (A[i][j]) -//#define _GETA(i,j) (A[(i)*nskip+(j)]) -#define GETA(i,j) ((i > j) ? _GETA(i,j) : _GETA(j,i)) - - -void dLDLTRemove (dReal **A, const int *p, dReal *L, dReal *d, - int n1, int n2, int r, int nskip) -{ - int i; - dAASSERT(A && p && L && d && n1 > 0 && n2 > 0 && r >= 0 && r < n2 && - n1 >= n2 && nskip >= n1); - #ifndef dNODEBUG - for (i=0; i<n2; i++) dIASSERT(p[i] >= 0 && p[i] < n1); - #endif - - if (r==n2-1) { - return; // deleting last row/col is easy - } - else if (r==0) { - dReal *a = (dReal*) ALLOCA (n2 * sizeof(dReal)); - for (i=0; i<n2; i++) a[i] = -GETA(p[i],p[0]); - a[0] += REAL(1.0); - dLDLTAddTL (L,d,a,n2,nskip); - } - else { - dReal *t = (dReal*) ALLOCA (r * sizeof(dReal)); - dReal *a = (dReal*) ALLOCA ((n2-r) * sizeof(dReal)); - for (i=0; i<r; i++) t[i] = L[r*nskip+i] / d[i]; - for (i=0; i<(n2-r); i++) - a[i] = dDot(L+(r+i)*nskip,t,r) - GETA(p[r+i],p[r]); - a[0] += REAL(1.0); - dLDLTAddTL (L + r*nskip+r, d+r, a, n2-r, nskip); - } - - // snip out row/column r from L and d - dRemoveRowCol (L,n2,nskip,r); - if (r < (n2-1)) memmove (d+r,d+r+1,(n2-r-1)*sizeof(dReal)); -} - - -void dRemoveRowCol (dReal *A, int n, int nskip, int r) -{ - int i; - dAASSERT(A && n > 0 && nskip >= n && r >= 0 && r < n); - if (r >= n-1) return; - if (r > 0) { - for (i=0; i<r; i++) - memmove (A+i*nskip+r,A+i*nskip+r+1,(n-r-1)*sizeof(dReal)); - for (i=r; i<(n-1); i++) - memcpy (A+i*nskip,A+i*nskip+nskip,r*sizeof(dReal)); - } - for (i=r; i<(n-1); i++) - memcpy (A+i*nskip+r,A+i*nskip+nskip+r+1,(n-r-1)*sizeof(dReal)); -} diff --git a/extern/ode/dist/ode/src/memory.cpp b/extern/ode/dist/ode/src/memory.cpp deleted file mode 100644 index df61f97375f..00000000000 --- a/extern/ode/dist/ode/src/memory.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -// if the dDEBUG_ALLOC macro is defined, the following tests are performed in -// the default allocator: -// - size > 0 for alloc and realloc -// - realloc and free operate on uncorrupted blocks -// - realloc and free with the correct sizes -// - on exit, report of block allocation statistics -// - on exit, report of unfreed blocks and if they are corrupted -// the allocator will also call Debug() when it allocates a block with -// sequence number `_d_seqstop' or pointer value `_d_ptrstop'. these variables -// are global and can be set in the debugger. - -#include <ode/config.h> -#include <ode/memory.h> -#include <ode/error.h> - -#ifdef dDEBUG_ALLOC - -// when debugging, this is a header that it put at start of all blocks. -// it contains `padding', which are PADSIZE elements of known value just -// before the user memory starts. another PADSIZE padding elements are put -// at the end of the user memory. the idea is that if the user accidentally -// steps outside the allocated memory, it can hopefully be detected by -// examining the padding elements. - -#define PADSIZE 10 -struct blockHeader { - long pad1; // protective padding - long seq; // sequence number - long size; // data size - long flags; // bit 0 = ignore this block in final report - blockHeader *next,*prev; // next & previous blocks - long pad[PADSIZE]; // protective padding -}; - -// compute the memory block size, including padding. the user memory block is -// rounded up to a multiple of 4 bytes, to get alignment for the padding at -// the end of the block. - -#define BSIZE(size) (((((size)-1) | 3)+1) + sizeof(blockHeader) + \ - PADSIZE * sizeof(long)) - -static blockHeader dummyblock = {0,0,0,0,&dummyblock,&dummyblock, - {0,0,0,0,0,0,0,0,0,0}}; -static blockHeader *firstblock = &dummyblock; -static long num_blocks_alloced = 0; -static long num_bytes_alloced = 0; -static long total_num_blocks_alloced = 0; -static long total_num_bytes_alloced = 0; -static long max_blocks_alloced = 0; -static long max_bytes_alloced = 0; - -long _d_seqstop = 0; -void *_d_ptrstop = 0; - -static int checkBlockOk (void *ptr, int fatal) -{ - if (ptr==0) dDebug (0,"0 passed to checkBlockOk()"); - blockHeader *b = ((blockHeader*) ptr) - 1; - int i,ok = 1; - if (b->pad1 != (long)0xdeadbeef || b->seq < 0 || b->size < 0) ok = 0; - if (ok) { - for (i=0; i<PADSIZE; i++) if (b->pad[i] != (long)0xdeadbeef) ok = 0; - } - if (ok) { - long *endpad = (long*) (((char*)ptr) + (((b->size-1) | 3)+1)); - for (i=0; i<PADSIZE; i++) if (endpad[i] != (long)0xdeadbeef) ok = 0; - } - if (!ok && fatal) - dDebug (0,"corrupted memory block found, ptr=%p, size=%d, " - "seq=%ld", ptr,b->size,b->seq); - return ok; -} - -#endif - - -static dAllocFunction *allocfn = 0; -static dReallocFunction *reallocfn = 0; -static dFreeFunction *freefn = 0; - - - -void dSetAllocHandler (dAllocFunction *fn) -{ - allocfn = fn; -} - - -void dSetReallocHandler (dReallocFunction *fn) -{ - reallocfn = fn; -} - - -void dSetFreeHandler (dFreeFunction *fn) -{ - freefn = fn; -} - - -dAllocFunction *dGetAllocHandler() -{ - return allocfn; -} - - -dReallocFunction *dGetReallocHandler() -{ - return reallocfn; -} - - -dFreeFunction *dGetFreeHandler() -{ - return freefn; -} - - -void * dAlloc (int size) -{ -#ifdef dDEBUG_ALLOC - if (size < 1) dDebug (0,"bad block size to Alloc()"); - - num_blocks_alloced++; - num_bytes_alloced += size; - total_num_blocks_alloced++; - total_num_bytes_alloced += size; - if (num_blocks_alloced > max_blocks_alloced) - max_blocks_alloced = num_blocks_alloced; - if (num_bytes_alloced > max_bytes_alloced) - max_bytes_alloced = num_bytes_alloced; - - if (total_num_blocks_alloced == _d_seqstop) - dDebug (0,"ALLOCATOR TRAP ON SEQUENCE NUMBER %d",_d_seqstop); - long size2 = BSIZE(size); - blockHeader *b = (blockHeader*) malloc (size2); - if (b+1 == _d_ptrstop) - dDebug (0,"ALLOCATOR TRAP ON BLOCK POINTER %p",_d_ptrstop); - for (unsigned int i=0; i < (size2/sizeof(long)); i++) - ((long*)b)[i] = 0xdeadbeef; - b->seq = total_num_blocks_alloced; - b->size = size; - b->flags = 0; - b->next = firstblock->next; - b->prev = firstblock; - firstblock->next->prev = b; - firstblock->next = b; - return b + 1; -#else - if (allocfn) return allocfn (size); else return malloc (size); -#endif -} - - -void * dRealloc (void *ptr, int oldsize, int newsize) -{ -#ifdef dDEBUG_ALLOC - if (ptr==0) dDebug (0,"Realloc() called with ptr==0"); - checkBlockOk (ptr,1); - blockHeader *b = ((blockHeader*) ptr) - 1; - if (b->size != oldsize) - dDebug (0,"Realloc(%p,%d,%d) has bad old size, good size " - "is %ld, seq=%ld",ptr,oldsize,newsize,b->size,b->seq); - void *p = dAlloc (newsize); - blockHeader *newb = ((blockHeader*) p) - 1; - newb->flags = b->flags; - if (oldsize>=1) memcpy (p,ptr,oldsize); - dFree (ptr,oldsize); - return p; -#else - if (reallocfn) return reallocfn (ptr,oldsize,newsize); - else return realloc (ptr,newsize); -#endif -} - - -void dFree (void *ptr, int size) -{ - if (!ptr) return; -#ifdef dDEBUG_ALLOC - checkBlockOk (ptr,1); - blockHeader *b = ((blockHeader*) ptr) - 1; - if (b->size != size) - dDebug (0,"Free(%p,%d) has bad size, good size " - "is %ld, seq=%ld",ptr,size,b->size,b->seq); - num_blocks_alloced--; - num_bytes_alloced -= b->size; - if (num_blocks_alloced < 0 || num_bytes_alloced < 0) - dDebug (0,"Free called too many times"); - - b->next->prev = b->prev; - b->prev->next = b->next; - memset (b,0,BSIZE(b->size)); - - free (b); -#else - if (freefn) freefn (ptr,size); else free (ptr); -#endif -} - - -void dAllocDontReport (void *ptr) -{ -#ifdef dDEBUG_ALLOC - checkBlockOk (ptr,1); - blockHeader *b = ((blockHeader*) ptr) - 1; - b->flags |= 1; -#endif -} - - -#ifdef dDEBUG_ALLOC - -static void printReport() -{ - // subtract the "dont report" blocks from the totals - blockHeader *b = firstblock; - do { - if (b != &dummyblock && (b->flags & 1)) { - num_blocks_alloced--; - num_bytes_alloced -= b->size; - if (!checkBlockOk (b+1,0)) - fprintf (stderr,"\tCORRUPTED: %p, size=%ld, seq=%ld\n",b+1, - b->size,b->seq); - } - b = b->prev; - } - while (b != firstblock); - - fprintf (stderr,"\nALLOCATOR REPORT\n"); - fprintf (stderr,"\tblocks still allocated: %ld\n",num_blocks_alloced); - fprintf (stderr,"\tbytes still allocated: %ld\n",num_bytes_alloced); - fprintf (stderr,"\ttotal blocks allocated: %ld\n",total_num_blocks_alloced); - fprintf (stderr,"\ttotal bytes allocated: %ld\n",total_num_bytes_alloced); - fprintf (stderr,"\tmax blocks allocated: %ld\n",max_blocks_alloced); - fprintf (stderr,"\tmax bytes allocated: %ld\n",max_bytes_alloced); - - b = firstblock; - do { - if (b != &dummyblock && (b->flags & 1)==0) { - int ok = checkBlockOk (b+1,0); - fprintf (stderr,"\tUNFREED: %p, size=%ld, seq=%ld (%s)\n",b+1, - b->size,b->seq, ok ? "ok" : "CORUPTED"); - } - b = b->prev; - } - while (b != firstblock); - fprintf (stderr,"\n"); -} - - -struct dMemoryReportPrinter { - ~dMemoryReportPrinter() { printReport(); } -} _dReportPrinter; - -#endif diff --git a/extern/ode/dist/ode/src/misc.cpp b/extern/ode/dist/ode/src/misc.cpp deleted file mode 100644 index bdc1579d5aa..00000000000 --- a/extern/ode/dist/ode/src/misc.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/config.h> -#include <ode/misc.h> -#include <ode/matrix.h> - -//**************************************************************************** -// random numbers - -static unsigned long seed = 0; - -unsigned long dRand() -{ - seed = (1664525L*seed + 1013904223L) & 0xffffffff; - return seed; -} - - -unsigned long dRandGetSeed() -{ - return seed; -} - - -void dRandSetSeed (unsigned long s) -{ - seed = s; -} - - -int dTestRand() -{ - unsigned long oldseed = seed; - int ret = 1; - seed = 0; - if (dRand() != 0x3c6ef35f || dRand() != 0x47502932 || - dRand() != 0xd1ccf6e9 || dRand() != 0xaaf95334 || - dRand() != 0x6252e503) ret = 0; - seed = oldseed; - return ret; -} - - -int dRandInt (int n) -{ - double a = double(n) / 4294967296.0; - return (int) (double(dRand()) * a); -} - - -dReal dRandReal() -{ - return ((dReal) dRand()) / ((dReal) 0xffffffff); -} - -//**************************************************************************** -// matrix utility stuff - -void dPrintMatrix (dReal *A, int n, int m, char *fmt, FILE *f) -{ - int i,j; - int skip = dPAD(m); - for (i=0; i<n; i++) { - for (j=0; j<m; j++) fprintf (f,fmt,A[i*skip+j]); - fprintf (f,"\n"); - } -} - - -void dMakeRandomVector (dReal *A, int n, dReal range) -{ - int i; - for (i=0; i<n; i++) A[i] = (dRandReal()*REAL(2.0)-REAL(1.0))*range; -} - - -void dMakeRandomMatrix (dReal *A, int n, int m, dReal range) -{ - int i,j; - int skip = dPAD(m); - dSetZero (A,n*skip); - for (i=0; i<n; i++) { - for (j=0; j<m; j++) A[i*skip+j] = (dRandReal()*REAL(2.0)-REAL(1.0))*range; - } -} - - -void dClearUpperTriangle (dReal *A, int n) -{ - int i,j; - int skip = dPAD(n); - for (i=0; i<n; i++) { - for (j=i+1; j<n; j++) A[i*skip+j] = 0; - } -} - - -dReal dMaxDifference (const dReal *A, const dReal *B, int n, int m) -{ - int i,j; - int skip = dPAD(m); - dReal diff,max; - max = 0; - for (i=0; i<n; i++) { - for (j=0; j<m; j++) { - diff = dFabs(A[i*skip+j] - B[i*skip+j]); - if (diff > max) max = diff; - } - } - return max; -} - - -dReal dMaxDifferenceLowerTriangle (const dReal *A, const dReal *B, int n) -{ - int i,j; - int skip = dPAD(n); - dReal diff,max; - max = 0; - for (i=0; i<n; i++) { - for (j=0; j<=i; j++) { - diff = dFabs(A[i*skip+j] - B[i*skip+j]); - if (diff > max) max = diff; - } - } - return max; -} diff --git a/extern/ode/dist/ode/src/objects.h b/extern/ode/dist/ode/src/objects.h deleted file mode 100644 index 4d2c4ca6af7..00000000000 --- a/extern/ode/dist/ode/src/objects.h +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -// object, body, and world structs. - - -#ifndef _ODE_OBJECT_H_ -#define _ODE_OBJECT_H_ - -#include <ode/common.h> -#include <ode/memory.h> -#include <ode/mass.h> -#include "array.h" - - -// some body flags - -enum { - dxBodyFlagFiniteRotation = 1, // use finite rotations - dxBodyFlagFiniteRotationAxis = 2, // use finite rotations only along axis - dxBodyDisabled = 4, // body is disabled - dxBodyNoGravity = 8 // body is not influenced by gravity -}; - - -// base class that does correct object allocation / deallocation - -struct dBase { - void *operator new (size_t size) { return dAlloc (size); } - void operator delete (void *ptr, size_t size) { dFree (ptr,size); } - void *operator new[] (size_t size) { return dAlloc (size); } - void operator delete[] (void *ptr, size_t size) { dFree (ptr,size); } -}; - - -// base class for bodies and joints - -struct dObject : public dBase { - dxWorld *world; // world this object is in - dObject *next; // next object of this type in list - dObject **tome; // pointer to previous object's next ptr - void *userdata; // user settable data - int tag; // used by dynamics algorithms -}; - - -struct dxBody : public dObject { - dxJointNode *firstjoint; // list of attached joints - int flags; // some dxBodyFlagXXX flags - dMass mass; // mass parameters about POR - dMatrix3 invI; // inverse of mass.I - dReal invMass; // 1 / mass.mass - dVector3 pos; // position of POR (point of reference) - dQuaternion q; // orientation quaternion - dMatrix3 R; // rotation matrix, always corresponds to q - dVector3 lvel,avel; // linear and angular velocity of POR - dVector3 facc,tacc; // force and torque accululators - dVector3 finite_rot_axis; // finite rotation axis, unit length or 0=none -}; - - -struct dxWorld : public dBase { - dxBody *firstbody; // body linked list - dxJoint *firstjoint; // joint linked list - int nb,nj; // number of bodies and joints in lists - dVector3 gravity; // gravity vector (m/s/s) - dReal global_erp; // global error reduction parameter - dReal global_cfm; // global costraint force mixing parameter -}; - -#endif - diff --git a/extern/ode/dist/ode/src/obstack.cpp b/extern/ode/dist/ode/src/obstack.cpp deleted file mode 100644 index a6b9d36fbb4..00000000000 --- a/extern/ode/dist/ode/src/obstack.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/common.h> -#include <ode/error.h> -#include <ode/memory.h> -#include "obstack.h" - -//**************************************************************************** -// macros and constants - -#define ROUND_UP_OFFSET_TO_EFFICIENT_SIZE(arena,ofs) \ - ofs = (int) (dEFFICIENT_SIZE( ((intP)(arena)) + ofs ) - ((intP)(arena)) ); - -#define MAX_ALLOC_SIZE \ - ((int)(dOBSTACK_ARENA_SIZE - sizeof (Arena) - EFFICIENT_ALIGNMENT + 1)) - -//**************************************************************************** -// dObStack - -dObStack::dObStack() -{ - first = 0; - last = 0; - current_arena = 0; - current_ofs = 0; -} - - -dObStack::~dObStack() -{ - // free all arenas - Arena *a,*nexta; - a = first; - while (a) { - nexta = a->next; - dFree (a,dOBSTACK_ARENA_SIZE); - a = nexta; - } -} - - -void *dObStack::alloc (int num_bytes) -{ - if (num_bytes > MAX_ALLOC_SIZE) dDebug (0,"num_bytes too large"); - - // allocate or move to a new arena if necessary - if (!first) { - // allocate the first arena if necessary - first = last = (Arena *) dAlloc (dOBSTACK_ARENA_SIZE); - first->next = 0; - first->used = sizeof (Arena); - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (first,first->used); - } - else { - // we already have one or more arenas, see if a new arena must be used - if ((last->used + num_bytes) > dOBSTACK_ARENA_SIZE) { - if (!last->next) { - last->next = (Arena *) dAlloc (dOBSTACK_ARENA_SIZE); - last->next->next = 0; - } - last = last->next; - last->used = sizeof (Arena); - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (last,last->used); - } - } - - // allocate an area in the arena - char *c = ((char*) last) + last->used; - last->used += num_bytes; - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (last,last->used); - return c; -} - - -void dObStack::freeAll() -{ - last = first; - if (first) { - first->used = sizeof(Arena); - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (first,first->used); - } -} - - -void *dObStack::rewind() -{ - current_arena = first; - current_ofs = sizeof (Arena); - if (current_arena) { - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (current_arena,current_ofs) - return ((char*) current_arena) + current_ofs; - } - else return 0; -} - - -void *dObStack::next (int num_bytes) -{ - // this functions like alloc, except that no new storage is ever allocated - if (!current_arena) return 0; - current_ofs += num_bytes; - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (current_arena,current_ofs); - if (current_ofs >= current_arena->used) { - current_arena = current_arena->next; - if (!current_arena) return 0; - current_ofs = sizeof (Arena); - ROUND_UP_OFFSET_TO_EFFICIENT_SIZE (current_arena,current_ofs); - } - return ((char*) current_arena) + current_ofs; -} diff --git a/extern/ode/dist/ode/src/obstack.h b/extern/ode/dist/ode/src/obstack.h deleted file mode 100644 index fa7155dd966..00000000000 --- a/extern/ode/dist/ode/src/obstack.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_OBSTACK_H_ -#define _ODE_OBSTACK_H_ - -#include "objects.h" - -// each obstack Arena pointer points to a block of this many bytes -#define dOBSTACK_ARENA_SIZE 16384 - - -struct dObStack : public dBase { - struct Arena { - Arena *next; // next arena in linked list - int used; // total number of bytes used in this arena, counting - }; // this header - - Arena *first; // head of the arena linked list. 0 if no arenas yet - Arena *last; // arena where blocks are currently being allocated - - // used for iterator - Arena *current_arena; - int current_ofs; - - dObStack(); - ~dObStack(); - - void *alloc (int num_bytes); - // allocate a block in the last arena, allocating a new arena if necessary. - // it is a runtime error if num_bytes is larger than the arena size. - - void freeAll(); - // free all blocks in all arenas. this does not deallocate the arenas - // themselves, so future alloc()s will reuse them. - - void *rewind(); - // rewind the obstack iterator, and return the address of the first - // allocated block. return 0 if there are no allocated blocks. - - void *next (int num_bytes); - // return the address of the next allocated block. 'num_bytes' is the size - // of the previous block. this returns null if there are no more arenas. - // the sequence of 'num_bytes' parameters passed to next() during a - // traversal of the list must exactly match the parameters passed to alloc(). -}; - - -#endif - diff --git a/extern/ode/dist/ode/src/ode.cpp b/extern/ode/dist/ode/src/ode.cpp deleted file mode 100644 index 1a14e3292a0..00000000000 --- a/extern/ode/dist/ode/src/ode.cpp +++ /dev/null @@ -1,1341 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -// this source file is mostly concerned with the data structures, not the -// numerics. - -#include "objects.h" -#include <ode/ode.h> -#include "joint.h" -#include <ode/odemath.h> -#include <ode/matrix.h> -#include "step.h" -#include <ode/memory.h> -#include <ode/error.h> - -// misc defines -#define ALLOCA dALLOCA16 - -//**************************************************************************** -// utility - -static inline void initObject (dObject *obj, dxWorld *w) -{ - obj->world = w; - obj->next = 0; - obj->tome = 0; - obj->userdata = 0; - obj->tag = 0; -} - - -// add an object `obj' to the list who's head pointer is pointed to by `first'. - -static inline void addObjectToList (dObject *obj, dObject **first) -{ - obj->next = *first; - obj->tome = first; - if (*first) (*first)->tome = &obj->next; - (*first) = obj; -} - - -// remove the object from the linked list - -static inline void removeObjectFromList (dObject *obj) -{ - if (obj->next) obj->next->tome = obj->tome; - *(obj->tome) = obj->next; - // safeguard - obj->next = 0; - obj->tome = 0; -} - - -// remove the joint from neighbour lists of all connected bodies - -static void removeJointReferencesFromAttachedBodies (dxJoint *j) -{ - for (int i=0; i<2; i++) { - dxBody *body = j->node[i].body; - if (body) { - dxJointNode *n = body->firstjoint; - dxJointNode *last = 0; - while (n) { - if (n->joint == j) { - if (last) last->next = n->next; - else body->firstjoint = n->next; - break; - } - last = n; - n = n->next; - } - } - } - j->node[0].body = 0; - j->node[0].next = 0; - j->node[1].body = 0; - j->node[1].next = 0; -} - -//**************************************************************************** -// island processing - -// this groups all joints and bodies in a world into islands. all objects -// in an island are reachable by going through connected bodies and joints. -// each island can be simulated separately. -// note that joints that are not attached to anything will not be included -// in any island, an so they do not affect the simulation. -// -// this function starts new island from unvisited bodies. however, it will -// never start a new islands from a disabled body. thus islands of disabled -// bodies will not be included in the simulation. disabled bodies are -// re-enabled if they are found to be part of an active island. - -static void processIslands (dxWorld *world, dReal stepsize) -{ - dxBody *b,*bb,**body; - dxJoint *j,**joint; - - // nothing to do if no bodies - if (world->nb <= 0) return; - - // make arrays for body and joint lists (for a single island) to go into - body = (dxBody**) ALLOCA (world->nb * sizeof(dxBody*)); - joint = (dxJoint**) ALLOCA (world->nj * sizeof(dxJoint*)); - int bcount = 0; // number of bodies in `body' - int jcount = 0; // number of joints in `joint' - - // set all body/joint tags to 0 - for (b=world->firstbody; b; b=(dxBody*)b->next) b->tag = 0; - for (j=world->firstjoint; j; j=(dxJoint*)j->next) j->tag = 0; - - // allocate a stack of unvisited bodies in the island. the maximum size of - // the stack can be the lesser of the number of bodies or joints, because - // new bodies are only ever added to the stack by going through untagged - // joints. all the bodies in the stack must be tagged! - int stackalloc = (world->nj < world->nb) ? world->nj : world->nb; - dxBody **stack = (dxBody**) ALLOCA (stackalloc * sizeof(dxBody*)); - - for (bb=world->firstbody; bb; bb=(dxBody*)bb->next) { - // get bb = the next enabled, untagged body, and tag it - if (bb->tag || (bb->flags & dxBodyDisabled)) continue; - bb->tag = 1; - - // tag all bodies and joints starting from bb. - int stacksize = 0; - b = bb; - body[0] = bb; - bcount = 1; - jcount = 0; - goto quickstart; - while (stacksize > 0) { - b = stack[--stacksize]; // pop body off stack - body[bcount++] = b; // put body on body list - quickstart: - - // traverse and tag all body's joints, add untagged connected bodies - // to stack - for (dxJointNode *n=b->firstjoint; n; n=n->next) { - if (!n->joint->tag) { - n->joint->tag = 1; - joint[jcount++] = n->joint; - if (n->body && !n->body->tag) { - n->body->tag = 1; - stack[stacksize++] = n->body; - } - } - } - dIASSERT(stacksize <= world->nb); - dIASSERT(stacksize <= world->nj); - } - - // now do something with body and joint lists - dInternalStepIsland (world,body,bcount,joint,jcount,stepsize); - - // what we've just done may have altered the body/joint tag values. - // we must make sure that these tags are nonzero. - // also make sure all bodies are in the enabled state. - int i; - for (i=0; i<bcount; i++) { - body[i]->tag = 1; - body[i]->flags &= ~dxBodyDisabled; - } - for (i=0; i<jcount; i++) joint[i]->tag = 1; - } - - // if debugging, check that all objects (except for disabled bodies, - // unconnected joints, and joints that are connected to disabled bodies) - // were tagged. -# ifndef dNODEBUG - for (b=world->firstbody; b; b=(dxBody*)b->next) { - if (b->flags & dxBodyDisabled) { - if (b->tag) dDebug (0,"disabled body tagged"); - } - else { - if (!b->tag) dDebug (0,"enabled body not tagged"); - } - } - for (j=world->firstjoint; j; j=(dxJoint*)j->next) { - if ((j->node[0].body && (j->node[0].body->flags & dxBodyDisabled)==0) || - (j->node[1].body && (j->node[1].body->flags & dxBodyDisabled)==0)) { - if (!j->tag) dDebug (0,"attached enabled joint not tagged"); - } - else { - if (j->tag) dDebug (0,"unattached or disabled joint tagged"); - } - } -# endif -} - -//**************************************************************************** -// debugging - -// see if an object list loops on itself (if so, it's bad). - -static int listHasLoops (dObject *first) -{ - if (first==0 || first->next==0) return 0; - dObject *a=first,*b=first->next; - int skip=0; - while (b) { - if (a==b) return 1; - b = b->next; - if (skip) a = a->next; - skip ^= 1; - } - return 0; -} - - -// check the validity of the world data structures - -static void checkWorld (dxWorld *w) -{ - dxBody *b; - dxJoint *j; - - // check there are no loops - if (listHasLoops (w->firstbody)) dDebug (0,"body list has loops"); - if (listHasLoops (w->firstjoint)) dDebug (0,"joint list has loops"); - - // check lists are well formed (check `tome' pointers) - for (b=w->firstbody; b; b=(dxBody*)b->next) { - if (b->next && b->next->tome != &b->next) - dDebug (0,"bad tome pointer in body list"); - } - for (j=w->firstjoint; j; j=(dxJoint*)j->next) { - if (j->next && j->next->tome != &j->next) - dDebug (0,"bad tome pointer in joint list"); - } - - // check counts - int n = 0; - for (b=w->firstbody; b; b=(dxBody*)b->next) n++; - if (w->nb != n) dDebug (0,"body count incorrect"); - n = 0; - for (j=w->firstjoint; j; j=(dxJoint*)j->next) n++; - if (w->nj != n) dDebug (0,"joint count incorrect"); - - // set all tag values to a known value - static int count = 0; - count++; - for (b=w->firstbody; b; b=(dxBody*)b->next) b->tag = count; - for (j=w->firstjoint; j; j=(dxJoint*)j->next) j->tag = count; - - // check all body/joint world pointers are ok - for (b=w->firstbody; b; b=(dxBody*)b->next) if (b->world != w) - dDebug (0,"bad world pointer in body list"); - for (j=w->firstjoint; j; j=(dxJoint*)j->next) if (j->world != w) - dDebug (0,"bad world pointer in joint list"); - - /* - // check for half-connected joints - actually now these are valid - for (j=w->firstjoint; j; j=(dxJoint*)j->next) { - if (j->node[0].body || j->node[1].body) { - if (!(j->node[0].body && j->node[1].body)) - dDebug (0,"half connected joint found"); - } - } - */ - - // check that every joint node appears in the joint lists of both bodies it - // attaches - for (j=w->firstjoint; j; j=(dxJoint*)j->next) { - for (int i=0; i<2; i++) { - if (j->node[i].body) { - int ok = 0; - for (dxJointNode *n=j->node[i].body->firstjoint; n; n=n->next) { - if (n->joint == j) ok = 1; - } - if (ok==0) dDebug (0,"joint not in joint list of attached body"); - } - } - } - - // check all body joint lists (correct body ptrs) - for (b=w->firstbody; b; b=(dxBody*)b->next) { - for (dxJointNode *n=b->firstjoint; n; n=n->next) { - if (&n->joint->node[0] == n) { - if (n->joint->node[1].body != b) - dDebug (0,"bad body pointer in joint node of body list (1)"); - } - else { - if (n->joint->node[0].body != b) - dDebug (0,"bad body pointer in joint node of body list (2)"); - } - if (n->joint->tag != count) dDebug (0,"bad joint node pointer in body"); - } - } - - // check all body pointers in joints, check they are distinct - for (j=w->firstjoint; j; j=(dxJoint*)j->next) { - if (j->node[0].body && (j->node[0].body == j->node[1].body)) - dDebug (0,"non-distinct body pointers in joint"); - if ((j->node[0].body && j->node[0].body->tag != count) || - (j->node[1].body && j->node[1].body->tag != count)) - dDebug (0,"bad body pointer in joint"); - } -} - - -void dWorldCheck (dxWorld *w) -{ - checkWorld (w); -} - -//**************************************************************************** -// body - -dxBody *dBodyCreate (dxWorld *w) -{ - dAASSERT (w); - dxBody *b = new dxBody; - initObject (b,w); - b->firstjoint = 0; - b->flags = 0; - dMassSetParameters (&b->mass,1,0,0,0,1,1,1,0,0,0); - dSetZero (b->invI,4*3); - b->invI[0] = 1; - b->invI[5] = 1; - b->invI[10] = 1; - b->invMass = 1; - dSetZero (b->pos,4); - dSetZero (b->q,4); - b->q[0] = 1; - dRSetIdentity (b->R); - dSetZero (b->lvel,4); - dSetZero (b->avel,4); - dSetZero (b->facc,4); - dSetZero (b->tacc,4); - dSetZero (b->finite_rot_axis,4); - addObjectToList (b,(dObject **) &w->firstbody); - w->nb++; - return b; -} - - -void dBodyDestroy (dxBody *b) -{ - dAASSERT (b); - - // detach all neighbouring joints, then delete this body. - dxJointNode *n = b->firstjoint; - while (n) { - // sneaky trick to speed up removal of joint references (black magic) - n->joint->node[(n == n->joint->node)].body = 0; - - dxJointNode *next = n->next; - n->next = 0; - removeJointReferencesFromAttachedBodies (n->joint); - n = next; - } - removeObjectFromList (b); - b->world->nb--; - delete b; -} - - -void dBodySetData (dBodyID b, void *data) -{ - dAASSERT (b); - b->userdata = data; -} - - -void *dBodyGetData (dBodyID b) -{ - dAASSERT (b); - return b->userdata; -} - - -void dBodySetPosition (dBodyID b, dReal x, dReal y, dReal z) -{ - dAASSERT (b); - b->pos[0] = x; - b->pos[1] = y; - b->pos[2] = z; -} - - -void dBodySetRotation (dBodyID b, const dMatrix3 R) -{ - dAASSERT (b && R); - dQuaternion q; - dRtoQ (R,q); - dNormalize4 (q); - b->q[0] = q[0]; - b->q[1] = q[1]; - b->q[2] = q[2]; - b->q[3] = q[3]; - dQtoR (b->q,b->R); -} - - -void dBodySetQuaternion (dBodyID b, const dQuaternion q) -{ - dAASSERT (b && q); - b->q[0] = q[0]; - b->q[1] = q[1]; - b->q[2] = q[2]; - b->q[3] = q[3]; - dNormalize4 (b->q); - dQtoR (b->q,b->R); -} - - -void dBodySetLinearVel (dBodyID b, dReal x, dReal y, dReal z) -{ - dAASSERT (b); - b->lvel[0] = x; - b->lvel[1] = y; - b->lvel[2] = z; -} - - -void dBodySetAngularVel (dBodyID b, dReal x, dReal y, dReal z) -{ - dAASSERT (b); - b->avel[0] = x; - b->avel[1] = y; - b->avel[2] = z; -} - - -const dReal * dBodyGetPosition (dBodyID b) -{ - dAASSERT (b); - return b->pos; -} - - -const dReal * dBodyGetRotation (dBodyID b) -{ - dAASSERT (b); - return b->R; -} - - -const dReal * dBodyGetQuaternion (dBodyID b) -{ - dAASSERT (b); - return b->q; -} - - -const dReal * dBodyGetLinearVel (dBodyID b) -{ - dAASSERT (b); - return b->lvel; -} - - -const dReal * dBodyGetAngularVel (dBodyID b) -{ - dAASSERT (b); - return b->avel; -} - - -void dBodySetMass (dBodyID b, const dMass *mass) -{ - dAASSERT (b && mass); - memcpy (&b->mass,mass,sizeof(dMass)); - if (dInvertPDMatrix (b->mass.I,b->invI,3)==0) { - dDEBUGMSG ("inertia must be positive definite"); - dRSetIdentity (b->invI); - } - b->invMass = dRecip(b->mass.mass); -} - - -void dBodyGetMass (dBodyID b, dMass *mass) -{ - dAASSERT (b && mass); - memcpy (mass,&b->mass,sizeof(dMass)); -} - - -void dBodyAddForce (dBodyID b, dReal fx, dReal fy, dReal fz) -{ - dAASSERT (b); - b->facc[0] += fx; - b->facc[1] += fy; - b->facc[2] += fz; -} - - -void dBodyAddTorque (dBodyID b, dReal fx, dReal fy, dReal fz) -{ - dAASSERT (b); - b->tacc[0] += fx; - b->tacc[1] += fy; - b->tacc[2] += fz; -} - - -void dBodyAddRelForce (dBodyID b, dReal fx, dReal fy, dReal fz) -{ - dAASSERT (b); - dVector3 t1,t2; - t1[0] = fx; - t1[1] = fy; - t1[2] = fz; - t1[3] = 0; - dMULTIPLY0_331 (t2,b->R,t1); - b->facc[0] += t2[0]; - b->facc[1] += t2[1]; - b->facc[2] += t2[2]; -} - - -void dBodyAddRelTorque (dBodyID b, dReal fx, dReal fy, dReal fz) -{ - dAASSERT (b); - dVector3 t1,t2; - t1[0] = fx; - t1[1] = fy; - t1[2] = fz; - t1[3] = 0; - dMULTIPLY0_331 (t2,b->R,t1); - b->tacc[0] += t2[0]; - b->tacc[1] += t2[1]; - b->tacc[2] += t2[2]; -} - - -void dBodyAddForceAtPos (dBodyID b, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) -{ - dAASSERT (b); - b->facc[0] += fx; - b->facc[1] += fy; - b->facc[2] += fz; - dVector3 f,q; - f[0] = fx; - f[1] = fy; - f[2] = fz; - q[0] = px - b->pos[0]; - q[1] = py - b->pos[1]; - q[2] = pz - b->pos[2]; - dCROSS (b->tacc,+=,q,f); -} - - -void dBodyAddForceAtRelPos (dBodyID b, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) -{ - dAASSERT (b); - dVector3 prel,f,p; - f[0] = fx; - f[1] = fy; - f[2] = fz; - f[3] = 0; - prel[0] = px; - prel[1] = py; - prel[2] = pz; - prel[3] = 0; - dMULTIPLY0_331 (p,b->R,prel); - b->facc[0] += f[0]; - b->facc[1] += f[1]; - b->facc[2] += f[2]; - dCROSS (b->tacc,+=,p,f); -} - - -void dBodyAddRelForceAtPos (dBodyID b, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) -{ - dAASSERT (b); - dVector3 frel,f; - frel[0] = fx; - frel[1] = fy; - frel[2] = fz; - frel[3] = 0; - dMULTIPLY0_331 (f,b->R,frel); - b->facc[0] += f[0]; - b->facc[1] += f[1]; - b->facc[2] += f[2]; - dVector3 q; - q[0] = px - b->pos[0]; - q[1] = py - b->pos[1]; - q[2] = pz - b->pos[2]; - dCROSS (b->tacc,+=,q,f); -} - - -void dBodyAddRelForceAtRelPos (dBodyID b, dReal fx, dReal fy, dReal fz, - dReal px, dReal py, dReal pz) -{ - dAASSERT (b); - dVector3 frel,prel,f,p; - frel[0] = fx; - frel[1] = fy; - frel[2] = fz; - frel[3] = 0; - prel[0] = px; - prel[1] = py; - prel[2] = pz; - prel[3] = 0; - dMULTIPLY0_331 (f,b->R,frel); - dMULTIPLY0_331 (p,b->R,prel); - b->facc[0] += f[0]; - b->facc[1] += f[1]; - b->facc[2] += f[2]; - dCROSS (b->tacc,+=,p,f); -} - - -const dReal * dBodyGetForce (dBodyID b) -{ - dAASSERT (b); - return b->facc; -} - - -const dReal * dBodyGetTorque (dBodyID b) -{ - dAASSERT (b); - return b->tacc; -} - - -void dBodySetForce (dBodyID b, dReal x, dReal y, dReal z) -{ - dAASSERT (b); - b->facc[0] = x; - b->facc[1] = y; - b->facc[2] = z; -} - - -void dBodySetTorque (dBodyID b, dReal x, dReal y, dReal z) -{ - dAASSERT (b); - b->tacc[0] = x; - b->tacc[1] = y; - b->tacc[2] = z; -} - - -void dBodyGetRelPointPos (dBodyID b, dReal px, dReal py, dReal pz, - dVector3 result) -{ - dAASSERT (b); - dVector3 prel,p; - prel[0] = px; - prel[1] = py; - prel[2] = pz; - prel[3] = 0; - dMULTIPLY0_331 (p,b->R,prel); - result[0] = p[0] + b->pos[0]; - result[1] = p[1] + b->pos[1]; - result[2] = p[2] + b->pos[2]; -} - - -void dBodyGetRelPointVel (dBodyID b, dReal px, dReal py, dReal pz, - dVector3 result) -{ - dAASSERT (b); - dVector3 prel,p; - prel[0] = px; - prel[1] = py; - prel[2] = pz; - prel[3] = 0; - dMULTIPLY0_331 (p,b->R,prel); - result[0] = b->lvel[0]; - result[1] = b->lvel[1]; - result[2] = b->lvel[2]; - dCROSS (result,+=,b->avel,p); -} - - -void dBodyGetPointVel (dBodyID b, dReal px, dReal py, dReal pz, - dVector3 result) -{ - dAASSERT (b); - dVector3 p; - p[0] = px - b->pos[0]; - p[1] = py - b->pos[1]; - p[2] = pz - b->pos[2]; - p[3] = 0; - result[0] = b->lvel[0]; - result[1] = b->lvel[1]; - result[2] = b->lvel[2]; - dCROSS (result,+=,b->avel,p); -} - - -void dBodyGetPosRelPoint (dBodyID b, dReal px, dReal py, dReal pz, - dVector3 result) -{ - dAASSERT (b); - dVector3 prel; - prel[0] = px - b->pos[0]; - prel[1] = py - b->pos[1]; - prel[2] = pz - b->pos[2]; - prel[3] = 0; - dMULTIPLY1_331 (result,b->R,prel); -} - - -void dBodyVectorToWorld (dBodyID b, dReal px, dReal py, dReal pz, - dVector3 result) -{ - dAASSERT (b); - dVector3 p; - p[0] = px; - p[1] = py; - p[2] = pz; - p[3] = 0; - dMULTIPLY0_331 (result,b->R,p); -} - - -void dBodyVectorFromWorld (dBodyID b, dReal px, dReal py, dReal pz, - dVector3 result) -{ - dAASSERT (b); - dVector3 p; - p[0] = px; - p[1] = py; - p[2] = pz; - p[3] = 0; - dMULTIPLY1_331 (result,b->R,p); -} - - -void dBodySetFiniteRotationMode (dBodyID b, int mode) -{ - dAASSERT (b); - b->flags &= ~(dxBodyFlagFiniteRotation | dxBodyFlagFiniteRotationAxis); - if (mode) { - b->flags |= dxBodyFlagFiniteRotation; - if (b->finite_rot_axis[0] != 0 || b->finite_rot_axis[1] != 0 || - b->finite_rot_axis[2] != 0) { - b->flags |= dxBodyFlagFiniteRotationAxis; - } - } -} - - -void dBodySetFiniteRotationAxis (dBodyID b, dReal x, dReal y, dReal z) -{ - dAASSERT (b); - b->finite_rot_axis[0] = x; - b->finite_rot_axis[1] = y; - b->finite_rot_axis[2] = z; - if (x != 0 || y != 0 || z != 0) { - dNormalize3 (b->finite_rot_axis); - b->flags |= dxBodyFlagFiniteRotationAxis; - } - else { - b->flags &= ~dxBodyFlagFiniteRotationAxis; - } -} - - -int dBodyGetFiniteRotationMode (dBodyID b) -{ - dAASSERT (b); - return ((b->flags & dxBodyFlagFiniteRotation) != 0); -} - - -void dBodyGetFiniteRotationAxis (dBodyID b, dVector3 result) -{ - dAASSERT (b); - result[0] = b->finite_rot_axis[0]; - result[1] = b->finite_rot_axis[1]; - result[2] = b->finite_rot_axis[2]; -} - - -int dBodyGetNumJoints (dBodyID b) -{ - dAASSERT (b); - int count=0; - for (dxJointNode *n=b->firstjoint; n; n=n->next, count++); - return count; -} - - -dJointID dBodyGetJoint (dBodyID b, int index) -{ - dAASSERT (b); - int i=0; - for (dxJointNode *n=b->firstjoint; n; n=n->next, i++) { - if (i == index) return n->joint; - } - return 0; -} - - -void dBodyEnable (dBodyID b) -{ - dAASSERT (b); - b->flags &= ~dxBodyDisabled; -} - - -void dBodyDisable (dBodyID b) -{ - dAASSERT (b); - b->flags |= dxBodyDisabled; -} - - -int dBodyIsEnabled (dBodyID b) -{ - dAASSERT (b); - return ((b->flags & dxBodyDisabled) == 0); -} - - -void dBodySetGravityMode (dBodyID b, int mode) -{ - dAASSERT (b); - if (mode) b->flags &= ~dxBodyNoGravity; - else b->flags |= dxBodyNoGravity; -} - - -int dBodyGetGravityMode (dBodyID b) -{ - dAASSERT (b); - return ((b->flags & dxBodyNoGravity) == 0); -} - -//**************************************************************************** -// joints - -static void dJointInit (dxWorld *w, dxJoint *j) -{ - dIASSERT (w && j); - initObject (j,w); - j->vtable = 0; - j->flags = 0; - j->node[0].joint = j; - j->node[0].body = 0; - j->node[0].next = 0; - j->node[1].joint = j; - j->node[1].body = 0; - j->node[1].next = 0; - addObjectToList (j,(dObject **) &w->firstjoint); - w->nj++; -} - - -static dxJoint *createJoint (dWorldID w, dJointGroupID group, - dxJoint::Vtable *vtable) -{ - dIASSERT (w && vtable); - dxJoint *j; - if (group) { - j = (dxJoint*) group->stack.alloc (vtable->size); - group->num++; - } - else j = (dxJoint*) dAlloc (vtable->size); - dJointInit (w,j); - j->vtable = vtable; - if (group) j->flags |= dJOINT_INGROUP; - if (vtable->init) vtable->init (j); - j->feedback = 0; - return j; -} - - -dxJoint * dJointCreateBall (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__dball_vtable); -} - - -dxJoint * dJointCreateHinge (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__dhinge_vtable); -} - - -dxJoint * dJointCreateSlider (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__dslider_vtable); -} - - -dxJoint * dJointCreateContact (dWorldID w, dJointGroupID group, - const dContact *c) -{ - dAASSERT (w && c); - dxJointContact *j = (dxJointContact *) - createJoint (w,group,&__dcontact_vtable); - j->contact = *c; - return j; -} - - -dxJoint * dJointCreateHinge2 (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__dhinge2_vtable); -} - - -dxJoint * dJointCreateUniversal (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__duniversal_vtable); -} - - -dxJoint * dJointCreateFixed (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__dfixed_vtable); -} - - -dxJoint * dJointCreateNull (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__dnull_vtable); -} - - -dxJoint * dJointCreateAMotor (dWorldID w, dJointGroupID group) -{ - dAASSERT (w); - return createJoint (w,group,&__damotor_vtable); -} - - -void dJointDestroy (dxJoint *j) -{ - dAASSERT (j); - if (j->flags & dJOINT_INGROUP) return; - removeJointReferencesFromAttachedBodies (j); - removeObjectFromList (j); - j->world->nj--; - dFree (j,j->vtable->size); -} - - -dJointGroupID dJointGroupCreate (int max_size) -{ - // not any more ... dUASSERT (max_size > 0,"max size must be > 0"); - dxJointGroup *group = new dxJointGroup; - group->num = 0; - return group; -} - - -void dJointGroupDestroy (dJointGroupID group) -{ - dAASSERT (group); - dJointGroupEmpty (group); - delete group; -} - - -void dJointGroupEmpty (dJointGroupID group) -{ - // the joints in this group are detached starting from the most recently - // added (at the top of the stack). this helps ensure that the various - // linked lists are not traversed too much, as the joints will hopefully - // be at the start of those lists. - // if any group joints have their world pointer set to 0, their world was - // previously destroyed. no special handling is required for these joints. - - dAASSERT (group); - int i; - dxJoint **jlist = (dxJoint**) ALLOCA (group->num * sizeof(dxJoint*)); - dxJoint *j = (dxJoint*) group->stack.rewind(); - for (i=0; i < group->num; i++) { - jlist[i] = j; - j = (dxJoint*) (group->stack.next (j->vtable->size)); - } - for (i=group->num-1; i >= 0; i--) { - if (jlist[i]->world) { - removeJointReferencesFromAttachedBodies (jlist[i]); - removeObjectFromList (jlist[i]); - jlist[i]->world->nj--; - } - } - group->num = 0; - group->stack.freeAll(); -} - - -void dJointAttach (dxJoint *joint, dxBody *body1, dxBody *body2) -{ - // check arguments - dUASSERT (joint,"bad joint argument"); - dUASSERT (body1 == 0 || body1 != body2,"can't have body1==body2"); - dxWorld *world = joint->world; - dUASSERT ( (!body1 || body1->world == world) && - (!body2 || body2->world == world), - "joint and bodies must be in same world"); - - // check if the joint can not be attached to just one body - dUASSERT (!((joint->flags & dJOINT_TWOBODIES) && - ((body1 != 0) ^ (body2 != 0))), - "joint can not be attached to just one body"); - - // remove any existing body attachments - if (joint->node[0].body || joint->node[1].body) { - removeJointReferencesFromAttachedBodies (joint); - } - - // if a body is zero, make sure that it is body2, so 0 --> node[1].body - if (body1==0) { - body1 = body2; - body2 = 0; - joint->flags &= (~dJOINT_REVERSE); - } - else { - joint->flags |= dJOINT_REVERSE; - } - - // attach to new bodies - joint->node[0].body = body1; - joint->node[1].body = body2; - if (body1) { - joint->node[1].next = body1->firstjoint; - body1->firstjoint = &joint->node[1]; - } - else joint->node[1].next = 0; - if (body2) { - joint->node[0].next = body2->firstjoint; - body2->firstjoint = &joint->node[0]; - } - else { - joint->node[0].next = 0; - } -} - - -void dJointSetData (dxJoint *joint, void *data) -{ - dAASSERT (joint); - joint->userdata = data; -} - - -void *dJointGetData (dxJoint *joint) -{ - dAASSERT (joint); - return joint->userdata; -} - - -int dJointGetType (dxJoint *joint) -{ - dAASSERT (joint); - return joint->vtable->typenum; -} - - -dBodyID dJointGetBody (dxJoint *joint, int index) -{ - dAASSERT (joint); - if (index >= 0 && index < 2) return joint->node[index].body; - else return 0; -} - - -void dJointSetFeedback (dxJoint *joint, dJointFeedback *f) -{ - dAASSERT (joint); - joint->feedback = f; -} - - -dJointFeedback *dJointGetFeedback (dxJoint *joint) -{ - dAASSERT (joint); - return joint->feedback; -} - - -int dAreConnected (dBodyID b1, dBodyID b2) -{ - dAASSERT (b1 && b2); - // look through b1's neighbour list for b2 - for (dxJointNode *n=b1->firstjoint; n; n=n->next) { - if (n->body == b2) return 1; - } - return 0; -} - -//**************************************************************************** -// world - -dxWorld * dWorldCreate() -{ - dxWorld *w = new dxWorld; - w->firstbody = 0; - w->firstjoint = 0; - w->nb = 0; - w->nj = 0; - dSetZero (w->gravity,4); - w->global_erp = REAL(0.2); -#if defined(dSINGLE) - w->global_cfm = 1e-5f; -#elif defined(dDOUBLE) - w->global_cfm = 1e-10; -#else - #error dSINGLE or dDOUBLE must be defined -#endif - return w; -} - - -void dWorldDestroy (dxWorld *w) -{ - // delete all bodies and joints - dAASSERT (w); - dxBody *nextb, *b = w->firstbody; - while (b) { - nextb = (dxBody*) b->next; - delete b; - b = nextb; - } - dxJoint *nextj, *j = w->firstjoint; - while (j) { - nextj = (dxJoint*)j->next; - if (j->flags & dJOINT_INGROUP) { - // the joint is part of a group, so "deactivate" it instead - j->world = 0; - j->node[0].body = 0; - j->node[0].next = 0; - j->node[1].body = 0; - j->node[1].next = 0; - dMessage (0,"warning: destroying world containing grouped joints"); - } - else { - dFree (j,j->vtable->size); - } - j = nextj; - } - delete w; -} - - -void dWorldSetGravity (dWorldID w, dReal x, dReal y, dReal z) -{ - dAASSERT (w); - w->gravity[0] = x; - w->gravity[1] = y; - w->gravity[2] = z; -} - - -void dWorldGetGravity (dWorldID w, dVector3 g) -{ - dAASSERT (w); - g[0] = w->gravity[0]; - g[1] = w->gravity[1]; - g[2] = w->gravity[2]; -} - - -void dWorldSetERP (dWorldID w, dReal erp) -{ - dAASSERT (w); - w->global_erp = erp; -} - - -dReal dWorldGetERP (dWorldID w) -{ - dAASSERT (w); - return w->global_erp; -} - - -void dWorldSetCFM (dWorldID w, dReal cfm) -{ - dAASSERT (w); - w->global_cfm = cfm; -} - - -dReal dWorldGetCFM (dWorldID w) -{ - dAASSERT (w); - return w->global_cfm; -} - - -void dWorldStep (dWorldID w, dReal stepsize) -{ - dUASSERT (w,"bad world argument"); - dUASSERT (stepsize > 0,"stepsize must be > 0"); - processIslands (w,stepsize); -} - - -void dWorldImpulseToForce (dWorldID w, dReal stepsize, - dReal ix, dReal iy, dReal iz, - dVector3 force) -{ - dAASSERT (w); - stepsize = dRecip(stepsize); - force[0] = stepsize * ix; - force[1] = stepsize * iy; - force[2] = stepsize * iz; - // @@@ force[3] = 0; -} - -//**************************************************************************** -// testing - -#define NUM 100 - -#define DO(x) - - -extern "C" void dTestDataStructures() -{ - int i; - DO(printf ("testDynamicsStuff()\n")); - - dBodyID body [NUM]; - int nb = 0; - dJointID joint [NUM]; - int nj = 0; - - for (i=0; i<NUM; i++) body[i] = 0; - for (i=0; i<NUM; i++) joint[i] = 0; - - DO(printf ("creating world\n")); - dWorldID w = dWorldCreate(); - checkWorld (w); - - for (;;) { - if (nb < NUM && dRandReal() > 0.5) { - DO(printf ("creating body\n")); - body[nb] = dBodyCreate (w); - DO(printf ("\t--> %p\n",body[nb])); - nb++; - checkWorld (w); - DO(printf ("%d BODIES, %d JOINTS\n",nb,nj)); - } - if (nj < NUM && nb > 2 && dRandReal() > 0.5) { - dBodyID b1 = body [dRand() % nb]; - dBodyID b2 = body [dRand() % nb]; - if (b1 != b2) { - DO(printf ("creating joint, attaching to %p,%p\n",b1,b2)); - joint[nj] = dJointCreateBall (w,0); - DO(printf ("\t-->%p\n",joint[nj])); - checkWorld (w); - dJointAttach (joint[nj],b1,b2); - nj++; - checkWorld (w); - DO(printf ("%d BODIES, %d JOINTS\n",nb,nj)); - } - } - if (nj > 0 && nb > 2 && dRandReal() > 0.5) { - dBodyID b1 = body [dRand() % nb]; - dBodyID b2 = body [dRand() % nb]; - if (b1 != b2) { - int k = dRand() % nj; - DO(printf ("reattaching joint %p\n",joint[k])); - dJointAttach (joint[k],b1,b2); - checkWorld (w); - DO(printf ("%d BODIES, %d JOINTS\n",nb,nj)); - } - } - if (nb > 0 && dRandReal() > 0.5) { - int k = dRand() % nb; - DO(printf ("destroying body %p\n",body[k])); - dBodyDestroy (body[k]); - checkWorld (w); - for (; k < (NUM-1); k++) body[k] = body[k+1]; - nb--; - DO(printf ("%d BODIES, %d JOINTS\n",nb,nj)); - } - if (nj > 0 && dRandReal() > 0.5) { - int k = dRand() % nj; - DO(printf ("destroying joint %p\n",joint[k])); - dJointDestroy (joint[k]); - checkWorld (w); - for (; k < (NUM-1); k++) joint[k] = joint[k+1]; - nj--; - DO(printf ("%d BODIES, %d JOINTS\n",nb,nj)); - } - } - - /* - printf ("creating world\n"); - dWorldID w = dWorldCreate(); - checkWorld (w); - printf ("creating body\n"); - dBodyID b1 = dBodyCreate (w); - checkWorld (w); - printf ("creating body\n"); - dBodyID b2 = dBodyCreate (w); - checkWorld (w); - printf ("creating joint\n"); - dJointID j = dJointCreateBall (w); - checkWorld (w); - printf ("attaching joint\n"); - dJointAttach (j,b1,b2); - checkWorld (w); - printf ("destroying joint\n"); - dJointDestroy (j); - checkWorld (w); - printf ("destroying body\n"); - dBodyDestroy (b1); - checkWorld (w); - printf ("destroying body\n"); - dBodyDestroy (b2); - checkWorld (w); - printf ("destroying world\n"); - dWorldDestroy (w); - */ -} diff --git a/extern/ode/dist/ode/src/odemath.cpp b/extern/ode/dist/ode/src/odemath.cpp deleted file mode 100644 index cd6dbc855fe..00000000000 --- a/extern/ode/dist/ode/src/odemath.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#define SHARED_CONFIG_H_INCLUDED_FROM_DEFINING_FILE 1 -#include <ode/common.h> -#include <ode/odemath.h> - - -// get some math functions under windows -#ifdef WIN32 -#include <float.h> -#ifndef CYGWIN // added by andy for cygwin -#define copysign(a,b) ((dReal)_copysign(a,b)) -#endif // added by andy for cygwin -#endif - - -// infinity declaration - -#ifdef DINFINITY_DECL -DINFINITY_DECL -#endif - - -// this may be called for vectors `a' with extremely small magnitude, for -// example the result of a cross product on two nearly perpendicular vectors. -// we must be robust to these small vectors. to prevent numerical error, -// first find the component a[i] with the largest magnitude and then scale -// all the components by 1/a[i]. then we can compute the length of `a' and -// scale the components by 1/l. this has been verified to work with vectors -// containing the smallest representable numbers. - -void dNormalize3 (dVector3 a) -{ - dReal a0,a1,a2,aa0,aa1,aa2,l; - dAASSERT (a); - a0 = a[0]; - a1 = a[1]; - a2 = a[2]; - aa0 = dFabs(a0); - aa1 = dFabs(a1); - aa2 = dFabs(a2); - if (aa1 > aa0) { - if (aa2 > aa1) { - goto aa2_largest; - } - else { // aa1 is largest - a0 /= aa1; - a2 /= aa1; - l = dRecipSqrt (a0*a0 + a2*a2 + 1); - a[0] = a0*l; - a[1] = copysign(l,a1); - a[2] = a2*l; - } - } - else { - if (aa2 > aa0) { - aa2_largest: // aa2 is largest - a0 /= aa2; - a1 /= aa2; - l = dRecipSqrt (a0*a0 + a1*a1 + 1); - a[0] = a0*l; - a[1] = a1*l; - a[2] = copysign(l,a2); - } - else { // aa0 is largest - if (aa0 <= 0) { - dDEBUGMSG ("vector has zero size"); - a[0] = 1; // if all a's are zero, this is where we'll end up. - a[1] = 0; // return a default unit length vector. - a[2] = 0; - return; - } - a1 /= aa0; - a2 /= aa0; - l = dRecipSqrt (a1*a1 + a2*a2 + 1); - a[0] = copysign(l,a0); - a[1] = a1*l; - a[2] = a2*l; - } - } -} - - -/* OLD VERSION */ -/* -void dNormalize3 (dVector3 a) -{ - dASSERT (a); - dReal l = dDOT(a,a); - if (l > 0) { - l = dRecipSqrt(l); - a[0] *= l; - a[1] *= l; - a[2] *= l; - } - else { - a[0] = 1; - a[1] = 0; - a[2] = 0; - } -} -*/ - - -void dNormalize4 (dVector4 a) -{ - dAASSERT (a); - dReal l = dDOT(a,a)+a[3]*a[3]; - if (l > 0) { - l = dRecipSqrt(l); - a[0] *= l; - a[1] *= l; - a[2] *= l; - a[3] *= l; - } - else { - dDEBUGMSG ("vector has zero size"); - a[0] = 1; - a[1] = 0; - a[2] = 0; - a[3] = 0; - } -} - - -void dPlaneSpace (const dVector3 n, dVector3 p, dVector3 q) -{ - dAASSERT (n && p && q); - if (dFabs(n[2]) > M_SQRT1_2) { - // choose p in y-z plane - dReal a = n[1]*n[1] + n[2]*n[2]; - dReal k = dRecipSqrt (a); - p[0] = 0; - p[1] = -n[2]*k; - p[2] = n[1]*k; - // set q = n x p - q[0] = a*k; - q[1] = -n[0]*p[2]; - q[2] = n[0]*p[1]; - } - else { - // choose p in x-y plane - dReal a = n[0]*n[0] + n[1]*n[1]; - dReal k = dRecipSqrt (a); - p[0] = -n[1]*k; - p[1] = n[0]*k; - p[2] = 0; - // set q = n x p - q[0] = -n[2]*p[1]; - q[1] = n[2]*p[0]; - q[2] = a*k; - } -} diff --git a/extern/ode/dist/ode/src/rotation.cpp b/extern/ode/dist/ode/src/rotation.cpp deleted file mode 100644 index 22b9fb13820..00000000000 --- a/extern/ode/dist/ode/src/rotation.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -quaternions have the format: (s,vx,vy,vz) where (vx,vy,vz) is the -"rotation axis" and s is the "rotation angle". - -*/ - -#include <ode/rotation.h> - - -#define _R(i,j) R[(i)*4+(j)] - -#define SET_3x3_IDENTITY \ - _R(0,0) = REAL(1.0); \ - _R(0,1) = REAL(0.0); \ - _R(0,2) = REAL(0.0); \ - _R(0,3) = REAL(0.0); \ - _R(1,0) = REAL(0.0); \ - _R(1,1) = REAL(1.0); \ - _R(1,2) = REAL(0.0); \ - _R(1,3) = REAL(0.0); \ - _R(2,0) = REAL(0.0); \ - _R(2,1) = REAL(0.0); \ - _R(2,2) = REAL(1.0); \ - _R(2,3) = REAL(0.0); - - -void dRSetIdentity (dMatrix3 R) -{ - dAASSERT (R); - SET_3x3_IDENTITY; -} - - -void dRFromAxisAndAngle (dMatrix3 R, dReal ax, dReal ay, dReal az, - dReal angle) -{ - dAASSERT (R); - dQuaternion q; - dQFromAxisAndAngle (q,ax,ay,az,angle); - dQtoR (q,R); -} - - -void dRFromEulerAngles (dMatrix3 R, dReal phi, dReal theta, dReal psi) -{ - dReal sphi,cphi,stheta,ctheta,spsi,cpsi; - dAASSERT (R); - sphi = dSin(phi); - cphi = dCos(phi); - stheta = dSin(theta); - ctheta = dCos(theta); - spsi = dSin(psi); - cpsi = dCos(psi); - _R(0,0) = cpsi*ctheta; - _R(0,1) = spsi*ctheta; - _R(0,2) =-stheta; - _R(1,0) = cpsi*stheta*sphi - spsi*cphi; - _R(1,1) = spsi*stheta*sphi + cpsi*cphi; - _R(1,2) = ctheta*sphi; - _R(2,0) = cpsi*stheta*cphi + spsi*sphi; - _R(2,1) = spsi*stheta*cphi - cpsi*sphi; - _R(2,2) = ctheta*cphi; -} - - -void dRFrom2Axes (dMatrix3 R, dReal ax, dReal ay, dReal az, - dReal bx, dReal by, dReal bz) -{ - dReal l,k; - dAASSERT (R); - l = dSqrt (ax*ax + ay*ay + az*az); - if (l <= REAL(0.0)) { - dDEBUGMSG ("zero length vector"); - return; - } - l = dRecip(l); - ax *= l; - ay *= l; - az *= l; - k = ax*bx + ay*by + az*bz; - bx -= k*ax; - by -= k*ay; - bz -= k*az; - l = dSqrt (bx*bx + by*by + bz*bz); - if (l <= REAL(0.0)) { - dDEBUGMSG ("zero length vector"); - return; - } - l = dRecip(l); - bx *= l; - by *= l; - bz *= l; - _R(0,0) = ax; - _R(1,0) = ay; - _R(2,0) = az; - _R(0,1) = bx; - _R(1,1) = by; - _R(2,1) = bz; - _R(0,2) = - by*az + ay*bz; - _R(1,2) = - bz*ax + az*bx; - _R(2,2) = - bx*ay + ax*by; -} - - -void dQSetIdentity (dQuaternion q) -{ - dAASSERT (q); - q[0] = 1; - q[1] = 0; - q[2] = 0; - q[3] = 0; -} - - -void dQFromAxisAndAngle (dQuaternion q, dReal ax, dReal ay, dReal az, - dReal angle) -{ - dAASSERT (q); - dReal l = ax*ax + ay*ay + az*az; - if (l > REAL(0.0)) { - angle *= REAL(0.5); - q[0] = dCos (angle); - l = dSin(angle) * dRecipSqrt(l); - q[1] = ax*l; - q[2] = ay*l; - q[3] = az*l; - } - else { - q[0] = 1; - q[1] = 0; - q[2] = 0; - q[3] = 0; - } -} - - -void dQMultiply0 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc) -{ - dAASSERT (qa && qb && qc); - qa[0] = qb[0]*qc[0] - qb[1]*qc[1] - qb[2]*qc[2] - qb[3]*qc[3]; - qa[1] = qb[0]*qc[1] + qb[1]*qc[0] + qb[2]*qc[3] - qb[3]*qc[2]; - qa[2] = qb[0]*qc[2] + qb[2]*qc[0] + qb[3]*qc[1] - qb[1]*qc[3]; - qa[3] = qb[0]*qc[3] + qb[3]*qc[0] + qb[1]*qc[2] - qb[2]*qc[1]; -} - - -void dQMultiply1 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc) -{ - dAASSERT (qa && qb && qc); - qa[0] = qb[0]*qc[0] + qb[1]*qc[1] + qb[2]*qc[2] + qb[3]*qc[3]; - qa[1] = qb[0]*qc[1] - qb[1]*qc[0] - qb[2]*qc[3] + qb[3]*qc[2]; - qa[2] = qb[0]*qc[2] - qb[2]*qc[0] - qb[3]*qc[1] + qb[1]*qc[3]; - qa[3] = qb[0]*qc[3] - qb[3]*qc[0] - qb[1]*qc[2] + qb[2]*qc[1]; -} - - -void dQMultiply2 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc) -{ - dAASSERT (qa && qb && qc); - qa[0] = qb[0]*qc[0] + qb[1]*qc[1] + qb[2]*qc[2] + qb[3]*qc[3]; - qa[1] = -qb[0]*qc[1] + qb[1]*qc[0] - qb[2]*qc[3] + qb[3]*qc[2]; - qa[2] = -qb[0]*qc[2] + qb[2]*qc[0] - qb[3]*qc[1] + qb[1]*qc[3]; - qa[3] = -qb[0]*qc[3] + qb[3]*qc[0] - qb[1]*qc[2] + qb[2]*qc[1]; -} - - -void dQMultiply3 (dQuaternion qa, const dQuaternion qb, const dQuaternion qc) -{ - dAASSERT (qa && qb && qc); - qa[0] = qb[0]*qc[0] - qb[1]*qc[1] - qb[2]*qc[2] - qb[3]*qc[3]; - qa[1] = -qb[0]*qc[1] - qb[1]*qc[0] + qb[2]*qc[3] - qb[3]*qc[2]; - qa[2] = -qb[0]*qc[2] - qb[2]*qc[0] + qb[3]*qc[1] - qb[1]*qc[3]; - qa[3] = -qb[0]*qc[3] - qb[3]*qc[0] + qb[1]*qc[2] - qb[2]*qc[1]; -} - - -// QtoR(), RtoQ() and WtoDQ() are derived from equations in "An Introduction -// to Physically Based Modeling: Rigid Body Simulation - 1: Unconstrained -// Rigid Body Dynamics" by David Baraff, Robotics Institute, Carnegie Mellon -// University, 1997. - -void dQtoR (const dQuaternion q, dMatrix3 R) -{ - dAASSERT (q && R); - // q = (s,vx,vy,vz) - dReal qq1 = 2*q[1]*q[1]; - dReal qq2 = 2*q[2]*q[2]; - dReal qq3 = 2*q[3]*q[3]; - _R(0,0) = 1 - qq2 - qq3; - _R(0,1) = 2*(q[1]*q[2] - q[0]*q[3]); - _R(0,2) = 2*(q[1]*q[3] + q[0]*q[2]); - _R(1,0) = 2*(q[1]*q[2] + q[0]*q[3]); - _R(1,1) = 1 - qq1 - qq3; - _R(1,2) = 2*(q[2]*q[3] - q[0]*q[1]); - _R(2,0) = 2*(q[1]*q[3] - q[0]*q[2]); - _R(2,1) = 2*(q[2]*q[3] + q[0]*q[1]); - _R(2,2) = 1 - qq1 - qq2; -} - - -void dRtoQ (const dMatrix3 R, dQuaternion q) -{ - dAASSERT (q && R); - dReal tr,s; - tr = _R(0,0) + _R(1,1) + _R(2,2); - if (tr >= 0) { - s = dSqrt (tr + 1); - q[0] = REAL(0.5) * s; - s = REAL(0.5) * dRecip(s); - q[1] = (_R(2,1) - _R(1,2)) * s; - q[2] = (_R(0,2) - _R(2,0)) * s; - q[3] = (_R(1,0) - _R(0,1)) * s; - } - else { - // find the largest diagonal element and jump to the appropriate case - if (_R(1,1) > _R(0,0)) { - if (_R(2,2) > _R(1,1)) goto case_2; - goto case_1; - } - if (_R(2,2) > _R(0,0)) goto case_2; - goto case_0; - - case_0: - s = dSqrt((_R(0,0) - (_R(1,1) + _R(2,2))) + 1); - q[1] = REAL(0.5) * s; - s = REAL(0.5) * dRecip(s); - q[2] = (_R(0,1) + _R(1,0)) * s; - q[3] = (_R(2,0) + _R(0,2)) * s; - q[0] = (_R(2,1) - _R(1,2)) * s; - return; - - case_1: - s = dSqrt((_R(1,1) - (_R(2,2) + _R(0,0))) + 1); - q[2] = REAL(0.5) * s; - s = REAL(0.5) * dRecip(s); - q[3] = (_R(1,2) + _R(2,1)) * s; - q[1] = (_R(0,1) + _R(1,0)) * s; - q[0] = (_R(0,2) - _R(2,0)) * s; - return; - - case_2: - s = dSqrt((_R(2,2) - (_R(0,0) + _R(1,1))) + 1); - q[3] = REAL(0.5) * s; - s = REAL(0.5) * dRecip(s); - q[1] = (_R(2,0) + _R(0,2)) * s; - q[2] = (_R(1,2) + _R(2,1)) * s; - q[0] = (_R(1,0) - _R(0,1)) * s; - return; - } -} - - -void dWtoDQ (const dVector3 w, const dQuaternion q, dVector4 dq) -{ - dAASSERT (w && q && dq); - dq[0] = REAL(0.5)*(- w[0]*q[1] - w[1]*q[2] - w[2]*q[3]); - dq[1] = REAL(0.5)*( w[0]*q[0] + w[1]*q[3] - w[2]*q[2]); - dq[2] = REAL(0.5)*(- w[0]*q[3] + w[1]*q[0] + w[2]*q[1]); - dq[3] = REAL(0.5)*( w[0]*q[2] - w[1]*q[1] + w[2]*q[0]); -} diff --git a/extern/ode/dist/ode/src/scrapbook.cpp b/extern/ode/dist/ode/src/scrapbook.cpp deleted file mode 100644 index ca8c11f1f1b..00000000000 --- a/extern/ode/dist/ode/src/scrapbook.cpp +++ /dev/null @@ -1,270 +0,0 @@ - -/* - -this is code that was once useful but has now been obseleted. - -this file should not be compiled as part of ODE! - -*/ - -//*************************************************************************** -// intersect a line segment with a plane - -extern "C" int dClipLineToBox (const dVector3 p1, const dVector3 p2, - const dVector3 p, const dMatrix3 R, - const dVector3 side) -{ - // compute the start and end of the line (p1 and p2) relative to the box. - // we will do all subsequent computations in this box-relative coordinate - // system. we have to do a translation and rotation for each point. - dVector3 tmp,s,e; - tmp[0] = p1[0] - p[0]; - tmp[1] = p1[1] - p[1]; - tmp[2] = p1[2] - p[2]; - dMULTIPLY1_331 (s,R,tmp); - tmp[0] = p2[0] - p[0]; - tmp[1] = p2[1] - p[1]; - tmp[2] = p2[2] - p[2]; - dMULTIPLY1_331 (e,R,tmp); - - // compute the vector 'v' from the start point to the end point - dVector3 v; - v[0] = e[0] - s[0]; - v[1] = e[1] - s[1]; - v[2] = e[2] - s[2]; - - // a point on the line is defined by the parameter 't'. t=0 corresponds - // to the start of the line, t=1 corresponds to the end of the line. - // we will clip the line to the box by finding the range of t where a - // point on the line is inside the box. the currently known bounds for - // t and tlo..thi. - dReal tlo=0,thi=1; - - // clip in the X/Y/Z direction - for (int i=0; i<3; i++) { - // first adjust s,e for the current t range. this is redundant for the - // first iteration, but never mind. - e[i] = s[i] + thi*v[i]; - s[i] = s[i] + tlo*v[i]; - // compute where t intersects the positive and negative sides. - dReal tp = ( side[i] - s[i])/v[i]; // @@@ handle case where denom=0 - dReal tm = (-side[i] - s[i])/v[i]; - // handle 9 intersection cases - if (s[i] <= -side[i]) { - tlo = tm; - if (e[i] <= -side[i]) return 0; - else if (e[i] >= side[i]) thi = tp; - } - else if (s[i] <= side[i]) { - if (e[i] <= -side[i]) thi = tm; - else if (e[i] >= side[i]) thi = tp; - } - else { - tlo = tp; - if (e[i] <= -side[i]) thi = tm; - else if (e[i] >= side[i]) return 0; - } - } - - //... @@@ AT HERE @@@ - - return 1; -} - - -//*************************************************************************** -// a nice try at C-B collision. unfortunately it doesn't work. the logic -// for testing for line-box intersection is correct, but unfortunately the -// closest-point distance estimates are often too large. as a result contact -// points are placed incorrectly. - - -int dCollideCB (const dxGeom *o1, const dxGeom *o2, int flags, - dContactGeom *contact, int skip) -{ - int i; - - dIASSERT (skip >= (int)sizeof(dContactGeom)); - dIASSERT (o1->_class->num == dCCylinderClass); - dIASSERT (o2->_class->num == dBoxClass); - contact->g1 = const_cast<dxGeom*> (o1); - contact->g2 = const_cast<dxGeom*> (o2); - dxCCylinder *cyl = (dxCCylinder*) CLASSDATA(o1); - dxBox *box = (dxBox*) CLASSDATA(o2); - - // get p1,p2 = cylinder axis endpoints, get radius - dVector3 p1,p2; - dReal clen = cyl->lz * REAL(0.5); - p1[0] = o1->pos[0] + clen * o1->R[2]; - p1[1] = o1->pos[1] + clen * o1->R[6]; - p1[2] = o1->pos[2] + clen * o1->R[10]; - p2[0] = o1->pos[0] - clen * o1->R[2]; - p2[1] = o1->pos[1] - clen * o1->R[6]; - p2[2] = o1->pos[2] - clen * o1->R[10]; - dReal radius = cyl->radius; - - // copy out box center, rotation matrix, and side array - dReal *c = o2->pos; - dReal *R = o2->R; - dReal *side = box->side; - - // compute the start and end of the line (p1 and p2) relative to the box. - // we will do all subsequent computations in this box-relative coordinate - // system. we have to do a translation and rotation for each point. - dVector3 tmp3,s,e; - tmp3[0] = p1[0] - c[0]; - tmp3[1] = p1[1] - c[1]; - tmp3[2] = p1[2] - c[2]; - dMULTIPLY1_331 (s,R,tmp3); - tmp3[0] = p2[0] - c[0]; - tmp3[1] = p2[1] - c[1]; - tmp3[2] = p2[2] - c[2]; - dMULTIPLY1_331 (e,R,tmp3); - - // compute the vector 'v' from the start point to the end point - dVector3 v; - v[0] = e[0] - s[0]; - v[1] = e[1] - s[1]; - v[2] = e[2] - s[2]; - - // compute the half-sides of the box - dReal S0 = side[0] * REAL(0.5); - dReal S1 = side[1] * REAL(0.5); - dReal S2 = side[2] * REAL(0.5); - - // compute the size of the bounding box around the line segment - dReal B0 = dFabs (v[0]); - dReal B1 = dFabs (v[1]); - dReal B2 = dFabs (v[2]); - - // for all 6 separation axes, measure the penetration depth. if any depth is - // less than 0 then the objects don't penetrate at all so we can just - // return 0. find the axis with the smallest depth, and record its normal. - - // note: normalR is set to point to a column of R if that is the smallest - // depth normal so far. otherwise normalR is 0 and normalC is set to a - // vector relative to the box. invert_normal is 1 if the sign of the normal - // should be flipped. - - dReal depth,trial_depth,tmp,length; - const dReal *normalR=0; - dVector3 normalC; - int invert_normal = 0; - int code = 0; // 0=no contact, 1-3=face contact, 4-6=edge contact - - depth = dInfinity; - - // look at face-normal axes - -#undef TEST -#define TEST(center,depth_expr,norm,contact_code) \ - tmp = (center); \ - trial_depth = radius + REAL(0.5) * ((depth_expr) - dFabs(tmp)); \ - if (trial_depth < 0) return 0; \ - if (trial_depth < depth) { \ - depth = trial_depth; \ - normalR = (norm); \ - invert_normal = (tmp < 0); \ - code = contact_code; \ - } - - TEST (s[0]+e[0], side[0] + B0, R+0, 1); - TEST (s[1]+e[1], side[1] + B1, R+1, 2); - TEST (s[2]+e[2], side[2] + B2, R+2, 3); - - // look at v x box-edge axes - -#undef TEST -#define TEST(box_radius,line_offset,nx,ny,nz,contact_code) \ - tmp = (line_offset); \ - trial_depth = (box_radius) - dFabs(tmp); \ - length = dSqrt ((nx)*(nx) + (ny)*(ny) + (nz)*(nz)); \ - if (length > 0) { \ - length = dRecip(length); \ - trial_depth = trial_depth * length + radius; \ - if (trial_depth < 0) return 0; \ - if (trial_depth < depth) { \ - depth = trial_depth; \ - normalR = 0; \ - normalC[0] = (nx)*length; \ - normalC[1] = (ny)*length; \ - normalC[2] = (nz)*length; \ - invert_normal = (tmp < 0); \ - code = contact_code; \ - } \ - } - - TEST (B2*S1+B1*S2,v[1]*s[2]-v[2]*s[1], 0,-v[2],v[1], 4); - TEST (B2*S0+B0*S2,v[2]*s[0]-v[0]*s[2], v[2],0,-v[0], 5); - TEST (B1*S0+B0*S1,v[0]*s[1]-v[1]*s[0], -v[1],v[0],0, 6); - -#undef TEST - - // if we get to this point, the box and ccylinder interpenetrate. - // compute the normal in global coordinates. - dReal *normal = contact[0].normal; - if (normalR) { - normal[0] = normalR[0]; - normal[1] = normalR[4]; - normal[2] = normalR[8]; - } - else { - dMULTIPLY0_331 (normal,R,normalC); - } - if (invert_normal) { - normal[0] = -normal[0]; - normal[1] = -normal[1]; - normal[2] = -normal[2]; - } - - // set the depth - contact[0].depth = depth; - - if (code == 0) { - return 0; // should never get here - } - else if (code >= 4) { - // handle edge contacts - // find an endpoint q1 on the intersecting edge of the box - dVector3 q1; - dReal sign[3]; - for (i=0; i<3; i++) q1[i] = c[i]; - sign[0] = (dDOT14(normal,R+0) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) q1[i] += sign[0] * S0 * R[i*4]; - sign[1] = (dDOT14(normal,R+1) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) q1[i] += sign[1] * S1 * R[i*4+1]; - sign[2] = (dDOT14(normal,R+2) > 0) ? REAL(1.0) : REAL(-1.0); - for (i=0; i<3; i++) q1[i] += sign[2] * S2 * R[i*4+2]; - - // find the other endpoint q2 of the intersecting edge - dVector3 q2; - for (i=0; i<3; i++) - q2[i] = q1[i] - R[code-4 + i*4] * (sign[code-4] * side[code-4]); - - // determine the closest point between the box edge and the line segment - dVector3 cp1,cp2; - dClosestLineSegmentPoints (q1,q2, p1,p2, cp1,cp2); - for (i=0; i<3; i++) contact[0].pos[i] = cp1[i] - REAL(0.5)*normal[i]*depth; - return 1; - } - else { - // handle face contacts. - // @@@ temporary: make deepest vertex on the line the contact point. - // @@@ this kind of works, but we sometimes need two contact points for - // @@@ stability. - - // compute 'v' in global coordinates - dVector3 gv; - for (i=0; i<3; i++) gv[i] = p2[i] - p1[i]; - - if (dDOT (normal,gv) > 0) { - for (i=0; i<3; i++) - contact[0].pos[i] = p1[i] + (depth*REAL(0.5)-radius)*normal[i]; - } - else { - for (i=0; i<3; i++) - contact[0].pos[i] = p2[i] + (depth*REAL(0.5)-radius)*normal[i]; - } - return 1; - } -} diff --git a/extern/ode/dist/ode/src/space.cpp b/extern/ode/dist/ode/src/space.cpp deleted file mode 100644 index 0c656573918..00000000000 --- a/extern/ode/dist/ode/src/space.cpp +++ /dev/null @@ -1,621 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -simple space ------------- - -reports all n^2 object intersections - - -multi-resolution hash table ---------------------------- - -the current implementation rebuilds a new hash table each time collide() -is called. we don't keep any state between calls. this is wasteful if there -are unmoving objects in the space. - - -TODO ----- - -less memory wasting may to prevent multiple collision callbacks for the -same pair? - -better virtual address function. - -the collision search can perhaps be optimized - as we search chains we can -come across other candidate intersections at other levels, perhaps we should -do the intersection check straight away? --> save on list searching time only, -which is not too significant. - -*/ - -//**************************************************************************** - -#include <ode/common.h> -#include <ode/space.h> -#include <ode/geom.h> -#include <ode/error.h> -#include <ode/memory.h> -#include "objects.h" -#include "geom_internal.h" - -//**************************************************************************** -// space base class - -struct dxSpace : public dBase { - int type; // don't want to use RTTI - virtual void destroy()=0; - virtual void add (dGeomID)=0; - virtual void remove (dGeomID)=0; - virtual void collide (void *data, dNearCallback *callback)=0; - virtual int query (dGeomID)=0; -}; - -#define TYPE_SIMPLE 0xbad -#define TYPE_HASH 0xbabe - -//**************************************************************************** -// stuff common to all spaces - -#define ALLOCA(x) dALLOCA16(x) - - -// collide two AABBs together. for the hash table space, this is called if -// the two AABBs inhabit the same hash table cells. this only calls the -// callback function if the boxes actually intersect. if a geom has an -// AABB test function, that is called to provide a further refinement of -// the intersection. - -static inline void collideAABBs (dReal bounds1[6], dReal bounds2[6], - dxGeom *g1, dxGeom *g2, - void *data, dNearCallback *callback) -{ - // no contacts if both geoms on the same body, and the body is not 0 - if (g1->body == g2->body && g1->body) return; - - if (bounds1[0] > bounds2[1] || - bounds1[1] < bounds2[0] || - bounds1[2] > bounds2[3] || - bounds1[3] < bounds2[2] || - bounds1[4] > bounds2[5] || - bounds1[5] < bounds2[4]) return; - if (g1->_class->aabb_test) { - if (g1->_class->aabb_test (g1,g2,bounds2) == 0) return; - } - if (g2->_class->aabb_test) { - if (g2->_class->aabb_test (g2,g1,bounds1) == 0) return; - } - callback (data,g1,g2); -} - -//**************************************************************************** -// simple space - reports all n^2 object intersections - -struct dxSimpleSpace : public dxSpace { - dGeomID first; - void destroy(); - void add (dGeomID); - void remove (dGeomID); - void collide (void *data, dNearCallback *callback); - int query (dGeomID); -}; - - -dSpaceID dSimpleSpaceCreate() -{ - dxSimpleSpace *w = new dxSimpleSpace; - w->type = TYPE_SIMPLE; - w->first = 0; - return w; -} - - -void dxSimpleSpace::destroy() -{ - // destroying each geom will call remove(). this will be efficient if - // we destroy geoms in list order. - dAASSERT (this); - dGeomID g,n; - g = first; - while (g) { - n = g->space.next; - dGeomDestroy (g); - g = n; - } - delete this; -} - - -void dxSimpleSpace::add (dGeomID obj) -{ - dAASSERT (this && obj); - dUASSERT (obj->spaceid == 0 && obj->space.next == 0, - "object is already in a space"); - obj->space.next = first; - first = obj; - obj->spaceid = this; -} - - -void dxSimpleSpace::remove (dGeomID geom_to_remove) -{ - dAASSERT (this && geom_to_remove); - dUASSERT (geom_to_remove->spaceid,"object is not in a space"); - dGeomID last=0,g=first; - while (g) { - if (g==geom_to_remove) { - if (last) last->space.next = g->space.next; - else first = g->space.next; - geom_to_remove->space.next = 0; - geom_to_remove->spaceid = 0; - return; - } - last = g; - g = g->space.next; - } -} - - -void dxSimpleSpace::collide (void *data, dNearCallback *callback) -{ - dAASSERT (this && callback); - dxGeom *g1,*g2; - int i,j,n; - - // count the number of objects - n=0; - for (g1=first; g1; g1=g1->space.next) n++; - - // allocate and fill bounds array - dReal *bounds = (dReal*) ALLOCA (6 * n * sizeof(dReal)); - i=0; - for (g1=first; g1; g1=g1->space.next) { - g1->_class->aabb (g1,bounds + i); - g1->space_aabb = bounds + i; - i += 6; - } - - // intersect all bounding boxes - i=0; - for (g1=first; g1; g1=g1->space.next) { - j=i+6; - for (g2=g1->space.next; g2; g2=g2->space.next) { - collideAABBs (bounds+i,bounds+j,g1,g2,data,callback); - j += 6; - } - i += 6; - } - - // reset the aabb fields of the geoms back to 0 - for (g1=first; g1; g1=g1->space.next) g1->space_aabb = 0; -} - - -// @@@ NOT FLEXIBLE ENOUGH -// -//int dSpaceCollide (dSpaceID space, dContactGeom **contact_array) -//{ -// int n = 0; -// dContactGeom *base = (dContact*) dStackAlloc (sizeof(dContact)); -// dContactGeom *c = base; -// for (dxGeom *g1=space->first; g1; g1=g1->space.next) { -// for (dxGeom *g2=g1->space.next; g2; g2=g2->space.next) { -// // generate at most 1 contact for this pair -// c->o1 = g1; -// c->o2 = g2; -// if (dCollide (0,c)) { -// c = (dContactGeom*) dStackAlloc (sizeof(dContactGeom)); -// n++; -// } -// } -// } -// *contact_array = base; -// return n; -//} - - -int dxSimpleSpace::query (dGeomID obj) -{ - dAASSERT (this && obj); - if (obj->spaceid != this) return 0; - dGeomID compare = first; - while (compare) { - if (compare == obj) return 1; - compare = compare->space.next; - } - dDebug (0,"object is not in the space it thinks it is in"); - return 0; -} - -//**************************************************************************** -// hash table space - -// kind of silly, but oh well... -#define MAXINT ((int)((((unsigned int)(-1)) << 1) >> 1)) - - -// prime[i] is the largest prime smaller than 2^i -#define NUM_PRIMES 31 -static long int prime[NUM_PRIMES] = {1L,2L,3L,7L,13L,31L,61L,127L,251L,509L, - 1021L,2039L,4093L,8191L,16381L,32749L,65521L,131071L,262139L, - 524287L,1048573L,2097143L,4194301L,8388593L,16777213L,33554393L, - 67108859L,134217689L,268435399L,536870909L,1073741789L}; - - -// currently the space 'container' is just a list of the geoms in the space. - -struct dxHashSpace : public dxSpace { - dxGeom *first; - int global_minlevel; // smallest hash table level to put AABBs in - int global_maxlevel; // objects that need a level larger than this will be - // put in a "big objects" list instead of a hash table - void destroy(); - void add (dGeomID); - void remove (dGeomID); - void collide (void *data, dNearCallback *callback); - int query (dGeomID); -}; - - -// an axis aligned bounding box -struct dxAABB { - dxAABB *next; // next in the list of all AABBs - dReal bounds[6]; // minx, maxx, miny, maxy, minz, maxz - int level; // the level this is stored in (cell size = 2^level) - int dbounds[6]; // AABB bounds, discretized to cell size - dxGeom *geom; // corresponding geometry object - int index; // index of this AABB, starting from 0 -}; - - -// a hash table node that represents an AABB that intersects a particular cell -// at a particular level -struct Node { - Node *next; // next node in hash table collision list, 0 if none - int x,y,z; // cell position in space, discretized to cell size - dxAABB *aabb; // axis aligned bounding box that intersects this cell -}; - - -// return the `level' of an AABB. the AABB will be put into cells at this -// level - the cell size will be 2^level. the level is chosen to be the -// smallest value such that the AABB occupies no more than 8 cells, regardless -// of its placement. this means that: -// size/2 < q <= size -// where q is the maximum AABB dimension. - -static int findLevel (dReal bounds[6]) -{ - // compute q - dReal q,q2; - q = bounds[1] - bounds[0]; // x bounds - q2 = bounds[3] - bounds[2]; // y bounds - if (q2 > q) q = q2; - q2 = bounds[5] - bounds[4]; // z bounds - if (q2 > q) q = q2; - - if (q == dInfinity) return MAXINT; - - // find level such that 0.5 * 2^level < q <= 2^level - int level; - frexp (q,&level); // q = (0.5 .. 1.0) * 2^level (definition of frexp) - return level; -} - - -// find a virtual memory address for a cell at the given level and x,y,z -// position. -// @@@ currently this is not very sophisticated, e.g. the scaling -// factors could be better designed to avoid collisions, and they should -// probably depend on the hash table physical size. - -static unsigned long getVirtualAddress (int level, int x, int y, int z) -{ - return level*1000 + x*100 + y*10 + z; -} - -//**************************************************************************** -// hash space public functions - -dSpaceID dHashSpaceCreate() -{ - dxHashSpace *w = new dxHashSpace; - w->type = TYPE_HASH; - w->first = 0; - w->global_minlevel = -3; - w->global_maxlevel = 10; - return w; -} - - -void dxHashSpace::destroy() -{ - // destroying each geom will call remove(). this will be efficient if - // we destroy geoms in list order. - dAASSERT (this); - dGeomID g,n; - g = first; - while (g) { - n = g->space.next; - dGeomDestroy (g); - g = n; - } - delete this; -} - - -void dHashSpaceSetLevels (dxSpace *space, int minlevel, int maxlevel) -{ - dUASSERT (minlevel <= maxlevel,"must have minlevel <= maxlevel"); - dUASSERT (space->type == TYPE_HASH,"must be a hash space"); - dxHashSpace *hspace = (dxHashSpace*) space; - hspace->global_minlevel = minlevel; - hspace->global_maxlevel = maxlevel; -} - - -void dxHashSpace::add (dGeomID obj) -{ - dAASSERT (this && obj); - dUASSERT (obj->spaceid == 0 && obj->space.next == 0, - "object is already in a space"); - obj->space.next = first; - first = obj; - obj->spaceid = this; -} - - -void dxHashSpace::remove (dGeomID geom_to_remove) -{ - dAASSERT (this && geom_to_remove); - dUASSERT (geom_to_remove->spaceid,"object is not in a space"); - dGeomID last=0,g=first; - while (g) { - if (g==geom_to_remove) { - if (last) last->space.next = g->space.next; - else first = g->space.next; - geom_to_remove->space.next = 0; - geom_to_remove->spaceid = 0; - return; - } - last = g; - g = g->space.next; - } -} - - -void dxHashSpace::collide (void *data, dNearCallback *callback) -{ - dAASSERT(this && callback); - dxGeom *geom; - dxAABB *aabb; - int i,maxlevel; - - // create a list of axis aligned bounding boxes for all geoms. count the - // number of AABBs as we go. set the level for all AABBs. put AABBs larger - // than the space's global_maxlevel in the big_boxes list, check everything - // else against that list at the end. for AABBs that are not too big, - // record the maximum level that we need. - - int n = 0; // number of AABBs in main list - int ntotal = 0; // total number of AABBs - dxAABB *first_aabb = 0; // list of AABBs in hash table - dxAABB *big_boxes = 0; // list of AABBs too big for hash table - maxlevel = global_minlevel - 1; - for (geom = first; geom; geom=geom->space.next) { - ntotal++; - dxAABB *aabb = (dxAABB*) ALLOCA (sizeof(dxAABB)); - geom->_class->aabb (geom,aabb->bounds); - geom->space_aabb = aabb->bounds; - aabb->geom = geom; - // compute level, but prevent cells from getting too small - int level = findLevel (aabb->bounds); - if (level < global_minlevel) level = global_minlevel; - if (level <= global_maxlevel) { - // aabb goes in main list - aabb->next = first_aabb; - first_aabb = aabb; - aabb->level = level; - if (level > maxlevel) maxlevel = level; - // cellsize = 2^level - dReal cellsize = (dReal) ldexp (1.0,level); - // discretize AABB position to cell size - for (i=0; i < 6; i++) aabb->dbounds[i] = (int) - floor (aabb->bounds[i]/cellsize); - // set AABB index - aabb->index = n; - n++; - } - else { - // aabb is too big, put it in the big_boxes list. we don't care about - // setting level, dbounds, index, or the maxlevel - aabb->next = big_boxes; - big_boxes = aabb; - } - } - - // 0 or 1 boxes can't collide with anything - if (ntotal < 2) return; - - // for `n' objects, an n*n array of bits is used to record if those objects - // have been intersection-tested against each other yet. this array can - // grow large with high n, but oh well... - int tested_rowsize = (n+7) >> 3; // number of bytes needed for n bits - unsigned char *tested = (unsigned char *) alloca (n * tested_rowsize); - memset (tested,0,n * tested_rowsize); - - // create a hash table to store all AABBs. each AABB may take up to 8 cells. - // we use chaining to resolve collisions, but we use a relatively large table - // to reduce the chance of collisions. - - // compute hash table size sz to be a prime > 8*n - for (i=0; i<NUM_PRIMES; i++) { - if (prime[i] >= (8*n)) break; - } - if (i >= NUM_PRIMES) i = NUM_PRIMES-1; // probably pointless - int sz = prime[i]; - - // allocate and initialize hash table node pointers - Node **table = (Node **) ALLOCA (sizeof(Node*) * sz); - for (i=0; i<sz; i++) table[i] = 0; - - // add each AABB to the hash table (may need to add it to up to 8 cells) - for (aabb=first_aabb; aabb; aabb=aabb->next) { - int *dbounds = aabb->dbounds; - for (int xi = dbounds[0]; xi <= dbounds[1]; xi++) { - for (int yi = dbounds[2]; yi <= dbounds[3]; yi++) { - for (int zi = dbounds[4]; zi <= dbounds[5]; zi++) { - // get the hash index - unsigned long hi = getVirtualAddress (aabb->level,xi,yi,zi) % sz; - // add a new node to the hash table - Node *node = (Node*) alloca (sizeof (Node)); - node->x = xi; - node->y = yi; - node->z = zi; - node->aabb = aabb; - node->next = table[hi]; - table[hi] = node; - } - } - } - } - - // now that all AABBs are loaded into the hash table, we do the actual - // collision detection. for all AABBs, check for other AABBs in the - // same cells for collisions, and then check for other AABBs in all - // intersecting higher level cells. - - int db[6]; // discrete bounds at current level - for (aabb=first_aabb; aabb; aabb=aabb->next) { - // we are searching for collisions with aabb - for (i=0; i<6; i++) db[i] = aabb->dbounds[i]; - for (int level = aabb->level; level <= maxlevel; level++) { - for (int xi = db[0]; xi <= db[1]; xi++) { - for (int yi = db[2]; yi <= db[3]; yi++) { - for (int zi = db[4]; zi <= db[5]; zi++) { - // get the hash index - unsigned long hi = getVirtualAddress (level,xi,yi,zi) % sz; - // search all nodes at this index - Node *node; - for (node = table[hi]; node; node=node->next) { - // node points to an AABB that may intersect aabb - if (node->aabb == aabb) continue; - if (node->aabb->level == level && - node->x == xi && node->y == yi && node->z == zi) { - // see if aabb and node->aabb have already been tested - // against each other - unsigned char mask; - if (aabb->index <= node->aabb->index) { - i = (aabb->index * tested_rowsize)+(node->aabb->index >> 3); - mask = 1 << (node->aabb->index & 7); - } - else { - i = (node->aabb->index * tested_rowsize)+(aabb->index >> 3); - mask = 1 << (aabb->index & 7); - } - dIASSERT (i >= 0 && i < (tested_rowsize*n)); - if ((tested[i] & mask)==0) { - collideAABBs (aabb->bounds,node->aabb->bounds, - aabb->geom,node->aabb->geom, - data,callback); - } - tested[i] |= mask; - } - } - } - } - } - // get the discrete bounds for the next level up - for (i=0; i<6; i++) db[i] >>= 1; - } - } - - // every AABB in the normal list must now be intersected against every - // AABB in the big_boxes list. so let's hope there are not too many objects - // in the big_boxes list. - for (aabb=first_aabb; aabb; aabb=aabb->next) { - for (dxAABB *aabb2=big_boxes; aabb2; aabb2=aabb2->next) { - collideAABBs (aabb->bounds,aabb2->bounds,aabb->geom,aabb2->geom, - data,callback); - } - } - - // intersected all AABBs in the big_boxes list together - for (aabb=big_boxes; aabb; aabb=aabb->next) { - for (dxAABB *aabb2=aabb->next; aabb2; aabb2=aabb2->next) { - collideAABBs (aabb->bounds,aabb2->bounds,aabb->geom,aabb2->geom, - data,callback); - } - } - - // reset the aabb fields of the geoms back to 0 - for (geom=first; geom; geom=geom->space.next) geom->space_aabb = 0; -} - - -int dxHashSpace::query (dGeomID obj) -{ - dAASSERT (this && obj); - if (obj->spaceid != this) return 0; - dGeomID compare = first; - while (compare) { - if (compare == obj) return 1; - compare = compare->space.next; - } - dDebug (0,"object is not in the space it thinks it is in"); - return 0; -} - -//**************************************************************************** -// space functions - -void dSpaceDestroy (dxSpace * space) -{ - space->destroy(); -} - - -void dSpaceAdd (dxSpace * space, dxGeom *g) -{ - space->add (g); -} - - -void dSpaceRemove (dxSpace * space, dxGeom *g) -{ - space->remove (g); -} - - -int dSpaceQuery (dxSpace * space, dxGeom *g) -{ - return space->query (g); -} - - -void dSpaceCollide (dxSpace * space, void *data, dNearCallback *callback) -{ - space->collide (data,callback); -} diff --git a/extern/ode/dist/ode/src/stack.cpp b/extern/ode/dist/ode/src/stack.cpp deleted file mode 100644 index e062f92b54f..00000000000 --- a/extern/ode/dist/ode/src/stack.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -@@@ this file should not be compiled any more @@@ - -#include <string.h> -#include <errno.h> -#include "stack.h" -#include "ode/error.h" -#include "ode/config.h" - -//**************************************************************************** -// unix version that uses mmap(). some systems have anonymous mmaps and some -// need to mmap /dev/zero. - -#ifndef WIN32 - -#include <unistd.h> -#include <sys/mman.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - - -void dStack::init (int max_size) -{ - if (sizeof(long int) != sizeof(char*)) dDebug (0,"internal"); - if (max_size <= 0) dDebug (0,"Stack::init() given size <= 0"); - -#ifndef MMAP_ANONYMOUS - static int dev_zero_fd = -1; // cached file descriptor for /dev/zero - if (dev_zero_fd < 0) dev_zero_fd = open ("/dev/zero", O_RDWR); - if (dev_zero_fd < 0) dError (0,"can't open /dev/zero (%s)",strerror(errno)); - base = (char*) mmap (0,max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, - dev_zero_fd,0); -#else - base = (char*) mmap (0,max_size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON,0,0); -#endif - - if (int(base) == -1) dError (0,"Stack::init(), mmap() failed, " - "max_size=%d (%s)",max_size,strerror(errno)); - size = max_size; - pointer = base; - frame = 0; -} - - -void dStack::destroy() -{ - munmap (base,size); - base = 0; - size = 0; - pointer = 0; - frame = 0; -} - -#endif - -//**************************************************************************** - -#ifdef WIN32 - -#include "windows.h" - - -void dStack::init (int max_size) -{ - if (sizeof(LPVOID) != sizeof(char*)) dDebug (0,"internal"); - if (max_size <= 0) dDebug (0,"Stack::init() given size <= 0"); - base = (char*) VirtualAlloc (NULL,max_size,MEM_RESERVE,PAGE_READWRITE); - if (base == 0) dError (0,"Stack::init(), VirtualAlloc() failed, " - "max_size=%d",max_size); - size = max_size; - pointer = base; - frame = 0; - committed = 0; - - // get page size - SYSTEM_INFO info; - GetSystemInfo (&info); - pagesize = info.dwPageSize; -} - - -void dStack::destroy() -{ - VirtualFree (base,0,MEM_RELEASE); - base = 0; - size = 0; - pointer = 0; - frame = 0; -} - -#endif diff --git a/extern/ode/dist/ode/src/stack.h b/extern/ode/dist/ode/src/stack.h deleted file mode 100644 index 3b98202b042..00000000000 --- a/extern/ode/dist/ode/src/stack.h +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* this comes from the `reuse' library. copy any changes back to the source. - -these stack allocation functions are a replacement for alloca(), except that -they allocate memory from a separate pool. - -advantages over alloca(): - - consecutive allocations are guaranteed to be contiguous with increasing - address. - - functions can allocate stack memory that is returned to the caller, - in other words pushing and popping stack frames is optional. - -disadvantages compared to alloca(): - - less portable - - slightly slower, although still orders of magnitude faster than malloc(). - - longjmp() and exceptions do not deallocate stack memory (but who cares?). - -just like alloca(): - - using too much stack memory does not fail gracefully, it fails with a - segfault. - -*/ - - -#ifndef _ODE_STACK_H_ -#define _ODE_STACK_H_ - - -#ifdef WIN32 -#include "windows.h" -#endif - - -struct dStack { - char *base; // bottom of the stack - int size; // maximum size of the stack - char *pointer; // current top of the stack - char *frame; // linked list of stack frame ptrs -# ifdef WIN32 // stuff for windows: - int pagesize; // - page size - this is ASSUMED to be a power of 2 - int committed; // - bytes committed in allocated region -#endif - - // initialize the stack. `max_size' is the maximum size that the stack can - // reach. on unix and windows a `virtual' memory block of this size is - // mapped into the address space but does not actually consume physical - // memory until it is referenced - so it is safe to set this to a high value. - - void init (int max_size); - - - // destroy the stack. this unmaps any virtual memory that was allocated. - - void destroy(); - - - // allocate `size' bytes from the stack and return a pointer to the allocated - // memory. `size' must be >= 0. the returned pointer will be aligned to the - // size of a long int. - - char * alloc (int size) - { - char *ret = pointer; - pointer += ((size-1) | (sizeof(long int)-1) )+1; -# ifdef WIN32 - // for windows we need to commit pages as they are required - if ((pointer-base) > committed) { - committed = ((pointer-base-1) | (pagesize-1))+1; // round up to pgsize - VirtualAlloc (base,committed,MEM_COMMIT,PAGE_READWRITE); - } -# endif - return ret; - } - - - // return the address that will be returned by the next call to alloc() - - char *nextAlloc() - { - return pointer; - } - - - // push and pop the current size of the stack. pushFrame() saves the current - // frame pointer on the stack, and popFrame() retrieves it. a typical - // stack-using function will bracket alloc() calls with pushFrame() and - // popFrame(). both functions return the current stack pointer - this should - // be the same value for the two bracketing calls. calling popFrame() too - // many times will result in a segfault. - - char * pushFrame() - { - char *newframe = pointer; - char **addr = (char**) alloc (sizeof(char*)); - *addr = frame; - frame = newframe; - return newframe; - - /* OLD CODE - *((char**)pointer) = frame; - frame = pointer; - char *ret = pointer; - pointer += sizeof(char*); - return ret; - */ - } - - char * popFrame() - { - pointer = frame; - frame = *((char**)pointer); - return pointer; - } -}; - - -#endif - diff --git a/extern/ode/dist/ode/src/step.cpp b/extern/ode/dist/ode/src/step.cpp deleted file mode 100644 index 16f77112ad2..00000000000 --- a/extern/ode/dist/ode/src/step.cpp +++ /dev/null @@ -1,1085 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include "objects.h" -#include "joint.h" -#include <ode/config.h> -#include <ode/odemath.h> -#include <ode/rotation.h> -#include <ode/timer.h> -#include <ode/error.h> -#include <ode/matrix.h> -#include "lcp.h" - -//**************************************************************************** -// misc defines - -#define FAST_FACTOR -//#define TIMING - -#define ALLOCA dALLOCA16 - -//**************************************************************************** -// debugging - comparison of various vectors and matrices produced by the -// slow and fast versions of the stepper. - -//#define COMPARE_METHODS - -#ifdef COMPARE_METHODS -#include "testing.h" -dMatrixComparison comparator; -#endif - -//**************************************************************************** -// special matrix multipliers - -// this assumes the 4th and 8th rows of B and C are zero. - -static void Multiply2_p8r (dReal *A, dReal *B, dReal *C, - int p, int r, int Askip) -{ - int i,j; - dReal sum,*bb,*cc; - dIASSERT (p>0 && r>0 && A && B && C); - bb = B; - for (i=p; i; i--) { - cc = C; - for (j=r; j; j--) { - sum = bb[0]*cc[0]; - sum += bb[1]*cc[1]; - sum += bb[2]*cc[2]; - sum += bb[4]*cc[4]; - sum += bb[5]*cc[5]; - sum += bb[6]*cc[6]; - *(A++) = sum; - cc += 8; - } - A += Askip - r; - bb += 8; - } -} - - -// this assumes the 4th and 8th rows of B and C are zero. - -static void MultiplyAdd2_p8r (dReal *A, dReal *B, dReal *C, - int p, int r, int Askip) -{ - int i,j; - dReal sum,*bb,*cc; - dIASSERT (p>0 && r>0 && A && B && C); - bb = B; - for (i=p; i; i--) { - cc = C; - for (j=r; j; j--) { - sum = bb[0]*cc[0]; - sum += bb[1]*cc[1]; - sum += bb[2]*cc[2]; - sum += bb[4]*cc[4]; - sum += bb[5]*cc[5]; - sum += bb[6]*cc[6]; - *(A++) += sum; - cc += 8; - } - A += Askip - r; - bb += 8; - } -} - - -// this assumes the 4th and 8th rows of B are zero. - -static void Multiply0_p81 (dReal *A, dReal *B, dReal *C, int p) -{ - int i; - dIASSERT (p>0 && A && B && C); - dReal sum; - for (i=p; i; i--) { - sum = B[0]*C[0]; - sum += B[1]*C[1]; - sum += B[2]*C[2]; - sum += B[4]*C[4]; - sum += B[5]*C[5]; - sum += B[6]*C[6]; - *(A++) = sum; - B += 8; - } -} - - -// this assumes the 4th and 8th rows of B are zero. - -static void MultiplyAdd0_p81 (dReal *A, dReal *B, dReal *C, int p) -{ - int i; - dIASSERT (p>0 && A && B && C); - dReal sum; - for (i=p; i; i--) { - sum = B[0]*C[0]; - sum += B[1]*C[1]; - sum += B[2]*C[2]; - sum += B[4]*C[4]; - sum += B[5]*C[5]; - sum += B[6]*C[6]; - *(A++) += sum; - B += 8; - } -} - - -// this assumes the 4th and 8th rows of B are zero. - -static void MultiplyAdd1_8q1 (dReal *A, dReal *B, dReal *C, int q) -{ - int k; - dReal sum; - dIASSERT (q>0 && A && B && C); - sum = 0; - for (k=0; k<q; k++) sum += B[k*8] * C[k]; - A[0] += sum; - sum = 0; - for (k=0; k<q; k++) sum += B[1+k*8] * C[k]; - A[1] += sum; - sum = 0; - for (k=0; k<q; k++) sum += B[2+k*8] * C[k]; - A[2] += sum; - sum = 0; - for (k=0; k<q; k++) sum += B[4+k*8] * C[k]; - A[4] += sum; - sum = 0; - for (k=0; k<q; k++) sum += B[5+k*8] * C[k]; - A[5] += sum; - sum = 0; - for (k=0; k<q; k++) sum += B[6+k*8] * C[k]; - A[6] += sum; -} - - -// this assumes the 4th and 8th rows of B are zero. - -static void Multiply1_8q1 (dReal *A, dReal *B, dReal *C, int q) -{ - int k; - dReal sum; - dIASSERT (q>0 && A && B && C); - sum = 0; - for (k=0; k<q; k++) sum += B[k*8] * C[k]; - A[0] = sum; - sum = 0; - for (k=0; k<q; k++) sum += B[1+k*8] * C[k]; - A[1] = sum; - sum = 0; - for (k=0; k<q; k++) sum += B[2+k*8] * C[k]; - A[2] = sum; - sum = 0; - for (k=0; k<q; k++) sum += B[4+k*8] * C[k]; - A[4] = sum; - sum = 0; - for (k=0; k<q; k++) sum += B[5+k*8] * C[k]; - A[5] = sum; - sum = 0; - for (k=0; k<q; k++) sum += B[6+k*8] * C[k]; - A[6] = sum; -} - -//**************************************************************************** -// body rotation - -// return sin(x)/x. this has a singularity at 0 so special handling is needed -// for small arguments. - -static inline dReal sinc (dReal x) -{ - // if |x| < 1e-4 then use a taylor series expansion. this two term expansion - // is actually accurate to one LS bit within this range if double precision - // is being used - so don't worry! - if (dFabs(x) < 1.0e-4) return REAL(1.0) - x*x*REAL(0.166666666666666666667); - else return dSin(x)/x; -} - - -// given a body b, apply its linear and angular rotation over the time -// interval h, thereby adjusting its position and orientation. - -static inline void moveAndRotateBody (dxBody *b, dReal h) -{ - int j; - - // handle linear velocity - for (j=0; j<3; j++) b->pos[j] += h * b->lvel[j]; - - if (b->flags & dxBodyFlagFiniteRotation) { - dVector3 irv; // infitesimal rotation vector - dQuaternion q; // quaternion for finite rotation - - if (b->flags & dxBodyFlagFiniteRotationAxis) { - // split the angular velocity vector into a component along the finite - // rotation axis, and a component orthogonal to it. - dVector3 frv,irv; // finite rotation vector - dReal k = dDOT (b->finite_rot_axis,b->avel); - frv[0] = b->finite_rot_axis[0] * k; - frv[1] = b->finite_rot_axis[1] * k; - frv[2] = b->finite_rot_axis[2] * k; - irv[0] = b->avel[0] - frv[0]; - irv[1] = b->avel[1] - frv[1]; - irv[2] = b->avel[2] - frv[2]; - - // make a rotation quaternion q that corresponds to frv * h. - // compare this with the full-finite-rotation case below. - h *= REAL(0.5); - dReal theta = k * h; - q[0] = dCos(theta); - dReal s = sinc(theta) * h; - q[1] = frv[0] * s; - q[2] = frv[1] * s; - q[3] = frv[2] * s; - } - else { - // make a rotation quaternion q that corresponds to w * h - dReal wlen = dSqrt (b->avel[0]*b->avel[0] + b->avel[1]*b->avel[1] + - b->avel[2]*b->avel[2]); - h *= REAL(0.5); - dReal theta = wlen * h; - q[0] = dCos(theta); - dReal s = sinc(theta) * h; - q[1] = b->avel[0] * s; - q[2] = b->avel[1] * s; - q[3] = b->avel[2] * s; - } - - // do the finite rotation - dQuaternion q2; - dQMultiply0 (q2,q,b->q); - for (j=0; j<4; j++) b->q[j] = q2[j]; - - // do the infitesimal rotation if required - if (b->flags & dxBodyFlagFiniteRotationAxis) { - dReal dq[4]; - dWtoDQ (irv,b->q,dq); - for (j=0; j<4; j++) b->q[j] += h * dq[j]; - } - } - else { - // the normal way - do an infitesimal rotation - dReal dq[4]; - dWtoDQ (b->avel,b->q,dq); - for (j=0; j<4; j++) b->q[j] += h * dq[j]; - } - - // normalize the quaternion and convert it to a rotation matrix - dNormalize4 (b->q); - dQtoR (b->q,b->R); -} - -//**************************************************************************** -// the slow, but sure way -// note that this does not do any joint feedback! - -// given lists of bodies and joints that form an island, perform a first -// order timestep. -// -// `body' is the body array, `nb' is the size of the array. -// `_joint' is the body array, `nj' is the size of the array. - -void dInternalStepIsland_x1 (dxWorld *world, dxBody * const *body, int nb, - dxJoint * const *_joint, int nj, dReal stepsize) -{ - int i,j,k; - int n6 = 6*nb; - -# ifdef TIMING - dTimerStart("preprocessing"); -# endif - - // number all bodies in the body list - set their tag values - for (i=0; i<nb; i++) body[i]->tag = i; - - // make a local copy of the joint array, because we might want to modify it. - // (the "dxJoint *const*" declaration says we're allowed to modify the joints - // but not the joint array, because the caller might need it unchanged). - dxJoint **joint = (dxJoint**) ALLOCA (nj * sizeof(dxJoint*)); - memcpy (joint,_joint,nj * sizeof(dxJoint*)); - - // for all bodies, compute the inertia tensor and its inverse in the global - // frame, and compute the rotational force and add it to the torque - // accumulator. - // @@@ check computation of rotational force. - dReal *I = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal)); - dReal *invI = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal)); - dSetZero (I,3*nb*4); - dSetZero (invI,3*nb*4); - for (i=0; i<nb; i++) { - dReal tmp[12]; - // compute inertia tensor in global frame - dMULTIPLY2_333 (tmp,body[i]->mass.I,body[i]->R); - dMULTIPLY0_333 (I+i*12,body[i]->R,tmp); - // compute inverse inertia tensor in global frame - dMULTIPLY2_333 (tmp,body[i]->invI,body[i]->R); - dMULTIPLY0_333 (invI+i*12,body[i]->R,tmp); - // compute rotational force - dMULTIPLY0_331 (tmp,I+i*12,body[i]->avel); - dCROSS (body[i]->tacc,-=,body[i]->avel,tmp); - } - - // add the gravity force to all bodies - for (i=0; i<nb; i++) { - if ((body[i]->flags & dxBodyNoGravity)==0) { - body[i]->facc[0] += body[i]->mass.mass * world->gravity[0]; - body[i]->facc[1] += body[i]->mass.mass * world->gravity[1]; - body[i]->facc[2] += body[i]->mass.mass * world->gravity[2]; - } - } - - // get m = total constraint dimension, nub = number of unbounded variables. - // create constraint offset array and number-of-rows array for all joints. - // the constraints are re-ordered as follows: the purely unbounded - // constraints, the mixed unbounded + LCP constraints, and last the purely - // LCP constraints. - // - // joints with m=0 are inactive and are removed from the joints array - // entirely, so that the code that follows does not consider them. - int m = 0; - dxJoint::Info1 *info = (dxJoint::Info1*) ALLOCA (nj*sizeof(dxJoint::Info1)); - int *ofs = (int*) ALLOCA (nj*sizeof(int)); - for (i=0, j=0; j<nj; j++) { // i=dest, j=src - joint[j]->vtable->getInfo1 (joint[j],info+i); - dIASSERT (info[i].m >= 0 && info[i].m <= 6 && - info[i].nub >= 0 && info[i].nub <= info[i].m); - if (info[i].m > 0) { - joint[i] = joint[j]; - i++; - } - } - nj = i; - - // the purely unbounded constraints - for (i=0; i<nj; i++) if (info[i].nub == info[i].m) { - ofs[i] = m; - m += info[i].m; - } - int nub = m; - // the mixed unbounded + LCP constraints - for (i=0; i<nj; i++) if (info[i].nub > 0 && info[i].nub < info[i].m) { - ofs[i] = m; - m += info[i].m; - } - // the purely LCP constraints - for (i=0; i<nj; i++) if (info[i].nub == 0) { - ofs[i] = m; - m += info[i].m; - } - - // create (6*nb,6*nb) inverse mass matrix `invM', and fill it with mass - // parameters -# ifdef TIMING - dTimerNow ("create mass matrix"); -# endif - int nskip = dPAD (n6); - dReal *invM = (dReal*) ALLOCA (n6*nskip*sizeof(dReal)); - dSetZero (invM,n6*nskip); - for (i=0; i<nb; i++) { - dReal *MM = invM+(i*6)*nskip+(i*6); - MM[0] = body[i]->invMass; - MM[nskip+1] = body[i]->invMass; - MM[2*nskip+2] = body[i]->invMass; - MM += 3*nskip+3; - for (j=0; j<3; j++) for (k=0; k<3; k++) { - MM[j*nskip+k] = invI[i*12+j*4+k]; - } - } - - // assemble some body vectors: fe = external forces, v = velocities - dReal *fe = (dReal*) ALLOCA (n6 * sizeof(dReal)); - dReal *v = (dReal*) ALLOCA (n6 * sizeof(dReal)); - dSetZero (fe,n6); - dSetZero (v,n6); - for (i=0; i<nb; i++) { - for (j=0; j<3; j++) fe[i*6+j] = body[i]->facc[j]; - for (j=0; j<3; j++) fe[i*6+3+j] = body[i]->tacc[j]; - for (j=0; j<3; j++) v[i*6+j] = body[i]->lvel[j]; - for (j=0; j<3; j++) v[i*6+3+j] = body[i]->avel[j]; - } - - // this will be set to the velocity update - dReal *vnew = (dReal*) ALLOCA (n6 * sizeof(dReal)); - dSetZero (vnew,n6); - - // if there are constraints, compute cforce - if (m > 0) { - // create a constraint equation right hand side vector `c', a constraint - // force mixing vector `cfm', and LCP low and high bound vectors, and an - // 'findex' vector. - dReal *c = (dReal*) ALLOCA (m*sizeof(dReal)); - dReal *cfm = (dReal*) ALLOCA (m*sizeof(dReal)); - dReal *lo = (dReal*) ALLOCA (m*sizeof(dReal)); - dReal *hi = (dReal*) ALLOCA (m*sizeof(dReal)); - int *findex = (int*) alloca (m*sizeof(int)); - dSetZero (c,m); - dSetValue (cfm,m,world->global_cfm); - dSetValue (lo,m,-dInfinity); - dSetValue (hi,m, dInfinity); - for (i=0; i<m; i++) findex[i] = -1; - - // create (m,6*nb) jacobian mass matrix `J', and fill it with constraint - // data. also fill the c vector. -# ifdef TIMING - dTimerNow ("create J"); -# endif - dReal *J = (dReal*) ALLOCA (m*nskip*sizeof(dReal)); - dSetZero (J,m*nskip); - dxJoint::Info2 Jinfo; - Jinfo.rowskip = nskip; - Jinfo.fps = dRecip(stepsize); - Jinfo.erp = world->global_erp; - for (i=0; i<nj; i++) { - Jinfo.J1l = J + nskip*ofs[i] + 6*joint[i]->node[0].body->tag; - Jinfo.J1a = Jinfo.J1l + 3; - if (joint[i]->node[1].body) { - Jinfo.J2l = J + nskip*ofs[i] + 6*joint[i]->node[1].body->tag; - Jinfo.J2a = Jinfo.J2l + 3; - } - else { - Jinfo.J2l = 0; - Jinfo.J2a = 0; - } - Jinfo.c = c + ofs[i]; - Jinfo.cfm = cfm + ofs[i]; - Jinfo.lo = lo + ofs[i]; - Jinfo.hi = hi + ofs[i]; - Jinfo.findex = findex + ofs[i]; - joint[i]->vtable->getInfo2 (joint[i],&Jinfo); - // adjust returned findex values for global index numbering - for (j=0; j<info[i].m; j++) { - if (findex[ofs[i] + j] >= 0) findex[ofs[i] + j] += ofs[i]; - } - } - - // compute A = J*invM*J' -# ifdef TIMING - dTimerNow ("compute A"); -# endif - dReal *JinvM = (dReal*) ALLOCA (m*nskip*sizeof(dReal)); - dSetZero (JinvM,m*nskip); - dMultiply0 (JinvM,J,invM,m,n6,n6); - int mskip = dPAD(m); - dReal *A = (dReal*) ALLOCA (m*mskip*sizeof(dReal)); - dSetZero (A,m*mskip); - dMultiply2 (A,JinvM,J,m,n6,m); - - // add cfm to the diagonal of A - for (i=0; i<m; i++) A[i*mskip+i] += cfm[i] * Jinfo.fps; - -# ifdef COMPARE_METHODS - comparator.nextMatrix (A,m,m,1,"A"); -# endif - - // compute `rhs', the right hand side of the equation J*a=c -# ifdef TIMING - dTimerNow ("compute rhs"); -# endif - dReal *tmp1 = (dReal*) ALLOCA (n6 * sizeof(dReal)); - dSetZero (tmp1,n6); - dMultiply0 (tmp1,invM,fe,n6,n6,1); - for (i=0; i<n6; i++) tmp1[i] += v[i]/stepsize; - dReal *rhs = (dReal*) ALLOCA (m * sizeof(dReal)); - dSetZero (rhs,m); - dMultiply0 (rhs,J,tmp1,m,n6,1); - for (i=0; i<m; i++) rhs[i] = c[i]/stepsize - rhs[i]; - -# ifdef COMPARE_METHODS - comparator.nextMatrix (c,m,1,0,"c"); - comparator.nextMatrix (rhs,m,1,0,"rhs"); -# endif - - // solve the LCP problem and get lambda. - // this will destroy A but that's okay -# ifdef TIMING - dTimerNow ("solving LCP problem"); -# endif - dReal *lambda = (dReal*) ALLOCA (m * sizeof(dReal)); - dReal *residual = (dReal*) ALLOCA (m * sizeof(dReal)); - dSolveLCP (m,A,lambda,rhs,residual,nub,lo,hi,findex); - -// OLD WAY - direct factor and solve -// -// // factorize A (L*L'=A) -//# ifdef TIMING -// dTimerNow ("factorize A"); -//# endif -// dReal *L = (dReal*) ALLOCA (m*mskip*sizeof(dReal)); -// memcpy (L,A,m*mskip*sizeof(dReal)); -// if (dFactorCholesky (L,m)==0) dDebug (0,"A is not positive definite"); -// -// // compute lambda -//# ifdef TIMING -// dTimerNow ("compute lambda"); -//# endif -// dReal *lambda = (dReal*) ALLOCA (m * sizeof(dReal)); -// memcpy (lambda,rhs,m * sizeof(dReal)); -// dSolveCholesky (L,lambda,m); - -# ifdef COMPARE_METHODS - comparator.nextMatrix (lambda,m,1,0,"lambda"); -# endif - - // compute the velocity update `vnew' -# ifdef TIMING - dTimerNow ("compute velocity update"); -# endif - dMultiply1 (tmp1,J,lambda,n6,m,1); - for (i=0; i<n6; i++) tmp1[i] += fe[i]; - dMultiply0 (vnew,invM,tmp1,n6,n6,1); - for (i=0; i<n6; i++) vnew[i] = v[i] + stepsize*vnew[i]; - - // see if the constraint has worked: compute J*vnew and make sure it equals - // `c' (to within a certain tolerance). -# ifdef TIMING - dTimerNow ("verify constraint equation"); -# endif - dMultiply0 (tmp1,J,vnew,m,n6,1); - dReal err = 0; - for (i=0; i<m; i++) err += dFabs(tmp1[i]-c[i]); - printf ("%.6e\n",err); - } - else { - // no constraints - dMultiply0 (vnew,invM,fe,n6,n6,1); - for (i=0; i<n6; i++) vnew[i] = v[i] + stepsize*vnew[i]; - } - -# ifdef COMPARE_METHODS - comparator.nextMatrix (vnew,n6,1,0,"vnew"); -# endif - - // apply the velocity update to the bodies -# ifdef TIMING - dTimerNow ("update velocity"); -# endif - for (i=0; i<nb; i++) { - for (j=0; j<3; j++) body[i]->lvel[j] = vnew[i*6+j]; - for (j=0; j<3; j++) body[i]->avel[j] = vnew[i*6+3+j]; - } - - // update the position and orientation from the new linear/angular velocity - // (over the given timestep) -# ifdef TIMING - dTimerNow ("update position"); -# endif - for (i=0; i<nb; i++) moveAndRotateBody (body[i],stepsize); - -# ifdef TIMING - dTimerNow ("tidy up"); -# endif - - // zero all force accumulators - for (i=0; i<nb; i++) { - body[i]->facc[0] = 0; - body[i]->facc[1] = 0; - body[i]->facc[2] = 0; - body[i]->facc[3] = 0; - body[i]->tacc[0] = 0; - body[i]->tacc[1] = 0; - body[i]->tacc[2] = 0; - body[i]->tacc[3] = 0; - } - -# ifdef TIMING - dTimerEnd(); - if (m > 0) dTimerReport (stdout,1); -# endif -} - -//**************************************************************************** -// an optimized version of dInternalStepIsland1() - -void dInternalStepIsland_x2 (dxWorld *world, dxBody * const *body, int nb, - dxJoint * const *_joint, int nj, dReal stepsize) -{ - int i,j,k; -# ifdef TIMING - dTimerStart("preprocessing"); -# endif - - dReal stepsize1 = dRecip(stepsize); - - // number all bodies in the body list - set their tag values - for (i=0; i<nb; i++) body[i]->tag = i; - - // make a local copy of the joint array, because we might want to modify it. - // (the "dxJoint *const*" declaration says we're allowed to modify the joints - // but not the joint array, because the caller might need it unchanged). - dxJoint **joint = (dxJoint**) ALLOCA (nj * sizeof(dxJoint*)); - memcpy (joint,_joint,nj * sizeof(dxJoint*)); - - // for all bodies, compute the inertia tensor and its inverse in the global - // frame, and compute the rotational force and add it to the torque - // accumulator. I and invI are vertically stacked 3x4 matrices, one per body. - // @@@ check computation of rotational force. - dReal *I = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal)); - dReal *invI = (dReal*) ALLOCA (3*nb*4 * sizeof(dReal)); - dSetZero (I,3*nb*4); - dSetZero (invI,3*nb*4); - for (i=0; i<nb; i++) { - dReal tmp[12]; - // compute inertia tensor in global frame - dMULTIPLY2_333 (tmp,body[i]->mass.I,body[i]->R); - dMULTIPLY0_333 (I+i*12,body[i]->R,tmp); - // compute inverse inertia tensor in global frame - dMULTIPLY2_333 (tmp,body[i]->invI,body[i]->R); - dMULTIPLY0_333 (invI+i*12,body[i]->R,tmp); - // compute rotational force - dMULTIPLY0_331 (tmp,I+i*12,body[i]->avel); - dCROSS (body[i]->tacc,-=,body[i]->avel,tmp); - } - - // add the gravity force to all bodies - for (i=0; i<nb; i++) { - if ((body[i]->flags & dxBodyNoGravity)==0) { - body[i]->facc[0] += body[i]->mass.mass * world->gravity[0]; - body[i]->facc[1] += body[i]->mass.mass * world->gravity[1]; - body[i]->facc[2] += body[i]->mass.mass * world->gravity[2]; - } - } - - // get m = total constraint dimension, nub = number of unbounded variables. - // create constraint offset array and number-of-rows array for all joints. - // the constraints are re-ordered as follows: the purely unbounded - // constraints, the mixed unbounded + LCP constraints, and last the purely - // LCP constraints. this assists the LCP solver to put all unbounded - // variables at the start for a quick factorization. - // - // joints with m=0 are inactive and are removed from the joints array - // entirely, so that the code that follows does not consider them. - // also number all active joints in the joint list (set their tag values). - // inactive joints receive a tag value of -1. - - int m = 0; - dxJoint::Info1 *info = (dxJoint::Info1*) ALLOCA (nj*sizeof(dxJoint::Info1)); - int *ofs = (int*) ALLOCA (nj*sizeof(int)); - for (i=0, j=0; j<nj; j++) { // i=dest, j=src - joint[j]->vtable->getInfo1 (joint[j],info+i); - dIASSERT (info[i].m >= 0 && info[i].m <= 6 && - info[i].nub >= 0 && info[i].nub <= info[i].m); - if (info[i].m > 0) { - joint[i] = joint[j]; - joint[i]->tag = i; - i++; - } - else { - joint[j]->tag = -1; - } - } - nj = i; - - // the purely unbounded constraints - for (i=0; i<nj; i++) if (info[i].nub == info[i].m) { - ofs[i] = m; - m += info[i].m; - } - int nub = m; - // the mixed unbounded + LCP constraints - for (i=0; i<nj; i++) if (info[i].nub > 0 && info[i].nub < info[i].m) { - ofs[i] = m; - m += info[i].m; - } - // the purely LCP constraints - for (i=0; i<nj; i++) if (info[i].nub == 0) { - ofs[i] = m; - m += info[i].m; - } - - // this will be set to the force due to the constraints - dReal *cforce = (dReal*) ALLOCA (nb*8 * sizeof(dReal)); - dSetZero (cforce,nb*8); - - // if there are constraints, compute cforce - if (m > 0) { - // create a constraint equation right hand side vector `c', a constraint - // force mixing vector `cfm', and LCP low and high bound vectors, and an - // 'findex' vector. - dReal *c = (dReal*) ALLOCA (m*sizeof(dReal)); - dReal *cfm = (dReal*) ALLOCA (m*sizeof(dReal)); - dReal *lo = (dReal*) ALLOCA (m*sizeof(dReal)); - dReal *hi = (dReal*) ALLOCA (m*sizeof(dReal)); - int *findex = (int*) alloca (m*sizeof(int)); - dSetZero (c,m); - dSetValue (cfm,m,world->global_cfm); - dSetValue (lo,m,-dInfinity); - dSetValue (hi,m, dInfinity); - for (i=0; i<m; i++) findex[i] = -1; - - // get jacobian data from constraints. a (2*m)x8 matrix will be created - // to store the two jacobian blocks from each constraint. it has this - // format: - // - // l l l 0 a a a 0 \ - // l l l 0 a a a 0 }-- jacobian body 1 block for joint 0 (3 rows) - // l l l 0 a a a 0 / - // l l l 0 a a a 0 \ - // l l l 0 a a a 0 }-- jacobian body 2 block for joint 0 (3 rows) - // l l l 0 a a a 0 / - // l l l 0 a a a 0 }--- jacobian body 1 block for joint 1 (1 row) - // l l l 0 a a a 0 }--- jacobian body 2 block for joint 1 (1 row) - // etc... - // - // (lll) = linear jacobian data - // (aaa) = angular jacobian data - // -# ifdef TIMING - dTimerNow ("create J"); -# endif - dReal *J = (dReal*) ALLOCA (2*m*8*sizeof(dReal)); - dSetZero (J,2*m*8); - dxJoint::Info2 Jinfo; - Jinfo.rowskip = 8; - Jinfo.fps = stepsize1; - Jinfo.erp = world->global_erp; - for (i=0; i<nj; i++) { - Jinfo.J1l = J + 2*8*ofs[i]; - Jinfo.J1a = Jinfo.J1l + 4; - Jinfo.J2l = Jinfo.J1l + 8*info[i].m; - Jinfo.J2a = Jinfo.J2l + 4; - Jinfo.c = c + ofs[i]; - Jinfo.cfm = cfm + ofs[i]; - Jinfo.lo = lo + ofs[i]; - Jinfo.hi = hi + ofs[i]; - Jinfo.findex = findex + ofs[i]; - joint[i]->vtable->getInfo2 (joint[i],&Jinfo); - // adjust returned findex values for global index numbering - for (j=0; j<info[i].m; j++) { - if (findex[ofs[i] + j] >= 0) findex[ofs[i] + j] += ofs[i]; - } - } - - // compute A = J*invM*J'. first compute JinvM = J*invM. this has the same - // format as J so we just go through the constraints in J multiplying by - // the appropriate scalars and matrices. -# ifdef TIMING - dTimerNow ("compute A"); -# endif - dReal *JinvM = (dReal*) ALLOCA (2*m*8*sizeof(dReal)); - dSetZero (JinvM,2*m*8); - for (i=0; i<nj; i++) { - int b = joint[i]->node[0].body->tag; - dReal body_invMass = body[b]->invMass; - dReal *body_invI = invI + b*12; - dReal *Jsrc = J + 2*8*ofs[i]; - dReal *Jdst = JinvM + 2*8*ofs[i]; - for (j=info[i].m-1; j>=0; j--) { - for (k=0; k<3; k++) Jdst[k] = Jsrc[k] * body_invMass; - dMULTIPLY0_133 (Jdst+4,Jsrc+4,body_invI); - Jsrc += 8; - Jdst += 8; - } - if (joint[i]->node[1].body) { - b = joint[i]->node[1].body->tag; - body_invMass = body[b]->invMass; - body_invI = invI + b*12; - for (j=info[i].m-1; j>=0; j--) { - for (k=0; k<3; k++) Jdst[k] = Jsrc[k] * body_invMass; - dMULTIPLY0_133 (Jdst+4,Jsrc+4,body_invI); - Jsrc += 8; - Jdst += 8; - } - } - } - - // now compute A = JinvM * J'. A's rows and columns are grouped by joint, - // i.e. in the same way as the rows of J. block (i,j) of A is only nonzero - // if joints i and j have at least one body in common. this fact suggests - // the algorithm used to fill A: - // - // for b = all bodies - // n = number of joints attached to body b - // for i = 1..n - // for j = i+1..n - // ii = actual joint number for i - // jj = actual joint number for j - // // (ii,jj) will be set to all pairs of joints around body b - // compute blockwise: A(ii,jj) += JinvM(ii) * J(jj)' - // - // this algorithm catches all pairs of joints that have at least one body - // in common. it does not compute the diagonal blocks of A however - - // another similar algorithm does that. - - int mskip = dPAD(m); - dReal *A = (dReal*) ALLOCA (m*mskip*sizeof(dReal)); - dSetZero (A,m*mskip); - for (i=0; i<nb; i++) { - for (dxJointNode *n1=body[i]->firstjoint; n1; n1=n1->next) { - for (dxJointNode *n2=n1->next; n2; n2=n2->next) { - // get joint numbers and ensure ofs[j1] >= ofs[j2] - int j1 = n1->joint->tag; - int j2 = n2->joint->tag; - if (ofs[j1] < ofs[j2]) { - int tmp = j1; - j1 = j2; - j2 = tmp; - } - - // if either joint was tagged as -1 then it is an inactive (m=0) - // joint that should not be considered - if (j1==-1 || j2==-1) continue; - - // determine if body i is the 1st or 2nd body of joints j1 and j2 - int jb1 = (joint[j1]->node[1].body == body[i]); - int jb2 = (joint[j2]->node[1].body == body[i]); - // jb1/jb2 must be 0 for joints with only one body - dIASSERT(joint[j1]->node[1].body || jb1==0); - dIASSERT(joint[j2]->node[1].body || jb2==0); - - // set block of A - MultiplyAdd2_p8r (A + ofs[j1]*mskip + ofs[j2], - JinvM + 2*8*ofs[j1] + jb1*8*info[j1].m, - J + 2*8*ofs[j2] + jb2*8*info[j2].m, - info[j1].m,info[j2].m, mskip); - } - } - } - // compute diagonal blocks of A - for (i=0; i<nj; i++) { - Multiply2_p8r (A + ofs[i]*(mskip+1), - JinvM + 2*8*ofs[i], - J + 2*8*ofs[i], - info[i].m,info[i].m, mskip); - if (joint[i]->node[1].body) { - MultiplyAdd2_p8r (A + ofs[i]*(mskip+1), - JinvM + 2*8*ofs[i] + 8*info[i].m, - J + 2*8*ofs[i] + 8*info[i].m, - info[i].m,info[i].m, mskip); - } - } - - // add cfm to the diagonal of A - for (i=0; i<m; i++) A[i*mskip+i] += cfm[i] * stepsize1; - -# ifdef COMPARE_METHODS - comparator.nextMatrix (A,m,m,1,"A"); -# endif - - // compute the right hand side `rhs' -# ifdef TIMING - dTimerNow ("compute rhs"); -# endif - dReal *tmp1 = (dReal*) ALLOCA (nb*8 * sizeof(dReal)); - dSetZero (tmp1,nb*8); - // put v/h + invM*fe into tmp1 - for (i=0; i<nb; i++) { - dReal body_invMass = body[i]->invMass; - dReal *body_invI = invI + i*12; - for (j=0; j<3; j++) tmp1[i*8+j] = body[i]->facc[j] * body_invMass + - body[i]->lvel[j] * stepsize1; - dMULTIPLY0_331 (tmp1 + i*8 + 4,body_invI,body[i]->tacc); - for (j=0; j<3; j++) tmp1[i*8+4+j] += body[i]->avel[j] * stepsize1; - } - // put J*tmp1 into rhs - dReal *rhs = (dReal*) ALLOCA (m * sizeof(dReal)); - dSetZero (rhs,m); - for (i=0; i<nj; i++) { - dReal *JJ = J + 2*8*ofs[i]; - Multiply0_p81 (rhs+ofs[i],JJ, - tmp1 + 8*joint[i]->node[0].body->tag, info[i].m); - if (joint[i]->node[1].body) { - MultiplyAdd0_p81 (rhs+ofs[i],JJ + 8*info[i].m, - tmp1 + 8*joint[i]->node[1].body->tag, info[i].m); - } - } - // complete rhs - for (i=0; i<m; i++) rhs[i] = c[i]*stepsize1 - rhs[i]; - -# ifdef COMPARE_METHODS - comparator.nextMatrix (c,m,1,0,"c"); - comparator.nextMatrix (rhs,m,1,0,"rhs"); -# endif - - // solve the LCP problem and get lambda. - // this will destroy A but that's okay -# ifdef TIMING - dTimerNow ("solving LCP problem"); -# endif - dReal *lambda = (dReal*) ALLOCA (m * sizeof(dReal)); - dReal *residual = (dReal*) ALLOCA (m * sizeof(dReal)); - dSolveLCP (m,A,lambda,rhs,residual,nub,lo,hi,findex); - -// OLD WAY - direct factor and solve -// -// // factorize A (L*L'=A) -//# ifdef TIMING -// dTimerNow ("factorize A"); -//# endif -// dReal *L = (dReal*) ALLOCA (m*mskip*sizeof(dReal)); -// memcpy (L,A,m*mskip*sizeof(dReal)); -//# ifdef FAST_FACTOR -// dFastFactorCholesky (L,m); // does not report non positive definiteness -//# else -// if (dFactorCholesky (L,m)==0) dDebug (0,"A is not positive definite"); -//# endif -// -// // compute lambda -//# ifdef TIMING -// dTimerNow ("compute lambda"); -//# endif -// dReal *lambda = (dReal*) ALLOCA (m * sizeof(dReal)); -// memcpy (lambda,rhs,m * sizeof(dReal)); -// dSolveCholesky (L,lambda,m); - -# ifdef COMPARE_METHODS - comparator.nextMatrix (lambda,m,1,0,"lambda"); -# endif - - // compute the constraint force `cforce' -# ifdef TIMING - dTimerNow ("compute constraint force"); -# endif - // compute cforce = J'*lambda - for (i=0; i<nj; i++) { - dReal *JJ = J + 2*8*ofs[i]; - dxBody* b1 = joint[i]->node[0].body; - dxBody* b2 = joint[i]->node[1].body; - dJointFeedback *fb = joint[i]->feedback; - - if (fb) { - // the user has requested feedback on the amount of force that this - // joint is applying to the bodies. we use a slightly slower - // computation that splits out the force components and puts them - // in the feedback structure. - dReal data1[8],data2[8]; - Multiply1_8q1 (data1, JJ, lambda+ofs[i], info[i].m); - dReal *cf1 = cforce + 8*b1->tag; - cf1[0] += (fb->f1[0] = data1[0]); - cf1[1] += (fb->f1[1] = data1[1]); - cf1[2] += (fb->f1[2] = data1[2]); - cf1[4] += (fb->t1[0] = data1[4]); - cf1[5] += (fb->t1[1] = data1[5]); - cf1[6] += (fb->t1[2] = data1[6]); - if (b2){ - Multiply1_8q1 (data2, JJ + 8*info[i].m, lambda+ofs[i], info[i].m); - dReal *cf2 = cforce + 8*b2->tag; - cf2[0] += (fb->f2[0] = data2[0]); - cf2[1] += (fb->f2[1] = data2[1]); - cf2[2] += (fb->f2[2] = data2[2]); - cf2[4] += (fb->t2[0] = data2[4]); - cf2[5] += (fb->t2[1] = data2[5]); - cf2[6] += (fb->t2[2] = data2[6]); - } - } - else { - // no feedback is required, let's compute cforce the faster way - MultiplyAdd1_8q1 (cforce + 8*b1->tag,JJ, lambda+ofs[i], info[i].m); - if (b2) { - MultiplyAdd1_8q1 (cforce + 8*b2->tag, - JJ + 8*info[i].m, lambda+ofs[i], info[i].m); - } - } - } - } - - // compute the velocity update -# ifdef TIMING - dTimerNow ("compute velocity update"); -# endif - - // add fe to cforce - for (i=0; i<nb; i++) { - for (j=0; j<3; j++) cforce[i*8+j] += body[i]->facc[j]; - for (j=0; j<3; j++) cforce[i*8+4+j] += body[i]->tacc[j]; - } - // multiply cforce by stepsize - for (i=0; i < nb*8; i++) cforce[i] *= stepsize; - // add invM * cforce to the body velocity - for (i=0; i<nb; i++) { - dReal body_invMass = body[i]->invMass; - dReal *body_invI = invI + i*12; - for (j=0; j<3; j++) body[i]->lvel[j] += body_invMass * cforce[i*8+j]; - dMULTIPLYADD0_331 (body[i]->avel,body_invI,cforce+i*8+4); - } - - // update the position and orientation from the new linear/angular velocity - // (over the given timestep) -# ifdef TIMING - dTimerNow ("update position"); -# endif - for (i=0; i<nb; i++) moveAndRotateBody (body[i],stepsize); - -# ifdef COMPARE_METHODS - dReal *tmp_vnew = (dReal*) ALLOCA (nb*6*sizeof(dReal)); - for (i=0; i<nb; i++) { - for (j=0; j<3; j++) tmp_vnew[i*6+j] = body[i]->lvel[j]; - for (j=0; j<3; j++) tmp_vnew[i*6+3+j] = body[i]->avel[j]; - } - comparator.nextMatrix (tmp_vnew,nb*6,1,0,"vnew"); -# endif - -# ifdef TIMING - dTimerNow ("tidy up"); -# endif - - // zero all force accumulators - for (i=0; i<nb; i++) { - body[i]->facc[0] = 0; - body[i]->facc[1] = 0; - body[i]->facc[2] = 0; - body[i]->facc[3] = 0; - body[i]->tacc[0] = 0; - body[i]->tacc[1] = 0; - body[i]->tacc[2] = 0; - body[i]->tacc[3] = 0; - } - -# ifdef TIMING - dTimerEnd(); - if (m > 0) dTimerReport (stdout,1); -# endif -} - -//**************************************************************************** - -void dInternalStepIsland (dxWorld *world, dxBody * const *body, int nb, - dxJoint * const *joint, int nj, dReal stepsize) -{ -# ifndef COMPARE_METHODS - dInternalStepIsland_x2 (world,body,nb,joint,nj,stepsize); -# endif - -# ifdef COMPARE_METHODS - int i; - - // save body state - dxBody *state = (dxBody*) ALLOCA (nb*sizeof(dxBody)); - for (i=0; i<nb; i++) memcpy (state+i,body[i],sizeof(dxBody)); - - // take slow step - comparator.reset(); - dInternalStepIsland_x1 (world,body,nb,joint,nj,stepsize); - comparator.end(); - - // restore state - for (i=0; i<nb; i++) memcpy (body[i],state+i,sizeof(dxBody)); - - // take fast step - dInternalStepIsland_x2 (world,body,nb,joint,nj,stepsize); - comparator.end(); - - //comparator.dump(); - //_exit (1); -# endif -} diff --git a/extern/ode/dist/ode/src/step.h b/extern/ode/dist/ode/src/step.h deleted file mode 100644 index c825a11c1dc..00000000000 --- a/extern/ode/dist/ode/src/step.h +++ /dev/null @@ -1,37 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#ifndef _ODE_STEP_H_ -#define _ODE_STEP_H_ - -#include <ode/common.h> - - -void dInternalStepIsland (dxWorld *world, - dxBody * const *body, int nb, - dxJoint * const *joint, int nj, - dReal stepsize); - - - -#endif - diff --git a/extern/ode/dist/ode/src/testing.cpp b/extern/ode/dist/ode/src/testing.cpp deleted file mode 100644 index d55afc25257..00000000000 --- a/extern/ode/dist/ode/src/testing.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -#include <ode/config.h> -#include <ode/misc.h> -#include <ode/memory.h> -#include "testing.h" - -#ifdef dDOUBLE -static const dReal tol = 1.0e-9; -#else -static const dReal tol = 1.0e-5f; -#endif - - -// matrix header on the stack - -struct dMatrixComparison::dMatInfo { - int n,m; // size of matrix - char name[128]; // name of the matrix - dReal *data; // matrix data - int size; // size of `data' -}; - - - -dMatrixComparison::dMatrixComparison() -{ - afterfirst = 0; - index = 0; -} - - -dMatrixComparison::~dMatrixComparison() -{ - reset(); -} - - -dReal dMatrixComparison::nextMatrix (dReal *A, int n, int m, int lower_tri, - char *name, ...) -{ - if (A==0 || n < 1 || m < 1 || name==0) dDebug (0,"bad args to nextMatrix"); - int num = n*dPAD(m); - - if (afterfirst==0) { - dMatInfo *mi = (dMatInfo*) dAlloc (sizeof(dMatInfo)); - mi->n = n; - mi->m = m; - mi->size = num * sizeof(dReal); - mi->data = (dReal*) dAlloc (mi->size); - memcpy (mi->data,A,mi->size); - - va_list ap; - va_start (ap,name); - vsprintf (mi->name,name,ap); - if (strlen(mi->name) >= sizeof (mi->name)) dDebug (0,"name too long"); - - mat.push (mi); - return 0; - } - else { - if (lower_tri && n != m) - dDebug (0,"dMatrixComparison, lower triangular matrix must be square"); - if (index >= mat.size()) dDebug (0,"dMatrixComparison, too many matrices"); - dMatInfo *mp = mat[index]; - index++; - - dMatInfo mi; - va_list ap; - va_start (ap,name); - vsprintf (mi.name,name,ap); - if (strlen(mi.name) >= sizeof (mi.name)) dDebug (0,"name too long"); - - if (strcmp(mp->name,mi.name) != 0) - dDebug (0,"dMatrixComparison, name mismatch (\"%s\" and \"%s\")", - mp->name,mi.name); - if (mp->n != n || mp->m != m) - dDebug (0,"dMatrixComparison, size mismatch (%dx%d and %dx%d)", - mp->n,mp->m,n,m); - - dReal maxdiff; - if (lower_tri) { - maxdiff = dMaxDifferenceLowerTriangle (A,mp->data,n); - } - else { - maxdiff = dMaxDifference (A,mp->data,n,m); - } - if (maxdiff > tol) - dDebug (0,"dMatrixComparison, matrix error (size=%dx%d, name=\"%s\", " - "error=%.4e)",n,m,mi.name,maxdiff); - return maxdiff; - } -} - - -void dMatrixComparison::end() -{ - if (mat.size() <= 0) dDebug (0,"no matrices in sequence"); - afterfirst = 1; - index = 0; -} - - -void dMatrixComparison::reset() -{ - for (int i=0; i<mat.size(); i++) { - dFree (mat[i]->data,mat[i]->size); - dFree (mat[i],sizeof(dMatInfo)); - } - mat.setSize (0); - afterfirst = 0; - index = 0; -} - - -void dMatrixComparison::dump() -{ - for (int i=0; i<mat.size(); i++) - printf ("%d: %s (%dx%d)\n",i,mat[i]->name,mat[i]->n,mat[i]->m); -} - -//**************************************************************************** -// unit test - -#include <setjmp.h> - -static jmp_buf jump_buffer; - -static void myDebug (int num, const char *msg, va_list ap) -{ - // printf ("(Error %d: ",num); - // vprintf (msg,ap); - // printf (")\n"); - longjmp (jump_buffer,1); -} - - -extern "C" void dTestMatrixComparison() -{ - volatile int i; - printf ("dTestMatrixComparison()\n"); - dMessageFunction *orig_debug = dGetDebugHandler(); - - dMatrixComparison mc; - dReal A[50*50]; - - // make first sequence - unsigned long seed = dRandGetSeed(); - for (i=1; i<49; i++) { - dMakeRandomMatrix (A,i,i+1,1.0); - mc.nextMatrix (A,i,i+1,0,"A%d",i); - } - mc.end(); - - //mc.dump(); - - // test identical sequence - dSetDebugHandler (&myDebug); - dRandSetSeed (seed); - if (setjmp (jump_buffer)) { - printf ("\tFAILED (1)\n"); - } - else { - for (i=1; i<49; i++) { - dMakeRandomMatrix (A,i,i+1,1.0); - mc.nextMatrix (A,i,i+1,0,"A%d",i); - } - mc.end(); - printf ("\tpassed (1)\n"); - } - dSetDebugHandler (orig_debug); - - // test broken sequences (with matrix error) - dRandSetSeed (seed); - volatile int passcount = 0; - for (i=1; i<49; i++) { - if (setjmp (jump_buffer)) { - passcount++; - } - else { - dSetDebugHandler (&myDebug); - dMakeRandomMatrix (A,i,i+1,1.0); - A[(i-1)*dPAD(i+1)+i] += REAL(0.01); - mc.nextMatrix (A,i,i+1,0,"A%d",i); - dSetDebugHandler (orig_debug); - } - } - mc.end(); - printf ("\t%s (2)\n",(passcount == 48) ? "passed" : "FAILED"); - - // test broken sequences (with name error) - dRandSetSeed (seed); - passcount = 0; - for (i=1; i<49; i++) { - if (setjmp (jump_buffer)) { - passcount++; - } - else { - dSetDebugHandler (&myDebug); - dMakeRandomMatrix (A,i,i+1,1.0); - mc.nextMatrix (A,i,i+1,0,"B%d",i); - dSetDebugHandler (orig_debug); - } - } - mc.end(); - printf ("\t%s (3)\n",(passcount == 48) ? "passed" : "FAILED"); - - // test identical sequence again - dSetDebugHandler (&myDebug); - dRandSetSeed (seed); - if (setjmp (jump_buffer)) { - printf ("\tFAILED (4)\n"); - } - else { - for (i=1; i<49; i++) { - dMakeRandomMatrix (A,i,i+1,1.0); - mc.nextMatrix (A,i,i+1,0,"A%d",i); - } - mc.end(); - printf ("\tpassed (4)\n"); - } - dSetDebugHandler (orig_debug); -} diff --git a/extern/ode/dist/ode/src/testing.h b/extern/ode/dist/ode/src/testing.h deleted file mode 100644 index aa4acf119db..00000000000 --- a/extern/ode/dist/ode/src/testing.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* stuff used for testing */ - -#ifndef _ODE_TESTING_H_ -#define _ODE_TESTING_H_ - -#include <ode/common.h> -#include "array.h" - - -// compare a sequence of named matrices/vectors, i.e. to make sure that two -// different pieces of code are giving the same results. - -class dMatrixComparison { - struct dMatInfo; - dArray<dMatInfo*> mat; - int afterfirst,index; - -public: - dMatrixComparison(); - ~dMatrixComparison(); - - dReal nextMatrix (dReal *A, int n, int m, int lower_tri, char *name, ...); - // add a new n*m matrix A to the sequence. the name of the matrix is given - // by the printf-style arguments (name,...). if this is the first sequence - // then this object will simply record the matrices and return 0. - // if this the second or subsequent sequence then this object will compare - // the matrices with the first sequence, and report any differences. - // the matrix error will be returned. if `lower_tri' is 1 then only the - // lower triangle of the matrix (including the diagonal) will be compared - // (the matrix must be square). - - void end(); - // end a sequence. - - void reset(); - // restarts the object, so the next sequence will be the first sequence. - - void dump(); - // print out info about all the matrices in the sequence -}; - - -#endif - diff --git a/extern/ode/dist/ode/src/timer.cpp b/extern/ode/dist/ode/src/timer.cpp deleted file mode 100644 index 87cb9f6f2fe..00000000000 --- a/extern/ode/dist/ode/src/timer.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/************************************************************************* - * * - * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * - * All rights reserved. Email: russ@q12.org Web: www.q12.org * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of EITHER: * - * (1) The GNU Lesser General Public License as published by the Free * - * Software Foundation; either version 2.1 of the License, or (at * - * your option) any later version. The text of the GNU Lesser * - * General Public License is included with this library in the * - * file LICENSE.TXT. * - * (2) The BSD-style license that is included with this library in * - * the file LICENSE-BSD.TXT. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * - * LICENSE.TXT and LICENSE-BSD.TXT for more details. * - * * - *************************************************************************/ - -/* - -TODO ----- - -* gettimeofday() and the pentium time stamp counter return the real time, - not the process time. fix this somehow! - -*/ - -#include <ode/common.h> -#include <ode/timer.h> - -// misc defines -#define ALLOCA dALLOCA16 - -//**************************************************************************** -// implementation for windows based on the multimedia performance counter. - -#ifdef WIN32 - -#include "windows.h" - -static inline void getClockCount (unsigned long cc[2]) -{ - LARGE_INTEGER a; - QueryPerformanceCounter (&a); - cc[0] = a.LowPart; - cc[1] = a.HighPart; -} - - -static inline void serialize() -{ -} - - -static inline double loadClockCount (unsigned long cc[2]) -{ - LARGE_INTEGER a; - a.LowPart = cc[0]; - a.HighPart = cc[1]; - return double(a.QuadPart); -} - - -double dTimerResolution() -{ - return 1.0/dTimerTicksPerSecond(); -} - - -double dTimerTicksPerSecond() -{ - static int query=0; - static double hz=0.0; - if (!query) { - LARGE_INTEGER a; - QueryPerformanceFrequency (&a); - hz = double(a.QuadPart); - query = 1; - } - return hz; -} - -#endif - -//**************************************************************************** -// implementation based on the pentium time stamp counter. the timer functions -// can be serializing or non-serializing. serializing will ensure that all -// instructions have executed and data has been written back before the cpu -// time stamp counter is read. the CPUID instruction is used to serialize. - -#if defined(PENTIUM) && !defined(WIN32) - -// we need to know the clock rate so that the timing function can report -// accurate times. this number only needs to be set accurately if we're -// doing performance tests and care about real-world time numbers - otherwise, -// just ignore this. i have not worked out how to determine this number -// automatically yet. - -#define PENTIUM_HZ (500e6) - - -static inline void getClockCount (unsigned long cc[2]) -{ - asm volatile ("\n\ - rdtsc\n\ - movl %%eax,(%%esi)\n\ - movl %%edx,4(%%esi)" - : : "S" (cc) : "%eax","%edx","cc","memory"); -} - - -static inline void serialize() -{ - asm volatile ("\n\ - mov $0,%%eax\n\ - cpuid" - : : : "%eax","%ebx","%ecx","%edx","cc","memory"); -} - - -static inline double loadClockCount (unsigned long a[2]) -{ - double ret; - asm volatile ("fildll %1; fstpl %0" : "=m" (ret) : "m" (a[0]) : - "cc","memory"); - return ret; -} - - -double dTimerResolution() -{ - return 1.0/PENTIUM_HZ; -} - - -double dTimerTicksPerSecond() -{ - return PENTIUM_HZ; -} - -#endif - -//**************************************************************************** -// otherwise, do the implementation based on gettimeofday(). - -#if !defined(PENTIUM) && !defined(WIN32) - -#ifndef macintosh - -#include <sys/time.h> -#include <unistd.h> - - -static inline void getClockCount (unsigned long cc[2]) -{ - struct timeval tv; - gettimeofday (&tv,0); - cc[0] = tv.tv_usec; - cc[1] = tv.tv_sec; -} - -#else // macintosh - -#include <MacTypes.h> -#include <Timer.h> - -static inline void getClockCount (unsigned long cc[2]) -{ - UnsignedWide ms; - Microseconds (&ms); - cc[1] = ms.lo / 1000000; - cc[0] = ms.lo - ( cc[1] * 1000000 ); -} - -#endif - - -static inline void serialize() -{ -} - - -static inline double loadClockCount (unsigned long a[2]) -{ - return a[1]*1.0e6 + a[0]; -} - - -double dTimerResolution() -{ - unsigned long cc1[2],cc2[2]; - getClockCount (cc1); - do { - getClockCount (cc2); - } - while (cc1[0]==cc2[0] && cc1[1]==cc2[1]); - do { - getClockCount (cc1); - } - while (cc1[0]==cc2[0] && cc1[1]==cc2[1]); - double t1 = loadClockCount (cc1); - double t2 = loadClockCount (cc2); - return (t1-t2) / dTimerTicksPerSecond(); -} - - -double dTimerTicksPerSecond() -{ - return 1000000; -} - -#endif - -//**************************************************************************** -// stop watches - -void dStopwatchReset (dStopwatch *s) -{ - s->time = 0; - s->cc[0] = 0; - s->cc[1] = 0; -} - - -void dStopwatchStart (dStopwatch *s) -{ - serialize(); - getClockCount (s->cc); -} - - -void dStopwatchStop (dStopwatch *s) -{ - unsigned long cc[2]; - serialize(); - getClockCount (cc); - double t1 = loadClockCount (s->cc); - double t2 = loadClockCount (cc); - s->time += t2-t1; -} - - -double dStopwatchTime (dStopwatch *s) -{ - return s->time / dTimerTicksPerSecond(); -} - -//**************************************************************************** -// code timers - -// maximum number of events to record -#define MAXNUM 100 - -static int num = 0; // number of entries used in event array -static struct { - unsigned long cc[2]; // clock counts - double total_t; // total clocks used in this slot. - double total_p; // total percentage points used in this slot. - int count; // number of times this slot has been updated. - char *description; // pointer to static string -} event[MAXNUM]; - - -// make sure all slot totals and counts reset to 0 at start - -static void initSlots() -{ - static int initialized=0; - if (!initialized) { - for (int i=0; i<MAXNUM; i++) { - event[i].count = 0; - event[i].total_t = 0; - event[i].total_p = 0; - } - initialized = 1; - } -} - - -void dTimerStart (const char *description) -{ - initSlots(); - event[0].description = const_cast<char*> (description); - num = 1; - serialize(); - getClockCount (event[0].cc); -} - - -void dTimerNow (const char *description) -{ - if (num < MAXNUM) { - // do not serialize - getClockCount (event[num].cc); - event[num].description = const_cast<char*> (description); - num++; - } -} - - -void dTimerEnd() -{ - if (num < MAXNUM) { - serialize(); - getClockCount (event[num].cc); - event[num].description = "TOTAL"; - num++; - } -} - -//**************************************************************************** -// print report - -static void fprintDoubleWithPrefix (FILE *f, double a, char *fmt) -{ - if (a >= 0.999999) { - fprintf (f,fmt,a); - return; - } - a *= 1000.0; - if (a >= 0.999999) { - fprintf (f,fmt,a); - fprintf (f,"m"); - return; - } - a *= 1000.0; - if (a >= 0.999999) { - fprintf (f,fmt,a); - fprintf (f,"u"); - return; - } - a *= 1000.0; - fprintf (f,fmt,a); - fprintf (f,"n"); -} - - -void dTimerReport (FILE *fout, int average) -{ - int i,maxl; - double ccunit = 1.0/dTimerTicksPerSecond(); - fprintf (fout,"\nTimer Report ("); - fprintDoubleWithPrefix (fout,ccunit,"%.2f "); - fprintf (fout,"s resolution)\n------------\n"); - if (num < 1) return; - - // get maximum description length - maxl = 0; - for (i=0; i<num; i++) { - int l = strlen (event[i].description); - if (l > maxl) maxl = l; - } - - // calculate total time - double t1 = loadClockCount (event[0].cc); - double t2 = loadClockCount (event[num-1].cc); - double total = t2 - t1; - if (total <= 0) total = 1; - - // compute time difference for all slots except the last one. update totals - double *times = (double*) ALLOCA (num * sizeof(double)); - for (i=0; i < (num-1); i++) { - double t1 = loadClockCount (event[i].cc); - double t2 = loadClockCount (event[i+1].cc); - times[i] = t2 - t1; - event[i].count++; - event[i].total_t += times[i]; - event[i].total_p += times[i]/total * 100.0; - } - - // print report (with optional averages) - for (i=0; i<num; i++) { - double t,p; - if (i < (num-1)) { - t = times[i]; - p = t/total * 100.0; - } - else { - t = total; - p = 100.0; - } - fprintf (fout,"%-*s %7.2fms %6.2f%%",maxl,event[i].description, - t*ccunit * 1000.0, p); - if (average && i < (num-1)) { - fprintf (fout," (avg %7.2fms %6.2f%%)", - (event[i].total_t / event[i].count)*ccunit * 1000.0, - event[i].total_p / event[i].count); - } - fprintf (fout,"\n"); - } - fprintf (fout,"\n"); -} diff --git a/extern/ode/dist/tools/build4 b/extern/ode/dist/tools/build4 deleted file mode 100755 index 49831e2df35..00000000000 --- a/extern/ode/dist/tools/build4 +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# build all four precision/release configurations and log the build messages -# (used for debugging). - -PLATFORM=unix-gcc -SETTINGS=config/user-settings - -if [ ! -f ode/src/ode.cpp ]; then - echo "run this from the ODE root directory" - exit 1 -fi - -function build() { -echo -e "$PRECISION $MODE\n\n" >> BUILD_LOG -cat <<END > $SETTINGS -PLATFORM=$PLATFORM -PRECISION=$PRECISION -BUILD=$MODE -END -make clean -make >> BUILD_LOG 2>&1 -echo -e "\n\n---------------------------------------------\n\n" >> BUILD_LOG -} - -echo > BUILD_LOG - -PRECISION=SINGLE -MODE=debug -build -PRECISION=SINGLE -MODE=release -build -PRECISION=DOUBLE -MODE=debug -build -PRECISION=DOUBLE -MODE=release -build - -make clean -rm -f $SETTINGS diff --git a/extern/ode/dist/tools/build4.bat b/extern/ode/dist/tools/build4.bat deleted file mode 100755 index c87e9a9e2ba..00000000000 --- a/extern/ode/dist/tools/build4.bat +++ /dev/null @@ -1,43 +0,0 @@ -@echo off -rem build all four precision/release configurations and log the build messages -rem (used for debugging). - -setlocal - -set PLATFORM=cygwin -set SETTINGS=config\user-settings - -echo SINGLE debug > BUILD_LOG -echo PLATFORM=%PLATFORM%> %SETTINGS% -echo PRECISION=SINGLE>> %SETTINGS% -echo BUILD=debug>> %SETTINGS% -make clean -make >> BUILD_LOG -echo --------------------------------------------- >> BUILD_LOG - -echo DOUBLE debug >> BUILD_LOG -echo PLATFORM=%PLATFORM%> %SETTINGS% -echo PRECISION=DOUBLE>> %SETTINGS% -echo BUILD=debug>> %SETTINGS% -make clean -make >> BUILD_LOG -echo --------------------------------------------- >> BUILD_LOG - -echo SINGLE release >> BUILD_LOG -echo PLATFORM=%PLATFORM%> %SETTINGS% -echo PRECISION=SINGLE>> %SETTINGS% -echo BUILD=release>> %SETTINGS% -make clean -make >> BUILD_LOG -echo --------------------------------------------- >> BUILD_LOG - -echo DOUBLE release >> BUILD_LOG -echo PLATFORM=%PLATFORM%> %SETTINGS% -echo PRECISION=DOUBLE>> %SETTINGS% -echo BUILD=release>> %SETTINGS% -make clean -make >> BUILD_LOG -echo --------------------------------------------- >> BUILD_LOG - -make clean -del %SETTINGS% diff --git a/extern/ode/dist/tools/make_distribution b/extern/ode/dist/tools/make_distribution deleted file mode 100755 index ed6d52bcbfd..00000000000 --- a/extern/ode/dist/tools/make_distribution +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -VER=0.03 -# VER=`date +%y%m%d` - -if [ ! -f ode/src/ode.cpp ]; then - echo "run this from the ODE root directory" - exit 1 -fi - -ODE_DIR=`pwd` - -cd /tmp -if [ -d /tmp/ode-$VER ]; then - echo "remove /tmp/ode-$VER first" - exit 1 -fi - -mkdir /tmp/ode-$VER -cp -av $ODE_DIR/* /tmp/ode-$VER -find /tmp/ode-$VER -type d -name CVS -exec rm -rf {} \; -print -find /tmp/ode-$VER -type f -name *~ -exec rm -f {} \; -print -rmdir /tmp/ode-$VER/build - -cd /tmp/ode-$VER -make clean -cp config/user-settings.example config/user-settings - -cd ode/doc -./doccer ode.doc > ode.html - -cd /tmp/ode-$VER -echo -e "\n\nMake any modifications you want, then exit the shell:" -bash - -cd /tmp -tar cfvz ode-$VER.tgz ode-$VER -rm -rf /tmp/ode-$VER - -echo -e "\ntype <return> to exit or 'c' to copy to q12" -read Q -if [ $Q ]; then - echo copying... - scp1 ode-$VER.tgz q12.org:~/q12/ode/release/ -fi diff --git a/extern/ode/dist/tools/process_deps b/extern/ode/dist/tools/process_deps deleted file mode 100755 index 9b95ddac382..00000000000 --- a/extern/ode/dist/tools/process_deps +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/perl - -$a = join ('',<STDIN>); -$a =~ s/\\\n/ /g; # join continued lines -$a =~ s/(^\S+:)/$ARGV[0]$1/gm; # put prefix in front of rules -$a =~ s/\s+\/\S+/ /g; # remove absolute path dependencies -$a =~ s/\s+\n/\n/g; # remove whitespace at end of lines -$a =~ s/[ \t]+/ /g; # clean up interior whitespace -$a =~ s/ / \\\n /g; # put back line continuations - -print $a; diff --git a/extern/ode/patchfile.FreeBSD b/extern/ode/patchfile.FreeBSD deleted file mode 100644 index 1725a3acc45..00000000000 --- a/extern/ode/patchfile.FreeBSD +++ /dev/null @@ -1,22 +0,0 @@ ---- dist/Makefile.org Sat Jan 11 23:55:46 2003 -+++ dist/Makefile Sat Jan 11 23:55:36 2003 -@@ -242,14 +242,16 @@ - clean: - -$(DEL_CMD) $(ODE_OBJECTS) $(ODE_TEST_EXE) $(ODE_LIB) $(DRAWSTUFF_OBJECTS) $(DRAWSTUFF_TEST_EXE) $(DRAWSTUFF_LIB) ode/test/*$(OBJ) drawstuff/dstest/*$(OBJ) $(CONFIGURATOR_EXE) $(CONFIG_H) - -+# Patched for FreeBSD -+ - %$(OBJ): %.c -- $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)1 $(C_OUT)$@ $< -+ $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) -I/usr/X11R6/include $(DEFINES) $(C_OPT)1 $(C_OUT)$@ $< - - %$(OBJ): %.cpp -- $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)$(OPT) $(C_OUT)$@ $< -+ $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) -I/usr/X11R6/include $(DEFINES) $(C_OPT)$(OPT) $(C_OUT)$@ $< - - %.exe: %$(OBJ) -- $(CC) $(C_EXEOUT)$@ $< $(ODE_LIB) $(DRAWSTUFF_LIB) $(RESOURCE_FILE) $(LINK_OPENGL) $(LINK_MATH) -+ $(CC) $(C_EXEOUT)$@ $< $(ODE_LIB) $(DRAWSTUFF_LIB) $(RESOURCE_FILE) $(LINK_OPENGL) $(LINK_MATH) -lXext - - # windows specific rules - diff --git a/extern/qhull/SConscript b/extern/qhull/SConscript index 7f911d1b7f1..d3db67cddc0 100644 --- a/extern/qhull/SConscript +++ b/extern/qhull/SConscript @@ -32,4 +32,4 @@ sources = ['src/geom.c', incs = 'include src' -env.BlenderLib ( 'extern_qhull', sources, Split(incs), Split(defs), libtype=['game2','player'], priority=[50, 85], compileflags = cflags) +env.BlenderLib ( 'extern_qhull', sources, Split(incs), Split(defs), libtype=['extern'], priority=[50], compileflags = cflags) diff --git a/extern/qhull/src/Makefile b/extern/qhull/src/Makefile index 8201e44f01b..81c06758cbb 100644 --- a/extern/qhull/src/Makefile +++ b/extern/qhull/src/Makefile @@ -1,3 +1,5 @@ +# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- +# vim: tabstop=8 # # $Id$ # @@ -22,7 +24,7 @@ # # The Original Code is: all of this file. # -# Contributor(s): none yet. +# Contributor(s): GSR # # ***** END GPL LICENSE BLOCK ***** # @@ -40,16 +42,13 @@ CSRCS = user.c global.c stat.c io.c geom2.c poly2.c \ CCSRCS = include nan_compile.mk -install: all debug +install: $(ALL_OR_DEBUG) @[ -d $(NAN_QHULL) ] || mkdir -p $(NAN_QHULL) @[ -d $(NAN_QHULL)/include/qhull ] || mkdir -p $(NAN_QHULL)/include/qhull - @[ -d $(NAN_QHULL)/lib ] || mkdir -p $(NAN_QHULL)/lib - @[ -d $(NAN_QHULL)/lib/debug ] || mkdir -p $(NAN_QHULL)/lib/debug - @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/lib$(LIBNAME).a $(NAN_QHULL)/lib/ -# @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/debug/lib$(LIBNAME).a $(NAN_QHULL)/lib/debug/ + @[ -d $(NAN_QHULL)/lib/$(DEBUG_DIR) ] || mkdir -p $(NAN_QHULL)/lib/$(DEBUG_DIR) + @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a $(NAN_QHULL)/lib/$(DEBUG_DIR) ifeq ($(OS),darwin) - ranlib $(NAN_QHULL)/lib/lib$(LIBNAME).a -# ranlib $(NAN_QHULL)/lib/debug/lib$(LIBNAME).a + ranlib $(NAN_QHULL)/lib/$(DEBUG_DIR)lib$(LIBNAME).a endif @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh ../include/qhull/*.h $(NAN_QHULL)/include/qhull diff --git a/extern/solid/Makefile b/extern/solid/Makefile index 3b333c5141d..206dc21c3fb 100644 --- a/extern/solid/Makefile +++ b/extern/solid/Makefile @@ -1,3 +1,5 @@ +# -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*- +# vim: tabstop=8 # # $Id$ # @@ -22,7 +24,7 @@ # # The Original Code is: all of this file. # -# Contributor(s): none yet. +# Contributor(s): GSR # # ***** END GPL LICENSE BLOCK ***** # @@ -37,18 +39,15 @@ DIRS = src include nan_subdirs.mk -install: all debug +install: $(ALL_OR_DEBUG) @[ -d $(NAN_SOLID) ] || mkdir -p $(NAN_SOLID) @[ -d $(NAN_SOLID)/include/SOLID ] || mkdir -p $(NAN_SOLID)/include/SOLID @[ -d $(NAN_SOLID)/include/SOLID/MT ] || mkdir -p $(NAN_SOLID)/include/SOLID/MT - @[ -d $(NAN_SOLID)/lib ] || mkdir -p $(NAN_SOLID)/lib - @[ -d $(NAN_SOLID)/lib/debug ] || mkdir -p $(NAN_SOLID)/lib/debug + @[ -d $(NAN_SOLID)/lib/$(DEBUG_DIR) ] || mkdir -p $(NAN_SOLID)/lib/$(DEBUG_DIR) @for i in $(LIBNAMES); do \ - $(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$$i/lib$$i.a $(NAN_SOLID)/lib/ ; \ - $(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$$i/debug/lib$$i.a $(NAN_SOLID)/lib/debug/ ; \ + $(NANBLENDERHOME)/intern/tools/cpifdiff.sh $(DIR)/$$i/$(DEBUG_DIR)lib$$i.a $(NAN_SOLID)/lib/$(DEBUG_DIR) ; \ if [ $(OS) = darwin ] ; then \ - ranlib $(NAN_SOLID)/lib/lib$$i.a ; \ - ranlib $(NAN_SOLID)/lib/debug/lib$$i.a ; \ + ranlib $(NAN_SOLID)/lib/$(DEBUG_DIR)lib$$i.a ; \ fi ; \ done @$(NANBLENDERHOME)/intern/tools/cpifdiff.sh include/*.h $(NAN_SOLID)/include/SOLID diff --git a/extern/solid/SConscript b/extern/solid/SConscript index 7482014c0a4..8c54442ca73 100644 --- a/extern/solid/SConscript +++ b/extern/solid/SConscript @@ -6,7 +6,7 @@ Import('env') defs = 'USE_DOUBLES QHULL _LIB' cflags = [] -if env['OURPLATFORM']=='win32-vc': +if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): defs += ' WIN32 NDEBUG _WINDOWS _LIB' cflags += ['/MT', '/W3', '/GX', '/Og', '/Ot', '/Ob1', '/Op', '/G6'] elif env['OURPLATFORM']=='win32-mingw': @@ -31,4 +31,4 @@ sources = env.Glob('src/*.cpp') + env.Glob('src/convex/*.cpp') + env.Glob('src/c incs = 'include src src/broad src/complex src/convex ../qhull/include' -env.BlenderLib ( libname='extern_solid', sources=sources, includes=Split(incs), defines=Split(defs), libtype=['game2','player'], priority=[45, 75] , compileflags = cflags) +env.BlenderLib ( libname='extern_solid', sources=sources, includes=Split(incs), defines=Split(defs), libtype=['extern'], priority=[10] , compileflags = cflags) diff --git a/extern/verse/CMakeLists.txt b/extern/verse/CMakeLists.txt deleted file mode 100644 index 318a550668e..00000000000 --- a/extern/verse/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# $Id$ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -SUBDIRS(dist) - diff --git a/extern/verse/Makefile b/extern/verse/Makefile deleted file mode 100644 index 51dc5543d2a..00000000000 --- a/extern/verse/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2002 by Hans Lambermont -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jiri Hnidek -# -# ***** END GPL LICENSE BLOCK ***** -LIBNAME = verse -SOURCEDIR = extern/$(LIBNAME) -DIR = $(OCGDIR)/$(SOURCEDIR) -DIRS = dist - -include nan_subdirs.mk -include nan_compile.mk -include nan_link.mk - -DISTDIR = dist -CP = ../../intern/tools/cpifdiff.sh - -ifeq ($(OS),windows) - EXT = .exe -endif - -install: all debug - @[ -d $(NAN_VERSE) ] || mkdir -p $(NAN_VERSE) - @[ -d $(NAN_VERSE)/include ] || mkdir -p $(NAN_VERSE)/include - @[ -d $(NAN_VERSE)/lib ] || mkdir -p $(NAN_VERSE)/lib - @[ -d $(OCGDIR)/bin ] || mkdir -p $(OCGDIR)/bin - @$(CP) $(DISTDIR)/*.h $(NAN_VERSE)/include - @$(CP) $(DIR)/libverse.a $(NAN_VERSE)/lib -ifeq ($(OS),darwin) - ranlib $(NAN_VERSE)/lib/libverse.a -endif - $(CCC) $(CCFLAGS) $(LDFLAGS) -o $(DIR)/verse$(EXT) $(DIR)/libverse.a $(LIBS) $(SLIBS) $(LLIBS) $(DADD) $(LOPTS) - @$(CP) $(DIR)/verse$(EXT) $(OCGDIR)/bin diff --git a/extern/verse/dist/BUGS b/extern/verse/dist/BUGS deleted file mode 100644 index 8c3603a3a45..00000000000 --- a/extern/verse/dist/BUGS +++ /dev/null @@ -1,8 +0,0 @@ - -Known problems with Verse - -2004-03-03 -* The source code needs plenty of cleaning up in order to compile more - cleanly. -* License information needs to be added all over the place. -* Decent documentation is missing. diff --git a/extern/verse/dist/CMakeLists.txt b/extern/verse/dist/CMakeLists.txt deleted file mode 100644 index ae130df6410..00000000000 --- a/extern/verse/dist/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# $Id$ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -SUBDIRS(mkprot_cmd) - -SET(SRC_MKPROT_OUT - v_gen_pack_init.c - v_gen_pack_a_node.c - v_gen_pack_b_node.c - v_gen_pack_c_node.c - v_gen_pack_g_node.c - v_gen_pack_m_node.c - v_gen_pack_o_node.c - v_gen_pack_s_node.c - v_gen_pack_t_node.c -) - -SET(INC .) - -SET(SRC - v_cmd_buf.c - v_connect.c - v_connection.c - v_encryption.c - v_func_storage.c - v_man_pack_node.c - v_network.c - v_network_in_que.c - v_network_out_que.c - v_pack.c - v_pack_method.c - v_prime.c - v_randgen.c - v_util.c - v_bignum.c - verse_ms.c - ${SRC_MKPROT_OUT} -) - -BLENDERLIB(verse "${SRC}" "${INC}") -ADD_DEPENDENCIES(verse mkprot) -#verselib = env.BlenderLib(libname='verse', sources=lib_source_files, includes=[], defines=defines, libtype=['core', 'intern'], priority = [5, 5]) - -SET(SRC_VERSE - vs_connection.c - vs_main.c - vs_node_audio.c - vs_node_bitmap.c - vs_node_curve.c - vs_node_geometry.c - vs_node_head.c - vs_node_material.c - vs_node_object.c - vs_node_particle.c - vs_node_storage.c - vs_node_text.c - vs_master.c -) - -ADD_EXECUTABLE(verse_server ${SRC_VERSE}) -IF(WIN32) -TARGET_LINK_LIBRARIES(verse_server verse ws2_32) -ELSE(WIN32) -TARGET_LINK_LIBRARIES(verse_server verse) -ENDIF(WIN32) -ADD_DEPENDENCIES(verse_server mkprot) -MESSAGE(STATUS "Configuring verse_server") diff --git a/extern/verse/dist/MAINTAINERS b/extern/verse/dist/MAINTAINERS deleted file mode 100644 index c467d5309b8..00000000000 --- a/extern/verse/dist/MAINTAINERS +++ /dev/null @@ -1,15 +0,0 @@ - - Verse Maintainers - -This file tries to list credits for the various parts of the -Verse core distribution, and also identify who maintains what. - -We are deeply appreciative of any contributions and thank you -all for your time and interest in helping make Verse a better -thing. - -* All code was originally written by Eskil Steenberg, and is - being maintained by him and Emil Brink. Contact us through - the project page at http://www.blender.org/modules/verse/. - -* SCons build file by N. Letwory, http://www.jester-depot.net/. diff --git a/extern/verse/dist/Makefile b/extern/verse/dist/Makefile deleted file mode 100644 index 69b5590b2bc..00000000000 --- a/extern/verse/dist/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# -# Makefile for Verse core; API and reference server. -# This pretty much requires GNU Make, I think. -# -# This build is slightly complicated that part of the C code that -# needs to go into the API implementation is generated by building -# and running other C files (this is the protocol definition). -# - -LIBNAME = verse -DIR = $(OCGDIR)/extern/$(LIBNAME) - -include nan_compile.mk - -# TARGETS = verse diff --git a/extern/verse/dist/Makefile.win32 b/extern/verse/dist/Makefile.win32 deleted file mode 100644 index 548881c6a16..00000000000 --- a/extern/verse/dist/Makefile.win32 +++ /dev/null @@ -1,102 +0,0 @@ -# -# Makefile for Verse core; API and reference server. -# Written by modifying the main GNU Makefile, for nmake. -# -# It is more hard-coded, relying on less intelligence in -# the make tool. -# -# This build is slightly complicated that part of the C code that -# needs to go into the API implementation is generated by building -# and running other C files (this is the protocol definition). -# - -CC = cl -CFLAGS = -LDFLAGS = -pg - -AR = ar -ARFLAGS = rus -RANLIB = ranlib - -TARGETS = verse.lib verse.exe - -# Automatically generated protocol things. -PROT_DEF = v_cmd_def_a.c v_cmd_def_b.c v_cmd_def_c.c v_cmd_def_g.c v_cmd_def_m.c v_cmd_def_o.c v_cmd_def_s.c v_cmd_def_t.c -PROT_TOOL = v_cmd_gen.c $(PROT_DEF) -PROT_OUT = v_gen_pack_init.c v_gen_unpack_func.h verse.h \ - v_gen_pack_a_node.c v_gen_pack_b_node.c v_gen_pack_c_node.c v_gen_pack_g_node.c v_gen_pack_m_node.c v_gen_pack_o_node.c v_gen_pack_s_node.c v_gen_pack_t_node.c - -# The API implementation is the protocol code plus a few bits. -LIBVERSE_SRC = v_gen_pack_init.c v_gen_unpack_func.h verse.h v_gen_pack_a_node.c v_gen_pack_b_node.c v_gen_pack_c_node.c v_gen_pack_g_node.c \ - v_gen_pack_m_node.c v_gen_pack_o_node.c v_gen_pack_s_node.c v_gen_pack_t_node.c \ - v_bignum.c v_cmd_buf.c v_connect.c \ - v_connection.c v_connection.h v_encryption.c \ - v_func_storage.c v_internal_verse.h v_man_pack_node.c \ - v_network.c v_network.h v_network_in_que.c v_network_out_que.c \ - v_pack.c v_pack.h v_pack_method.c v_prime.c v_randgen.c v_util.c - -LIBVERSE_OBJ = v_gen_pack_init.obj v_gen_pack_a_node.obj v_gen_pack_b_node.obj v_gen_pack_c_node.obj v_gen_pack_g_node.obj \ - v_gen_pack_m_node.obj v_gen_pack_o_node.obj v_gen_pack_s_node.obj v_gen_pack_t_node.obj \ - v_bignum.obj v_cmd_buf.obj v_connect.obj \ - v_connection.obj v_encryption.obj \ - v_func_storage.obj v_man_pack_node.obj \ - v_network.obj v_network_in_que.obj v_network_out_que.obj \ - v_pack.obj v_pack_method.obj v_prime.obj v_randgen.obj v_util.obj - -# The server is a simple 1:1 mapping, but in Windows nmake ... That doesn't help much. :/ -VERSE_SRC = vs_connection.c vs_main.c vs_master.c vs_node_audio.c vs_node_bitmap.c vs_node_curve.c vs_node_geometry.c vs_node_head.c vs_node_material.c vs_node_object.c vs_node_particle.c vs_node_storage.c vs_node_text.c -VERSE_OBJ = vs_connection.obj vs_main.obj vs_master.obj vs_node_audio.obj vs_node_bitmap.obj vs_node_curve.obj vs_node_geometry.obj \ - vs_node_head.obj vs_node_material.obj vs_node_object.obj vs_node_particle.obj vs_node_storage.obj vs_node_text.obj - -# ----------------------------------------------------- - -ALL: verse.lib verse.exe - -verse.exe: $(VERSE_OBJ) verse.lib resources\verse.res - cl /Fe$@ $** wsock32.lib - -verse.lib: $(LIBVERSE_OBJ) - link /lib /nologo /out:$@ $** - -# ----------------------------------------------------- - -# Here are the automatically generated pieces of the puzzle. -# Basically, we generate v_gen_pack_X_node.c files by compiling -# the v_cmd_def_X.c files together with some driver glue and -# running the result. -# - -# The autogen outputs all depend on the tool. -$(PROT_OUT): mkprot.exe - mkprot.exe - -# Build the protocol maker, from the definitions themselves. -mkprot.exe: $(PROT_TOOL) verse_header.h - $(CC) /DV_GENERATE_FUNC_MODE /Fe$@ $(PROT_TOOL) - -# Clean away all the generated parts of the protocol implementation. -cleanprot: clean - del mkprot $(PROT_OUT) mkprot.exe - -# ----------------------------------------------------- - -clean: - del *.obj $(TARGETS) - -# ----------------------------------------------------- - -# Utter ugliness to create release archives. Needs to improve, but should work for a while. -dist: - RELEASE=$$( \ - R=`grep V_RELEASE_NUMBER verse.h | tr -s ' \t' | tr -d '"\r' | cut -d' ' -f3` ; \ - P=`grep V_RELEASE_PATCH verse.h | tr -s ' \t' | tr -d '"\r' | cut -d' ' -f3` ; \ - L=`grep V_RELEASE_LABEL verse.h | tr -s ' \t' | tr -d '"\r' | cut -d' ' -f3` ; echo r$${R}p$$P$$L ) ; \ - if [ $$RELEASE ]; then ( \ - rm -rf /tmp/verse; \ - mkdir -p /tmp/verse; \ - cp -a * /tmp/verse; \ - cd /tmp && zip verse-$$RELEASE.zip -r verse -x 'verse/*CVS*' -x 'verse/.*' ; \ - ); mv /tmp/verse-$$RELEASE.zip . \ - ;else \ - echo "Couldn't auto-set RELEASE from verse.h, something is fishy" \ - ;fi diff --git a/extern/verse/dist/README.html b/extern/verse/dist/README.html deleted file mode 100644 index b3b3050bf12..00000000000 --- a/extern/verse/dist/README.html +++ /dev/null @@ -1,173 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> -<head> -<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> -<title>Verse README</title> -<style type="text/css"> - -h1.title { -text-align: center; -} - -p.author { -text-align: center; -} - -p.note { -background-color: #ffeeee; -margin-left: 5em; -margin-right: 5em; -border-style: solid; -border-color: black; -border-width: thin; -} - -pre.shell { -background-color: #ddddff; -border-color: black; -padding: .5em; -border-style: solid; -border-color: black; -border-width: thin; -} - -ul.variables { -list-style: none; -font-family: monospace; -} - -</style> -</head> - -<body> -<h1 class="title">Verse</h1> - -<p> -This is the Verse protocol and sample server implementations. -</p> -<p> -For more information, see <a href="http://verse.blender.org/">the Verse web site</a>. -</p> -<h1>Building the Verse Core</h1> -<p class="note"> -Note: This section is only of interest to developers, who wish to build the Verse core themselves. -If you have chosen a binary download, you will already have the server and can skip the rest -of this section. -</p> -<p> -Running "make" here will build the API library, "libverse.a" (and its -header file, "verse.h"). These two will then be used to build the -reference Verse server binary, called "verse". -</p> -<p> -If you are more comfortable with <a href="http://www.scons.org/">SCons</a>, and of course have it -installed on your system, you can type "scons" instead. -</p> - -<h1>Starting the Server</h1> -<p> -The Verse server is a command-line program, without a graphical user interface. -You simply start it, and it will immediately begin listening for incoming -connections on a network socket. Here is how a typical invocation looks: -</p> -<pre class="shell">~> verse -</pre> -<p> -If you don't ask it to do otherwise, the Verse server will start listening for UDP packets -on its default port. The port number currently used by Verse is 4950. -</p> -<p class="note"> -Note: This is not an official <a href="http://www.iana.org/">registered</a>, port number. -It is possible that it gets assigned to someone else, in case Verse will need to change. -</p> -<p> -You can use the following command line options to control the server's operation: -</p> -<dl> - <dt>-h</dt> - <dd> - Print a help text, that shows all understood options. - </dd> - <dt>-ms</dt> - <dd> - Enables master server communications to the default, built-in address. Use the -h option to learn - what this address is. Please note that master server communication is <strong>disabled</strong> by default. - </dd> - <dt>-ms:ip=IP</dt> - <dd> - Sets a new address to use for master server communication. This also implies -ms, i.e. the server - will try to register itself with the given master server. For details on the protocol used to do - this, please see the <a href="http://verse.blender.org/cms/Master_Server__v2.775.0.html">spec</a>. - </dd> - <dt>-ms:de=DESC</dt> - <dd> - Sets the description to use for this server, when registering with the the master server. This is - only used if master server communication is actually enabled. The description is expected to be a - human-readable string, like <code>"A test server, run on a cable modem, and offline during local daytime"</code> - or something. - </dd> - <dt>-ms:ta=TAGS</dt> - <dd> - Sets the tags to use for this server, when registering with the the master server. This is only used - if master server communication is actually enabled. The tags consists of a comma-separated list of - single words. Each word must begin with a letter, and contain only letters, digits, or underscore - characters. For instance: <code>home,r6p1,linux,sweden,open</code>. - </dd> - <dt>-port=N</dt> - <dd> - Use the indicated port number, rather than the default. Note that ports below 1024 are generally - off-limits to ordinary users. Running Verse on such a port is not recommended. - </dd> - <dt>-version</dt> - <dd> - Prints the version string of the server to the terminal, and then exits (successfully). See - <a href="#rellab">below</a> for information how the version string is constructed. - </dd> -</dl> -<p> -For example, here is how to start the server, register it with the default master server, and run -on port number equal to 16333: -</p> -<pre class="shell">~> ./server -ms -port=16333 -</pre> -<p> -Here is a more complicated example, that uses an explicit master server address, and also sets both -the description and tags: -</p> -<pre class="shell">~> ./server -ms:ip=master.example.net -ms:de="A test server, for the documentation" -ms:ta=example,docs -</pre> -<p> -Options can occur in any order, with later options overriding earlier ones, in case of conflicts. -</p> - -<h1><a name="rellab">Release Labeling</a></h1> -<p> -Verse uses a simple two-level numbering scheme to identify releases. -There is a "release number", and a "patch level" on each release. The -intent is that within a release, the API does not change and neither -should the network protocol. Between releases, we might improve the -API which will require application programmers to update their code -to stay in sync. We can do non-API-altering changes within a release -by increasing the patch level, for bug fixing and other things. -</p> -<p> -The symbols <code>V_RELEASE_NUMBER</code> and <code>V_RELEASE_PATCH</code> -are integer literals that hold the values for the API you have, and can be -used (and displayed) in application source code as you see fit. There is -also a string, <code>V_RELEASE_LABEL</code>, which is sometimes used. -</p> -<p> -To form a complete Verse version number, the above-mentioned symbols are -to be combined like so: -"r<i><code><V_RELEASE_NUMBER></code></i>p<i><code><V_RELEASE_PATCH><V_RELEASE_LABEL></code></i>". -So, the following variable values: -<ul class="variables"> -<li>V_RELEASE_VERSION = 2 -<li>V_RELEASE_VERSION = 51 -<li>V_RELEASE_LABEL = "foo" -</ul> -Would generate the version string "<code>r2p51foo</code>". -</p> - -</body> -</html> diff --git a/extern/verse/dist/SConstruct b/extern/verse/dist/SConstruct deleted file mode 100644 index a80a1ac79e9..00000000000 --- a/extern/verse/dist/SConstruct +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env python -# -# I think it is quite straight-forward to add new platforms, -# just look at the old makefile and at the existing platforms. -# -# This SConstruct creates a configuration file which can be -# used for tweaking a build. -# -# For more about SConstruct, see <http://www.scons.org/>. -# - -import os -import os.path -import sys -import re -import time -import string -from distutils import sysconfig - -Import('env') - -defines = [] -cflags = [] -debug_flags = [] -extra_flags = [] -release_flags = [] -warn_flags = [] -platform_libs = [] -platform_libpath = [] -platform_linkflags = [] - -ourplatform = env['OURPLATFORM'] -if ourplatform == 'win32-vc': - print "Building on win32" - defines += ['_WIN32'] - warn_flags = ['/Wall'] - platform_libs = ['ws2_32'] -elif ourplatform == 'win32-mingw': - defines += ['_WIN32', 'WIN32'] - platform_libs = ['shell32', 'kernel32', 'gdi32', 'user32', 'ws2_32'] -elif ourplatform == 'linux2': - print "Building on linux2" -elif ourplatform == 'openbsd3': - print "Building on openbsd3" - -root_build_dir = env['BF_BUILDDIR'] - -if env['VERSE_BUILD_BINARY'] == 'release': - cflags = extra_flags + release_flags + warn_flags - if ourplatform == 'win32-vc': - defines += ['NDEBUG'] -else: - cflags = extra_flags + debug_flags + warn_flags - if ourplatform == 'win32-vc': - #defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib?? - platform_linkflags += ['/DEBUG','/PDB:verse.pdb'] - - -verse_env = env.Clone() - -cmd_gen_files = (['v_cmd_gen.c', - 'v_cmd_def_a.c', - 'v_cmd_def_b.c', - 'v_cmd_def_c.c', - 'v_cmd_def_g.c', - 'v_cmd_def_m.c', - 'v_cmd_def_o.c', - 'v_cmd_def_s.c', - 'v_cmd_def_t.c' - ]) - -cmd_gen_deps = (['v_gen_pack_init.c']) - -proto_env = env.Clone() -proto_env.Append(CPPDEFINES=['V_GENERATE_FUNC_MODE']) -mkprot_tool = proto_env.Program(target = 'mkprot', source = cmd_gen_files) - -mkprot_re = re.compile('v_cmd_def_([a-z]{1}).c') -def mkprot_emitter(target = None, source = None, env = None): - newtargets = list() - for s in source: - p, f = os.path.split(str(s)) - m = mkprot_re.match(f) - if m: - newtargets.append("v_gen_pack_"+m.group(1)+"_node.c") - newtargets.extend(['verse.h']) - env.Depends(newtargets, mkprot_tool) - return (newtargets, source) - -mkprot_bld = Builder(action = "\"" + mkprot_tool[0].abspath + "\" -src=\""+os.getcwd()+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\" -dst=\""+os.path.abspath(env['BF_BUILDDIR'])+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\"", - emitter = mkprot_emitter) - -verse_env['BUILDERS']['Protocol'] = mkprot_bld - -cmd_gen_deps.extend(verse_env.Protocol('do_mkprot', cmd_gen_files)) - -cmd_gen_deps.pop() - -lib_source_files = (['v_cmd_buf.c', - 'v_connect.c', - 'v_connection.c', - 'v_encryption.c', - 'v_func_storage.c', - 'v_man_pack_node.c', - 'v_network.c', - 'v_network_in_que.c', - 'v_network_out_que.c', - 'v_pack.c', - 'v_pack_method.c', - 'v_prime.c', - 'v_randgen.c', - 'v_util.c', - 'v_bignum.c', - 'verse_ms.c' - ]) -lib_source_files.extend(cmd_gen_deps) - -server_source_files = (['vs_connection.c', - 'vs_main.c', - 'vs_master.c', - 'vs_node_audio.c', - 'vs_node_bitmap.c', - 'vs_node_curve.c', - 'vs_node_geometry.c', - 'vs_node_head.c', - 'vs_node_material.c', - 'vs_node_object.c', - 'vs_node_particle.c', - 'vs_node_storage.c', - 'vs_node_text.c' - ]) - -verselib_env = verse_env.Clone() -verselib_env.Append(CPPDEFINES = defines) - -verseserver_env = verse_env.Clone() -verseserver_env.Append(CPPDEFINES = defines) -verseserver_env.Append (LIBPATH = ['.']) -verseserver_env.Append (LIBS= ['verse']) -verseserver_env.Append (LIBS= platform_libs) - -verselib_env.BlenderLib(libname='verse', sources=lib_source_files, includes=["."], defines = defines, libtype=['core', 'intern', 'player'], priority = [5, 5, 100]) -verseserver_env.BlenderProg(builddir="#"+root_build_dir+os.sep, progname='verse', sources=server_source_files, libs=[], -libpath='#'+env['BF_BUILDDIR']+'/lib') - - diff --git a/extern/verse/dist/examples/list-nodes.c b/extern/verse/dist/examples/list-nodes.c deleted file mode 100644 index 6c9cc000d7c..00000000000 --- a/extern/verse/dist/examples/list-nodes.c +++ /dev/null @@ -1,39 +0,0 @@ -/* A minimalist Verse example. Ask server for nodes, print information. */ - -#include <stdio.h> -#include <stdlib.h> - -#include "verse.h" /* Bring in the Verse API. */ - -/* A callback for connection acception: will be called when server accepts this client. */ -static void callback_accept_connect(void *user, uint32 avatar, void *address, void *connection, uint8 *host_id) -{ - uint32 i, mask = 0; - - printf("Connected to a Verse host!\n\nListing nodes:\n"); - - /* Build node subscription mask. */ - for(i = 0; i < V_NT_NUM_TYPES; i++) - mask |= 1 << i; - verse_send_node_index_subscribe(mask); /* Request listing of all nodes. */ -} - -/* A callback for node creation: is called to report information about existing nodes, too. */ -static void callback_node_create(void *user, VNodeID node_id, VNodeType type, VNodeOwner ownership) -{ - printf(" Node #%u has type %u\n", node_id, type); -} - -int main(void) -{ - /* Register callbacks for interesting commands. */ - verse_callback_set(verse_send_connect_accept, callback_accept_connect, NULL); - verse_callback_set(verse_send_node_create, callback_node_create, NULL); - - /* Kick off program by connecting to Verse host on local machine. */ - verse_send_connect("list-nodes", "<secret>", "localhost", NULL); - while(TRUE) - verse_callback_update(10000); /* Listen to network, get callbacks. */ - - return EXIT_SUCCESS; /* This is never reached. */ -} diff --git a/extern/verse/dist/mkprot_cmd/CMakeLists.txt b/extern/verse/dist/mkprot_cmd/CMakeLists.txt deleted file mode 100644 index f6e89f912e5..00000000000 --- a/extern/verse/dist/mkprot_cmd/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# $Id$ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2006, Blender Foundation -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): Jacques Beaurain. -# -# ***** END GPL LICENSE BLOCK ***** - -SET(SRC - ../v_cmd_gen.c - ../v_cmd_def_a.c - ../v_cmd_def_b.c - ../v_cmd_def_c.c - ../v_cmd_def_g.c - ../v_cmd_def_m.c - ../v_cmd_def_o.c - ../v_cmd_def_s.c - ../v_cmd_def_t.c -) - -ADD_DEFINITIONS(-DV_GENERATE_FUNC_MODE) -ADD_EXECUTABLE(mkprot ${SRC}) - -# Uncoment the following to get verse to generate the files using dependency -# tracking without having the generated files submitted in CVS. -# -#ADD_CUSTOM_COMMAND(TARGET mkprot -# POST_BUILD -# COMMAND mkprot -src=${CMAKE_CURRENT_SOURCE_DIR}/../ -dst=${CMAKE_CURRENT_SOURCE_DIR}/../ -# MAIN_DEPENDENCY ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/mkprot -# WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR} -#) -MESSAGE(STATUS "Configuring mkprot(verse)") - diff --git a/extern/verse/dist/resources/Makefile.win32 b/extern/verse/dist/resources/Makefile.win32 deleted file mode 100644 index 8e7b4a09bbd..00000000000 --- a/extern/verse/dist/resources/Makefile.win32 +++ /dev/null @@ -1,11 +0,0 @@ -# -# This builds a resource file for the Verse server, for the icon. -# - -ALL: verse.res - -verse.res: verse.rc - - -clean: - del *.res diff --git a/extern/verse/dist/resources/verse.ico b/extern/verse/dist/resources/verse.ico Binary files differdeleted file mode 100644 index b30f4c927ef..00000000000 --- a/extern/verse/dist/resources/verse.ico +++ /dev/null diff --git a/extern/verse/dist/resources/verse.rc b/extern/verse/dist/resources/verse.rc deleted file mode 100644 index a068a6f3e3e..00000000000 --- a/extern/verse/dist/resources/verse.rc +++ /dev/null @@ -1 +0,0 @@ -1 ICON verse.ico diff --git a/extern/verse/dist/resources/verse.res b/extern/verse/dist/resources/verse.res Binary files differdeleted file mode 100644 index ed4db6ca27f..00000000000 --- a/extern/verse/dist/resources/verse.res +++ /dev/null diff --git a/extern/verse/dist/v_bignum.c b/extern/verse/dist/v_bignum.c deleted file mode 100644 index 3f65af03427..00000000000 --- a/extern/verse/dist/v_bignum.c +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Routines for big (thousands of bits) unsigned integers, and - * doing simple maths operations on them. Written by Emil Brink. - * - * Part of the Verse core, see license details elsewhere. - * - * Bignums are represented as vectors of VBigDig (unsigned short), - * where the first element holds the length of the number in such - * digits. So a 32-bit number would be { 2, low, high }; digits are - * in little-endian format. - * - * Verse's uint16 and uint32 types are *not* used, since there is no - * need to limit the bits. If your machine has 32-bit shorts and 64- - * bit ints, this code should cope. - * - * By using unsigned shorts, which are assumed to be half the size of - * an unsigned int, we can easily do intermediary steps in int-sized - * variables, and thus get space for manual carry-management. - * - * This is the second incarnation of this code, the first one used - * a fixed 2,048-bit VBigNum structure passed by value. It had to be - * replaced since it was too weak for the desired functionality. Now, - * there's roughly 1,5 weeks of time gone into this code, which still - * means it's optimized for simplicity rather than speed. - * - * There has been neither time nor interest to meditate over FFTs and - * Karatsubas. Reasonable improvements are of course welcome, although - * this code *should* not be a bottleneck. Famous last words... - * - * In general, these routines do not do a lot of error checking, they - * assume you know what you're doing. Numbers must have >0 digits. - * Shifts should not be overly large (1e3 bits: safe, ~2e9+: avoid). -*/ - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_randgen.h" - -#include "v_bignum.h" - -#define MAX_DIG ((1UL << V_BIGBITS) - 1) - -/* ----------------------------------------------------------------------------------------- */ - -/* Some routines need temporary storage to hold a term or two (the multi- - * plier, for instance). Since we don't want to use malloc()/free(), let's - * just have a bunch of digits that it's possible to allocate from in a - * stack-like manner. -*/ -static VBigDig heap[2048 + 32]; -static unsigned int heap_pos; - -/* Allocate a number of <n> digits, returning it un-initialized. */ -static VBigDig * bignum_alloc(unsigned int n) -{ - VBigDig *y; - - if(heap_pos + n > sizeof heap / sizeof *heap) - { - printf("Out of memory in bignum heap -- unbalanced calls?\n"); - return NULL; - } - y = heap + heap_pos; - heap_pos += n + 1; - *y = n; - return y; -} - -/* Free a number previously allocated by bignum_allow() above. MUST match in sequences. */ -static void bignum_free(const VBigDig *x) -{ - heap_pos -= *x + 1; -} - -/* ----------------------------------------------------------------------------------------- */ - -/* Set x from bits. External representation is big-endian byte array. */ -void v_bignum_raw_import(VBigDig *x, const void *bits) -{ - const unsigned char *bytes = bits; - int i; - - for(i = *x++ - 1; i >= 0; i--) - { - x[i] = ((VBigDig) *bytes++) << 8; - x[i] |= *bytes++; - } -} - -/* Set bits to value of x. External representation is big-endian byte array. */ -void v_bignum_raw_export(const VBigDig *x, void *bits) -{ - unsigned char *bytes = bits; - int i; - - for(i = *x++ - 1; i >= 0; i--) - { - *bytes++ = x[i] >> 8; - *bytes++ = (unsigned char) x[i]; - } -} - -/* ----------------------------------------------------------------------------------------- */ - -/* Assigns x = 0. */ -void v_bignum_set_zero(VBigDig *x) -{ - memset(x + 1, 0, *x * sizeof *x); -} - -/* Assigns x = 1. */ -void v_bignum_set_one(VBigDig *x) -{ - int i; - - for(i = *x++ - 1, *x++ = 1; i > 0; i--) - *x++ = 0; -} - -/* Assigns x = y. */ -void v_bignum_set_digit(VBigDig *x, VBigDig y) -{ - v_bignum_set_zero(x); - x[1] = y; -} - -/* Assigns x = <string>, with string in decimal ASCII. Kind of slow. */ -void v_bignum_set_string(VBigDig *x, const char *string) -{ - unsigned int d; - - v_bignum_set_zero(x); - for(; *string && isdigit(*string); string++) - { - v_bignum_mul_digit(x, 10); - d = *string - '0'; - v_bignum_add_digit(x, d); - } -} - -/* Assigns x = <string>, with string in hexadecimal ASCII. */ -void v_bignum_set_string_hex(VBigDig *x, const char *string) -{ - unsigned int d; - - if(string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) - string += 2; - v_bignum_set_zero(x); - for(; *string && isxdigit(*string); string++) - { - v_bignum_bit_shift_left(x, 4); - d = tolower(*string) - '0'; - if(d > 9) - d -= ('a' - '0') - 10; - x[1] |= (d & 0xF); - } -} - -/* Performs x = y, taking care to handle different precisions correctly by truncating. */ -void v_bignum_set_bignum(VBigDig *x, const VBigDig *y) -{ - int xs, ys, i, s; - - xs = x[0]; - ys = y[0]; - if(xs == ys) /* For same sizes, just memcpy() and be done. */ - { - memcpy(x + 1, y + 1, xs * sizeof *x); - return; - } - else if(ys > xs) - s = xs; - else - s = ys; - /* Copy as many digits as will fit, and clear any remaining high digits. */ - for(i = 1; i <= s; i++) - x[i] = y[i]; - for(; i <= xs; i++) - x[i] = 0; -} - -/* Performs x = y[msb:msb-bits], right-adjusting the result. */ -void v_bignum_set_bignum_part(VBigDig *x, const VBigDig *y, unsigned int msb, unsigned int bits) -{ - unsigned int i, bit; - - v_bignum_set_zero(x); - if(y == NULL || msb > (y[0] * (CHAR_BIT * sizeof *x))) - return; - for(i = 0; i < bits; i++) - { - bit = msb - (bits - 1) + i; - if(v_bignum_bit_test(y, bit)) - v_bignum_bit_set(x, i); - } -} - -/* Set x to a random bunch of bits. Should use a real random source. */ -void v_bignum_set_random(VBigDig *x, VRandGen *gen) -{ - unsigned int s = *x++; - - if(gen != NULL) - v_randgen_get(gen, x, s * sizeof *x); - else - { - fprintf(stderr, "** Warning: Calling v_bignum_set_random() without VRandGen is potentially expensive\n"); - if((gen = v_randgen_new()) != NULL) - { - v_randgen_get(gen, x, s * sizeof *x); - v_randgen_destroy(gen); - } - else - fprintf(stderr, __FILE__ ": Couldn't create random number generator\n"); - } -} - -/* Print x in hexadecimal, with 0x prefix but no linefeed. */ -void v_bignum_print_hex(const VBigDig *x) -{ - int i, s = *x; - - printf("0x"); - for(i = 0; i < s; i++) - printf("%04X", x[s - i]); -} - -/* Print x in hexadecimal, with linefeed. */ -void v_bignum_print_hex_lf(const VBigDig *x) -{ - v_bignum_print_hex(x); - printf("\n"); -} - -/* ----------------------------------------------------------------------------------------- */ - -/* x = ~x. */ -void v_bignum_not(VBigDig *x) -{ - unsigned int i, s = *x++; - - for(i = 0; i < s; i++) - x[i] = ~x[i]; -} - -int v_bignum_bit_test(const VBigDig *x, unsigned int bit) -{ - unsigned int slot = bit / (CHAR_BIT * sizeof *x), m = 1 << (bit % (CHAR_BIT * sizeof *x)); - - if(slot < x[0]) - return (x[slot + 1] & m) != 0; - return 0; -} - -/* Compute x |= (1 << bit). */ -void v_bignum_bit_set(VBigDig *x, unsigned int bit) -{ - unsigned int slot, m; - - if(bit >= (*x * (CHAR_BIT * sizeof *x))) - return; - slot = bit / (CHAR_BIT * sizeof *x); - m = 1 << (bit % (CHAR_BIT * sizeof *x)); - x[1 + slot] |= m; -} - -/* Returns index of most signifant '1' bit of x, or -1 if x == 0. */ -int v_bignum_bit_msb(const VBigDig *x) -{ - int i; - unsigned int s = *x++; - - for(i = s - 1; i >= 0; i--) - { - if(x[i] != 0) - { - int bit = (i + 1) * (CHAR_BIT * sizeof *x) - 1; - VBigDig d = x[i], mask; - - for(mask = 1 << (CHAR_BIT * sizeof *x - 1); mask != 0; mask >>= 1, bit--) - { - if(d & mask) - return bit; - } - } - } - return -1; -} - -int v_bignum_bit_size(const VBigDig *x) -{ - return *x * V_BIGBITS; -} - -/* Perform x <<= count. */ -void v_bignum_bit_shift_left(VBigDig *x, unsigned int count) -{ - unsigned int t, carry, s = *x++; - register int i; - - if(count >= CHAR_BIT * sizeof *x) /* Shift whole digits. */ - { - unsigned int places = count / (CHAR_BIT * sizeof *x); - - for(i = s - 1; i >= (int) places; i--) - x[i] = x[i - places]; - for(; i >= 0; i--) /* Clear out the LSBs. */ - x[i] = 0; - count -= places * (CHAR_BIT * sizeof *x); - if(count == 0) - return; - } - /* Shift bits. */ - for(i = carry = 0; i < (int) s; i++) - { - t = (x[i] << count) | carry; - x[i] = t; - carry = t >> (CHAR_BIT * sizeof *x); - } -} - -/* Perform x <<= 1. This is a frequent operation so it can have its own function. */ -void v_bignum_bit_shift_left_1(VBigDig *x) -{ - register unsigned int t, carry, s = *x++, i; - - /* Shift bits. */ - for(i = carry = 0; i < s; i++) - { - t = (x[i] << 1) | carry; - x[i] = t; - carry = t >> (CHAR_BIT * sizeof *x); - } -} - -/* Perform x >>= count. */ -void v_bignum_bit_shift_right(VBigDig *x, unsigned int count) -{ - unsigned int t, carry, s = *x++; - int i; - - /* Shift entire digits first. */ - if(count >= CHAR_BIT * sizeof *x) - { - unsigned int places = count / (CHAR_BIT * sizeof *x); - - if(places > s) - { - memset(x, 0, s * sizeof *x); - return; - } - for(i = 0; i < (int) (s - places); i++) - x[i] = x[i + places]; - for(; i < (int) s; i++) - x[i] = 0; - count -= places * CHAR_BIT * sizeof *x; - if(count == 0) - return; - } - /* Shift any remaining bits. */ - for(i = s - 1, carry = 0; i >= 0; i--) - { - t = x[i] << (CHAR_BIT * sizeof *x); - t >>= count; - t |= carry; - carry = (t & MAX_DIG) << (CHAR_BIT * sizeof *x); - x[i] = t >> (CHAR_BIT * sizeof *x); - } -} - -/* ----------------------------------------------------------------------------------------- */ - -/* Return x == 0. */ -int v_bignum_eq_zero(const VBigDig *x) -{ - unsigned int i, s = *x++; - - for(i = 0; i < s; i++) - if(x[i]) - return 0; - return 1; -} - -/* Return x == 1. */ -int v_bignum_eq_one(const VBigDig *x) -{ - unsigned int i, s = *x++; - - if(x[0] != 1) - return 0; - for(i = 1; i < s; i++) - if(x[i]) - return 0; - return 1; -} - -/* Returns x == y, handling different lengths properly. */ -int v_bignum_eq(const VBigDig *x, const VBigDig *y) -{ - unsigned int i, xs, ys, cs; - - if(x == y) /* Quick test thanks to pointer representation. */ - return 1; - xs = *x++; - ys = *y++; - - if(xs == ys) /* Same size? Then let's be quick about this. */ - return memcmp(x, y, xs * sizeof *x) == 0; - else - { - cs = xs < ys ? xs : ys; /* Common size. */ - if(memcmp(x, y, cs * sizeof *x) == 0) - { - const VBigDig *l; - - if(cs == xs) /* y is longer. */ - l = y, i = ys - 1; - else - l = x, i = xs - 1; - for(; i > cs; i--) - if(l[i]) - return 0; - return 1; - } - } - return 0; -} - -/* Returns x >= y. */ -int v_bignum_gte(const VBigDig *x, const VBigDig *y) -{ - unsigned int xs, ys; - int i, j, k; - - if(x == y) - return 1; - /* Find indexes of highest-most used digit in each of the numbers. */ - xs = *x++; - ys = *y++; - for(i = xs - 1; i >= 0; i--) - if(x[i] != 0) - break; - for(j = ys - 1; j >= 0; j--) - if(y[j] != 0) - break; - /* Both zero? */ - if(i < 0 && j < 0) - return 1; - /* Quick answers exists for different-sized numbers. Find them. */ - if(i < j) - return 0; - if(i > j) - return 1; - /* Compare digit by digit. */ - for(k = i; k >= 0; k--) - { - if(x[k] < y[k]) - return 0; - if(x[k] > y[k]) - return 1; - } - return x[k] >= y[k]; -} - -/* ----------------------------------------------------------------------------------------- */ - -/* Computes x += y. */ -void v_bignum_add_digit(VBigDig *x, VBigDig y) -{ - unsigned int i, s = *x++, t; - - t = x[0] + y; - x[0] = t; - if(t > MAX_DIG) - { - for(i = 1; i < s; i++) - { - if(++x[i]) - break; - } - } -} - -/* Computes x -= y. */ -void v_bignum_sub_digit(VBigDig *x, VBigDig y) -{ - unsigned int i, s = *x++, t; - - t = x[0] - y; - x[0] = t; - if(t > MAX_DIG) - { - for(i = 1; i < s; i++) - { - x[i]--; - if(x[i] < MAX_DIG) - break; - } - } -} - -/* Computes x *= y. */ -void v_bignum_mul_digit(VBigDig *x, VBigDig y) -{ - unsigned int i, s = *x++, carry, t; - - for(i = carry = 0; i < s; i++) - { - t = x[i] * y + carry; - x[i] = t; - carry = t >> (CHAR_BIT * sizeof *x); - } -} - -/* ----------------------------------------------------------------------------------------- */ - -/* Computes x += y. */ -void v_bignum_add(VBigDig *x, const VBigDig *y) -{ - unsigned int i, xs = *x++, ys = *y++, s, carry, t; - - s = xs < ys ? xs : ys; - for(i = carry = 0; i < s; i++) - { - t = x[i] + y[i] + carry; - x[i] = t; - carry = t > MAX_DIG; - } - for(; carry && i < xs; i++) - { - t = x[i] + carry; - x[i] = t; - carry = t > MAX_DIG; - } -} - -/* Computes x -= y. */ -void v_bignum_sub(VBigDig *x, const VBigDig *y) -{ - unsigned int i, xs = *x++, ys = *y++, s, carry, t; - - if(x == y) - { - v_bignum_set_zero(x - 1); - return; - } - s = xs < ys ? xs : ys; - for(i = carry = 0; i < s; i++) - { - t = x[i] - y[i] - carry; - x[i] = t; - carry = t > MAX_DIG; - } - for(; carry && i < xs; i++) - { - t = x[i] - carry; - x[i] = t; - carry = t > MAX_DIG; - } -} - -/* Compute x *= y, using as many digits as is necessary, then truncating the - * result down. This is Algorithm 14.12 from "Handbook of Applied Cryptography". -*/ -void v_bignum_mul(VBigDig *x, const VBigDig *y) -{ - int n = *x, t = *y, i, j; - VBigDigs uv = 0, c, w[2048]; - - memset(w, 0, (n + t + 1) * sizeof *w); - for(i = 0; i < t; i++) - { - c = 0; - for(j = 0; j < n; j++) - { - uv = w[i + j] + x[1 + j] * y[1 + i] + c; - w[i + j] = uv & ((1 << V_BIGBITS) - 1); - c = uv >> V_BIGBITS; - } - w[i + n + 1] = uv >> V_BIGBITS; - } - /* Write low words of w back into x. */ - for(i = 0; i < *x; i++) - x[1 + i] = w[i]; -} - -/* Computes x /= y and remainder = x % y. */ -void v_bignum_div(VBigDig *x, const VBigDig *y, VBigDig *remainder) -{ - VBigDig *q, *work; - int msbx = v_bignum_bit_msb(x), msby = v_bignum_bit_msb(y), next; - - /* Compare magnitudes of inputs, allows quick exits. */ - if(msby > msbx) - { - if(remainder != NULL) - v_bignum_set_bignum(remainder, x); - v_bignum_set_zero(x); - return; - } - if(msby < 0) - { - v_bignum_set_zero(x); - return; - } - q = bignum_alloc(*x); - v_bignum_set_zero(q); - work = bignum_alloc(*x); - v_bignum_set_bignum_part(work, x, msbx, msby + 1); - - for(next = msbx - (msby + 1); next >= -1; next--) - { - v_bignum_bit_shift_left_1(q); - if(v_bignum_gte(work, y)) - { - q[1] |= 1; - v_bignum_sub(work, y); - } - v_bignum_bit_shift_left_1(work); - if(v_bignum_bit_test(x, next)) - work[1] |= 1; - } - v_bignum_bit_shift_right(work, 1); /* Undo the last shift (when next==-1). */ - - if(remainder != NULL) - { -/* printf("div() got remainder "); - v_bignum_print_hex_lf(work); -*/ - v_bignum_set_bignum(remainder, work); - } - bignum_free(work); - v_bignum_set_bignum(x, q); - bignum_free(q); -} - -/* Computes x %= y. */ -void v_bignum_mod(VBigDig *x, const VBigDig *y) -{ - int digs; - VBigDig *tmp; - -/* printf("computing "); - v_bignum_print_hex(x); - printf("L %% "); - v_bignum_print_hex(y); -*/ - digs = *x > *y ? *x : *y; - tmp = bignum_alloc(digs); - v_bignum_div(x, y, tmp); - v_bignum_set_bignum(x, tmp); - bignum_free(tmp); -/* printf("L = "); - v_bignum_print_hex_lf(x); -*/ -} - -/* Initialize Barrett reduction by computing the "mu" helper value. Defined in - * Handbook of Applied Cryptography algorithm 14.42 as floor(b^2k / m). -*/ -const VBigDig * v_bignum_reduce_begin(const VBigDig *m) -{ - VBigDig *mu; - int k; - - for(k = *m; m[k] == 0; k--) - ; -/* printf("k=%d -> digits are 0..%u\n", k, k - 1); - printf("computing mu=floor(65536^%d/", 2 * k); - v_bignum_print_hex(m); - printf(")\n"); -*/ mu = bignum_alloc(2 * k + 1); - /* b ^ 2k is just 65536 << 2k, i.e. set bit 16 * 2k. */ - v_bignum_set_zero(mu); - v_bignum_bit_set(mu, V_BIGBITS * 2 * k); -/* v_bignum_print_hex_lf(mu);*/ - v_bignum_div(mu, m, NULL); - - return mu; -} - -void v_bignum_reduce_end(const VBigDig *mu) -{ - bignum_free(mu); -} - -/* Compute x % m, using mu as the helper quantity mu, precomputed by the - * routine above. -*/ -void v_bignum_reduce(VBigDig *x, const VBigDig *m, const VBigDig *mu) -{ - VBigDig *q, *r1, *r2, *r; - int i, k; - - for(k = *m; m[k] == 0; k--) - ; - /* Step 1, compute the q helper. */ - q = bignum_alloc(*x + *mu - (k - 1)); /* Tighter bound number length (was 2 * *x). */ - v_bignum_set_bignum(q, x); - v_bignum_bit_shift_right(q, V_BIGBITS * (k - 1)); - v_bignum_mul(q, mu); - v_bignum_bit_shift_right(q, V_BIGBITS * (k + 1)); - - /* Step 2, initialize. */ - r1 = bignum_alloc(*x); - r2 = bignum_alloc(*x); - v_bignum_set_bignum(r1, x); - for(i = k + 1; i < *r1; i++) - r1[i + 1] = 0; - v_bignum_set_bignum(r2, q); - v_bignum_mul(r2, m); - for(i = k + 1; i < *r2; i++) - r2[i + 1] = 0; - r = x; - v_bignum_set_bignum(r, r1); - v_bignum_sub(r, r2); - /* Step 3, make sure r is positive. */ - if(v_bignum_bit_test(r, V_BIGBITS * *r - 1)) - { - VBigDig *term; - - term = bignum_alloc(k + 1 * V_BIGBITS); - v_bignum_set_zero(term); - v_bignum_bit_set(term, V_BIGBITS * (k + 1)); - v_bignum_add(r, term); - bignum_free(term); - } - /* Step 4, loop. */ - while(v_bignum_gte(r, m)) - v_bignum_sub(r, m); - - bignum_free(r2); - bignum_free(r1); - bignum_free(q); -} - -/* Compute x * x using the algorithm 14.16 from "Handbook of Applied Cryptography". - * Note that since 'w' needs to be double-precision (i.e., 32-bit), we cannot allocate - * it using bignum_alloc() cleanly. Thus the static limit, which should be enough here. - * NOTE: This very much assumes V_BIGBITS == 16. -*/ -void v_bignum_square_half(VBigDig *x) -{ - VBigDigs w[256], uv, c, ouv; - int t = *x / 2, i, j, high; - - if(t == 0) - return; - for(; x[t] == 0; t--) - ; - memset(w, 0, 2 * t * sizeof *w); /* Clear digits of w. */ -/* printf("print %lu, ", ++count); - v_bignum_print_hex(x); - printf("*"); - v_bignum_print_hex(x); -*/ for(i = 0; i < t; i++) - { -/* printf("computing w[%d]: %lX + %lX * %lX\n", 2 * i, w[2 * i], x[1 + i], x[1 + i]);*/ - uv = w[2 * i] + x[1 + i] * x[1 + i]; -/* printf("setting w[%d]=%X [before]\n", 2 * i, uv & 0xffff);*/ - w[2 * i] = uv & 0xffff; - c = uv >> V_BIGBITS; -/* printf("uv before=%X, c=%X\n", uv, c);*/ - high = 0; - for(j = i + 1; j < t; j++) - { -/* printf("computing uv=%X+2*%X*%X+%X\n", w[i + j], x[1 + j], x[1 + i], c);*/ - uv = ((VBigDigs)x[1 + j]) * ((VBigDigs)x[1 + i]); - high = (uv & 0x80000000) != 0; - uv *= 2; - ouv = uv; /* Addition below might wrap and generate high bit. */ - uv += w[i + j] + c; -/* printf("ouv=0x%lX uv=0x%lX\n", ouv, uv);*/ - high |= uv < ouv; -/* printf("setting w[%d]=%lX [inner] uv=%lX high=%d c=%X\n", i + j, uv & 0xffff, uv, high, c);*/ - w[i + j] = uv & 0xffff; - c = (uv >> V_BIGBITS) | (high << V_BIGBITS); - } -/* printf("setting w[%d] to %X [after]\n", i + t, (uv >> 16) | (high << 16));*/ - w[i + t] = (uv >> V_BIGBITS) | (high << V_BIGBITS); - } -/* printf("w=0x"); - for(i = *x - 1; i >= 0; i--) - printf("%04X.", w[i]); - printf("\n"); -*/ /* Write low words of w back into x, trashing it with the square. */ - for(i = 0; i < 2 * t; i++) - x[1 + i] = w[i]; - for(; i < *x; i++) - x[1 + i] = 0; -/* printf("=="); - v_bignum_print_hex_lf(x); -*/ -} - -/* Computes x = (x^y) % n, where ^ denotes exponentiation. */ -void v_bignum_pow_mod(VBigDig *x, const VBigDig *y, const VBigDig *n) -{ - VBigDig *tmp; - const VBigDig *mu; - int i, k; - -/* printf("computing pow("); - v_bignum_print_hex(x); - printf("L,"); - v_bignum_print_hex(y); - printf("L,"); - v_bignum_print_hex(n); - printf("L)\n"); -*/ - tmp = bignum_alloc(2 * *x); /* Squaring needs twice the bits, or lossage occurs. */ - v_bignum_set_bignum(tmp, x); - k = v_bignum_bit_msb(y); - mu = v_bignum_reduce_begin(n); - for(i = k - 1; i >= 0; i--) - { - v_bignum_square_half(tmp); - v_bignum_reduce(tmp, n, mu); - if(v_bignum_bit_test(y, i)) - { - v_bignum_mul(tmp, x); - v_bignum_reduce(tmp, n, mu); - } - } - v_bignum_set_bignum(x, tmp); - v_bignum_reduce_end(mu); - bignum_free(tmp); -} - -/* ----------------------------------------------------------------------------------------- */ - -#if defined STANDALONE - -int main(void) -{ - VBigDig VBIGNUM(x, 3648), VBIGNUM(y, 128), VBIGNUM(z, 128); - - printf("MAX_DIG=%u\n", MAX_DIG); - - v_bignum_set_string_hex(x, "0x433864FE0F8FAC180FF1BC3A5BFD0C5566F6B11679E27294EDCC43056EB73EE118415E0CD6E6519509476EB21341ED0328BA7B14E0ED80D5E100A4549C5202B57B4CF17A74987631B6BA896C0DBA2095A7EDE5B9C4B4EEFCD1B9EF8474BCB7FBD0F64B549625D444847ED1FCB7F8050EB4F22794F694A0FAC6DFFB781C264B227966840185F9216484F6A7954741CB11FC14DEC2937EAD2CE640FD9A4339706BDB5BC355079C2F2F7994669DFA5B20C50D957A676E67C86835037078323A0BDAD3686B8E638749F327A7AD433C0D18BCD2FC970D125914C7FBEE061290A0F0F3572E207"); - v_bignum_set_bignum(y, x); - v_bignum_set_digit(z, 77); - - printf("x:"); - v_bignum_print_hex_lf(x); - printf("y:"); - v_bignum_print_hex_lf(y); - printf("r:"); - v_bignum_print_hex_lf(z); - v_bignum_pow_mod(x, y, z); - printf(" ="); - v_bignum_print_hex_lf(x); - - return 0; -} - -#endif /* STANDALONE */ diff --git a/extern/verse/dist/v_bignum.h b/extern/verse/dist/v_bignum.h deleted file mode 100644 index 06e58844452..00000000000 --- a/extern/verse/dist/v_bignum.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Verse routines for big integer operations. - * Handy in heavy encryption done during connect. -*/ - -#include <limits.h> - -#include "v_randgen.h" - -/* ----------------------------------------------------------------------------------------- */ - -typedef unsigned short VBigDig; /* Type used to hold one digit of a bignum. */ -typedef unsigned int VBigDigs; /* Should hold precisely two digits. */ - -#define V_BIGBITS (CHAR_BIT * sizeof (VBigDig)) - -/* Use this macro to initialize big number variables, like so: - * VBigDig BIGNUM(foo, 128), BIGNUM(bar, 256); - * Creates automatic variables 'foo' of 128 bits, and 'bar' of 256. - * - * Note that 'bits' must be a multiple of V_BIGBITS, completely - * arbitrary number sizes are not supported by this module. -*/ -#define VBIGNUM(n, bits) n[1 + (bits / V_BIGBITS)] = { bits / V_BIGBITS } - -/* ----------------------------------------------------------------------------------------- */ - -/* Import/export numbers from raw bits. The number x must have been allocated - * with the desired number of bits to read/write. -*/ -extern void v_bignum_raw_import(VBigDig *x, const void *bits); -extern void v_bignum_raw_export(const VBigDig *x, void *bits); - -/* Initializers. */ -extern void v_bignum_set_zero(VBigDig *x); -extern void v_bignum_set_one(VBigDig *x); -extern void v_bignum_set_digit(VBigDig *x, VBigDig y); -extern void v_bignum_set_string(VBigDig *x, const char *string); /* Decimal. */ -extern void v_bignum_set_string_hex(VBigDig *x, const char *string); -extern void v_bignum_set_bignum(VBigDig *x, const VBigDig *y); -/* x = <bits> most significant <bits> bits of <y>, starting at <msb>. Right- - * adjusted in x, so that e.g. y=0xcafebabec001 msb=47 bits=16 gives x=0xcafe. -*/ -extern void v_bignum_set_bignum_part(VBigDig *x, const VBigDig *y, - unsigned int msb, unsigned int bits); -extern void v_bignum_set_random(VBigDig *x, VRandGen *gen); - -/* Handy during debugging. */ -extern void v_bignum_print_hex(const VBigDig *x); -extern void v_bignum_print_hex_lf(const VBigDig *x); - -/* Bit operators. */ -extern void v_bignum_not(VBigDig *x); -extern int v_bignum_bit_test(const VBigDig *x, unsigned int bit); -extern void v_bignum_bit_set(VBigDig *x, unsigned int bit); -extern int v_bignum_bit_msb(const VBigDig *x); -extern int v_bignum_bit_size(const VBigDig *x); -extern void v_bignum_bit_shift_left(VBigDig *x, unsigned int count); -extern void v_bignum_bit_shift_left_1(VBigDig *x); -extern void v_bignum_bit_shift_right(VBigDig *x, unsigned int count); - -/* Comparators. */ -extern int v_bignum_eq_zero(const VBigDig *x); /* x == 0. */ -extern int v_bignum_eq_one(const VBigDig *x); /* x == 1. */ -extern int v_bignum_eq(const VBigDig *x, const VBigDig *y); /* x == y. */ -extern int v_bignum_gte(const VBigDig *x, const VBigDig *y); /* x >= y. */ - -/* Number vs single-digit arithmetic. */ -extern void v_bignum_add_digit(VBigDig *x, VBigDig y); /* x += y. */ -extern void v_bignum_sub_digit(VBigDig *x, VBigDig y); /* x -= y. */ -extern void v_bignum_mul_digit(VBigDig *x, VBigDig y); /* x *= y. */ - -/* Arithmetic. */ -extern void v_bignum_add(VBigDig *x, const VBigDig *y); /* x += y. */ -extern void v_bignum_sub(VBigDig *x, const VBigDig *y); /* x -= y. */ -extern void v_bignum_mul(VBigDig *x, const VBigDig *y); /* x *= y. */ -extern void v_bignum_div(VBigDig *x, const VBigDig *y, VBigDig *remainder); -extern void v_bignum_mod(VBigDig *x, const VBigDig *y); /* x %= y. */ - -/* Barrett reducer for fast x % m computation. Requires precalcing step. */ -extern const VBigDig * v_bignum_reduce_begin(const VBigDig *m); -extern void v_bignum_reduce(VBigDig *x, const VBigDig *m, const VBigDig *mu); -extern void v_bignum_reduce_end(const VBigDig *mu); - -/* Compute x *= x, assuming x only uses half of its actual size. */ -extern void v_bignum_square_half(VBigDig *x); - -/* Compute pow(x, y, n) == (x raised to the y:th power) modulo n. */ -extern void v_bignum_pow_mod(VBigDig *x, const VBigDig *y, const VBigDig *n); diff --git a/extern/verse/dist/v_cmd_buf.c b/extern/verse/dist/v_cmd_buf.c deleted file mode 100644 index b7faf227352..00000000000 --- a/extern/verse/dist/v_cmd_buf.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "verse_header.h" -#include "v_pack.h" -#include "v_cmd_buf.h" - -static const size_t vcmdbuf_chunk_size[] = { 10000, 10000, 10000, 10000, 8000, 5000, 500 }; /* If you think memory is cheap, set this to a high value. */ - -/* Sizes of individual command buffers, indexable by VCMDBufSize values. Switch-killer. */ -static const size_t vcmdbuf_size[] = { - sizeof (VCMDBuffer10), sizeof (VCMDBuffer20), sizeof (VCMDBuffer30), sizeof (VCMDBuffer80), - sizeof (VCMDBuffer160), sizeof (VCMDBuffer320), sizeof (VCMDBuffer1500) -}; - -#define VCMDBUF_INIT_CHUNK_FACTOR 0.5 - -static struct { - VCMDBufHead *buffers[VCMDBS_COUNT]; - unsigned int available[VCMDBS_COUNT]; -} VCMDBufData; - -static boolean v_cmd_buf_initialized = FALSE; - -void cmd_buf_init(void) -{ - unsigned int i, j; - VCMDBufHead *buf, *b; - - for(i = 0; i < VCMDBS_COUNT; i++) - { - VCMDBufData.buffers[i] = NULL; - VCMDBufData.available[i] = (unsigned int) (vcmdbuf_chunk_size[i] * VCMDBUF_INIT_CHUNK_FACTOR); - for(j = 0, buf = NULL; j < VCMDBufData.available[i]; j++, buf = b) - { - b = v_cmd_buf_allocate(i); - b->next = buf; - } - VCMDBufData.buffers[i] = buf; - } - v_cmd_buf_initialized = TRUE; -} - -VCMDBufHead * v_cmd_buf_allocate(VCMDBufSize buf_size) -{ - VCMDBufHead *output = NULL; - - if(VCMDBufData.buffers[buf_size] != NULL) - { - output = VCMDBufData.buffers[buf_size]; - VCMDBufData.buffers[buf_size] = output->next; - VCMDBufData.available[buf_size]--; - } - else - { - if(buf_size < sizeof vcmdbuf_size / sizeof *vcmdbuf_size) - output = malloc(vcmdbuf_size[buf_size]); - else - { - fprintf(stderr, "v_cmd_buf.c: Can't handle buffer size %d\n", buf_size); - return NULL; - } - output->buf_size = buf_size; - } - output->next = NULL; - output->packet = 0; - output->size = 0; - output->address_size = -1; - return output; -} - -void v_cmd_buf_free(VCMDBufHead *head) -{ - if(VCMDBufData.available[head->buf_size] < vcmdbuf_chunk_size[head->buf_size]) - { - head->next = VCMDBufData.buffers[head->buf_size]; - VCMDBufData.buffers[head->buf_size] = head; - VCMDBufData.available[head->buf_size]++; - } - else - free(head); -} - -void v_cmd_buf_set_size(VCMDBufHead *head, unsigned int size) -{ - head->size = size; -} - -void v_cmd_buf_set_address_size(VCMDBufHead *head, unsigned int size) -{ - unsigned int i; - - head->address_size = size; - head->address_sum = 0; - for(i = 1; i < size + 1; i++) - head->address_sum += i * i * (uint32)(((VCMDBuffer1500 *)head)->buf[i - 1]); -} - -void v_cmd_buf_set_unique_address_size(VCMDBufHead *head, unsigned int size) -{ - static unsigned int i = 0; - - head->address_size = size; - head->address_sum = i++; -} - -boolean v_cmd_buf_compare(VCMDBufHead *a, VCMDBufHead *b) -{ - if(a->address_sum != b->address_sum) - return FALSE; - if(a->address_size != b->address_size) - return FALSE; - return memcmp(((VCMDBuffer1500 *)a)->buf, ((VCMDBuffer1500 *)b)->buf, a->address_size) == 0; -} diff --git a/extern/verse/dist/v_cmd_buf.h b/extern/verse/dist/v_cmd_buf.h deleted file mode 100644 index 6eda7640bb1..00000000000 --- a/extern/verse/dist/v_cmd_buf.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** -*/ - -#include <stdlib.h> - -#include "verse_header.h" -#include "v_pack.h" - -#define V_NOQ_MAX_PACKET_SIZE 1500 - -typedef enum { - VCMDBS_10 = 0, - VCMDBS_20 = 1, - VCMDBS_30 = 2, - VCMDBS_80 = 3, - VCMDBS_160 = 4, - VCMDBS_320 = 5, - VCMDBS_1500 = 6, - VCMDBS_COUNT = 7 -} VCMDBufSize; - -typedef struct { - void *next; - uint32 packet; - unsigned int address_size; - unsigned int address_sum; - VCMDBufSize buf_size; - unsigned int size; -} VCMDBufHead; - -typedef struct { - VCMDBufHead head; - uint8 buf[10]; -} VCMDBuffer10; - -typedef struct { - VCMDBufHead head; - uint8 buf[20]; -} VCMDBuffer20; - -typedef struct { - VCMDBufHead head; - uint8 buf[30]; -} VCMDBuffer30; - -typedef struct { - VCMDBufHead head; - uint8 buf[80]; -} VCMDBuffer80; - -typedef struct { - VCMDBufHead head; - uint8 buf[160]; -} VCMDBuffer160; - -typedef struct { - VCMDBufHead head; - uint8 buf[320]; -} VCMDBuffer320; - - -typedef struct { - VCMDBufHead head; - uint8 buf[1500]; -} VCMDBuffer1500; - -extern VCMDBufHead *v_cmd_buf_allocate(VCMDBufSize buf_size); -extern void v_cmd_buf_free(VCMDBufHead *head); - -extern void v_cmd_buf_set_size(VCMDBufHead *head, unsigned int size); -extern void v_cmd_buf_set_address_size(VCMDBufHead *head, unsigned int size); -extern void v_cmd_buf_set_unique_address_size(VCMDBufHead *head, unsigned int size); -extern boolean v_cmd_buf_compare(VCMDBufHead *a, VCMDBufHead *b); diff --git a/extern/verse/dist/v_cmd_def_a.c b/extern/verse/dist/v_cmd_def_a.c deleted file mode 100644 index 8557601428b..00000000000 --- a/extern/verse/dist/v_cmd_def_a.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Command definitions for audio node commands. -*/ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_audio_cmd_def(void) -{ - v_cg_new_cmd(V_NT_AUDIO, "a_buffer_create", 160, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_BUFFER_ID, "buffer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_add_param(VCGP_ENUM_NAME, "VNABlockType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_REAL64, "frequency"); - v_cg_alias(FALSE, "a_buffer_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_AUDIO, "a_buffer_subscribe", 161, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_BUFFER_ID, "layer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "a_buffer_unsubscribe", NULL, 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_AUDIO, "a_block_set", 162, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "buffer_id"); - v_cg_add_param(VCGP_UINT32, "block_index"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_ENUM_NAME, "VNABlockType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNABlock"); - v_cg_add_param(VCGP_POINTER, "samples"); - - v_cg_add_param(VCGP_PACK_INLINE, "\tbuffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);\n"); - - v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(type <= VN_A_BLOCK_REAL64)\n\t{\n" - "\t\tVNABlock\tblock;\n" - "\t\tbuffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);\n" - "\t\tif(func_a_block_set != NULL)\n" - "\t\t\tfunc_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, &block);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_alias(FALSE, "a_block_clear", "if(type > VN_A_BLOCK_REAL64)", 3, NULL); - v_cg_end_cmd(); - - - v_cg_new_cmd(V_NT_AUDIO, "a_stream_create", 163, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "stream_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_alias(FALSE, "a_stream_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_AUDIO, "a_stream_subscribe", 164, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "stream_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "a_stream_unsubscribe", NULL, 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_AUDIO, "a_stream", 165, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "stream_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "time_s"); - v_cg_add_param(VCGP_UINT32, "time_f"); - v_cg_add_param(VCGP_ENUM_NAME, "VNABlockType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_REAL64, "frequency"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNABlock"); - v_cg_add_param(VCGP_POINTER, "samples"); - - v_cg_add_param(VCGP_PACK_INLINE, "\tbuffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);\n"); - - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n\t\tVNABlock\tblock;\n\tbuffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);\n" - "\t\tif(func_a_stream != NULL)\n" - "\t\t\tfunc_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, &block);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - - v_cg_end_cmd(); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_b.c b/extern/verse/dist/v_cmd_def_b.c deleted file mode 100644 index b266b03648c..00000000000 --- a/extern/verse/dist/v_cmd_def_b.c +++ /dev/null @@ -1,44 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> - -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_bitmap_cmd_def(void) -{ - v_cg_new_cmd(V_NT_BITMAP, "b_dimensions_set", 80, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT16, "width"); - v_cg_add_param(VCGP_UINT16, "height"); - v_cg_add_param(VCGP_UINT16, "depth"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_BITMAP, "b_layer_create", 81, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_add_param(VCGP_ENUM_NAME, "VNBLayerType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_alias(FALSE, "b_layer_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_BITMAP, "b_layer_subscribe", 82, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT8, "level"); - v_cg_alias(FALSE, "b_layer_unsubscribe", "if(level == 255)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_manual_cmd(83, "b_tile_set", "void verse_send_b_tile_set(VNodeID node_id, VLayerID layer_id, " - "uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile)", - NULL, NULL); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_c.c b/extern/verse/dist/v_cmd_def_c.c deleted file mode 100644 index 317b45e1a27..00000000000 --- a/extern/verse/dist/v_cmd_def_c.c +++ /dev/null @@ -1,35 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_curve_cmd_def(void) -{ - v_cg_new_cmd(V_NT_CURVE, "c_curve_create", 128, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "curve_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_add_param(VCGP_UINT8, "dimensions"); - v_cg_alias(FALSE, "c_curve_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_CURVE, "c_curve_subscribe", 129, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "curve_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "c_curve_unsubscribe", "if(!alias_bool)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_manual_cmd(130, "c_key_set", "void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, " - "uint32 key_id, uint8 dimensions, const real64 *pre_value, const uint32 *pre_pos, " - "const real64 *value, real64 pos, const real64 *post_value, const uint32 *post_pos)", - "c_key_destroy", "void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, " - "uint32 key_id)"); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_g.c b/extern/verse/dist/v_cmd_def_g.c deleted file mode 100644 index 5a4ea7202b4..00000000000 --- a/extern/verse/dist/v_cmd_def_g.c +++ /dev/null @@ -1,183 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_geometry_cmd_def(void) -{ - unsigned int order[] = { 0, 2 }; - - v_cg_new_cmd(V_NT_GEOMETRY, "g_layer_create", 48, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_add_param(VCGP_ENUM_NAME, "VNGLayerType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_UINT32, "def_uint"); - v_cg_add_param(VCGP_REAL64, "def_real"); - v_cg_alias(FALSE, "g_layer_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_layer_subscribe", 49, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_ENUM_NAME, "VNRealFormat"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_alias(FALSE, "g_layer_unsubscribe", "if(type > VN_FORMAT_REAL64)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_xyz_real32", 50, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "vertex_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL32, "x"); - v_cg_add_param(VCGP_REAL32, "y"); - v_cg_add_param(VCGP_REAL32, "z"); - v_cg_alias(FALSE, "g_vertex_delete_real32", "if(x == V_REAL32_MAX || y == V_REAL32_MAX || z == V_REAL32_MAX)", 2, order); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_xyz_real64", 51, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "vertex_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL64, "x"); - v_cg_add_param(VCGP_REAL64, "y"); - v_cg_add_param(VCGP_REAL64, "z"); - v_cg_alias(FALSE, "g_vertex_delete_real64", "if(x == V_REAL64_MAX || y == V_REAL64_MAX || z == V_REAL64_MAX)", 2, order); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_uint32", 52, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "vertex_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "value"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_real64", 53, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "vertex_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL64, "value"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_set_real32", 54, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "vertex_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL32, "value"); - v_cg_end_cmd(); -/* - v_cg_new_cmd(V_NT_GEOMETRY, "g_vertex_delete", VCGCT_NORMAL); - v_cg_add_param(VCGP_UINT32, "vertex_id"); - v_cg_end_cmd(); -*/ - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_corner_uint32", 55, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "v0"); - v_cg_add_param(VCGP_UINT32, "v1"); - v_cg_add_param(VCGP_UINT32, "v2"); - v_cg_add_param(VCGP_UINT32, "v3"); - v_cg_alias(FALSE, "g_polygon_delete", "if(layer_id == 1 && v0 == ~0u)", 2, order); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_corner_real64", 56, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL64, "v0"); - v_cg_add_param(VCGP_REAL64, "v1"); - v_cg_add_param(VCGP_REAL64, "v2"); - v_cg_add_param(VCGP_REAL64, "v3"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_corner_real32", 57, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL32, "v0"); - v_cg_add_param(VCGP_REAL32, "v1"); - v_cg_add_param(VCGP_REAL32, "v2"); - v_cg_add_param(VCGP_REAL32, "v3"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_uint8", 58, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT8, "value"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_uint32", 59, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "value"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_real64", 60, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL64, "value"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_polygon_set_face_real32", 61, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_LAYER_ID, "layer_id"); - v_cg_add_param(VCGP_UINT32, "polygon_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL32, "value"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_crease_set_vertex", 62, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "layer"); - v_cg_add_param(VCGP_UINT32, "def_crease"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_crease_set_edge", 63, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "layer"); - v_cg_add_param(VCGP_UINT32, "def_crease"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_GEOMETRY, "g_bone_create", 64, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "bone_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "weight"); - v_cg_add_param(VCGP_NAME, "reference"); - v_cg_add_param(VCGP_UINT16, "parent"); - v_cg_add_param(VCGP_REAL64, "pos_x"); - v_cg_add_param(VCGP_REAL64, "pos_y"); - v_cg_add_param(VCGP_REAL64, "pos_z"); - v_cg_add_param(VCGP_NAME, "position_label"); - v_cg_add_param(VCGP_NAME, "rotation_label"); - v_cg_add_param(VCGP_NAME, "scale_label"); - v_cg_alias(FALSE, "g_bone_destroy", "if(weight[0] == 0)", 2, NULL); - - v_cg_end_cmd(); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_m.c b/extern/verse/dist/v_cmd_def_m.c deleted file mode 100644 index 3f4b9aa7178..00000000000 --- a/extern/verse/dist/v_cmd_def_m.c +++ /dev/null @@ -1,273 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_material_cmd_def(void) -{ - v_cg_new_cmd(V_NT_MATERIAL, "m_fragment_create", 68, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_FRAGMENT_ID, "frag_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_ENUM_NAME, "VNMFragmentType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_POINTER_TYPE, "VMatFrag"); - v_cg_add_param(VCGP_POINTER, "fragment"); - - v_cg_add_param(VCGP_PACK_INLINE, "\tswitch(type)\n" - "\t{\n" - "\tcase VN_M_FT_COLOR :\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.red);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.green);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.blue);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_LIGHT :\n" - "\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->light.type);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->light.normal_falloff);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->light.brdf);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_r, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_g, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_b, 16);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_REFLECTION :\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->reflection.normal_falloff);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_TRANSPARENCY :\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.normal_falloff);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.refraction_index);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_GEOMETRY :\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_r, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_g, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_b, 16);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_VOLUME :\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.diffusion);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_r);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_g);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_b);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_VIEW :\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_TEXTURE :\n" - "\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->texture.bitmap);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_r, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_g, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_b, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->texture.filtered);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->texture.mapping);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_NOISE :\n" - "\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->noise.type);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->noise.mapping);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_BLENDER :\n" - "\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->blender.type);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_a);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_b);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.control);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_CLAMP :\n" - "\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->clamp.min);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.red);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.green);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.blue);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->clamp.data);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_MATRIX :\n" - "\t\t{\n" - "\t\t\tunsigned int i;\n" - "\t\t\tfor(i = 0; i < 16; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->matrix.matrix[i]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->matrix.data);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_RAMP :\n" - "\t\tif(fragment->ramp.point_count == 0)\n" - "\t\t\treturn;\n" - "\t\t{\n" - "\t\t\tunsigned int i, pos;\n" - "\t\t\tdouble last;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.type);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.channel);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->ramp.mapping);\n" - "\t\t\tpos = buffer_pos;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], fragment->ramp.point_count);\n" - "\t\t\tlast = fragment->ramp.ramp[0].pos - 1;\n" - "\t\t\tfor(i = 0; i < fragment->ramp.point_count && fragment->ramp.ramp[i].pos > last && i < 48; i++)\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].pos);\n" - "\t\t\t\tlast = fragment->ramp.ramp[i].pos;\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].red);\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].green);\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].blue);\n" - "\t\t\t}\n\t\t\tif(i != fragment->ramp.point_count)\n" - "\t\t\t\tvnp_raw_pack_uint8(&buf[pos], i);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_ANIMATION :\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->animation.label, 16);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_ALTERNATIVE :\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_a);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_b);\n" - "\t\tbreak;\n" - "\tcase VN_M_FT_OUTPUT :\n" - "\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->output.label, 16);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.front);\n" - "\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.back);\n" - "\t\tbreak;\n" - "\t}\n"); - - v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(type <= VN_M_FT_OUTPUT)\n" - "\t{\n" - "\t\tVMatFrag frag;\n" - "\t\tuint8 temp;\n" - "\t\tswitch(type)\n" - "\t\t{\n" - "\t\tcase VN_M_FT_COLOR :\n" - "\t\t\tif(buffer_pos + 3 * 8 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.red);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.green);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.blue);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_LIGHT :\n" - "\t\t\tif(buffer_pos + 13 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\tfrag.light.type = (VNMLightType)temp;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.light.normal_falloff);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.light.brdf);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_r, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_g, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_b, 16, buffer_length - buffer_pos);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_REFLECTION :\n" - "\t\t\tif(buffer_pos + 8 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.reflection.normal_falloff);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_TRANSPARENCY :\n" - "\t\t\tif(buffer_pos + 16 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.normal_falloff);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.refraction_index);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_VOLUME :\n" - "\t\t\tif(buffer_pos + 32 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.diffusion);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_r);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_g);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_b);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_VIEW :\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_GEOMETRY :\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_r, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_g, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_b, 16, buffer_length - buffer_pos);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_TEXTURE :\n" - "\t\t\tif(buffer_pos + 10 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.texture.bitmap);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_r, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_g, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_b, 16, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\tfrag.texture.filtered = (VNMNoiseType)temp;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.texture.mapping);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_NOISE :\n" - "\t\t\tif(buffer_pos + 3 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\tfrag.noise.type = (VNMNoiseType)temp;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.noise.mapping);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_BLENDER :\n" - "\t\t\tif(buffer_pos + 7 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\tfrag.blender.type = (VNMBlendType)temp;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_a);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_b);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.control);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_CLAMP :\n" - "\t\t\tif(buffer_pos + 27 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\tfrag.clamp.min = (VNMBlendType)temp;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.red);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.green);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.blue);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.clamp.data);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_MATRIX :\n" - "\t\t\tif(buffer_pos + 8 * 16 + 2 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\telse\n" - "\t\t\t{\n" - "\t\t\t\tunsigned int i;\n" - "\t\t\t\tfor(i = 0; i < 16; i++)\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.matrix.matrix[i]);\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.matrix.data);\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_RAMP :\n" - "\t\t\tif(buffer_pos + 5 + 4 * 8 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\telse\n" - "\t\t\t{\n" - "\t\t\t\tunsigned int i, pos;\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\t\tfrag.ramp.type = (VNMRampType)temp;\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp);\n" - "\t\t\t\tfrag.ramp.channel = (VNMRampChannel)temp;\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.ramp.mapping);\n" - "\t\t\t\tpos = buffer_pos;\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &frag.ramp.point_count);\n" - "\t\t\t\tfor(i = 0; i < frag.ramp.point_count && buffer_pos + 8 * 4 <= buffer_length && i < 48; i++)\n" - "\t\t\t\t{\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].pos);\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].red);\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].green);\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].blue);\n" - "\t\t\t\t}if(i != frag.ramp.point_count)\n" - "\t\t\t\t\tfrag.ramp.point_count = i;\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_ANIMATION :\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.animation.label, 16, buffer_length - buffer_pos);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_ALTERNATIVE :\n" - "\t\t\tif(buffer_pos + 4 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_a);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_b);\n" - "\t\t\tbreak;\n" - "\t\tcase VN_M_FT_OUTPUT :\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.output.label, 16, buffer_length - buffer_pos);\n" - "\t\t\tif(buffer_pos + 4 > buffer_length)\n" - "\t\t\t\treturn -1;\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.front);\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.back);\n" - "\t\t\tbreak;\n" - "\t\t}\n" - "\t\tif(func_m_fragment_create != NULL)\n" - "\t\t\tfunc_m_fragment_create(v_fs_get_user_data(68), node_id, frag_id, type, &frag);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_alias(FALSE, "m_fragment_destroy", "if(type > VN_M_FT_OUTPUT)", 2, NULL); - - v_cg_end_cmd(); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_o.c b/extern/verse/dist/v_cmd_def_o.c deleted file mode 100644 index a0135f2a4a7..00000000000 --- a/extern/verse/dist/v_cmd_def_o.c +++ /dev/null @@ -1,517 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_object_cmd_def(void) -{ - v_cg_new_cmd(V_NT_OBJECT, "o_transform_pos_real32", 32, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "time_s"); - v_cg_add_param(VCGP_UINT32, "time_f"); - v_cg_add_param(VCGP_POINTER_TYPE,"real32"); - v_cg_add_param(VCGP_POINTER, "pos"); - v_cg_add_param(VCGP_POINTER_TYPE,"real32"); - v_cg_add_param(VCGP_POINTER, "speed"); - v_cg_add_param(VCGP_POINTER_TYPE,"real32"); - v_cg_add_param(VCGP_POINTER, "accelerate"); - v_cg_add_param(VCGP_POINTER_TYPE,"real32"); - v_cg_add_param(VCGP_POINTER, "drag_normal"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tunsigned char mask = 0;\n" - "\t\tunsigned int cmd;\n" - "\t\tcmd = buffer_pos++;\n" - "\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[0]);\n" - "\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[1]);\n" - "\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[2]);\n" - "\t\tif(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001))\n" - "\t\t{\n" - "\t\t\tmask |= 1;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[2]);\n" - "\t\t}\n" - "\t\tif(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001))\n" - "\t\t{\n" - "\t\t\tmask |= 2;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[2]);\n" - "\t\t}\n" - "\t\tif(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001))\n" - "\t\t{\n" - "\t\t\tmask |= 4;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[2]);\n" - "\t\t}\n" - "\t\tif(drag > 0.0000001 || drag < -0.0000001)\n" - "\t\t{\n" - "\t\t\tmask |= 8;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);\n" - "\t\t}\n" - "\t\tvnp_raw_pack_uint8(&buf[cmd], mask);\n" - "\t}if(FALSE)\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n" - "\t\tfloat output[4][3];\n" - "\t\tunsigned int i, j;\n" - "\t\tchar mask, pow = 1;\n" - "\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n" - "\t\tfor(j = 0; j < 3; j++)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[0][j]);\n" - "\t\tfor(i = 1; i < 4; i++)\n" - "\t\t{\n" - "\t\t\tif((mask & pow) != 0)\n" - "\t\t\t\tfor(j = 0; j < 3; j++)\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[i][j]);\n" - "\t\t\telse\n" - "\t\t\t\tfor(j = 0; j < 3; j++)\n" - "\t\t\t\t\toutput[i][j] = 0;\n" - "\t\t\tpow *= 2;\n" - "\t\t}\n" - "\t\tif((mask & pow) != 0)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag);\n" - "\t\telse\n" - "\t\t\tdrag = 0.0f;\n" - "\t\tif(func_o_transform_pos_real32 != NULL)\n" - "\t\t\tfunc_o_transform_pos_real32(v_fs_get_user_data(32), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_add_param(VCGP_REAL32, "drag"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_transform_rot_real32", 33, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "time_s"); - v_cg_add_param(VCGP_UINT32, "time_f"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32"); - v_cg_add_param(VCGP_POINTER, "rot"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32"); - v_cg_add_param(VCGP_POINTER, "speed"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32"); - v_cg_add_param(VCGP_POINTER, "accelerate"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNQuat32"); - v_cg_add_param(VCGP_POINTER, "drag_normal"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tuint8 mask = 0;\n" - "\t\tunsigned int maskpos;\n" - "\t\tmaskpos = buffer_pos++;\t\t/* Remember location, and reserve a byte for the mask. */\n" - "\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], rot);\n" - "\t\tif(v_quat32_valid(speed))\n" - "\t\t{\n" - "\t\t\tmask |= 1;\n" - "\t\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], speed);\n" - "\t\t}\n" - "\t\tif(v_quat32_valid(accelerate))\n" - "\t\t{\n" - "\t\t\tmask |= 2;\n" - "\t\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], accelerate);\n" - "\t\t}\n" - "\t\tif(v_quat32_valid(drag_normal))\n" - "\t\t{\n" - "\t\t\tmask |= 4;\n" - "\t\t\tbuffer_pos += vnp_pack_quat32(&buf[buffer_pos], drag_normal);\n" - "\t\t}\n" - "\t\tif(drag > 0.0000001 || drag < -0.0000001)\n" - "\t\t{\n" - "\t\t\tmask |= 8;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag);\n" - "\t\t}\n" - "\t\tvnp_raw_pack_uint8(&buf[maskpos], mask);\t/* Write the mask into start of command. */\n" - "\t}\n" - "\tif(FALSE)\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n" - "\t\tVNQuat32 trot, temp[3], *q[3];\n" - "\t\tunsigned int i;\n" - "\t\tuint8 mask, test;\n" - "\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n" - "\t\tbuffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &trot);\n" - "\t\tfor(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1)\n" - "\t\t{\n" - "\t\t\tif(mask & test)\t\t/* Field present? */\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &temp[i]);\n" - "\t\t\t\tq[i] = &temp[i];\n" - "\t\t\t}\n" - "\t\t\telse\n" - "\t\t\t\tq[i] = NULL;\n" - "\t\t}\n" - "\t\tif(mask & test)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag);\n" - "\t\telse\n" - "\t\t\tdrag = 0.0;\n" - "\t\tif(func_o_transform_rot_real32 != NULL)\n" - "\t\t\tfunc_o_transform_rot_real32(v_fs_get_user_data(33), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_add_param(VCGP_REAL32, "drag"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_transform_scale_real32", 34, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL32, "scale_x"); - v_cg_add_param(VCGP_REAL32, "scale_y"); - v_cg_add_param(VCGP_REAL32, "scale_z"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_transform_pos_real64", 35, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "time_s"); - v_cg_add_param(VCGP_UINT32, "time_f"); - v_cg_add_param(VCGP_POINTER_TYPE,"real64"); - v_cg_add_param(VCGP_POINTER, "pos"); - v_cg_add_param(VCGP_POINTER_TYPE,"real64"); - v_cg_add_param(VCGP_POINTER, "speed"); - v_cg_add_param(VCGP_POINTER_TYPE,"real64"); - v_cg_add_param(VCGP_POINTER, "accelerate"); - v_cg_add_param(VCGP_POINTER_TYPE,"real64"); - v_cg_add_param(VCGP_POINTER, "drag_normal"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tunsigned char mask = 0;\n" - "\t\tunsigned int cmd;\n" - "\t\tcmd = buffer_pos++;\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[0]);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[1]);\n" - "\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[2]);\n" - "\t\tif(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001))\n" - "\t\t{\n" - "\t\t\tmask |= 1;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[2]);\n" - "\t\t}\n" - "\t\tif(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001))\n" - "\t\t{\n" - "\t\t\tmask |= 2;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[2]);\n" - "\t\t}\n" - "\t\tif(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001))\n" - "\t\t{\n" - "\t\t\tmask |= 4;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[2]);\n" - "\t\t}\n" - "\t\tif(drag > 0.0000001 || drag < -0.0000001)\n" - "\t\t{\n" - "\t\t\tmask |= 8;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);\n" - "\t\t}\n" - "\t\tvnp_raw_pack_uint8(&buf[cmd], mask);\n" - "\t}if(FALSE)\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n" - "\t\tdouble output[4][3];\n" - "\t\tunsigned int i, j;\n" - "\t\tchar mask, pow = 1;\n" - "\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n" - "\t\tfor(j = 0; j < 3; j++)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]);\n" - "\t\tfor(i = 1; i < 4; i++)\n" - "\t\t{\n" - "\t\t\tif((mask & pow) != 0)\n" - "\t\t\t\tfor(j = 0; j < 3; j++)\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]);\n" - "\t\t\telse\n" - "\t\t\t\tfor(j = 0; j < 3; j++)\n" - "\t\t\t\t\toutput[i][j] = 0;\n" - "\t\t\tpow *= 2;\n" - "\t\t}\n" - "\t\tif((mask & pow) != 0)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag);\n" - "\t\telse\n" - "\t\t\tdrag = 0.0;\n" - "\t\tif(func_o_transform_pos_real64 != NULL)\n" - "\t\t\tfunc_o_transform_pos_real64(v_fs_get_user_data(35), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_add_param(VCGP_REAL64, "drag"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_transform_rot_real64", 36, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "time_s"); - v_cg_add_param(VCGP_UINT32, "time_f"); - v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64"); - v_cg_add_param(VCGP_POINTER, "rot"); - v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64"); - v_cg_add_param(VCGP_POINTER, "speed"); - v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64"); - v_cg_add_param(VCGP_POINTER, "accelerate"); - v_cg_add_param(VCGP_POINTER_TYPE,"VNQuat64"); - v_cg_add_param(VCGP_POINTER, "drag_normal"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tuint8 mask = 0;\n" - "\t\tunsigned int maskpos;\n" - "\t\tmaskpos = buffer_pos++;\t\t/* Remember location, and reserve a byte for the mask. */\n" - "\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], rot);\n" - "\t\tif(v_quat64_valid(speed))\n" - "\t\t{\n" - "\t\t\tmask |= 1;\n" - "\t\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], speed);\n" - "\t\t}\n" - "\t\tif(v_quat64_valid(accelerate))\n" - "\t\t{\n" - "\t\t\tmask |= 2;\n" - "\t\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], accelerate);\n" - "\t\t}\n" - "\t\tif(v_quat64_valid(drag_normal))\n" - "\t\t{\n" - "\t\t\tmask |= 4;\n" - "\t\t\tbuffer_pos += vnp_pack_quat64(&buf[buffer_pos], drag_normal);\n" - "\t\t}\n" - "\t\tif(drag > 0.0000001 || drag < -0.0000001)\n" - "\t\t{\n" - "\t\t\tmask |= 8;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag);\n" - "\t\t}\n" - "\t\tvnp_raw_pack_uint8(&buf[maskpos], mask);\t/* Write the mask into start of command. */\n" - "\t}\n" - "\tif(FALSE)\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n" - "\t\tVNQuat64 trot, temp[3], *q[3];\n" - "\t\tunsigned int i;\n" - "\t\tuint8 mask, test;\n" - "\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n" - "\t\tbuffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &trot);\n" - "\t\tfor(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1)\n" - "\t\t{\n" - "\t\t\tif(mask & test)\t\t/* Field present? */\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &temp[i]);\n" - "\t\t\t\tq[i] = &temp[i];\n" - "\t\t\t}\n" - "\t\t\telse\n" - "\t\t\t\tq[i] = NULL;\n" - "\t\t}\n" - "\t\tif(mask & test)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag);\n" - "\t\telse\n" - "\t\t\tdrag = 0.0;\n" - "\t\tif(func_o_transform_rot_real64 != NULL)\n" - "\t\t\tfunc_o_transform_rot_real64(v_fs_get_user_data(36), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_add_param(VCGP_REAL64, "drag"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_transform_scale_real64", 37, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL64, "scale_x"); - v_cg_add_param(VCGP_REAL64, "scale_y"); - v_cg_add_param(VCGP_REAL64, "scale_z"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_transform_subscribe", 38, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_ENUM_NAME, "VNRealFormat"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_alias(TRUE, "o_transform_unsubscribe", NULL, 4, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_light_set", 39, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_REAL64, "light_r"); - v_cg_add_param(VCGP_REAL64, "light_g"); - v_cg_add_param(VCGP_REAL64, "light_b"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_link_set", 40, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "link_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NODE_ID, "link"); - v_cg_add_param(VCGP_NAME, "label"); - v_cg_add_param(VCGP_UINT32, "target_id"); - v_cg_alias(TRUE, "o_link_destroy", NULL, 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_method_group_create", 41, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_alias(FALSE, "o_method_group_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_method_group_subscribe", 42, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "o_method_group_unsubscribe", NULL, 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_method_create", 43, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_UINT16, "method_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_LONG_NAME, "name"); - v_cg_add_param(VCGP_UINT8, "param_count"); - v_cg_add_param(VCGP_POINTER_TYPE,"VNOParamType"); - v_cg_add_param(VCGP_POINTER, "param_types"); - v_cg_add_param(VCGP_POINTER_TYPE,"char *"); - v_cg_add_param(VCGP_POINTER, "param_names"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tunsigned int i, j, sum = 1;\n" - "\t\tfor(i = 0; i < param_count; i++)\n" - "\t\t{\n" - "\t\t\tsum += 3;\n" - "\t\t\tfor(j = 0; param_names[i][j] != 0; j++);\n" - "\t\t}\n" - "\t\tif(sum + buffer_pos > 1500)\n" - "\t\t\treturn;\n" - "\t\tfor(i = 0; i < param_count; i++)\n" - "\t\t{\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], param_types[i]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], param_names[i], 1500 - buffer_pos);\n" - "\t\t}\n" - "\t}\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(param_count != 255)\n" - "\t{\n" - "\t\tunsigned int i, size, text = 0;\n" - "\t\tVNOParamType types[256];\n" - "\t\tuint8 t;\n" - "\t\tchar name_buf[1500], *names[256];\n" - "\t\tfor(i = 0; i < param_count; i++)\n" - "\t\t{\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &t);\n" - "\t\t\ttypes[i] = t;\n" - "\t\t\tnames[i] = &name_buf[text];\n" - "\t\t\tsize = vnp_raw_unpack_string(&buf[buffer_pos], names[i], 1500 - buffer_pos, buffer_length - buffer_pos);\n" - "\t\t\tbuffer_pos += size;\n" - "\t\t\ttext += size;\n" - "\t\t}\n" - "\t\tif(func_o_method_create != NULL)\n" - "\t\t\tfunc_o_method_create(v_fs_get_user_data(43), node_id, group_id, method_id, name, param_count, types, (const char **) names);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_alias(FALSE, "o_method_destroy", "if(name[0] == 0)", 3, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_method_call", 44, VCGCT_UNIQUE); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_UINT16, "method_id"); - v_cg_add_param(VCGP_NODE_ID, "sender"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNOPackedParams"); - v_cg_add_param(VCGP_POINTER, "params"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tunsigned int i;\n" - "\t\tuint16 size;\n" - "\t\tvnp_raw_unpack_uint16(params, &size);\n" - "\t\tfor(i = 0; i < size; i++)\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)params)[i]);\n" - "\t\tfree((void *) params);\t/* Drop the const. */\n" - "\t}\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n" - "\t\tunsigned int i;\n" - "\t\tuint8 par[1500];\n" - "\t\tuint16 size;\n" - "\t\tvnp_raw_unpack_uint16(&buf[buffer_pos], &size);\n" - "\t\tfor(i = 0; i < size; i++)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &par[i]);\n" - "\t\tif(func_o_method_call != NULL)\n" - "\t\t\tfunc_o_method_call(v_fs_get_user_data(44), node_id, group_id, method_id, sender, par);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_anim_run", 45, VCGCT_UNIQUE); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "link_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT32, "time_s"); - v_cg_add_param(VCGP_UINT32, "time_f"); - v_cg_add_param(VCGP_UINT8, "dimensions"); - v_cg_add_param(VCGP_POINTER_TYPE, "real64"); - v_cg_add_param(VCGP_POINTER, "pos"); - v_cg_add_param(VCGP_POINTER_TYPE, "real64"); - v_cg_add_param(VCGP_POINTER, "speed"); - v_cg_add_param(VCGP_POINTER_TYPE, "real64"); - v_cg_add_param(VCGP_POINTER, "accel"); - v_cg_add_param(VCGP_POINTER_TYPE, "real64"); - v_cg_add_param(VCGP_POINTER, "scale"); - v_cg_add_param(VCGP_POINTER_TYPE, "real64"); - v_cg_add_param(VCGP_POINTER, "scale_speed"); - v_cg_add_param(VCGP_PACK_INLINE, "\t{\n" - "\t\tunsigned char mask = 0;\n" - "\t\tunsigned int cmd, i;\n" - "\t\tcmd = buffer_pos++;\n" - "\t\tif(dimensions > 4)\n" - "\t\t\tdimensions = 4;\n" - "\t\tfor(i = 0; i < dimensions; i++)\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[i]);\n" - "\t\tif(speed != NULL)\n" - "\t\t{\n" - "\t\t\tmask |= 1;\n" - "\t\t\tfor(i = 0; i < dimensions; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[i]);\n" - "\t\t}\n" - "\t\tif(accel != NULL)\n" - "\t\t{\n" - "\t\t\tmask |= 2;\n" - "\t\t\tfor(i = 0; i < dimensions; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accel[i]);\n" - "\t\t}\n" - "\t\tif(scale != NULL)\n" - "\t\t{\n" - "\t\t\tmask |= 3;\n" - "\t\t\tfor(i = 0; i < dimensions; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale[i]);\n" - "\t\t}\n" - "\t\tif(scale_speed != NULL)\n" - "\t\t{\n" - "\t\t\tmask |= 4;\n" - "\t\t\tfor(i = 0; i < dimensions; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_speed[i]);\n" - "\t\t}\n" - "\t\tvnp_raw_pack_uint8(&buf[cmd], mask);\n" - "\t}\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\t{\n" - "\t\tdouble output[5][4];\n" - "\t\tunsigned int i, j;\n" - "\t\tchar mask, pow = 1;\n" - "\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask);\n" - "\t\tif(dimensions > 4)\n" - "\t\t\tdimensions = 4;\n" - "\t\tfor(j = 0; j < dimensions; j++)\n" - "\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]);\n" - "\t\tfor(i = 1; i < 5; i++)\n" - "\t\t{\n" - "\t\t\tif((mask & pow) != 0)\n" - "\t\t\t\tfor(j = 0; j < dimensions; j++)\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]);\n" - "\t\t\telse\n" - "\t\t\t\tfor(j = 0; j < dimensions; j++)\n" - "\t\t\t\t\toutput[i][j] = 0;\n" - "\t\t\tpow *= 2;\n" - "\t\t}\n" - "\t\tif(func_o_anim_run != NULL)\n" - "\t\t\tfunc_o_anim_run(v_fs_get_user_data(45), node_id, link_id, time_s, time_f, dimensions, &output[0][0], &output[1][0], &output[2][0], &output[3][0], &output[4][0]);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_OBJECT, "o_hide", 46, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_UINT8, "hidden"); - v_cg_end_cmd(); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_s.c b/extern/verse/dist/v_cmd_def_s.c deleted file mode 100644 index 1b8b69dcd6d..00000000000 --- a/extern/verse/dist/v_cmd_def_s.c +++ /dev/null @@ -1,211 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_system_cmd_def(void) -{ - v_cg_new_manual_cmd(0, "connect", "VSession verse_send_connect(const char *name, const char *pass, const char *address, const uint8 *expected_host_id)", NULL, NULL); - - v_cg_new_manual_cmd(1, "connect_accept", "VSession verse_send_connect_accept(VNodeID avatar, const char *address, uint8 *host_id)", NULL, NULL); - - v_cg_new_manual_cmd(2, "connect_terminate", "void verse_send_connect_terminate(const char *address, const char *bye)", NULL, NULL); - - v_cg_new_manual_cmd(5, "ping", "void verse_send_ping(const char *address, const char *message)", NULL, NULL); - - v_cg_new_cmd(V_NT_SYSTEM, "error_message", 6, VCGCT_UNIQUE); - v_cg_add_param(VCGP_LONG_NAME, "message"); - - v_cg_new_cmd(V_NT_SYSTEM, "packet_ack", 7, VCGCT_INVISIBLE_SYSTEM); - v_cg_add_param(VCGP_UINT32, "packet_id"); - v_cg_add_param(VCGP_PACK_INLINE, "\tv_cmd_buf_set_unique_address_size(head, buffer_pos);\n" - "\tv_cmd_buf_set_size(head, buffer_pos);\n" - "\tv_noq_send_ack_nak_buf(v_con_get_network_queue(), head);\n" - "\treturn;\n"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "packet_nak", 8, VCGCT_INVISIBLE_SYSTEM); - v_cg_add_param(VCGP_UINT32, "packet_id"); - v_cg_add_param(VCGP_PACK_INLINE, "\tv_cmd_buf_set_unique_address_size(head, buffer_pos);\n" - "\tv_cmd_buf_set_size(head, buffer_pos);\n" - "\tv_noq_send_ack_nak_buf(v_con_get_network_queue(), head);\n" - "\treturn;\n"); - v_cg_end_cmd(); - - - v_cg_new_cmd(V_NT_SYSTEM, "node_index_subscribe", 9, VCGCT_NORMAL); - v_cg_add_param(VCGP_UINT32, "mask"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "node_create", 10, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_ENUM_NAME, "VNodeType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_ENUM_NAME, "VNodeOwner"); - v_cg_add_param(VCGP_ENUM, "owner"); - v_cg_alias(FALSE, "node_destroy", "if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES)", 1, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "node_subscribe", 11, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "node_unsubscribe", NULL, 1, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "tag_group_create", 16, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_alias(FALSE, "tag_group_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "tag_group_subscribe", 17, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "tag_group_unsubscribe", NULL, 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "tag_create", 18, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_UINT16, "group_id"); - v_cg_add_param(VCGP_UINT16, "tag_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_add_param(VCGP_ENUM_NAME, "VNTagType"); - v_cg_add_param(VCGP_ENUM, "type"); - v_cg_add_param(VCGP_POINTER_TYPE, "VNTag"); - v_cg_add_param(VCGP_POINTER, "tag"); - v_cg_add_param(VCGP_PACK_INLINE, "\tif(type > VN_TAG_BLOB)\n" - "\t{\n" - "\t\tv_cmd_buf_free(head);\n" - "\t\treturn;\n" - "\t}\n" - "\tswitch(type)\n" - "\t{\n" - "\t\tcase VN_TAG_BOOLEAN :\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vboolean);\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_UINT32 :\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vuint32);\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_REAL64 :\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64);\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_STRING :\n" - "\t\t{\n" - "\t\t\tunsigned int i;\n" - "\t\t\tfor(i = 0; ((VNTag *)tag)->vstring[i] != 0 && i < VN_TAG_MAX_BLOB_SIZE; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vstring[i]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_REAL64_VEC3 :\n" - "\t\t{\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[0]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[1]);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[2]);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_LINK :\n" - "\t\t{\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vlink);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_ANIMATION :\n" - "\t\t{\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.curve);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.start);\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.end);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\t\tcase VN_TAG_BLOB :\n" - "\t\t{\n" - "\t\t\tunsigned int i;\n" - "\t\t\tif(((VNTag *)tag)->vblob.size > VN_TAG_MAX_BLOB_SIZE)\n" - "\t\t\t\t((VNTag *)tag)->vblob.size = VN_TAG_MAX_BLOB_SIZE;\n" - "\t\t\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], ((VNTag *)tag)->vblob.size);\n" - "\t\t\tfor(i = 0; i < ((VNTag *)tag)->vblob.size; i++)\n" - "\t\t\t\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)((VNTag *)tag)->vblob.blob)[i]);\n" - "\t\t}\n" - "\t\tbreak;\n" - "\t\tdefault :\n" - "\t\t\t;\n" - "\t}\n"); - v_cg_add_param(VCGP_UNPACK_INLINE, "\tif(type < VN_TAG_TYPE_COUNT)\n" - "\t{\n" - "\t\tVNTag tag;\n" - "\t\tunsigned int i;\n" - "\t\tchar string[VN_TAG_MAX_BLOB_SIZE];\n" - "\t\tswitch(type)\n" - "\t\t{\n" - "\t\t\tcase VN_TAG_BOOLEAN :\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &tag.vboolean);\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_UINT32 :\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vuint32);\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_REAL64 :\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64);\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_STRING :\n" - "\t\t\t{\n" - "\t\t\t\ttag.vstring = string;\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], string, VN_TAG_MAX_BLOB_SIZE, buffer_length - buffer_pos);\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_REAL64_VEC3 :\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[0]);\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[1]);\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[2]);\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_LINK :\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vlink);\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_ANIMATION :\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.curve);\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.start);\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.end);\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\t\tcase VN_TAG_BLOB :\n" - "\t\t\t{\n" - "\t\t\t\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag.vblob.size);\n" - "\t\t\t\tif(tag.vblob.size > VN_TAG_MAX_BLOB_SIZE)\n" - "\t\t\t\t\ttag.vblob.size = VN_TAG_MAX_BLOB_SIZE;\n" - "\t\t\t\ttag.vblob.blob = string;\n" - "\t\t\t\tfor(i = 0; i < tag.vblob.size; i++)\n" - "\t\t\t\t\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &string[i]);\n" - "\t\t\t}\n" - "\t\t\tbreak;\n" - "\t\tdefault :\n" - "\t\t\t;\n" - "\t\t}\n" - "\t\tif(func_tag_create != NULL)\n" - "\t\tfunc_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, type, &tag);\n" - "\t\treturn buffer_pos;\n" - "\t}\n"); - v_cg_alias(FALSE, "tag_destroy", "if(type >= VN_TAG_TYPE_COUNT)", 3, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_SYSTEM, "node_name_set", 19, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_LONG_NAME, "name"); - - v_cg_end_cmd(); -} - -#endif diff --git a/extern/verse/dist/v_cmd_def_t.c b/extern/verse/dist/v_cmd_def_t.c deleted file mode 100644 index 3c568b42d7b..00000000000 --- a/extern/verse/dist/v_cmd_def_t.c +++ /dev/null @@ -1,36 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include "verse_header.h" -#include "v_cmd_gen.h" -#include "v_cmd_buf.h" - -#if defined(V_GENERATE_FUNC_MODE) - -void v_gen_text_cmd_def(void) -{ - v_cg_new_cmd(V_NT_TEXT, "t_language_set", 96, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_LONG_NAME, "language"); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_TEXT, "t_buffer_create", 97, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_BUFFER_ID, "buffer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_add_param(VCGP_NAME, "name"); - v_cg_alias(FALSE, "t_buffer_destroy", "if(name[0] == 0)", 2, NULL); - v_cg_end_cmd(); - - v_cg_new_cmd(V_NT_TEXT, "t_buffer_subscribe", 98, VCGCT_NORMAL); - v_cg_add_param(VCGP_NODE_ID, "node_id"); - v_cg_add_param(VCGP_BUFFER_ID, "buffer_id"); - v_cg_add_param(VCGP_END_ADDRESS, NULL); - v_cg_alias(TRUE, "t_buffer_unsubscribe", NULL, 2, NULL); - v_cg_end_cmd(); - - v_cg_new_manual_cmd(99, "t_text_set", "void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text)", NULL, NULL); -} - -#endif diff --git a/extern/verse/dist/v_cmd_gen.c b/extern/verse/dist/v_cmd_gen.c deleted file mode 100644 index 3d18f8cf1af..00000000000 --- a/extern/verse/dist/v_cmd_gen.c +++ /dev/null @@ -1,939 +0,0 @@ -/* -** -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "verse_header.h" -#include "v_cmd_buf.h" - -#include "v_cmd_gen.h" - -#if defined _WIN32 -#include <direct.h> -#define chdir _chdir -#define snprintf _snprintf -#endif - -#if defined V_GENERATE_FUNC_MODE - -#define MAX_PARAMS_PER_CMD 32 - -static struct { - FILE *nodes[V_NT_NUM_TYPES_NETPACK]; - FILE *init; - FILE *unpack; - FILE *verse_h; - FILE *internal_verse_h; - const char *func_name; - VNodeType type; - VCGCommandType command; - unsigned int param_count; - VCGParam param_type[MAX_PARAMS_PER_CMD]; - const char *param_name[MAX_PARAMS_PER_CMD]; - unsigned int cmd_id; - const char *alias_name; - const char *alias_qualifier; - unsigned int alias_param; - unsigned int *alias_param_array; - char alias_bool_switch; -} VCGData; - -extern void v_gen_system_cmd_def(void); -extern void v_gen_object_cmd_def(void); -extern void v_gen_geometry_cmd_def(void); -extern void v_gen_material_cmd_def(void); -extern void v_gen_bitmap_cmd_def(void); -extern void v_gen_text_cmd_def(void); -extern void v_gen_curve_cmd_def(void); -extern void v_gen_audio_cmd_def(void); - -static int v_cg_init(const char *src_path) -{ - char buf[1024]; - int i; - FILE *f; - - VCGData.nodes[V_NT_OBJECT] = fopen("v_gen_pack_o_node.c", "w"); - VCGData.nodes[V_NT_GEOMETRY] = fopen("v_gen_pack_g_node.c", "w"); - VCGData.nodes[V_NT_MATERIAL] = fopen("v_gen_pack_m_node.c", "w"); - VCGData.nodes[V_NT_BITMAP] = fopen("v_gen_pack_b_node.c", "w"); - VCGData.nodes[V_NT_TEXT] = fopen("v_gen_pack_t_node.c", "w"); - VCGData.nodes[V_NT_CURVE] = fopen("v_gen_pack_c_node.c", "w"); - VCGData.nodes[V_NT_AUDIO] = fopen("v_gen_pack_a_node.c", "w"); - VCGData.nodes[V_NT_SYSTEM] = fopen("v_gen_pack_s_node.c", "w"); - VCGData.init = fopen("v_gen_pack_init.c", "w"); - VCGData.unpack = fopen("v_gen_unpack_func.h", "w"); - VCGData.verse_h = fopen("verse.h", "w"); - VCGData.internal_verse_h = fopen("v_internal_verse.h", "w"); - for(i = 0; i < V_NT_NUM_TYPES_NETPACK + 1; i++) - { - if(i == V_NT_NUM_TYPES_NETPACK) - f = VCGData.init; - else - f = VCGData.nodes[i]; - fprintf(f, - "/*\n" - "** This is automatically generated source code -- do not edit.\n" - "** Changes are affected either by editing the corresponding protocol\n" - "** definition file (v_cmd_def_X.c where X=node type), or by editing\n" - "** the code generator itself, in v_cmd_gen.c.\n" - "*/\n\n"); - fprintf(f, "#include <stdlib.h>\n"); - fprintf(f, "#include <stdio.h>\n\n"); - fprintf(f, "#include \"v_cmd_gen.h\"\n"); - fprintf(f, "#if !defined(V_GENERATE_FUNC_MODE)\n"); - fprintf(f, "#include \"verse.h\"\n"); - fprintf(f, "#include \"v_cmd_buf.h\"\n"); - fprintf(f, "#include \"v_network_out_que.h\"\n"); - fprintf(f, "#include \"v_network.h\"\n"); - fprintf(f, "#include \"v_connection.h\"\n"); - fprintf(f, "#include \"v_util.h\"\n\n"); - } - VCGData.cmd_id = 0; - fprintf(f, "#include \"v_gen_unpack_func.h\"\n\n"); - fprintf(f, - "#include \"verse.h\"\n\n\n" - "extern void verse_send_packet_ack(uint32 packet_id);\n" - "extern void verse_send_packet_nak(uint32 packet_id);\n\n"); - - fprintf(VCGData.init, "void init_pack_and_unpack(void)\n{\n"); - fprintf(VCGData.verse_h, - "/*\n" - "** Verse API Header file (for use with libverse.a).\n" - "** This is automatically generated code; do not edit.\n" - "*/\n\n" - "\n" - "#if !defined VERSE_H\n" - "\n" - "#if defined __cplusplus\t\t/* Declare as C symbols for C++ users. */\n" - "extern \"C\" {\n" - "#endif\n\n" - "#define\tVERSE_H\n\n"); - /* Copy contents of "verse_header.h" into output "verse.h". */ - snprintf(buf, sizeof buf, "%sverse_header.h", src_path); - f = fopen(buf, "r"); - if(f != NULL) - { - while((i = fgetc(f)) != EOF) - fputc(i, VCGData.verse_h); - fclose(f); - } - else - { - fprintf(stderr, "mkprot: Couldn't find \"%s\" input file\n", buf); - return 0; - } - fprintf(VCGData.verse_h, "\n/* Command sending functions begin. ----------------------------------------- */\n\n"); - return 1; -} - -static void v_cg_close(void) -{ - unsigned int i; - for(i = 0; i < V_NT_NUM_TYPES_NETPACK; i++) - { - fprintf(VCGData.nodes[i], "#endif\n\n"); - } - fprintf(VCGData.init, "}\n#endif\n\n"); - fprintf(VCGData.verse_h, - "\n#if defined __cplusplus\n" - "}\n" - "#endif\n"); - fprintf(VCGData.verse_h, "\n#endif\t\t/* VERSE_H */\n"); -} - -void v_cg_new_cmd(VCGCommandType type, const char *name, unsigned int cmd_id, VCGCommandType command) -{ - VCGData.param_count = 0; - VCGData.func_name = name; - VCGData.type = type; - VCGData.cmd_id = cmd_id; - VCGData.command = command; -/* printf("def: %u: %s\n", cmd_id, name);*/ -} - -void v_cg_new_manual_cmd(unsigned int cmd_id, const char *name, const char *def, const char *alias_name, const char *alias_def) -{ - fprintf(VCGData.verse_h, "extern %s;\n", def); - if(alias_def != NULL) - fprintf(VCGData.verse_h, "extern %s;\n", alias_def); - fprintf(VCGData.init, "\tv_fs_add_func(%i, v_unpack_%s, (void *) verse_send_%s, ", cmd_id, name, name); - if(alias_name != NULL) - fprintf(VCGData.init, "(void *) verse_send_%s);\n", alias_name); - else - fprintf(VCGData.init, "NULL);\n"); - fprintf(VCGData.unpack, "extern unsigned int v_unpack_%s(const char *data, size_t length);\n", name); -/* printf("def: %u: %s\n", cmd_id, name);*/ -} - -void v_cg_alias(char bool_switch, const char *name, const char *qualifier, unsigned int param, unsigned int *param_array) -{ - VCGData.alias_name = name; - VCGData.alias_qualifier = qualifier; - VCGData.alias_param = param; - VCGData.alias_param_array = param_array; - VCGData.alias_bool_switch = bool_switch; -} - -void v_cg_add_param(VCGParam type, const char *name) -{ - if(VCGData.param_count == MAX_PARAMS_PER_CMD) - exit(1); - VCGData.param_type[VCGData.param_count] = type; - VCGData.param_name[VCGData.param_count] = name; - VCGData.param_count++; -} - -static void v_cg_gen_func_params(FILE *f, boolean types, boolean alias) -{ - unsigned int i; - unsigned int length, active; - length = VCGData.param_count; - if(alias) - length = VCGData.alias_param; - for(i = 0; i < length; i++) - { - if(alias && VCGData.alias_param_array != NULL) - active = VCGData.alias_param_array[i]; - else - { - for(;(VCGData.param_type[i] == VCGP_PACK_INLINE || VCGData.param_type[i] == VCGP_UNPACK_INLINE || VCGData.param_type[i] == VCGP_POINTER_TYPE || VCGData.param_type[i] == VCGP_ENUM_NAME) && i < VCGData.param_count; i++); - if(i == VCGData.param_count) - break; - active = i; - } - - if(active < VCGData.param_count && VCGData.param_type[active] != VCGP_END_ADDRESS) - { - switch(VCGData.param_type[active]) - { - case VCGP_UINT8 : - fprintf(f, "uint8 %s", VCGData.param_name[active]); - break; - case VCGP_UINT16 : - fprintf(f, "uint16 %s", VCGData.param_name[active]); - break; - case VCGP_UINT32 : - fprintf(f, "uint32 %s", VCGData.param_name[active]); - break; - case VCGP_REAL32 : - fprintf(f, "real32 %s", VCGData.param_name[active]); - break; - case VCGP_REAL64 : - fprintf(f, "real64 %s", VCGData.param_name[active]); - break; - case VCGP_POINTER : - if(active != 0 && VCGData.param_type[active - 1] == VCGP_POINTER_TYPE) - fprintf(f, "const %s *%s", VCGData.param_name[active - 1], VCGData.param_name[active]); - else - fprintf(f, "const void *%s", VCGData.param_name[active]); - break; - case VCGP_NAME : - if(types) - fprintf(f, "char %s[16]", VCGData.param_name[active]); - else - fprintf(f, "const char *%s", VCGData.param_name[active]); - break; - case VCGP_LONG_NAME : - if(types) - fprintf(f, "char %s[512]", VCGData.param_name[active]); - else - fprintf(f, "const char *%s", VCGData.param_name[active]); - break; - case VCGP_NODE_ID : - fprintf(f, "VNodeID %s", VCGData.param_name[active]); - break; - case VCGP_LAYER_ID : - fprintf(f, "VLayerID %s", VCGData.param_name[active]); - break; - case VCGP_BUFFER_ID : - fprintf(f, "VBufferID %s", VCGData.param_name[active]); - break; - case VCGP_FRAGMENT_ID : - fprintf(f, "VNMFragmentID %s", VCGData.param_name[active]); - break; - case VCGP_ENUM : -/* if(types) - fprintf(f, "uint8 %s", VCGData.param_name[active]); - else -*/ fprintf(f, "%s %s", VCGData.param_name[active - 1], VCGData.param_name[active]); - break; - } - if(types) - fprintf(f, ";\n\t"); - else - { - for(;(VCGData.param_type[active + 1] == VCGP_END_ADDRESS || VCGData.param_type[active + 1] == VCGP_PACK_INLINE || VCGData.param_type[active + 1] == VCGP_UNPACK_INLINE || VCGData.param_type[active + 1] == VCGP_POINTER_TYPE) && active < VCGData.param_count; active++); - if(active + 1 < length) - fprintf(f, ", "); - } - } - } -} - -static void v_cg_create_print(FILE *f, boolean send, boolean alias) -{ - unsigned int i, length, active; - const char *name; - if(VCGData.command == VCGCT_INVISIBLE_SYSTEM) - return; - name = VCGData.func_name; - if(alias) - name = VCGData.alias_name; - if(send) - fprintf(f, "\tprintf(\"send: verse_send_%s(", name); - else - fprintf(f, "\tprintf(\"receive: verse_send_%s(", name); - - length = VCGData.param_count; - if(alias) - length = VCGData.alias_param; - for(i = 0; i < length; i++) - { - if(alias && VCGData.alias_param_array != NULL) - active = VCGData.alias_param_array[i]; - else - active = i; - - switch(VCGData.param_type[active]) - { - case VCGP_NODE_ID : - fprintf(f, "%s = %%u ", VCGData.param_name[active]); - break; - case VCGP_UINT8 : - case VCGP_UINT16 : - case VCGP_UINT32 : - case VCGP_LAYER_ID : - case VCGP_BUFFER_ID : - case VCGP_ENUM : - case VCGP_FRAGMENT_ID : - fprintf(f, "%s = %%u ", VCGData.param_name[active]); - break; - case VCGP_REAL32 : - case VCGP_REAL64 : - fprintf(f, "%s = %%f ", VCGData.param_name[active]); - break; - case VCGP_POINTER : - if(send) - fprintf(f, "%s = %%p ", VCGData.param_name[active]); - break; - case VCGP_NAME : - case VCGP_LONG_NAME : - fprintf(f, "%s = %%s ", VCGData.param_name[active]); - break; - } - } - if(send) - fprintf(f, ");\\n\""); - else - fprintf(f, "); callback = %%p\\n\""); - - for(i = 0; i < length; i++) - { - if(alias && VCGData.alias_param_array != NULL) - active = VCGData.alias_param_array[i]; - else - active = i; - switch(VCGData.param_type[active]) - { - case VCGP_NODE_ID : - fprintf(f, ", %s", VCGData.param_name[active]); - break; - case VCGP_POINTER : - if(!send) - break; - case VCGP_UINT8 : - case VCGP_UINT16 : - case VCGP_UINT32 : - case VCGP_LAYER_ID : - case VCGP_BUFFER_ID : - case VCGP_ENUM : - case VCGP_FRAGMENT_ID : - case VCGP_REAL32 : - case VCGP_REAL64 : - case VCGP_NAME : - case VCGP_LONG_NAME : - fprintf(f, ", %s", VCGData.param_name[active]); - break; - } - } - if(send) - fprintf(f, ");\n"); - else if(alias) - fprintf(f, ", v_fs_get_alias_user_func(%u));\n", VCGData.cmd_id); - else - fprintf(f, ", v_fs_get_user_func(%u));\n", VCGData.cmd_id); - -} - -static unsigned int v_cg_compute_command_size(unsigned int start, boolean end) -{ - unsigned int size = 0; - for(; start < VCGData.param_count; start++) - { - switch(VCGData.param_type[start]) - { - case VCGP_UINT8 : - case VCGP_ENUM : - size++; - break; - case VCGP_UINT16 : - case VCGP_LAYER_ID : - case VCGP_BUFFER_ID : - case VCGP_FRAGMENT_ID : - size += 2; - break; - case VCGP_NODE_ID : - case VCGP_UINT32 : - case VCGP_REAL32 : - size += 4; - break; - case VCGP_REAL64 : - size += 8; - break; - case VCGP_NAME : - if(end) - return size; - size += 16; - break; - case VCGP_LONG_NAME : - if(end) - return size; - size += 512; - break; - case VCGP_POINTER : - case VCGP_PACK_INLINE : - case VCGP_UNPACK_INLINE : - if(end) - return size; - size += 1500; - break; - case VCGP_END_ADDRESS : - if(end) - return size; - } - } - return size; -} - -void v_cg_set_command_address(FILE *f, boolean alias) -{ - unsigned int i, j, count = 0, length, size = 1, *param, def[] ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; - - for(i = 0; i < VCGData.param_count; i++) - if(VCGData.param_type[i] == VCGP_END_ADDRESS) - break; - if(i == VCGData.param_count) - return; - if(alias) - length = VCGData.alias_param; - else - length = VCGData.param_count; - - if(alias && VCGData.alias_param_array != 0) - param = VCGData.alias_param_array; - else - param = def; - - if(i == VCGData.param_count) - return; - fprintf(f, "\tif("); - for(i = j = 0; i < VCGData.param_count; i++) - { - switch(VCGData.param_type[i]) - { - case VCGP_UINT8 : - case VCGP_ENUM : - size++; - break; - case VCGP_UINT16 : - case VCGP_LAYER_ID : - case VCGP_BUFFER_ID : - case VCGP_FRAGMENT_ID : - size += 2; - break; - case VCGP_NODE_ID : - case VCGP_UINT32 : - case VCGP_REAL32 : - size += 4; - break; - } - if(j < length && param[j] == i) - { - switch(VCGData.param_type[param[j]]) - { - case VCGP_UINT8 : - case VCGP_ENUM : - break; - case VCGP_UINT16 : - case VCGP_LAYER_ID : - case VCGP_BUFFER_ID : - case VCGP_FRAGMENT_ID : - if(count++ != 0) - fprintf(f, " || "); - fprintf(f, "%s == (uint16) ~0u", VCGData.param_name[param[j]]); - break; - case VCGP_NODE_ID : - case VCGP_UINT32 : - case VCGP_REAL32 : - if(count++ != 0) - fprintf(f, " || "); - fprintf(f, "%s == (uint32) ~0u", VCGData.param_name[param[j]]); - break; - } - j++; - } - if(VCGData.param_type[i] == VCGP_END_ADDRESS) - { - fprintf(f, ")\n"); - fprintf(f, "\t\tv_cmd_buf_set_unique_address_size(head, %u);\n", size); - fprintf(f, "\telse\n"); - fprintf(f, "\t\tv_cmd_buf_set_address_size(head, %u);\n", size); - return; - } - } - fprintf(f, ")\n"); - fprintf(f, "\t\tv_cmd_buf_set_unique_address_size(head, %u);\n", size); - fprintf(f, "\telse\n"); - fprintf(f, "\t\tv_cmd_buf_set_address_size(head, %u);\n", size); - return; -} - -static const char * v_cg_compute_buffer_size(void) -{ - unsigned int size; - size = v_cg_compute_command_size(0, FALSE) + 1; - if(size <= 10) - return "VCMDBS_10"; - else if(size <= 20) - return "VCMDBS_20"; - else if(size <= 30) - return "VCMDBS_30"; - else if(size <= 80) - return "VCMDBS_80"; - else if(size <= 160) - return "VCMDBS_160"; - else if(size <= 320) - return "VCMDBS_320"; - return "VCMDBS_1500"; -} - -static void v_cg_gen_pack(boolean alias) -{ - unsigned int i, j, size = 0, ad_size = 0; - boolean printed = FALSE; - boolean address = FALSE; - boolean no_param; - - FILE *f; - f = VCGData.nodes[VCGData.type]; - printf("generating function: verse_send_%s\n", VCGData.func_name); - if(alias) - fprintf(f, "void verse_send_%s(", VCGData.alias_name); - else - fprintf(f, "void verse_send_%s(", VCGData.func_name); - v_cg_gen_func_params(f, FALSE, alias); - fprintf(f, ")\n{\n\tuint8 *buf;\n"); - fprintf(f, "\tunsigned int buffer_pos = 0;\n"); - fprintf(f, "\tVCMDBufHead *head;\n"); - fprintf(f, "\thead = v_cmd_buf_allocate(%s);/* Allocating the buffer */\n", v_cg_compute_buffer_size()); - fprintf(f, "\tbuf = ((VCMDBuffer10 *)head)->buf;\n\n"); - - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], %u);\t/* Pack the command. */\n", VCGData.cmd_id); - - fprintf(f, "#if defined V_PRINT_SEND_COMMANDS\n"); - v_cg_create_print(f, TRUE, alias); - fprintf(f, "#endif\n"); - - for(i = 0; i < VCGData.param_count; i++) - { - const char *param = VCGData.param_name[i]; - no_param = FALSE; - if(alias) - { - if(i >= VCGData.alias_param && VCGData.alias_param_array == NULL) - no_param = TRUE; - if(VCGData.alias_param_array != NULL) - { - for(j = 0; j < VCGData.alias_param; j++) - if(VCGData.alias_param_array[j] == i) - break; - if(j == VCGData.alias_param) - no_param = TRUE; - } - } - - if(no_param) - param = "-1"; - - switch(VCGData.param_type[i]) - { - case VCGP_UINT8 : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], %s);\n", param); - break; - case VCGP_UINT16 : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param); - break; - case VCGP_UINT32 : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], %s);\n", param); - break; - case VCGP_ENUM : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)%s);\n", param); - break; - } - if(VCGData.param_type[i] == VCGP_REAL32) - { - if(no_param) - param = "V_REAL32_MAX"; - fprintf(f, "\tbuffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], %s);\n", param); - } - if(VCGData.param_type[i] == VCGP_REAL64) - { - if(no_param) - param = "V_REAL64_MAX"; - fprintf(f, "\tbuffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], %s);\n", param); - } - if(no_param) - param = "NULL"; - switch(VCGData.param_type[i]) - { - case VCGP_NAME : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], %s, 16);\n", param); - break; - case VCGP_LONG_NAME : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_string(&buf[buffer_pos], %s, 512);\n", param); - break; - } - if(no_param) - { - /* Horrible work-around, that prevents vertex/polygon deletes from misbehaving. */ - if(strncmp(VCGData.alias_name, "g_vertex_delete_real", 20) == 0 && i == 1) - param = "0"; - else if(strncmp(VCGData.alias_name, "g_polygon_delete", 16) == 0 && i == 1) - param = "1"; - else - param = "-1"; - } - switch(VCGData.param_type[i]) - { - case VCGP_NODE_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], %s);\n", param); - break; - case VCGP_LAYER_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param); - break; - case VCGP_BUFFER_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param); - break; - case VCGP_FRAGMENT_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], %s);\n", param); - break; - } - if(!alias && VCGData.param_type[i] == VCGP_PACK_INLINE) - fprintf(f, "%s", VCGData.param_name[i]); - } - if(VCGData.alias_name != NULL && VCGData.alias_bool_switch) - { - if(alias) - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);\n"); - else - fprintf(f, "\tbuffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);\n"); - } - v_cg_set_command_address(f, alias); - fprintf(f, "\tv_cmd_buf_set_size(head, buffer_pos);\n"); - - fprintf(f, "\tv_noq_send_buf(v_con_get_network_queue(), head);\n"); - fprintf(f, "}\n\n"); -} - -static void v_cg_gen_unpack(void) -{ - FILE *f; - unsigned int i; - boolean printed = FALSE; - - f = VCGData.nodes[VCGData.type]; - printf("generating function: v_unpack_%s\n", VCGData.func_name); - fprintf(f, "unsigned int v_unpack_%s(const char *buf, size_t buffer_length)\n", VCGData.func_name); - fprintf(f, "{\n"); - for(i = 0; i < VCGData.param_count && VCGData.param_type[i] != VCGP_ENUM; i++); - if(i < VCGData.param_count) - fprintf(f, "\tuint8 enum_temp;\n"); - fprintf(f, "\tunsigned int buffer_pos = 0;\n"); - fprintf(f, "\tvoid (* func_%s)(void *user_data, ", VCGData.func_name); - v_cg_gen_func_params(f, FALSE, FALSE); - fprintf(f, ");\n\t"); - v_cg_gen_func_params(f, TRUE, FALSE); - if(VCGData.alias_name != NULL && VCGData.alias_bool_switch) - fprintf(f, "uint8\talias_bool;\n"); - fprintf(f, "\n\tfunc_%s = v_fs_get_user_func(%u);\n", VCGData.func_name, VCGData.cmd_id); - fprintf(f, "\tif(buffer_length < %u)\n\t\treturn -1;\n", v_cg_compute_command_size(0, TRUE)); - for(i = 0; i < VCGData.param_count; i++) - { - switch(VCGData.param_type[i]) - { - case VCGP_UINT8 : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_UINT16 : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_UINT32 : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_REAL32 : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_REAL64 : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_POINTER_TYPE : - break; - case VCGP_POINTER : - break; - case VCGP_NAME : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], %s, 16, buffer_length - buffer_pos);\n", VCGData.param_name[i]); - if(i + 1 < VCGData.param_count) - fprintf(f, "\tif(buffer_length < %u + buffer_pos)\n\t\treturn -1;\n", v_cg_compute_command_size(i + 1, TRUE)); - break; - case VCGP_LONG_NAME : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], %s, 512, buffer_length - buffer_pos);\n", VCGData.param_name[i]); - if(i + 1 < VCGData.param_count) - fprintf(f, "\tif(buffer_length < %u + buffer_pos)\n\t\treturn -1;\n", v_cg_compute_command_size(i + 1, TRUE)); - break; - case VCGP_NODE_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_LAYER_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_BUFFER_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_FRAGMENT_ID : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &%s);\n", VCGData.param_name[i]); - break; - case VCGP_ENUM : - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);\n"); - fprintf(f, "\t%s = (%s)enum_temp;\n", VCGData.param_name[i], VCGData.param_name[i - 1]); - break; - case VCGP_UNPACK_INLINE : - if(!printed) - { - fprintf(f, "#if defined V_PRINT_RECEIVE_COMMANDS\n"); - if(VCGData.alias_name != NULL) - { - fprintf(f, "\t%s\n\t", VCGData.alias_qualifier); - v_cg_create_print(f, FALSE, TRUE); - fprintf(f, "\telse\n\t"); - } - v_cg_create_print(f, FALSE, FALSE); - fprintf(f, "#endif\n"); - printed = TRUE; - } - fprintf(f, "%s\n", VCGData.param_name[i++]); - break; - } - } - if(VCGData.alias_name != NULL && VCGData.alias_bool_switch) - { - fprintf(f, "\tif(buffer_length < buffer_pos + 1)\n"); - fprintf(f, "\t\treturn -1;\n"); - fprintf(f, "\tbuffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);\n"); - } - if(!printed) - { - fprintf(f, "#if defined V_PRINT_RECEIVE_COMMANDS\n"); - if(VCGData.alias_name != NULL) - { - if(VCGData.alias_qualifier != NULL) - fprintf(f, "\t%s\n\t", VCGData.alias_qualifier); - else - fprintf(f, "\tif(!alias_bool)\n\t"); - v_cg_create_print(f, FALSE, TRUE); - fprintf(f, "\telse\n\t"); - } - v_cg_create_print(f, FALSE, FALSE); - fprintf(f, "#endif\n"); - printed = TRUE; - } - - if(VCGData.alias_name != NULL) - { - unsigned int active; - - if(VCGData.alias_bool_switch) - fprintf(f, "\tif(!alias_bool)\n"); - else - fprintf(f, "\t%s\n", VCGData.alias_qualifier); - fprintf(f, "\t{\n"); - fprintf(f, "\t\tvoid (* alias_%s)(void *user_data, ", VCGData.alias_name); - v_cg_gen_func_params(f, FALSE, TRUE); - fprintf(f, ");\n"); - fprintf(f, "\t\talias_%s = v_fs_get_alias_user_func(%u);\n", VCGData.alias_name, VCGData.cmd_id); - fprintf(f, "\t\tif(alias_%s != NULL)\n", VCGData.alias_name); - fprintf(f, "\t\t\talias_%s(v_fs_get_alias_user_data(%u)", VCGData.alias_name, VCGData.cmd_id); - for(i = 0; i < VCGData.param_count && i < VCGData.alias_param; i++) - { - if(VCGData.alias_param_array != NULL) - active = VCGData.alias_param_array[i]; - else - active = i; - - if(VCGData.param_type[active] != VCGP_PACK_INLINE && - VCGData.param_type[active] != VCGP_UNPACK_INLINE && - VCGData.param_type[active] != VCGP_END_ADDRESS && - VCGData.param_type[active] != VCGP_POINTER_TYPE) - { - if(VCGData.param_type[active] == VCGP_ENUM_NAME) - { - fprintf(f, ", (%s)%s", VCGData.param_name[active], VCGData.param_name[active + 1]); - i++; - } - else - fprintf(f, ", %s", VCGData.param_name[active]); - } - } - fprintf(f, ");\n\t\treturn buffer_pos;\n\t}\n"); - } - - fprintf(f, "\tif(func_%s != NULL)\n", VCGData.func_name); - fprintf(f, "\t\tfunc_%s(v_fs_get_user_data(%u)", VCGData.func_name, VCGData.cmd_id); - for(i = 0; i < VCGData.param_count; i++) - { - if(VCGData.param_type[i] != VCGP_PACK_INLINE && VCGData.param_type[i] != VCGP_UNPACK_INLINE && VCGData.param_type[i] != VCGP_END_ADDRESS && VCGData.param_type[i] != VCGP_POINTER_TYPE) - { - if(VCGData.param_type[i] == VCGP_ENUM_NAME) - { - fprintf(f, ", (%s) %s", VCGData.param_name[i], VCGData.param_name[i + 1]); - i++; - } - else - fprintf(f, ", %s", VCGData.param_name[i]); - } - } - fprintf(f, ");\n"); - fprintf(f, "\n\treturn buffer_pos;\n"); - fprintf(f, "}\n\n"); -} - -static void v_cg_gen_alias(void) -{ - FILE *f; - unsigned int i; - f = VCGData.nodes[VCGData.type]; - fprintf(f, "void verse_send_%s(", VCGData.alias_name); - v_cg_gen_func_params(f, FALSE, TRUE); - fprintf(f, ")\n{\n"); - fprintf(f, "\tverse_send_%s(", VCGData.func_name); - for(i = 0; i < VCGData.param_count; i++) - if(VCGData.param_type[i] != VCGP_ENUM_NAME && VCGData.param_type[i] != VCGP_PACK_INLINE && VCGData.param_type[i] != VCGP_UNPACK_INLINE && VCGData.param_type[i] != VCGP_END_ADDRESS && VCGData.param_type[i] != VCGP_POINTER_TYPE) - fprintf(f, ", %s", VCGData.param_name[i]); - fprintf(f, "}\n\n"); -} - -static void v_cg_gen_init(void) -{ - FILE *f; - f = VCGData.init; - fprintf(f, "\tv_fs_add_func(%i, v_unpack_%s, verse_send_%s, ", VCGData.cmd_id, VCGData.func_name, VCGData.func_name); - if(VCGData.alias_name != NULL) - fprintf(f, "verse_send_%s);\n", VCGData.alias_name); - else - fprintf(f, "NULL);\n"); -} - -static void v_cg_gen_verse_h(void) -{ - FILE *f; - if(VCGData.command == VCGCT_INVISIBLE_SYSTEM) - f = VCGData.internal_verse_h; - else - f = VCGData.verse_h; - fprintf(f, "extern void verse_send_%s(", VCGData.func_name); - v_cg_gen_func_params(f, FALSE, FALSE); - fprintf(f, ");\n"); - if(VCGData.alias_name != NULL) - { - fprintf(f, "extern void verse_send_%s(", VCGData.alias_name); - v_cg_gen_func_params(f, FALSE, TRUE); - fprintf(f, ");\n"); - } -} - -static void v_cg_gen_unpack_h(void) -{ - fprintf(VCGData.unpack, "extern unsigned int v_unpack_%s(const char *data, size_t length);\n", VCGData.func_name); -} - -void v_cg_end_cmd(void) -{ - v_cg_gen_pack(FALSE); - if(VCGData.alias_name != NULL) - v_cg_gen_pack(TRUE); - v_cg_gen_unpack(); - v_cg_gen_init(); - v_cg_gen_verse_h(); - v_cg_gen_unpack_h(); - VCGData.alias_name = NULL; -} - -int main(int argc, char *argv[]) -{ - const char *src = ""; - int i; - - for(i = 1; argv[i] != NULL; i++) - { - if(strcmp(argv[i], "-h") == 0) - { - printf("Verse protocol generation tool.\nUsage:\n"); - printf(" -h\t\tPrint this usage information, and exit.\n"); - printf(" -src=PATH\tSets source path prefix to PATH. It must be possible to find\n"); - printf("\t\tthe \"verse_header.h\" input file by appending that name to PATH.\n"); - printf("\t\tThus, PATH must end with a proper directory separator character.\n"); - printf(" -dst=PATH\tSets output directory, where all output files are written.\n"); - printf("\t\tIf used, use -src to point to where \"verse_header.h\" is.\n"); - printf("\nThe -src and -dst options were added to simplify building of Verse-Blender.\n"); - return EXIT_SUCCESS; - } - else if(strncmp(argv[i], "-src=", 5) == 0) - src = argv[i] + 5; - else if(strncmp(argv[i], "-dst=", 5) == 0) - { - if(chdir(argv[i] + 5) != 0) - fprintf(stderr, "%s: Couldn't set output directory to \"%s\"\n", argv[0], argv[i] + 5); - } - else - fprintf(stderr, "%s: Ignoring unknown option \"%s\"\n", argv[0], argv[i]); - } - - printf("start\n"); - if(!v_cg_init(src)) - return EXIT_FAILURE; - v_gen_system_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_object_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_geometry_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_material_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_bitmap_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_text_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_curve_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_gen_audio_cmd_def(); - fprintf(VCGData.verse_h, "\n"); - v_cg_close(); - printf("end\n"); - - return EXIT_SUCCESS; -} - -#endif diff --git a/extern/verse/dist/v_cmd_gen.h b/extern/verse/dist/v_cmd_gen.h deleted file mode 100644 index 6cc19a84d19..00000000000 --- a/extern/verse/dist/v_cmd_gen.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** -*/ - -/* Define this to at least build the code that regenerates the variable parts of the code. */ -/*#define V_GENERATE_FUNC_MODE*/ - -typedef enum { - VCGP_UINT8, - VCGP_UINT16, - VCGP_UINT32, - VCGP_REAL32, - VCGP_REAL64, - VCGP_POINTER_TYPE, - VCGP_POINTER, - VCGP_NAME, - VCGP_LONG_NAME, - VCGP_NODE_ID, - VCGP_LAYER_ID, - VCGP_BUFFER_ID, - VCGP_FRAGMENT_ID, - VCGP_ENUM_NAME, - VCGP_ENUM, - VCGP_PACK_INLINE, - VCGP_UNPACK_INLINE, - VCGP_END_ADDRESS -} VCGParam; - -typedef enum { - VCGCT_NORMAL, - VCGCT_UNIQUE, - VCGCT_ONCE, - VCGCT_INVISIBLE_SYSTEM, /* In the dark we are all invisible. */ - VCGCT_ORDERED -} VCGCommandType; - -extern void v_cg_new_cmd(VCGCommandType type, const char *name, unsigned int cmd_id, VCGCommandType command); -extern void v_cg_add_param(VCGParam type, const char *name); -extern void v_cg_alias(char bool_switch, const char *name, const char *qualifier, - unsigned int param, unsigned int *param_array); -extern void v_cg_end_cmd(void); -extern void v_cg_new_manual_cmd(unsigned int cmd_id, const char *name, const char *params, const char *alias_name, const char *alias_params); diff --git a/extern/verse/dist/v_connect.c b/extern/verse/dist/v_connect.c deleted file mode 100644 index 31be90e2d47..00000000000 --- a/extern/verse/dist/v_connect.c +++ /dev/null @@ -1,490 +0,0 @@ -/* -** -*/ - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_encryption.h" -#include "v_util.h" - -extern void verse_send_packet_ack(uint32 packet_id); - -static void v_send_hidden_connect_contact(void) /* Stage 0: Clinets inital call to connect to host */ -{ - uint8 buf[V_ENCRYPTION_LOGIN_KEY_HALF_SIZE + 4 + 1 + 1], *key; - unsigned int i, buffer_pos = 0; - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 0);/* Packing the packet id */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Packing the command */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Stage 0 */ - - key = v_con_get_my_key(); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], key[V_ENCRYPTION_LOGIN_PUBLIC_START + i]);/* Packing the command */ - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], key[V_ENCRYPTION_LOGIN_N_START + i]);/* Packing the command */ - - v_n_send_data(v_con_get_network_address(), buf, buffer_pos); -} - -static void v_send_hidden_connect_send_key(void) /* Stage 1: Hosts reply to any atempt to connect */ -{ - uint8 buf[V_ENCRYPTION_LOGIN_KEY_SIZE * 3 + 4 + 1 + 1 + 1 + 4 + 4], *host_id; - unsigned int i, buffer_pos = 0, s, f; - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 0);/* Packing the packet id */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Packing the command */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 1);/* Stage 1 */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], V_RELEASE_NUMBER);/* version */ - v_n_get_current_time(&s, &f); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], s);/* time, seconds */ - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], f);/* time, fraction */ - host_id = v_con_get_host_id(); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], host_id[V_ENCRYPTION_LOGIN_PUBLIC_START + i]); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], host_id[V_ENCRYPTION_LOGIN_N_START + i]); - - v_n_send_data(v_con_get_network_address(), buf, buffer_pos); -} - -static void v_send_hidden_connect_login(void) /* Stage 2: clients sends encrypted name and password */ -{ - uint8 buf[1500], *key, name_pass[V_ENCRYPTION_LOGIN_KEY_SIZE], encrypted_key[V_ENCRYPTION_LOGIN_KEY_SIZE]; - const char *name, *pass; - unsigned int buffer_pos = 0, i; - - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 1);/* Packing the packet id */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);/* Packing the command */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 2);/* Stage 2 */ - name = v_con_get_name(); - /* Pad data area with randomness. */ - for(i = 0; i < sizeof name_pass; i++) - name_pass[i] = rand() >> 13; - v_strlcpy(name_pass, name, V_ENCRYPTION_LOGIN_KEY_SIZE / 2); - pass = v_con_get_pass(); - v_strlcpy(name_pass + V_ENCRYPTION_LOGIN_KEY_SIZE / 2, pass, V_ENCRYPTION_LOGIN_KEY_SIZE / 2); - /* Make sure last (MSB) byte is clear, to guarantee that data < key for RSA math. */ - name_pass[sizeof name_pass - 1] = 0; - key = v_con_get_other_key(); - v_e_connect_encrypt(encrypted_key, name_pass, &key[V_ENCRYPTION_LOGIN_PUBLIC_START], &key[V_ENCRYPTION_LOGIN_N_START]); - - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], encrypted_key[i]); - v_n_send_data(v_con_get_network_address(), buf, buffer_pos); -} - -static void v_send_hidden_connect_accept(void) /* Host accepts Clients connectionatempt and sends over data encryption key */ -{ - uint8 buf[1500], *client_key, encrypted[V_ENCRYPTION_DATA_KEY_SIZE]; - unsigned int i, buffer_pos = 0; - - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 1);/* Packing the packet id */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 1);/* Packing the command */ - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], verse_session_get_avatar()); - client_key = v_con_get_other_key(); - v_e_connect_encrypt(encrypted, v_con_get_data_key(), &client_key[V_ENCRYPTION_LOGIN_PUBLIC_START], &client_key[V_ENCRYPTION_LOGIN_N_START]); - for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], encrypted[i]); - v_n_send_data(v_con_get_network_address(), buf, buffer_pos); -} - -static void v_send_hidden_connect_terminate(VNetworkAddress *address, unsigned int packet_id, const char *bye) /* Host accepts Clients connectionatempt and sends over data encryption key */ -{ - uint8 buf[1500]; - unsigned int buffer_pos = 0; - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id);/* Packing the packet id */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 2);/* Packing the command */ - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], bye, 512); /* pack message */ - v_e_data_encrypt_command(buf, sizeof (uint32), buf + sizeof (uint32), buffer_pos, v_con_get_data_key()); - v_n_send_data(address, buf, buffer_pos); -} - -VSession verse_send_connect(const char *name, const char *pass, const char *address, const uint8 *expected_key) -{ - uint8 *my_key, *key = NULL; - unsigned int i; - VNetworkAddress a; - VSession *session; - if(v_n_set_network_address(&a, address)) - { -#if defined(V_PRINT_SEND_COMMANDS) - char ip_string[32]; -#endif - session = v_con_connect(a.ip, a.port, V_CS_CONTACT); -#if defined(V_PRINT_SEND_COMMANDS) - v_n_get_address_string(&a, ip_string); - printf("send: %p = verse_send_connect(name = %s, pass = %s, address = %s (%s), expected_key = %p)\n", session, name, pass, address, ip_string, expected_key); -#endif - v_con_set_name_pass(name, pass); - if(expected_key != NULL) - { - key = malloc((sizeof *key) * V_ENCRYPTION_LOGIN_KEY_HALF_SIZE); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_HALF_SIZE; i++) - key[i] = expected_key[i]; - *v_con_get_expected_key() = key; - } - my_key = v_con_get_my_key(); - v_e_connect_create_key(&my_key[V_ENCRYPTION_LOGIN_PRIVATE_START], &my_key[V_ENCRYPTION_LOGIN_PUBLIC_START], &my_key[V_ENCRYPTION_LOGIN_N_START]); - v_send_hidden_connect_contact(); - v_con_inqueue_timer_update(); /* Reset timer in connection's in queue, above takes a while. */ - return session; - } - else - { -#if defined(V_PRINT_SEND_COMMANDS) - printf("send: NULL = verse_send_connect(name = %s, pass = %s, address = %s (Unressolved DNS), key = %p);\n", name, pass, address, key); -#endif - return NULL; - } -} - -void v_update_connection_pending(boolean resend) -{ - VSession (* func_connect)(void *user_data, const char *name, const char *pass, const char *address, const uint8 *key) = NULL; - VSession (* func_connect_accept)(void *user_data, VNodeID avatar, char *address, uint8 *host_id); - void (* func_connect_terminate)(void *user_data, char *address, const char *bye); - char address_string[32]; - - switch(v_con_get_connect_stage()) - { - case V_CS_CONTACT : /* client tries to contact host */ - if(resend) - v_send_hidden_connect_contact(); - break; - case V_CS_CONTACTED : /* Host replies with challange */ - if(resend) - v_send_hidden_connect_send_key(); - break; - case V_CS_PENDING_ACCEPT : /* Client sends login */ - if(resend) - v_send_hidden_connect_login(); - break; - case V_CS_PENDING_HOST_CALLBACK : /* Host got login waits for accept connect callback */ - v_con_set_connect_stage(V_CS_PENDING_DECISION); - func_connect = v_fs_get_user_func(0); - v_n_get_address_string(v_con_get_network_address(), address_string); -#if defined(V_PRINT_RECEIVE_COMMANDS) - printf("receive: verse_send_connect(address = %s, name = %s, pass = %s, key = NULL); callback = %p\n", address_string, v_con_get_name(), v_con_get_pass(), func_connect); -#endif - if(func_connect != 0) - func_connect(v_fs_get_user_data(0), v_con_get_name(), v_con_get_pass(), address_string, NULL); - break; - case V_CS_PENDING_CLIENT_CALLBACK_ACCEPT : /* Host got login waits for accept connect callback */ - v_con_set_connect_stage(V_CS_CONNECTED); - func_connect_accept = v_fs_get_user_func(1); - v_n_get_address_string(v_con_get_network_address(), address_string); -#if defined(V_PRINT_RECEIVE_COMMANDS) - printf("receive: func_connect_accept(avatar = %u, address = %s, name = %s, pass = %s, key = NULL); callback = %p\n", - verse_session_get_avatar(), address_string, v_con_get_name(), v_con_get_pass(), func_connect); -#endif - if(func_connect_accept != 0) - func_connect_accept(v_fs_get_user_data(1), verse_session_get_avatar(), address_string, NULL); - break; - case V_CS_PENDING_CLIENT_CALLBACK_TERMINATE : /* Host got login waits for accept connect callback */ - v_con_set_connect_stage(V_CS_CONNECTED); - func_connect_terminate = v_fs_get_user_func(2); - v_n_get_address_string(v_con_get_network_address(), address_string); -#if defined(V_PRINT_RECEIVE_COMMANDS) - printf("receive: func_connect_terminate(address = %s, bye = %s); callback = %p\n", address_string, "no message", func_connect); -#endif - if(func_connect_terminate != 0) - func_connect_terminate(v_fs_get_user_data(2), address_string, "no message"); - break; - default: - ; - } -} - -void v_unpack_connection(const char *buf, unsigned int buffer_length) /* un packing all stages of connect command */ -{ - unsigned int buffer_pos, i, pack_id; - uint32 seconds, fractions, pre; - uint8 /*key[V_ENCRYPTION_LOGIN_KEY_SIZE], */stage, cmd_id, version; - - if(buffer_length < 5) - return; - - buffer_pos = vnp_raw_unpack_uint32(buf, &pack_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &cmd_id); - pre = v_con_get_connect_stage(); - if(cmd_id == 0) - { - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &stage); - printf(" Handling connection, stage %u\n", stage); - if(stage == V_CS_IDLE && V_CS_IDLE == v_con_get_connect_stage()) /* reseved by host */ - { - uint8 *other_key, *my_key; - - verse_send_packet_ack(pack_id); - my_key = v_con_get_my_key(); - v_con_set_data_key(v_e_data_create_key()); - other_key = v_con_get_other_key(); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i]);/* Packing the command */ - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_N_START + i]);/* Packing the command */ - v_con_set_connect_stage(V_CS_CONTACTED); - v_send_hidden_connect_send_key(); - return; - } - if(stage == V_CS_CONTACT && V_CS_CONTACT == v_con_get_connect_stage()) - { - uint8 *other_key; /* *host_id, *my_key, a[V_ENCRYPTION_LOGIN_KEY_SIZE], b[V_ENCRYPTION_LOGIN_KEY_SIZE];*/ - verse_send_packet_ack(pack_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &version); - if(version != V_RELEASE_NUMBER) - { - /* char error_message[128]; - func_connect_deny = v_fs_get_user_func(2); - #if defined(V_PRINT_RECEIVE_COMMANDS) - printf("receive: verse_send_connect_deny(Host is running version %u you are running version %u); callback = %p\n", (uint32)version, (uint32)V_RELEASE_NUMBER func_connect_deny); - #endif - if(func_connect_deny != NULL) - { - sprintf(error_message, "Host is running version %u you are running version %u", (uint32)version, (uint32)V_RELEASE_NUMBER); - func_connect_deny(v_fs_get_user_data(2), error_message); - }*/ - return; - } - - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &seconds); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &fractions); - v_con_set_time(seconds, fractions); - - other_key = v_con_get_other_key(); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i]); - for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &other_key[V_ENCRYPTION_LOGIN_N_START + i]); - - v_con_set_connect_stage(V_CS_PENDING_ACCEPT); - v_send_hidden_connect_login(); - return; - } -#if 0 - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_HALF_SIZE && encrypted_key[i] == 0; i++); - if(i < 0) - { - other_key = v_con_get_my_key(); - v_e_connect_encrypt(decrypted_key, encrypted_key, &other_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i], &other_key[V_ENCRYPTION_LOGIN_N_START + i]); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_HALF_SIZE && my_key[V_ENCRYPTION_LOGIN_PUBLIC_START + i] == decrypted_key[i]; i++); - if(i < 0) /* Host is not who it appers top be */ - { - func_connect_deny = v_fs_get_user_func(2); -#if defined(V_PRINT_RECEIVE_COMMANDS) - printf("receive: verse_send_connect_deny(Host failed identity check); callback = %p\n", func_connect_deny); -#endif - if(func_connect_deny != NULL) - func_connect_deny(v_fs_get_user_data(2), "Host failed identity check"); - return; - } - } -#endif - if(stage == V_CS_CONTACTED && V_CS_CONTACTED == v_con_get_connect_stage()) /* reseved by host */ - { - char *host_id, unpack[V_ENCRYPTION_LOGIN_KEY_SIZE], data[V_ENCRYPTION_LOGIN_KEY_SIZE]; - VNetworkAddress *address; - verse_send_packet_ack(pack_id); - address = v_con_get_network_address(); - for(i = 0; i < V_ENCRYPTION_LOGIN_KEY_SIZE; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &data[i]); - host_id = v_con_get_host_id(); - v_e_connect_encrypt(unpack, data, &host_id[V_ENCRYPTION_LOGIN_PRIVATE_START], &host_id[V_ENCRYPTION_LOGIN_N_START]); - v_con_set_name_pass(unpack, &unpack[V_ENCRYPTION_LOGIN_KEY_SIZE / 2]); - v_con_set_connect_stage(V_CS_PENDING_HOST_CALLBACK); - return; - } - } - if(cmd_id == 1 && V_CS_PENDING_ACCEPT == v_con_get_connect_stage()) /* reseved by client */ - { - uint8 *my_key, key[V_ENCRYPTION_DATA_KEY_SIZE], decrypted[V_ENCRYPTION_DATA_KEY_SIZE]; - uint32 avatar; - verse_send_packet_ack(pack_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &avatar); - v_con_set_avatar(avatar); - for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &key[i]); - my_key = v_con_get_my_key(); - v_e_connect_encrypt(decrypted, key, &my_key[V_ENCRYPTION_LOGIN_PRIVATE_START], &my_key[V_ENCRYPTION_LOGIN_N_START]); - v_con_set_data_key(decrypted); - v_con_set_connect_stage(V_CS_PENDING_CLIENT_CALLBACK_ACCEPT); - v_send_hidden_connect_send_key(); - return; - } - if(cmd_id == 2 && V_CS_PENDING_ACCEPT == v_con_get_connect_stage()) /* reseved by client */ - { - verse_send_packet_ack(pack_id); - /* buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos); - */ v_con_set_connect_stage(V_CS_PENDING_CLIENT_CALLBACK_TERMINATE); - return; - } -} - -VSession verse_send_connect_accept(VNodeID avatar, const char *address, uint8 *host_id) -{ - VNetworkAddress a; -#if defined(V_PRINT_SEND_COMMANDS) - printf("send: verse_send_connect_accept(avatar = %u, address = %s, host_id = NULL);\n", avatar, address); -#endif - - if(!v_n_set_network_address(&a, address)) - return NULL; - if(v_co_switch_connection(a.ip, a.port)) - { - if(v_con_get_connect_stage() != V_CS_PENDING_DECISION) - return NULL; - v_con_set_avatar(avatar); - v_con_set_connect_stage(V_CS_CONNECTED); - v_send_hidden_connect_accept(); - return v_con_get_network_queue(); - } - return NULL; -} - -void v_callback_connect_terminate(const char *bye) -{ - void (* func_connect_terminate)(void *user_data, char *address, const char *bye); - char address_string[32]; - - printf("terminate (%s)\n", bye); - func_connect_terminate = v_fs_get_user_func(2); - v_n_get_address_string(v_con_get_network_address(), address_string); -#if defined(V_PRINT_RECEIVE_COMMANDS) - printf("receive: verse_send_connect_terminate(address = %s, bye = %s); callback = %p\n", address_string, bye, func_connect_terminate); -#endif - if(func_connect_terminate != 0) - func_connect_terminate(v_fs_get_user_data(2), address_string, bye); -} - -void verse_send_connect_terminate(const char *address, const char *bye) -{ - VNetworkAddress a; -#if defined(V_PRINT_RECEIVE_COMMANDS) - printf("send: verse_send_connect_terminate(address = %s, bye = %s);\n", address, bye); -#endif - - if(address == NULL) - v_send_hidden_connect_terminate(v_con_get_network_address(), v_noq_get_next_out_packet_id(v_con_get_network_queue()), bye); - else if(!v_n_set_network_address(&a, address)) - return; - else if(v_co_switch_connection(a.ip, a.port)) - v_send_hidden_connect_terminate(v_con_get_network_address(), v_noq_get_next_out_packet_id(v_con_get_network_queue()), bye); - - if(v_con_get_connect_stage() != V_CS_PENDING_DECISION) - verse_session_destroy(v_con_get_network_queue()); -} - -void verse_send_ping(const char *address, const char *message) -{ - VNetworkAddress a; - if(v_n_set_network_address(&a, address)) - { - unsigned int buffer_pos = 0; - uint8 buf[1500]; - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], 0);/* Packing the Packet id */ - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 5);/* Packing the command */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_ping(address = %s text = %s);\n", address, message); -#endif - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], message, 1400); - v_n_send_data(&a, buf, buffer_pos); - } -#if defined V_PRINT_SEND_COMMANDS - else - printf("send: verse_send_ping(address = %s (FAULTY) message = %s);\n", address, message); -#endif -} - -unsigned int v_unpack_ping(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_ping)(void *user_data, const char *address, const char *text); - char address[64]; - char message[1400]; - - func_ping = v_fs_get_user_func(5); - v_n_get_address_string(v_con_get_network_address(), address); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], message, 1400, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_ping(address = %s message = %s ); callback = %p\n", address, message, v_fs_get_user_func(5)); -#endif - if(func_ping != NULL) - func_ping(v_fs_get_user_data(5), address, message); - return buffer_pos; -} - -typedef struct { - uint32 ip; - uint16 port; - char message[1400]; - void *next; -} VPingCommand; - -static VPingCommand *v_ping_commands = NULL; - -boolean v_connect_unpack_ping(const char *buf, size_t buffer_length, uint32 ip, uint16 port) -{ - if(buffer_length > 5) - { - unsigned int buffer_pos = 0; - uint8 cmd_id; - uint32 pack_id; - - buffer_pos = vnp_raw_unpack_uint32(&buf[buffer_pos], &pack_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &cmd_id); - if(cmd_id == 5) - { - if(NULL != v_fs_get_user_func(5)) - { - VPingCommand *pc; - - pc = malloc(sizeof *pc); - pc->ip = ip; - pc->port = port; - vnp_raw_unpack_string(&buf[buffer_pos], pc->message, - sizeof pc->message, buffer_length - buffer_pos); - pc->next = v_ping_commands; - v_ping_commands = pc; - } - return TRUE; - } - } - return FALSE; -} - -void v_ping_update(void) -{ - VPingCommand *cp; - void (* func_ping)(void *user_data, const char *address, const char *text); - VNetworkAddress a; - char address[64]; - func_ping = v_fs_get_user_func(5); - - while(v_ping_commands != NULL) - { - cp = v_ping_commands->next; - a.ip = v_ping_commands->ip; - a.port = v_ping_commands->port; - v_n_get_address_string(&a, address); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_ping(address = %s message = %s ); callback = %p\n", address, v_ping_commands->message, v_fs_get_user_func(5)); -#endif - if(func_ping != NULL) - func_ping(v_fs_get_user_data(5), address, v_ping_commands->message); - free(v_ping_commands); - v_ping_commands = cp; - } -} - -#endif diff --git a/extern/verse/dist/v_connection.c b/extern/verse/dist/v_connection.c deleted file mode 100644 index 3bfafad5660..00000000000 --- a/extern/verse/dist/v_connection.c +++ /dev/null @@ -1,490 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_buf.h" -#include "v_network_in_que.h" -#include "v_network_out_que.h" -#include "v_cmd_gen.h" -#include "v_connection.h" -#include "v_encryption.h" -#include "v_util.h" - -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" - -#define CONNECTION_CHUNK_SIZE 16 -#define V_MAX_CONNECT_PACKET_SIZE 1500 -#define V_CON_MAX_MICROSECOND_BETWEEN_SENDS 100 -#define V_RE_CONNECTON_TIME_OUT 4 -#define V_CONNECTON_TIME_OUT 30 - -typedef struct { - VNetOutQueue *out_queue; - VNetInQueue in_queue; - VNetworkAddress network_address; - boolean connected; - unsigned int avatar; -/* unsigned int packet_id;*/ - int32 timedelta_s; - uint32 timedelta_f; - boolean destroy_flag; - void *ordered_storage; - char name[V_ENCRYPTION_LOGIN_KEY_SIZE / 2]; - char pass[V_ENCRYPTION_LOGIN_KEY_SIZE / 2]; - VConnectStage connect_stage; - unsigned int stage_atempts; - uint8 key_my[V_ENCRYPTION_LOGIN_KEY_FULL_SIZE]; - uint8 key_other[V_ENCRYPTION_LOGIN_KEY_FULL_SIZE]; - uint8 key_data[V_ENCRYPTION_DATA_KEY_SIZE]; - uint8 *expected_key; -} VConnection; - -static struct { - VConnection *con; - unsigned int con_count; - unsigned int current_connection; - VNetworkAddress *connect_address; - void *unified_func_storage; - uint16 connect_port; - unsigned int pending_packets; - uint8 host_id[V_ENCRYPTION_LOGIN_KEY_FULL_SIZE]; -} VConData; - -extern void cmd_buf_init(void); - -void v_con_init(void) /* since verse doesnt have an init function this function is runned over an ove ard starts whit a check it it has run before */ -{ - static boolean v_con_initialized = FALSE; - - if(v_con_initialized) - return; - cmd_buf_init(); - v_con_initialized = TRUE; - VConData.con = malloc(CONNECTION_CHUNK_SIZE * sizeof *VConData.con); - memset(VConData.con, 0, CONNECTION_CHUNK_SIZE * sizeof *VConData.con); /* Clear the memory. */ - VConData.con_count = 0; - VConData.pending_packets = 0; -/* v_e_connect_create_key(&VConData.host_id[V_ENCRYPTION_LOGIN_PRIVATE_START], - &VConData.host_id[V_ENCRYPTION_LOGIN_PUBLIC_START], - &VConData.host_id[V_ENCRYPTION_LOGIN_N_START]);*/ /* default host id if none is set by user */ -} - -void verse_set_port(uint16 port) -{ - v_n_set_port(port); -} - -void verse_host_id_create(uint8 *id) -{ - v_e_connect_create_key(&id[V_ENCRYPTION_LOGIN_PRIVATE_START], - &id[V_ENCRYPTION_LOGIN_PUBLIC_START], &id[V_ENCRYPTION_LOGIN_N_START]); -} - -void verse_host_id_set(uint8 *id) -{ - memcpy(VConData.host_id, id, V_ENCRYPTION_LOGIN_KEY_FULL_SIZE); -} - -extern void *v_fs_create_func_storage(void); -extern void *v_create_ordered_storage(void); -extern void v_destroy_ordered_storage(void *data); - -void *v_con_connect(uint32 ip, uint16 port, VConnectStage stage) /* creates a new connection slot */ -{ - v_con_init(); /* init connections, if not done yet */ - if((VConData.con_count - 1) % CONNECTION_CHUNK_SIZE == 0) /* do we need more slots for connections, then reallocate more space */ - VConData.con = realloc(VConData.con, (sizeof *VConData.con) * (VConData.con_count + CONNECTION_CHUNK_SIZE)); - VConData.con[VConData.con_count].out_queue = v_noq_create_network_queue(); /* create a out queue fo all out going commands */ - v_niq_clear(&VConData.con[VConData.con_count].in_queue); /* clear and init the que of incomming packets.*/ - VConData.con[VConData.con_count].connected = FALSE; /* not yet propperly connected and should not accept commands yet */ - VConData.con[VConData.con_count].network_address.ip = ip; /* ip address of other side */ - VConData.con[VConData.con_count].network_address.port = port; /* port used by other side */ - VConData.con[VConData.con_count].avatar = 0; /* no avatar set yet*/ -/* VConData.con[VConData.con_count].packet_id = 2;*/ - VConData.con[VConData.con_count].destroy_flag = FALSE; /* this is a flag that is set once the connection is about to be destroyed.*/ - VConData.con[VConData.con_count].ordered_storage = v_create_ordered_storage(); - VConData.con[VConData.con_count].name[0] = 0; /* nouser name set yet */ - VConData.con[VConData.con_count].pass[0] = 0; /* no password set yet */ - VConData.con[VConData.con_count].connect_stage = stage; /* this is the stage of the connection, it show if the connection is ready, the init state depends if this is a client or host */ - VConData.con[VConData.con_count].stage_atempts = 0; /* each stage in the connection prosess is atempted multiple times to avoid failiure if packets get lost*/ - VConData.con[VConData.con_count].timedelta_s = 0; /* number of seconds since last incomming packet to the connection*/ - VConData.con[VConData.con_count].timedelta_f = 0; /* number of fractions of a second since last incomming packet to the connection*/ - VConData.con[VConData.con_count].expected_key = NULL; /* expected hist id if this is a client */ - VConData.current_connection = VConData.con_count; /* set the new connection to the current*/ - ++VConData.con_count; /* add one to the number of connections*/ - return VConData.con[VConData.current_connection].out_queue; -} - -void verse_session_destroy(VSession session) /* a session can not be destroyed right away, because this function might be called inside a call back from the session it tryes tpo destroy, therfor it only markes it*/ -{ - unsigned int i; - for(i = 0; i < VConData.con_count && VConData.con[i].out_queue != session; i++); - if(i < VConData.con_count) - { - VConData.con[i].destroy_flag = TRUE; - } -} - -void verse_session_set(VSession session) /* find a session and make it the current*/ -{ - unsigned int i; - for(i = 0; i < VConData.con_count && session != VConData.con[i].out_queue; i++); - if(i < VConData.con_count) - VConData.current_connection = i; -} - -VSession verse_session_get(void) -{ - if(VConData.current_connection < VConData.con_count) - return VConData.con[VConData.current_connection].out_queue; - return NULL; -} - -uint32 v_co_find_connection(uint32 ip, uint16 port) /* if a packet comes form a ip address what connection does it belong to? */ -{ - unsigned int i; - - for(i = 0; i < VConData.con_count; i++) - { - if(ip == VConData.con[i].network_address.ip && - port == VConData.con[i].network_address.port && - VConData.con[i].destroy_flag == 0) - { - return i; - } - } - return -1; -} - -boolean v_co_switch_connection(uint32 ip, uint16 port) /* switches to the current connection to one ip address if it exists */ -{ - unsigned int i; - for(i = 0; i < VConData.con_count; i++) - { - if(ip == VConData.con[i].network_address.ip && port == VConData.con[i].network_address.port) - { - VConData.current_connection = i; - return TRUE; - } - } - return FALSE; -} - -void v_con_inqueue_timer_update(void) -{ - if(VConData.current_connection < VConData.con_count) - { - v_niq_timer_update(&VConData.con[VConData.current_connection].in_queue); - } -} - -/* -extern void v_fs_buf_unpack(const uint8 *data, unsigned int length); -extern void v_fs_buf_store_pack(uint8 *data, unsigned int length); -extern boolean v_fs_buf_unpack_stored(void); -*/ -extern void v_unpack_connection(const char *buf, unsigned int buffer_length); - -extern void verse_send_packet_nak(uint32 packet_id); -extern void v_callback_connect_terminate(const char *bye); -extern boolean v_connect_unpack_ping(const char *buf, size_t buffer_length, uint32 ip, uint16 port); -extern void v_ping_update(void); -void v_fs_unpack_beginning(uint8 *data, unsigned int length); - -/* Main function that receives and distributes all incoming packets. */ -boolean v_con_network_listen(void) -{ - VNetworkAddress address; - uint8 buf[V_MAX_CONNECT_PACKET_SIZE], *store; - int size = 0; - unsigned int connection; - uint32 packet_id; - boolean ret = FALSE; - - v_con_init(); /* Init if needed. */ - connection = VConData.current_connection; /* Store current connection in a local variable so that we can restore it later. */ - size = v_n_receive_data(&address, buf, sizeof buf); /* Ask for incoming data from the network. */ - while(size != -1 && size != 0) /* Did we get any data? */ - { - VConData.current_connection = v_co_find_connection(address.ip, address.port); /* Is there a connection matching the IP and port? */ - vnp_raw_unpack_uint32(buf, &packet_id); /* Unpack the ID of the packet. */ -/* printf("got packet ID %u, %d bytes, connection %u\n", packet_id, size, VConData.current_connection);*/ - if(VConData.current_connection < VConData.con_count && - !(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED && packet_id == 0)) /* If this isn't a packet from an existing connection, disregard it. */ - { - if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED) /* Is this connection initialized? */ - { - store = v_niq_store(&VConData.con[VConData.current_connection].in_queue, size, packet_id); /* Store the packet. */ - if(store != NULL) - { - VConData.pending_packets++; /* We now have one more packet pending unpack. */ - v_e_data_decrypt_packet(store, buf, size, VConData.con[VConData.current_connection].key_data); /* Decrypt the packet. */ - v_fs_unpack_beginning(store, size); - } - } - else - { - v_unpack_connection(buf, size); /* This is an ongoing connecton-attempt. */ - v_niq_timer_update(&VConData.con[VConData.current_connection].in_queue); - } - } - else if(v_connect_unpack_ping(buf, size, address.ip, address.port)) /* Ping handled. */ - ; - else if(v_fs_func_accept_connections()) /* Do we accept connection-attempts? */ - { - if(VConData.current_connection >= VConData.con_count || - V_RE_CONNECTON_TIME_OUT < v_niq_time_out(&VConData.con[VConData.current_connection].in_queue)) /* Is it a new client, or an old client that we haven't heard form in some time? */ - { - if(VConData.current_connection < VConData.con_count) - { - VConData.con[VConData.current_connection].network_address.ip = 0; - VConData.con[VConData.current_connection].destroy_flag = TRUE; /* Destroy old connection if there is one. */ - } - v_con_connect(address.ip, address.port, V_CS_IDLE); /* Create a new connection. */ - v_unpack_connection(buf, size); /* Unpack the connection-attempt. */ - } - } - else - { - fprintf(stderr, __FILE__ ": Unhandled packet--dropping\n"); - if(VConData.con_count > 0) - { - fprintf(stderr, __FILE__ ": State: connections=%u, current=%u (stage %u), packet_id=%u\n", - VConData.con_count, - VConData.current_connection, - (VConData.current_connection < VConData.con_count) ? VConData.con[VConData.current_connection].connect_stage : 0, - packet_id); - } - } - size = v_n_receive_data(&address, buf, sizeof buf); /* See if there are more incoming packets. */ - ret = TRUE; - } - VConData.current_connection = connection; /* Reset the current connection. */ - - return ret; -} - -extern void v_update_connection_pending(boolean resend); - -boolean v_con_callback_update(void) -{ - static unsigned int seconds; - boolean output = FALSE; - size_t size; - unsigned int connection, s; - VNetInPacked *p; - - v_n_get_current_time(&s, NULL); - connection = VConData.current_connection; - for(VConData.current_connection = 0; VConData.current_connection < VConData.con_count; VConData.current_connection++) - if(VConData.con[VConData.current_connection].connect_stage != V_CS_CONNECTED) - v_update_connection_pending(s != seconds); - seconds = s; - VConData.current_connection = connection; - if(VConData.pending_packets == 0) - return FALSE; - if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED) - { - while((p = v_niq_get(&VConData.con[VConData.current_connection].in_queue, &size)) != NULL) - { - VConData.pending_packets--; - v_fs_unpack(p->data, size); - v_niq_release(&VConData.con[VConData.current_connection].in_queue, p); - output = TRUE; - } - v_con_network_listen(); - } - return output; -} - -void verse_callback_update(unsigned int microseconds) -{ - unsigned int connection, passed; - - v_ping_update(); /* Deliver any pending pings. */ - connection = VConData.current_connection; - for(VConData.current_connection = 0; VConData.current_connection < VConData.con_count; VConData.current_connection++) - { - if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED) - v_noq_send_queue(VConData.con[VConData.current_connection].out_queue, &VConData.con[VConData.current_connection].network_address); - if(VConData.con[VConData.current_connection].destroy_flag == TRUE) - { - v_noq_destroy_network_queue(VConData.con[VConData.current_connection].out_queue); - VConData.pending_packets -= v_niq_free(&VConData.con[VConData.current_connection].in_queue); - v_destroy_ordered_storage(VConData.con[VConData.current_connection].ordered_storage); - if(VConData.con[VConData.current_connection].expected_key != NULL) - free(VConData.con[VConData.current_connection].expected_key); - if(VConData.con_count - 1 != VConData.current_connection) - VConData.con[VConData.current_connection] = VConData.con[VConData.con_count - 1]; - VConData.con_count--; - if(connection >= VConData.con_count) - VConData.current_connection = 0; - return; - } - } - VConData.current_connection = connection; - - if(VConData.con_count > 0) - { -/* printf("checking timeout of stage %d connection %u\n", - VConData.con[VConData.current_connection].connect_stage, VConData.current_connection); -*/ if(V_CONNECTON_TIME_OUT < v_niq_time_out(&VConData.con[VConData.current_connection].in_queue)) - { - if(VConData.con[VConData.current_connection].connect_stage != V_CS_CONNECTED) - { - VConData.con[VConData.current_connection].destroy_flag = TRUE; - } - else - v_callback_connect_terminate("connection timed out"); - } - } - - v_con_network_listen(); - if(VConData.con_count > 0) - if(v_con_callback_update()) - return; - for(passed = 0; passed < microseconds && VConData.pending_packets == 0;) - { - boolean update; - if(microseconds - passed > V_CON_MAX_MICROSECOND_BETWEEN_SENDS) /* Still a long way to go? */ - passed += v_n_wait_for_incoming(V_CON_MAX_MICROSECOND_BETWEEN_SENDS); - else - passed += v_n_wait_for_incoming(microseconds - passed); - do - { - update = v_con_network_listen(); - connection = VConData.current_connection; - for(VConData.current_connection = 0; VConData.current_connection < VConData.con_count; VConData.current_connection++) - { - if(VConData.con[VConData.current_connection].connect_stage == V_CS_CONNECTED) - { - if(v_noq_send_queue(VConData.con[VConData.current_connection].out_queue, &VConData.con[VConData.current_connection].network_address)) - update = TRUE; - } - } - VConData.current_connection = connection; - } while(update); - } - if(VConData.con_count > 0) - v_con_callback_update(); -} - -void v_con_set_name_pass(const char *name, const char *pass) -{ - v_strlcpy(VConData.con[VConData.current_connection].name, name, sizeof VConData.con[VConData.current_connection].name); - v_strlcpy(VConData.con[VConData.current_connection].pass, pass, sizeof VConData.con[VConData.current_connection].pass); -} - -const char * v_con_get_name(void) -{ - return VConData.con[VConData.current_connection].name; -} - -const char * v_con_get_pass(void) -{ - return VConData.con[VConData.current_connection].pass; -} - -void v_con_set_connect_stage(VConnectStage stage) -{ - VConData.con[VConData.current_connection].connect_stage = stage; - VConData.con[VConData.current_connection].stage_atempts = 0; -} - -VConnectStage v_con_get_connect_stage(void) -{ - return VConData.con[VConData.current_connection].connect_stage; -} - -uint8 *v_con_get_my_key(void) -{ - return VConData.con[VConData.current_connection].key_my; -} - -uint8 *v_con_get_other_key(void) -{ - return VConData.con[VConData.current_connection].key_other; -} - -uint8 **v_con_get_expected_key(void) -{ - return &VConData.con[VConData.current_connection].expected_key; -} - -uint8 * v_con_get_host_id(void) -{ - return VConData.host_id; -} - -void v_con_set_data_key(const uint8 *key) -{ - memcpy(VConData.con[VConData.current_connection].key_data, key, V_ENCRYPTION_DATA_KEY_SIZE); -} - -const uint8 * v_con_get_data_key(void) -{ - return VConData.con[VConData.current_connection].key_data; -} - -void * v_con_get_network_queue(void) -{ - return VConData.con[VConData.current_connection].out_queue; -} - -VNetworkAddress * v_con_get_network_address(void) -{ - return &VConData.con[VConData.current_connection].network_address; -} - -void * v_con_get_ordered_storage(void) -{ - return VConData.con[VConData.current_connection].ordered_storage; -} - -void v_con_set_avatar(uint32 avatar) -{ - VConData.con[VConData.current_connection].avatar = avatar; -} - -uint32 verse_session_get_avatar(void) -{ - return VConData.con[VConData.current_connection].avatar; -} - -void verse_session_get_time(uint32 *seconds, uint32 *fractions) -{ - uint32 s, f; - v_n_get_current_time(&s, &f); - if((uint32)~0 - f < VConData.con[VConData.current_connection].timedelta_f) - s++; - if(seconds != NULL) - { - if(VConData.con[VConData.current_connection].timedelta_s < 0) - *seconds = s - (uint32)(-VConData.con[VConData.current_connection].timedelta_s); - else - *seconds = s + VConData.con[VConData.current_connection].timedelta_s; - } - if(fractions != NULL) - *fractions = f + VConData.con[VConData.current_connection].timedelta_f; -} - -void v_con_set_time(uint32 seconds, uint32 fractions) -{ - uint32 s, f; - v_n_get_current_time(&s, &f); - - if(f < fractions) - s--; - if (s < seconds) - VConData.con[VConData.current_connection].timedelta_s = -(int)(seconds - s); - else - VConData.con[VConData.current_connection].timedelta_s = (int)(s - seconds); - VConData.con[VConData.current_connection].timedelta_f = f - fractions; -} - -#endif diff --git a/extern/verse/dist/v_connection.h b/extern/verse/dist/v_connection.h deleted file mode 100644 index 1d2ac53d597..00000000000 --- a/extern/verse/dist/v_connection.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -** -*/ - -#include "v_network.h" - -typedef struct{ - char name[16]; - char pass[16]; - uint8 key; - VNodeID avatar; -}VSConnectionID; - -typedef enum{ - V_CS_IDLE = 0, /* Host connection waiting for connection */ - V_CS_CONTACT = 1, /* client tryes to contact host */ - V_CS_CONTACTED = 2, /* Host replyes whit challange */ - V_CS_PENDING_ACCEPT = 3, /* Client sends login */ - V_CS_PENDING_HOST_CALLBACK = 4, /* Host got login waits for accept connect callback */ - V_CS_PENDING_CLIENT_CALLBACK_ACCEPT = 5, /* Host got login waits for accept connect callback */ - V_CS_PENDING_CLIENT_CALLBACK_TERMINATE = 6, /* Host got login waits for connect terminate callback */ - V_CS_PENDING_DECISION = 7, /* Host got has executed Callback waits for accept command */ - V_CS_CONNECTED = 8 /* Connection establiched */ -}VConnectStage; - -/* Connection related functions (v_connection.c) */ - -extern boolean v_con_network_listen(void); - -extern void v_con_set_name_pass(const char *name, const char *pass); -extern const char * v_con_get_name(void); -extern const char * v_con_get_pass(void); - -extern void v_con_set_avatar(uint32 avatar); -extern void v_con_set_time(uint32 seconds, uint32 fractions); - -extern void v_con_set_connect_stage(VConnectStage stage); -extern VConnectStage v_con_get_connect_stage(void); - - -extern uint8 *v_con_get_my_key(void); -extern uint8 *v_con_get_other_key(void); -extern uint8 *v_con_get_host_id(void); -extern uint8 **v_con_get_expected_key(void); - -extern void v_con_set_data_key(const uint8 *key); -extern const uint8 * v_con_get_data_key(void); - - -extern void * v_con_get_network_queue(void); -extern VNetworkAddress *v_con_get_network_address(void); -extern void * v_con_get_network_address_id(unsigned int id); -extern unsigned int * v_con_get_network_expected_packet(void); -extern void * v_con_get_ordered_storage(void); -extern void * v_con_get_func_storage(void); -extern void * v_con_connect(uint32 ip, uint16 port, VConnectStage stage); -extern unsigned int v_con_get_network_address_count(void); - -extern boolean v_co_switch_connection(uint32 ip, uint16 port); - -extern void v_con_inqueue_timer_update(void); - - -/* Func storage related functions (v_func_storage.c)*/ -extern void v_fs_unpack(uint8 *data, unsigned int length); - -extern boolean v_fs_func_accept_connections(void); -extern void v_fs_add_func(unsigned int cmd_id, unsigned int (*unpack_func)(const char *buf, size_t buffer_length), void *pack_func, void *alias_func); - -extern void * v_fs_get_alias_user_func(unsigned int cmd_id); -extern void * v_fs_get_alias_user_data(unsigned int cmd_id); -extern void * v_fs_get_user_func(unsigned int cmd_id); -extern void * v_fs_get_user_data(unsigned int cmd_id); diff --git a/extern/verse/dist/v_encryption.c b/extern/verse/dist/v_encryption.c deleted file mode 100644 index aea0f8e6979..00000000000 --- a/extern/verse/dist/v_encryption.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Verse encryption routines. Implements RSA encryption/decryption plus fast XORx. -*/ - -#if !defined(V_GENERATE_FUNC_MODE) - -#include <ctype.h> -#include <stdio.h> -#include <string.h> - -#include "verse.h" -#include "v_pack.h" -#include "v_bignum.h" -#include "v_encryption.h" - -#define BITS V_ENCRYPTION_LOGIN_KEY_BITS /* Save some typing. */ - -extern void v_prime_set_random(VBigDig *x); -extern void v_prime_set_table(VBigDig *x, int i); - -const uint8 * v_e_data_create_key(void) /* possibly the worst key gen ever */ -{ - static unsigned int counter = 0; - static uint8 buffer[V_ENCRYPTION_DATA_KEY_SIZE]; - unsigned int i, temp; - - for(i = 0; i < V_ENCRYPTION_DATA_KEY_SIZE; i++) - { - counter++; - temp = (counter << 13) ^ counter; - temp = (temp * (temp * temp * 15731 + 789221) + 1376312589) & 0x7fffffff; - buffer[i] = temp; - } - /* FIXME: This really isn't very pretty. */ - buffer[0] &= 0x3f; /* Make sure top word is... Low. For RSA compatibility. */ - -/* memset(buffer, 0, sizeof buffer); - fprintf(stderr, "**WARNING: XOR data encryption disabled\n"); -*/ - return buffer; -} - -void v_e_data_encrypt_command(uint8 *packet, size_t packet_size, const uint8 *command, size_t command_size, const uint8 *key) -{ - uint32 pos, i; - - vnp_raw_unpack_uint32(packet, &pos); -/* printf("encrypting packet %u", pos);*/ - pos = key[pos % V_ENCRYPTION_DATA_KEY_SIZE] + packet_size; -/* printf(" -> pos=%u (size %u)", pos, packet_size); - printf(", key begins: ["); - for(i = 0; i < 16; i++) - printf(" %02X", key[(pos + i) % V_ENCRYPTION_DATA_KEY_SIZE]); - printf(" ]\n"); -*/ - for(i = 0; i < command_size; i++) - packet[packet_size + i] = command[i] ^ key[(i + pos) % V_ENCRYPTION_DATA_KEY_SIZE]; -} - -void v_e_data_decrypt_packet(uint8 *to, const uint8 *from, size_t size, const uint8 *key) -{ - uint32 pos, i; - - vnp_raw_unpack_uint32(from, &pos); -/* printf("decrypting packet %u", pos);*/ - pos = key[pos % V_ENCRYPTION_DATA_KEY_SIZE]; -/* printf(" -> pos=%u", pos); - printf(", key begins: ["); - for(i = 0; i < 16; i++) - printf(" %02X", key[(i + pos) % V_ENCRYPTION_DATA_KEY_SIZE]); - printf(" ]\n"); -*/ for(i = 0; i < 4; i++) - to[i] = from[i]; - for(i = 4; i < size; i++) - to[i] = from[i] ^ key[(i + pos) % V_ENCRYPTION_DATA_KEY_SIZE]; -} - -#endif - -/* From Knuth. Computes multiplicative inverse of u, modulo v. */ -void v_e_math_inv(VBigDig *inv, const VBigDig *u, const VBigDig *v) -{ - VBigDig VBIGNUM(u1, 2*BITS), VBIGNUM(u3, 2*BITS), VBIGNUM(v1, 2*BITS), VBIGNUM(v3, 2 *BITS), - VBIGNUM(t1, 2*BITS), VBIGNUM(t3, 2*BITS), VBIGNUM(q, 2*BITS), VBIGNUM(w, 2*BITS); - int iter = 1; - - v_bignum_set_one(u1); - v_bignum_set_bignum(u3, u); - v_bignum_set_zero(v1); - v_bignum_set_bignum(v3, v); - - while(!v_bignum_eq_zero(v3)) - { - v_bignum_set_bignum(q, u3); - v_bignum_div(q, v3, t3); - v_bignum_set_bignum(w, q); - v_bignum_mul(w, v1); - v_bignum_set_bignum(t1, u1); - v_bignum_add(t1, w); - - v_bignum_set_bignum(u1, v1); - v_bignum_set_bignum(v1, t1); - v_bignum_set_bignum(u3, v3); - v_bignum_set_bignum(v3, t3); - iter = -iter; - } - if(iter < 0) - { - v_bignum_set_bignum(inv, v); - v_bignum_sub(inv, u1); - } - else - v_bignum_set_bignum(inv, u1); -} - -void v_e_connect_create_key(uint8 *private_key, uint8 *public_key, uint8 *n) -{ - VBigDig VBIGNUM(p, BITS / 2), VBIGNUM(q, BITS / 2), VBIGNUM(qmo, BITS / 2), VBIGNUM(phi, BITS), - VBIGNUM(pub, BITS), VBIGNUM(priv, BITS), VBIGNUM(mod, BITS); - -#if !defined _WIN32 - /* FIXME: This is a security backdoor. Intent is simply to save time during testing. */ - if(getenv("VERSE_NORSA") != NULL) - { - printf("VERSE: Found the NORSA envvar, using constant keys\n"); - v_prime_set_table(p, 0); - v_prime_set_table(q, 1); - goto compute_phi; - } -#endif -/* printf("find prime p\n");*/ - v_prime_set_random(p); -/* printf("find prime q\n");*/ - v_prime_set_random(q); -compute_phi: -/* printf("done, computing key\n");*/ -/* printf("p="); - v_bignum_print_hex_lf(p); - printf("q="); - v_bignum_print_hex_lf(q); -*/ v_bignum_set_bignum(phi, p); - v_bignum_sub_digit(phi, 1); - v_bignum_set_bignum(qmo, q); - v_bignum_sub_digit(qmo, 1); - v_bignum_mul(phi, qmo); -/* printf("phi="); - v_bignum_print_hex_lf(phi); -*/ v_bignum_set_string_hex(pub, "0x10001"); - v_e_math_inv(priv, pub, phi); -/* printf(" pub="); - v_bignum_print_hex_lf(pub); - printf("priv="); - v_bignum_print_hex_lf(priv); -*/ - v_bignum_set_bignum(mod, p); - v_bignum_mul(mod, q); -/* printf(" mod="); - v_bignum_print_hex_lf(mod); - printf("key-creation finished\n"); -*/ /* Write out the keys. */ - v_bignum_raw_export(pub, public_key); - v_bignum_raw_export(priv, private_key); - v_bignum_raw_export(mod, n); -} - -void v_e_connect_encrypt(uint8 *output, const uint8 *data, const uint8 *key, const uint8 *key_n) -{ - VBigDig VBIGNUM(packet, BITS), VBIGNUM(expo, BITS), VBIGNUM(mod, BITS); - - v_bignum_raw_import(packet, data); - v_bignum_raw_import(expo, key); - v_bignum_raw_import(mod, key_n); - - /* Verify that data is less than the modulo, this is a prerequisite for encryption. */ - if(!v_bignum_gte(mod, packet)) - { - printf("*** WARNING. Data is not less than modulo, as it should be--encryption will break!\n"); - printf(" RSA modulo: "); - v_bignum_print_hex_lf(mod); - printf(" RSA data: "); - v_bignum_print_hex_lf(packet); - } -/* printf("RSA key: "); - v_bignum_print_hex_lf(expo); - printf("RSA mod: "); - v_bignum_print_hex_lf(mod); - printf("RSA in: "); - v_bignum_print_hex_lf(packet); - printf("bits in packet: %d, ", v_bignum_bit_msb(packet) + 1); - printf("bits in modulo: %d\n", v_bignum_bit_msb(mod) + 1); -*/ v_bignum_pow_mod(packet, expo, mod); /* Blam. */ -/* printf("RSA out: "); - v_bignum_print_hex_lf(packet); -*/ v_bignum_raw_export(packet, output); -} - -#if defined CRYPTALONE -void v_encrypt_test(void) -{ - uint8 k_priv[BITS / 8], k_pub[BITS / 8], k_n[BITS / 8], cipher[BITS / 8], plain[BITS / 8], decode[BITS / 8], i; - - printf("testing RSA-crypto\n"); - v_e_connect_create_key(k_pub, k_priv, k_n); -/* exit(0);*/ - printf("key pair generated, encrypting something\n"); - memset(plain, 0, sizeof plain); - strcpy(plain, "This is some text to encrypt, to give it something to chew on."); - printf("plain: %02X (%u)\n", plain[0], strlen(plain)); - v_e_connect_encrypt(cipher, plain, k_pub, k_n); - printf("plain: %02X, cipher: %02X\n", plain[0], cipher[0]); - v_e_connect_encrypt(decode, cipher, k_priv, k_n); - printf("decoded: %02X: '", decode[0]); - for(i = 0; decode[i] != 0; i++) - putchar(decode[i]); - printf("'\n"); -/* printf("\npublic key: "); - v_bignum_print_hex_lf(k_public); - printf("private key: "); - v_bignum_print_hex_lf(k_private); - v_bignum_set_string(msg, "123"); - gettimeofday(&t1, NULL); - v_bignum_pow_mod(msg, k_private, k_n); - gettimeofday(&t2, NULL); - printf("encrypted: "); - v_bignum_print_hex_lf(msg); - printf("encrypted %u bits in %g s\n", BITS, t2.tv_sec - t1.tv_sec + 1.0E-6 * (t2.tv_usec - t1.tv_usec)); - - gettimeofday(&t1, NULL); - v_bignum_pow_mod(msg, k_public, k_n); - gettimeofday(&t2, NULL); - printf("decrypted: "); - v_bignum_print_hex_lf(msg); - printf("decrypted %u bits in %g s\n", BITS, t2.tv_sec - t1.tv_sec + 1.0E-6 * (t2.tv_usec - t1.tv_usec)); - exit(0); -*//* v_e_encrypt(cipher, plain, &k_private, &k_n); - printf("encrypted data: "); - for(i = 0; i < sizeof cipher; i++) - printf("%c", isalnum(cipher[i]) ? cipher[i] : '?'); - printf("\n\n"); - printf("decrypting\n"); - v_e_encrypt(decode, cipher, &k_public, &k_n); - printf("decrypted data: "); - for(i = 0; i < sizeof cipher; i++) - printf("%c", isalnum(decode[i]) ? decode[i] : '?'); - printf("\n\n"); -*/ -} - -int main(void) -{ - v_encrypt_test(); - - return 0; -} -#endif diff --git a/extern/verse/dist/v_encryption.h b/extern/verse/dist/v_encryption.h deleted file mode 100644 index cbfb5ff692f..00000000000 --- a/extern/verse/dist/v_encryption.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Verse encryption routines. There are two distinct flavors of encryption - * in use: one "heavy" for login/connection establishment security, and - * a far lighter symmetrical one that is applied to each data packet after - * the key has been exchanged during connection. -*/ - -#include "verse.h" - -/* Internal key size definitions. *MUST* be kept in sync with V_HOST_ID_SIZE in verse_header.h! */ -#define V_ENCRYPTION_LOGIN_KEY_BITS 512 -#define V_ENCRYPTION_LOGIN_KEY_SIZE (V_ENCRYPTION_LOGIN_KEY_BITS / 8) -#define V_ENCRYPTION_LOGIN_KEY_FULL_SIZE (3 * V_ENCRYPTION_LOGIN_KEY_SIZE) -#define V_ENCRYPTION_LOGIN_KEY_HALF_SIZE (2 * V_ENCRYPTION_LOGIN_KEY_SIZE) - -#define V_ENCRYPTION_LOGIN_PUBLIC_START (0 * V_ENCRYPTION_LOGIN_KEY_SIZE) -#define V_ENCRYPTION_LOGIN_PRIVATE_START (1 * V_ENCRYPTION_LOGIN_KEY_SIZE) -#define V_ENCRYPTION_LOGIN_N_START (2 * V_ENCRYPTION_LOGIN_KEY_SIZE) - -#define V_ENCRYPTION_DATA_KEY_SIZE (V_ENCRYPTION_LOGIN_KEY_BITS / 8) - -/* Connection encryption. Heavy, and symmetrical, so encrypt() does both encryption - * and decryption given the proper key. Current algorithm used is RSA. -*/ -extern void v_e_connect_create_key(uint8 *private_key, uint8 *public_key, uint8 *n); -extern void v_e_connect_encrypt(uint8 *output, const uint8 *data, const uint8 *key, const uint8 *key_n); - -/* Actual data traffic encryption. Also symmetrical, with a single key. Uses XOR. */ -extern const uint8 * v_e_data_create_key(void); -extern void v_e_data_encrypt_command(uint8 *packet, size_t packet_length, - const uint8 *command, size_t command_length, const uint8 *key); -extern void v_e_data_decrypt_packet(uint8 *to, const uint8 *from, size_t size, const uint8 *key); diff --git a/extern/verse/dist/v_func_storage.c b/extern/verse/dist/v_func_storage.c deleted file mode 100644 index 86c7815c2af..00000000000 --- a/extern/verse/dist/v_func_storage.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * -*/ - -#include <stdio.h> -#include <stdlib.h> -#include "verse_header.h" -#include "v_pack.h" -#include "v_cmd_gen.h" -#include "v_connection.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" - -#define V_FS_MAX_CMDS 256 - -extern void init_pack_and_unpack(void); - -static struct { - unsigned int (*unpack_func[V_FS_MAX_CMDS])(const char *data, size_t length); - void *pack_func[V_FS_MAX_CMDS]; - void *user_func[V_FS_MAX_CMDS]; - void *user_data[V_FS_MAX_CMDS]; - void *alias_pack_func[V_FS_MAX_CMDS]; - void *alias_user_func[V_FS_MAX_CMDS]; - void *alias_user_data[V_FS_MAX_CMDS]; - boolean call; -} VCmdData; - -static boolean v_fs_initialized = FALSE; - -extern void verse_send_packet_ack(uint32 packet_id); -extern void callback_send_packet_ack(void *user, uint32 packet_id); -extern void verse_send_packet_nak(uint32 packet_id); -extern void callback_send_packet_nak(void *user, uint32 packet_id); - -void v_fs_init(void) -{ - unsigned int i; - if(v_fs_initialized) - return; - for(i = 0; i < V_FS_MAX_CMDS; i++) - { - VCmdData.unpack_func[i] = NULL; - VCmdData.pack_func[i] = NULL; - VCmdData.user_func[i] = NULL; - VCmdData.user_data[i] = NULL; - VCmdData.alias_pack_func[i] = NULL; - VCmdData.alias_user_func[i] = NULL; - VCmdData.alias_user_data[i] = NULL; - } - #if !defined(V_GENERATE_FUNC_MODE) - init_pack_and_unpack(); - #endif - for(i = 0; i < V_FS_MAX_CMDS && VCmdData.pack_func[i] != verse_send_packet_ack; i++); - VCmdData.user_func[i] = callback_send_packet_ack; - for(i = 0; i < V_FS_MAX_CMDS && VCmdData.pack_func[i] != verse_send_packet_nak; i++); - VCmdData.user_func[i] = callback_send_packet_nak; - - v_fs_initialized = TRUE; -} - - -void v_fs_add_func(unsigned int cmd_id, unsigned int (*unpack_func)(const char *data, size_t length), void *pack_func, void *alias_func) -{ - VCmdData.unpack_func[cmd_id] = unpack_func; - VCmdData.pack_func[cmd_id] = pack_func; - VCmdData.alias_pack_func[cmd_id] = alias_func; -} - -void *v_fs_get_user_func(unsigned int cmd_id) -{ -/* if(VCmdData.call)*/ - return VCmdData.user_func[cmd_id]; - return NULL; -} - -void *v_fs_get_user_data(unsigned int cmd_id) -{ - return VCmdData.user_data[cmd_id]; -} - -void *v_fs_get_alias_user_func(unsigned int cmd_id) -{ -/* if(VCmdData.call)*/ - return VCmdData.alias_user_func[cmd_id]; - return NULL; -} - -void *v_fs_get_alias_user_data(unsigned int cmd_id) -{ - return VCmdData.alias_user_data[cmd_id]; -} - -void verse_callback_set(void *command, void *callback, void *user) -{ - unsigned int i; - if(!v_fs_initialized) - v_fs_init(); - - for(i = 0; i < V_FS_MAX_CMDS; i++) - { - if(VCmdData.pack_func[i] == command) - { - VCmdData.user_data[i] = user; - VCmdData.user_func[i] = callback; - return; - } - if(VCmdData.alias_pack_func[i] == command) - { - VCmdData.alias_user_data[i] = user; - VCmdData.alias_user_func[i] = callback; - return; - } - } -} - -/* Do we accept incoming connections, i.e. are we a host implementation? */ -boolean v_fs_func_accept_connections(void) -{ - return VCmdData.user_func[0] != NULL; -} - -/* Inspect beginning of packet, looking for ACK or NAK commands. */ -void v_fs_unpack_beginning(const uint8 *data, unsigned int length) -{ - uint32 id, i = 4; - uint8 cmd_id; - - i += vnp_raw_unpack_uint8(&data[i], &cmd_id); - while(i < length && (cmd_id == 7 || cmd_id == 8)) - { - i += vnp_raw_unpack_uint32(&data[i], &id); - if(cmd_id == 7) - callback_send_packet_ack(NULL, id); - else - callback_send_packet_nak(NULL, id); - i += vnp_raw_unpack_uint8(&data[i], &cmd_id); - } -} - -void v_fs_unpack(uint8 *data, unsigned int length) -{ - uint32 i, output, pack_id; - uint8 cmd_id, last = 255; - - i = vnp_raw_unpack_uint32(data, &pack_id); /* each packet starts with a 32 bit id */ - vnp_raw_unpack_uint8(&data[i], &cmd_id); - while(i < length && (cmd_id == 7 || cmd_id == 8)) - { - i += 5; - vnp_raw_unpack_uint8(&data[i], &cmd_id); - } - while(i < length) - { - i += vnp_raw_unpack_uint8(&data[i], &cmd_id); - if(VCmdData.unpack_func[cmd_id] != NULL) - { - VCmdData.call = TRUE; - output = VCmdData.unpack_func[cmd_id](&data[i], length - i); - if(output == (unsigned int) -1) /* Can this happen? Should be size_t or int, depending. */ - { - printf("** Aborting decode, command %u unpacker returned failure\n", cmd_id); -/* verse_send_packet_nak(pack_id);*/ - return; - } - last = cmd_id; - i += output; - } - else /* If unknown command byte was found, complain loudly and stop parsing packet. */ - { - size_t j; - - printf("\n** Unknown command ID %u (0x%02X) encountered--aborting packet decode len=%u pos=%u last=%u\n", cmd_id, cmd_id, length, i, last); - printf(" decoded %u bytes: ", --i); - for(j = 0; j < i; j++) - printf("%02X ", data[j]); - printf("\n (packet id=%u)", pack_id); - printf(" remaining %u bytes: ", length - i); - for(j = i; j < length; j++) - printf("%02X ", data[j]); - printf("\n"); -/* *(char *) 0 = 0;*/ - break; - } - } -/* if(expected != NULL) - verse_send_packet_ack(pack_id);*/ -} - -extern unsigned int v_unpack_connection(const char *data, size_t length); - -#endif diff --git a/extern/verse/dist/v_gen_pack_a_node.c b/extern/verse/dist/v_gen_pack_a_node.c deleted file mode 100644 index dc8e53e1a7f..00000000000 --- a/extern/verse/dist/v_gen_pack_a_node.c +++ /dev/null @@ -1,521 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_a_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 160); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_buffer_create(node_id = %u buffer_id = %u name = %s type = %u frequency = %f );\n", node_id, buffer_id, name, type, frequency); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], frequency); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_a_buffer_destroy(VNodeID node_id, VBufferID buffer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 160); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_buffer_destroy(node_id = %u buffer_id = %u );\n", node_id, buffer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_a_buffer_create(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_a_buffer_create)(void *user_data, VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency); - VNodeID node_id; - VBufferID buffer_id; - char name[16]; - VNABlockType type; - real64 frequency; - - func_a_buffer_create = v_fs_get_user_func(160); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); - if(buffer_length < 9 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNABlockType)enum_temp; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frequency); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_a_buffer_destroy(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(160)); - else - printf("receive: verse_send_a_buffer_create(node_id = %u buffer_id = %u name = %s type = %u frequency = %f ); callback = %p\n", node_id, buffer_id, name, type, frequency, v_fs_get_user_func(160)); -#endif - if(name[0] == 0) - { - void (* alias_a_buffer_destroy)(void *user_data, VNodeID node_id, VBufferID buffer_id); - alias_a_buffer_destroy = v_fs_get_alias_user_func(160); - if(alias_a_buffer_destroy != NULL) - alias_a_buffer_destroy(v_fs_get_alias_user_data(160), node_id, buffer_id); - return buffer_pos; - } - if(func_a_buffer_create != NULL) - func_a_buffer_create(v_fs_get_user_data(160), node_id, buffer_id, name, (VNABlockType) type, frequency); - - return buffer_pos; -} - -void verse_send_a_buffer_subscribe(VNodeID node_id, VBufferID layer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 161); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_buffer_subscribe(node_id = %u layer_id = %u );\n", node_id, layer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_a_buffer_unsubscribe(VNodeID node_id, VBufferID layer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 161); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_buffer_unsubscribe(node_id = %u layer_id = %u );\n", node_id, layer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_a_buffer_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_a_buffer_subscribe)(void *user_data, VNodeID node_id, VBufferID layer_id); - VNodeID node_id; - VBufferID layer_id; - uint8 alias_bool; - - func_a_buffer_subscribe = v_fs_get_user_func(161); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_a_buffer_unsubscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(161)); - else - printf("receive: verse_send_a_buffer_subscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_user_func(161)); -#endif - if(!alias_bool) - { - void (* alias_a_buffer_unsubscribe)(void *user_data, VNodeID node_id, VBufferID layer_id); - alias_a_buffer_unsubscribe = v_fs_get_alias_user_func(161); - if(alias_a_buffer_unsubscribe != NULL) - alias_a_buffer_unsubscribe(v_fs_get_alias_user_data(161), node_id, layer_id); - return buffer_pos; - } - if(func_a_buffer_subscribe != NULL) - func_a_buffer_subscribe(v_fs_get_user_data(161), node_id, layer_id); - - return buffer_pos; -} - -void verse_send_a_block_set(VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 162); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_block_set(node_id = %u buffer_id = %u block_index = %u type = %u samples = %p );\n", node_id, buffer_id, block_index, type, samples); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], block_index); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u || block_index == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_a_block_clear(VNodeID node_id, VLayerID buffer_id, uint32 block_index) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 162); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_block_clear(node_id = %u buffer_id = %u block_index = %u );\n", node_id, buffer_id, block_index); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], block_index); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u || block_index == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_a_block_set(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_a_block_set)(void *user_data, VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples); - VNodeID node_id; - VLayerID buffer_id; - uint32 block_index; - VNABlockType type; - const VNABlock *samples; - - func_a_block_set = v_fs_get_user_func(162); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &block_index); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNABlockType)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - if(type > VN_A_BLOCK_REAL64) - printf("receive: verse_send_a_block_clear(node_id = %u buffer_id = %u block_index = %u ); callback = %p\n", node_id, buffer_id, block_index, v_fs_get_alias_user_func(162)); - else - printf("receive: verse_send_a_block_set(node_id = %u buffer_id = %u block_index = %u type = %u ); callback = %p\n", node_id, buffer_id, block_index, type, v_fs_get_user_func(162)); -#endif - if(type <= VN_A_BLOCK_REAL64) - { - VNABlock block; - buffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block); - if(func_a_block_set != NULL) - func_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, &block); - return buffer_pos; - } - - if(type > VN_A_BLOCK_REAL64) - { - void (* alias_a_block_clear)(void *user_data, VNodeID node_id, VLayerID buffer_id, uint32 block_index); - alias_a_block_clear = v_fs_get_alias_user_func(162); - if(alias_a_block_clear != NULL) - alias_a_block_clear(v_fs_get_alias_user_data(162), node_id, buffer_id, block_index); - return buffer_pos; - } - if(func_a_block_set != NULL) - func_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, samples); - - return buffer_pos; -} - -void verse_send_a_stream_create(VNodeID node_id, VLayerID stream_id, const char *name) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 163); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_stream_create(node_id = %u stream_id = %u name = %s );\n", node_id, stream_id, name); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_a_stream_destroy(VNodeID node_id, VLayerID stream_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 163); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_stream_destroy(node_id = %u stream_id = %u );\n", node_id, stream_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_a_stream_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_a_stream_create)(void *user_data, VNodeID node_id, VLayerID stream_id, const char *name); - VNodeID node_id; - VLayerID stream_id; - char name[16]; - - func_a_stream_create = v_fs_get_user_func(163); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_a_stream_destroy(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_alias_user_func(163)); - else - printf("receive: verse_send_a_stream_create(node_id = %u stream_id = %u name = %s ); callback = %p\n", node_id, stream_id, name, v_fs_get_user_func(163)); -#endif - if(name[0] == 0) - { - void (* alias_a_stream_destroy)(void *user_data, VNodeID node_id, VLayerID stream_id); - alias_a_stream_destroy = v_fs_get_alias_user_func(163); - if(alias_a_stream_destroy != NULL) - alias_a_stream_destroy(v_fs_get_alias_user_data(163), node_id, stream_id); - return buffer_pos; - } - if(func_a_stream_create != NULL) - func_a_stream_create(v_fs_get_user_data(163), node_id, stream_id, name); - - return buffer_pos; -} - -void verse_send_a_stream_subscribe(VNodeID node_id, VLayerID stream_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 164); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_stream_subscribe(node_id = %u stream_id = %u );\n", node_id, stream_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_a_stream_unsubscribe(VNodeID node_id, VLayerID stream_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 164); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_stream_unsubscribe(node_id = %u stream_id = %u );\n", node_id, stream_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_a_stream_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_a_stream_subscribe)(void *user_data, VNodeID node_id, VLayerID stream_id); - VNodeID node_id; - VLayerID stream_id; - uint8 alias_bool; - - func_a_stream_subscribe = v_fs_get_user_func(164); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_a_stream_unsubscribe(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_alias_user_func(164)); - else - printf("receive: verse_send_a_stream_subscribe(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_user_func(164)); -#endif - if(!alias_bool) - { - void (* alias_a_stream_unsubscribe)(void *user_data, VNodeID node_id, VLayerID stream_id); - alias_a_stream_unsubscribe = v_fs_get_alias_user_func(164); - if(alias_a_stream_unsubscribe != NULL) - alias_a_stream_unsubscribe(v_fs_get_alias_user_data(164), node_id, stream_id); - return buffer_pos; - } - if(func_a_stream_subscribe != NULL) - func_a_stream_subscribe(v_fs_get_user_data(164), node_id, stream_id); - - return buffer_pos; -} - -void verse_send_a_stream(VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 165); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_a_stream(node_id = %u stream_id = %u time_s = %u time_f = %u type = %u frequency = %f samples = %p );\n", node_id, stream_id, time_s, time_f, type, frequency, samples); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], frequency); - buffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples); - if(node_id == (uint32) ~0u || stream_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_a_stream(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_a_stream)(void *user_data, VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples); - VNodeID node_id; - VLayerID stream_id; - uint32 time_s; - uint32 time_f; - VNABlockType type; - real64 frequency; - const VNABlock *samples; - - func_a_stream = v_fs_get_user_func(165); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNABlockType)enum_temp; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frequency); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_a_stream(node_id = %u stream_id = %u time_s = %u time_f = %u type = %u frequency = %f ); callback = %p\n", node_id, stream_id, time_s, time_f, type, frequency, v_fs_get_user_func(165)); -#endif - { - VNABlock block; - buffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block); - if(func_a_stream != NULL) - func_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, &block); - return buffer_pos; - } - - if(func_a_stream != NULL) - func_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, samples); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_b_node.c b/extern/verse/dist/v_gen_pack_b_node.c deleted file mode 100644 index a4792a10fe4..00000000000 --- a/extern/verse/dist/v_gen_pack_b_node.c +++ /dev/null @@ -1,238 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_b_dimensions_set(VNodeID node_id, uint16 width, uint16 height, uint16 depth) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 80); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_b_dimensions_set(node_id = %u width = %u height = %u depth = %u );\n", node_id, width, height, depth); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], width); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], height); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], depth); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_b_dimensions_set(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_b_dimensions_set)(void *user_data, VNodeID node_id, uint16 width, uint16 height, uint16 depth); - VNodeID node_id; - uint16 width; - uint16 height; - uint16 depth; - - func_b_dimensions_set = v_fs_get_user_func(80); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &width); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &height); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &depth); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_b_dimensions_set(node_id = %u width = %u height = %u depth = %u ); callback = %p\n", node_id, width, height, depth, v_fs_get_user_func(80)); -#endif - if(func_b_dimensions_set != NULL) - func_b_dimensions_set(v_fs_get_user_data(80), node_id, width, height, depth); - - return buffer_pos; -} - -void verse_send_b_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNBLayerType type) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 81); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_b_layer_create(node_id = %u layer_id = %u name = %s type = %u );\n", node_id, layer_id, name, type); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_b_layer_destroy(VNodeID node_id, VLayerID layer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 81); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_b_layer_destroy(node_id = %u layer_id = %u );\n", node_id, layer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_b_layer_create(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_b_layer_create)(void *user_data, VNodeID node_id, VLayerID layer_id, const char *name, VNBLayerType type); - VNodeID node_id; - VLayerID layer_id; - char name[16]; - VNBLayerType type; - - func_b_layer_create = v_fs_get_user_func(81); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); - if(buffer_length < 1 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNBLayerType)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_b_layer_destroy(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(81)); - else - printf("receive: verse_send_b_layer_create(node_id = %u layer_id = %u name = %s type = %u ); callback = %p\n", node_id, layer_id, name, type, v_fs_get_user_func(81)); -#endif - if(name[0] == 0) - { - void (* alias_b_layer_destroy)(void *user_data, VNodeID node_id, VLayerID layer_id); - alias_b_layer_destroy = v_fs_get_alias_user_func(81); - if(alias_b_layer_destroy != NULL) - alias_b_layer_destroy(v_fs_get_alias_user_data(81), node_id, layer_id); - return buffer_pos; - } - if(func_b_layer_create != NULL) - func_b_layer_create(v_fs_get_user_data(81), node_id, layer_id, name, (VNBLayerType) type); - - return buffer_pos; -} - -void verse_send_b_layer_subscribe(VNodeID node_id, VLayerID layer_id, uint8 level) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 82); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_b_layer_subscribe(node_id = %u layer_id = %u level = %u );\n", node_id, layer_id, level); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], level); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_b_layer_unsubscribe(VNodeID node_id, VLayerID layer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 82); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_b_layer_unsubscribe(node_id = %u layer_id = %u );\n", node_id, layer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], -1); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_b_layer_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_b_layer_subscribe)(void *user_data, VNodeID node_id, VLayerID layer_id, uint8 level); - VNodeID node_id; - VLayerID layer_id; - uint8 level; - - func_b_layer_subscribe = v_fs_get_user_func(82); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &level); -#if defined V_PRINT_RECEIVE_COMMANDS - if(level == 255) - printf("receive: verse_send_b_layer_unsubscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(82)); - else - printf("receive: verse_send_b_layer_subscribe(node_id = %u layer_id = %u level = %u ); callback = %p\n", node_id, layer_id, level, v_fs_get_user_func(82)); -#endif - if(level == 255) - { - void (* alias_b_layer_unsubscribe)(void *user_data, VNodeID node_id, VLayerID layer_id); - alias_b_layer_unsubscribe = v_fs_get_alias_user_func(82); - if(alias_b_layer_unsubscribe != NULL) - alias_b_layer_unsubscribe(v_fs_get_alias_user_data(82), node_id, layer_id); - return buffer_pos; - } - if(func_b_layer_subscribe != NULL) - func_b_layer_subscribe(v_fs_get_user_data(82), node_id, layer_id, level); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_c_node.c b/extern/verse/dist/v_gen_pack_c_node.c deleted file mode 100644 index b75fa213383..00000000000 --- a/extern/verse/dist/v_gen_pack_c_node.c +++ /dev/null @@ -1,189 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_c_curve_create(VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 128); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_c_curve_create(node_id = %u curve_id = %u name = %s dimensions = %u );\n", node_id, curve_id, name, dimensions); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions); - if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_c_curve_destroy(VNodeID node_id, VLayerID curve_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 128); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_c_curve_destroy(node_id = %u curve_id = %u );\n", node_id, curve_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], -1); - if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_c_curve_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_c_curve_create)(void *user_data, VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions); - VNodeID node_id; - VLayerID curve_id; - char name[16]; - uint8 dimensions; - - func_c_curve_create = v_fs_get_user_func(128); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &curve_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); - if(buffer_length < 1 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &dimensions); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_c_curve_destroy(node_id = %u curve_id = %u ); callback = %p\n", node_id, curve_id, v_fs_get_alias_user_func(128)); - else - printf("receive: verse_send_c_curve_create(node_id = %u curve_id = %u name = %s dimensions = %u ); callback = %p\n", node_id, curve_id, name, dimensions, v_fs_get_user_func(128)); -#endif - if(name[0] == 0) - { - void (* alias_c_curve_destroy)(void *user_data, VNodeID node_id, VLayerID curve_id); - alias_c_curve_destroy = v_fs_get_alias_user_func(128); - if(alias_c_curve_destroy != NULL) - alias_c_curve_destroy(v_fs_get_alias_user_data(128), node_id, curve_id); - return buffer_pos; - } - if(func_c_curve_create != NULL) - func_c_curve_create(v_fs_get_user_data(128), node_id, curve_id, name, dimensions); - - return buffer_pos; -} - -void verse_send_c_curve_subscribe(VNodeID node_id, VLayerID curve_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 129); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_c_curve_subscribe(node_id = %u curve_id = %u );\n", node_id, curve_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_c_curve_unsubscribe(VNodeID node_id, VLayerID curve_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 129); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_c_curve_unsubscribe(node_id = %u curve_id = %u );\n", node_id, curve_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_c_curve_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_c_curve_subscribe)(void *user_data, VNodeID node_id, VLayerID curve_id); - VNodeID node_id; - VLayerID curve_id; - uint8 alias_bool; - - func_c_curve_subscribe = v_fs_get_user_func(129); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &curve_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_c_curve_unsubscribe(node_id = %u curve_id = %u ); callback = %p\n", node_id, curve_id, v_fs_get_alias_user_func(129)); - else - printf("receive: verse_send_c_curve_subscribe(node_id = %u curve_id = %u ); callback = %p\n", node_id, curve_id, v_fs_get_user_func(129)); -#endif - if(!alias_bool) - { - void (* alias_c_curve_unsubscribe)(void *user_data, VNodeID node_id, VLayerID curve_id); - alias_c_curve_unsubscribe = v_fs_get_alias_user_func(129); - if(alias_c_curve_unsubscribe != NULL) - alias_c_curve_unsubscribe(v_fs_get_alias_user_data(129), node_id, curve_id); - return buffer_pos; - } - if(func_c_curve_subscribe != NULL) - func_c_curve_subscribe(v_fs_get_user_data(129), node_id, curve_id); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_g_node.c b/extern/verse/dist/v_gen_pack_g_node.c deleted file mode 100644 index 5a70173554d..00000000000 --- a/extern/verse/dist/v_gen_pack_g_node.c +++ /dev/null @@ -1,1154 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_g_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNGLayerType type, uint32 def_uint, real64 def_real) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 48); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_layer_create(node_id = %u layer_id = %u name = %s type = %u def_uint = %u def_real = %f );\n", node_id, layer_id, name, type, def_uint, def_real); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], def_uint); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], def_real); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_g_layer_destroy(VNodeID node_id, VLayerID layer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 48); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_layer_destroy(node_id = %u layer_id = %u );\n", node_id, layer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_layer_create(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_g_layer_create)(void *user_data, VNodeID node_id, VLayerID layer_id, const char *name, VNGLayerType type, uint32 def_uint, real64 def_real); - VNodeID node_id; - VLayerID layer_id; - char name[16]; - VNGLayerType type; - uint32 def_uint; - real64 def_real; - - func_g_layer_create = v_fs_get_user_func(48); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); - if(buffer_length < 13 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNGLayerType)enum_temp; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &def_uint); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &def_real); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_g_layer_destroy(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(48)); - else - printf("receive: verse_send_g_layer_create(node_id = %u layer_id = %u name = %s type = %u def_uint = %u def_real = %f ); callback = %p\n", node_id, layer_id, name, type, def_uint, def_real, v_fs_get_user_func(48)); -#endif - if(name[0] == 0) - { - void (* alias_g_layer_destroy)(void *user_data, VNodeID node_id, VLayerID layer_id); - alias_g_layer_destroy = v_fs_get_alias_user_func(48); - if(alias_g_layer_destroy != NULL) - alias_g_layer_destroy(v_fs_get_alias_user_data(48), node_id, layer_id); - return buffer_pos; - } - if(func_g_layer_create != NULL) - func_g_layer_create(v_fs_get_user_data(48), node_id, layer_id, name, (VNGLayerType) type, def_uint, def_real); - - return buffer_pos; -} - -void verse_send_g_layer_subscribe(VNodeID node_id, VLayerID layer_id, VNRealFormat type) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 49); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_layer_subscribe(node_id = %u layer_id = %u type = %u );\n", node_id, layer_id, type); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_g_layer_unsubscribe(VNodeID node_id, VLayerID layer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 49); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_layer_unsubscribe(node_id = %u layer_id = %u );\n", node_id, layer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_layer_subscribe(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_g_layer_subscribe)(void *user_data, VNodeID node_id, VLayerID layer_id, VNRealFormat type); - VNodeID node_id; - VLayerID layer_id; - VNRealFormat type; - - func_g_layer_subscribe = v_fs_get_user_func(49); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNRealFormat)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - if(type > VN_FORMAT_REAL64) - printf("receive: verse_send_g_layer_unsubscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(49)); - else - printf("receive: verse_send_g_layer_subscribe(node_id = %u layer_id = %u type = %u ); callback = %p\n", node_id, layer_id, type, v_fs_get_user_func(49)); -#endif - if(type > VN_FORMAT_REAL64) - { - void (* alias_g_layer_unsubscribe)(void *user_data, VNodeID node_id, VLayerID layer_id); - alias_g_layer_unsubscribe = v_fs_get_alias_user_func(49); - if(alias_g_layer_unsubscribe != NULL) - alias_g_layer_unsubscribe(v_fs_get_alias_user_data(49), node_id, layer_id); - return buffer_pos; - } - if(func_g_layer_subscribe != NULL) - func_g_layer_subscribe(v_fs_get_user_data(49), node_id, layer_id, (VNRealFormat) type); - - return buffer_pos; -} - -void verse_send_g_vertex_set_xyz_real32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 x, real32 y, real32 z) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 50); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_set_xyz_real32(node_id = %u layer_id = %u vertex_id = %u x = %f y = %f z = %f );\n", node_id, layer_id, vertex_id, x, y, z); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], x); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], y); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], z); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_g_vertex_delete_real32(VNodeID node_id, uint32 vertex_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 50); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_delete_real32(node_id = %u vertex_id = %u );\n", node_id, vertex_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], 0); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], V_REAL32_MAX); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], V_REAL32_MAX); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], V_REAL32_MAX); - if(node_id == (uint32) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_vertex_set_xyz_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_vertex_set_xyz_real32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 x, real32 y, real32 z); - VNodeID node_id; - VLayerID layer_id; - uint32 vertex_id; - real32 x; - real32 y; - real32 z; - - func_g_vertex_set_xyz_real32 = v_fs_get_user_func(50); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &vertex_id); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &x); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &y); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &z); -#if defined V_PRINT_RECEIVE_COMMANDS - if(x == V_REAL32_MAX || y == V_REAL32_MAX || z == V_REAL32_MAX) - printf("receive: verse_send_g_vertex_delete_real32(node_id = %u vertex_id = %u ); callback = %p\n", node_id, vertex_id, v_fs_get_alias_user_func(50)); - else - printf("receive: verse_send_g_vertex_set_xyz_real32(node_id = %u layer_id = %u vertex_id = %u x = %f y = %f z = %f ); callback = %p\n", node_id, layer_id, vertex_id, x, y, z, v_fs_get_user_func(50)); -#endif - if(x == V_REAL32_MAX || y == V_REAL32_MAX || z == V_REAL32_MAX) - { - void (* alias_g_vertex_delete_real32)(void *user_data, VNodeID node_id, uint32 vertex_id); - alias_g_vertex_delete_real32 = v_fs_get_alias_user_func(50); - if(alias_g_vertex_delete_real32 != NULL) - alias_g_vertex_delete_real32(v_fs_get_alias_user_data(50), node_id, vertex_id); - return buffer_pos; - } - if(func_g_vertex_set_xyz_real32 != NULL) - func_g_vertex_set_xyz_real32(v_fs_get_user_data(50), node_id, layer_id, vertex_id, x, y, z); - - return buffer_pos; -} - -void verse_send_g_vertex_set_xyz_real64(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 x, real64 y, real64 z) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 51); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_set_xyz_real64(node_id = %u layer_id = %u vertex_id = %u x = %f y = %f z = %f );\n", node_id, layer_id, vertex_id, x, y, z); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], x); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], y); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], z); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_g_vertex_delete_real64(VNodeID node_id, uint32 vertex_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 51); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_delete_real64(node_id = %u vertex_id = %u );\n", node_id, vertex_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], 0); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - if(node_id == (uint32) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_vertex_set_xyz_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_vertex_set_xyz_real64)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 x, real64 y, real64 z); - VNodeID node_id; - VLayerID layer_id; - uint32 vertex_id; - real64 x; - real64 y; - real64 z; - - func_g_vertex_set_xyz_real64 = v_fs_get_user_func(51); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &vertex_id); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &x); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &y); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &z); -#if defined V_PRINT_RECEIVE_COMMANDS - if(x == V_REAL64_MAX || y == V_REAL64_MAX || z == V_REAL64_MAX) - printf("receive: verse_send_g_vertex_delete_real64(node_id = %u vertex_id = %u ); callback = %p\n", node_id, vertex_id, v_fs_get_alias_user_func(51)); - else - printf("receive: verse_send_g_vertex_set_xyz_real64(node_id = %u layer_id = %u vertex_id = %u x = %f y = %f z = %f ); callback = %p\n", node_id, layer_id, vertex_id, x, y, z, v_fs_get_user_func(51)); -#endif - if(x == V_REAL64_MAX || y == V_REAL64_MAX || z == V_REAL64_MAX) - { - void (* alias_g_vertex_delete_real64)(void *user_data, VNodeID node_id, uint32 vertex_id); - alias_g_vertex_delete_real64 = v_fs_get_alias_user_func(51); - if(alias_g_vertex_delete_real64 != NULL) - alias_g_vertex_delete_real64(v_fs_get_alias_user_data(51), node_id, vertex_id); - return buffer_pos; - } - if(func_g_vertex_set_xyz_real64 != NULL) - func_g_vertex_set_xyz_real64(v_fs_get_user_data(51), node_id, layer_id, vertex_id, x, y, z); - - return buffer_pos; -} - -void verse_send_g_vertex_set_uint32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, uint32 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 52); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_set_uint32(node_id = %u layer_id = %u vertex_id = %u value = %u );\n", node_id, layer_id, vertex_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_vertex_set_uint32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_vertex_set_uint32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, uint32 value); - VNodeID node_id; - VLayerID layer_id; - uint32 vertex_id; - uint32 value; - - func_g_vertex_set_uint32 = v_fs_get_user_func(52); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &vertex_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_vertex_set_uint32(node_id = %u layer_id = %u vertex_id = %u value = %u ); callback = %p\n", node_id, layer_id, vertex_id, value, v_fs_get_user_func(52)); -#endif - if(func_g_vertex_set_uint32 != NULL) - func_g_vertex_set_uint32(v_fs_get_user_data(52), node_id, layer_id, vertex_id, value); - - return buffer_pos; -} - -void verse_send_g_vertex_set_real64(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 53); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_set_real64(node_id = %u layer_id = %u vertex_id = %u value = %f );\n", node_id, layer_id, vertex_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_vertex_set_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_vertex_set_real64)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 value); - VNodeID node_id; - VLayerID layer_id; - uint32 vertex_id; - real64 value; - - func_g_vertex_set_real64 = v_fs_get_user_func(53); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &vertex_id); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_vertex_set_real64(node_id = %u layer_id = %u vertex_id = %u value = %f ); callback = %p\n", node_id, layer_id, vertex_id, value, v_fs_get_user_func(53)); -#endif - if(func_g_vertex_set_real64 != NULL) - func_g_vertex_set_real64(v_fs_get_user_data(53), node_id, layer_id, vertex_id, value); - - return buffer_pos; -} - -void verse_send_g_vertex_set_real32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 54); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_vertex_set_real32(node_id = %u layer_id = %u vertex_id = %u value = %f );\n", node_id, layer_id, vertex_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], vertex_id); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || vertex_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_vertex_set_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_vertex_set_real32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 value); - VNodeID node_id; - VLayerID layer_id; - uint32 vertex_id; - real32 value; - - func_g_vertex_set_real32 = v_fs_get_user_func(54); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &vertex_id); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_vertex_set_real32(node_id = %u layer_id = %u vertex_id = %u value = %f ); callback = %p\n", node_id, layer_id, vertex_id, value, v_fs_get_user_func(54)); -#endif - if(func_g_vertex_set_real32 != NULL) - func_g_vertex_set_real32(v_fs_get_user_data(54), node_id, layer_id, vertex_id, value); - - return buffer_pos; -} - -void verse_send_g_polygon_set_corner_uint32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 v0, uint32 v1, uint32 v2, uint32 v3) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 55); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_corner_uint32(node_id = %u layer_id = %u polygon_id = %u v0 = %u v1 = %u v2 = %u v3 = %u );\n", node_id, layer_id, polygon_id, v0, v1, v2, v3); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], v0); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], v1); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], v2); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], v3); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_g_polygon_delete(VNodeID node_id, uint32 polygon_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 55); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_delete(node_id = %u polygon_id = %u );\n", node_id, polygon_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], 1); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - if(node_id == (uint32) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_corner_uint32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_corner_uint32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 v0, uint32 v1, uint32 v2, uint32 v3); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - uint32 v0; - uint32 v1; - uint32 v2; - uint32 v3; - - func_g_polygon_set_corner_uint32 = v_fs_get_user_func(55); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &v0); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &v1); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &v2); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &v3); -#if defined V_PRINT_RECEIVE_COMMANDS - if(layer_id == 1 && v0 == ~0u) - printf("receive: verse_send_g_polygon_delete(node_id = %u polygon_id = %u ); callback = %p\n", node_id, polygon_id, v_fs_get_alias_user_func(55)); - else - printf("receive: verse_send_g_polygon_set_corner_uint32(node_id = %u layer_id = %u polygon_id = %u v0 = %u v1 = %u v2 = %u v3 = %u ); callback = %p\n", node_id, layer_id, polygon_id, v0, v1, v2, v3, v_fs_get_user_func(55)); -#endif - if(layer_id == 1 && v0 == ~0u) - { - void (* alias_g_polygon_delete)(void *user_data, VNodeID node_id, uint32 polygon_id); - alias_g_polygon_delete = v_fs_get_alias_user_func(55); - if(alias_g_polygon_delete != NULL) - alias_g_polygon_delete(v_fs_get_alias_user_data(55), node_id, polygon_id); - return buffer_pos; - } - if(func_g_polygon_set_corner_uint32 != NULL) - func_g_polygon_set_corner_uint32(v_fs_get_user_data(55), node_id, layer_id, polygon_id, v0, v1, v2, v3); - - return buffer_pos; -} - -void verse_send_g_polygon_set_corner_real64(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 v0, real64 v1, real64 v2, real64 v3) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 56); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_corner_real64(node_id = %u layer_id = %u polygon_id = %u v0 = %f v1 = %f v2 = %f v3 = %f );\n", node_id, layer_id, polygon_id, v0, v1, v2, v3); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], v0); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], v1); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], v2); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], v3); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_corner_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_corner_real64)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 v0, real64 v1, real64 v2, real64 v3); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - real64 v0; - real64 v1; - real64 v2; - real64 v3; - - func_g_polygon_set_corner_real64 = v_fs_get_user_func(56); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &v0); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &v1); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &v2); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &v3); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_polygon_set_corner_real64(node_id = %u layer_id = %u polygon_id = %u v0 = %f v1 = %f v2 = %f v3 = %f ); callback = %p\n", node_id, layer_id, polygon_id, v0, v1, v2, v3, v_fs_get_user_func(56)); -#endif - if(func_g_polygon_set_corner_real64 != NULL) - func_g_polygon_set_corner_real64(v_fs_get_user_data(56), node_id, layer_id, polygon_id, v0, v1, v2, v3); - - return buffer_pos; -} - -void verse_send_g_polygon_set_corner_real32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 v0, real32 v1, real32 v2, real32 v3) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 57); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_corner_real32(node_id = %u layer_id = %u polygon_id = %u v0 = %f v1 = %f v2 = %f v3 = %f );\n", node_id, layer_id, polygon_id, v0, v1, v2, v3); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], v0); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], v1); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], v2); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], v3); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_corner_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_corner_real32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 v0, real32 v1, real32 v2, real32 v3); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - real32 v0; - real32 v1; - real32 v2; - real32 v3; - - func_g_polygon_set_corner_real32 = v_fs_get_user_func(57); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &v0); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &v1); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &v2); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &v3); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_polygon_set_corner_real32(node_id = %u layer_id = %u polygon_id = %u v0 = %f v1 = %f v2 = %f v3 = %f ); callback = %p\n", node_id, layer_id, polygon_id, v0, v1, v2, v3, v_fs_get_user_func(57)); -#endif - if(func_g_polygon_set_corner_real32 != NULL) - func_g_polygon_set_corner_real32(v_fs_get_user_data(57), node_id, layer_id, polygon_id, v0, v1, v2, v3); - - return buffer_pos; -} - -void verse_send_g_polygon_set_face_uint8(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint8 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 58); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_face_uint8(node_id = %u layer_id = %u polygon_id = %u value = %u );\n", node_id, layer_id, polygon_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_face_uint8(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_face_uint8)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint8 value); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - uint8 value; - - func_g_polygon_set_face_uint8 = v_fs_get_user_func(58); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_polygon_set_face_uint8(node_id = %u layer_id = %u polygon_id = %u value = %u ); callback = %p\n", node_id, layer_id, polygon_id, value, v_fs_get_user_func(58)); -#endif - if(func_g_polygon_set_face_uint8 != NULL) - func_g_polygon_set_face_uint8(v_fs_get_user_data(58), node_id, layer_id, polygon_id, value); - - return buffer_pos; -} - -void verse_send_g_polygon_set_face_uint32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 59); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_face_uint32(node_id = %u layer_id = %u polygon_id = %u value = %u );\n", node_id, layer_id, polygon_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_face_uint32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_face_uint32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 value); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - uint32 value; - - func_g_polygon_set_face_uint32 = v_fs_get_user_func(59); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_polygon_set_face_uint32(node_id = %u layer_id = %u polygon_id = %u value = %u ); callback = %p\n", node_id, layer_id, polygon_id, value, v_fs_get_user_func(59)); -#endif - if(func_g_polygon_set_face_uint32 != NULL) - func_g_polygon_set_face_uint32(v_fs_get_user_data(59), node_id, layer_id, polygon_id, value); - - return buffer_pos; -} - -void verse_send_g_polygon_set_face_real64(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 60); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_face_real64(node_id = %u layer_id = %u polygon_id = %u value = %f );\n", node_id, layer_id, polygon_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_face_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_face_real64)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 value); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - real64 value; - - func_g_polygon_set_face_real64 = v_fs_get_user_func(60); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_polygon_set_face_real64(node_id = %u layer_id = %u polygon_id = %u value = %f ); callback = %p\n", node_id, layer_id, polygon_id, value, v_fs_get_user_func(60)); -#endif - if(func_g_polygon_set_face_real64 != NULL) - func_g_polygon_set_face_real64(v_fs_get_user_data(60), node_id, layer_id, polygon_id, value); - - return buffer_pos; -} - -void verse_send_g_polygon_set_face_real32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 value) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 61); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_polygon_set_face_real32(node_id = %u layer_id = %u polygon_id = %u value = %f );\n", node_id, layer_id, polygon_id, value); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], polygon_id); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], value); - if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u || polygon_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_polygon_set_face_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_polygon_set_face_real32)(void *user_data, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 value); - VNodeID node_id; - VLayerID layer_id; - uint32 polygon_id; - real32 value; - - func_g_polygon_set_face_real32 = v_fs_get_user_func(61); - if(buffer_length < 10) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &polygon_id); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &value); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_polygon_set_face_real32(node_id = %u layer_id = %u polygon_id = %u value = %f ); callback = %p\n", node_id, layer_id, polygon_id, value, v_fs_get_user_func(61)); -#endif - if(func_g_polygon_set_face_real32 != NULL) - func_g_polygon_set_face_real32(v_fs_get_user_data(61), node_id, layer_id, polygon_id, value); - - return buffer_pos; -} - -void verse_send_g_crease_set_vertex(VNodeID node_id, const char *layer, uint32 def_crease) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 62); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_crease_set_vertex(node_id = %u layer = %s def_crease = %u );\n", node_id, layer, def_crease); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], layer, 16); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], def_crease); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_crease_set_vertex(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_crease_set_vertex)(void *user_data, VNodeID node_id, const char *layer, uint32 def_crease); - VNodeID node_id; - char layer[16]; - uint32 def_crease; - - func_g_crease_set_vertex = v_fs_get_user_func(62); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], layer, 16, buffer_length - buffer_pos); - if(buffer_length < 4 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &def_crease); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_crease_set_vertex(node_id = %u layer = %s def_crease = %u ); callback = %p\n", node_id, layer, def_crease, v_fs_get_user_func(62)); -#endif - if(func_g_crease_set_vertex != NULL) - func_g_crease_set_vertex(v_fs_get_user_data(62), node_id, layer, def_crease); - - return buffer_pos; -} - -void verse_send_g_crease_set_edge(VNodeID node_id, const char *layer, uint32 def_crease) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 63); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_crease_set_edge(node_id = %u layer = %s def_crease = %u );\n", node_id, layer, def_crease); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], layer, 16); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], def_crease); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_crease_set_edge(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_crease_set_edge)(void *user_data, VNodeID node_id, const char *layer, uint32 def_crease); - VNodeID node_id; - char layer[16]; - uint32 def_crease; - - func_g_crease_set_edge = v_fs_get_user_func(63); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], layer, 16, buffer_length - buffer_pos); - if(buffer_length < 4 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &def_crease); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_g_crease_set_edge(node_id = %u layer = %s def_crease = %u ); callback = %p\n", node_id, layer, def_crease, v_fs_get_user_func(63)); -#endif - if(func_g_crease_set_edge != NULL) - func_g_crease_set_edge(v_fs_get_user_data(63), node_id, layer, def_crease); - - return buffer_pos; -} - -void verse_send_g_bone_create(VNodeID node_id, uint16 bone_id, const char *weight, const char *reference, uint16 parent, real64 pos_x, real64 pos_y, real64 pos_z, const char *position_label, const char *rotation_label, const char *scale_label) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_160);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 64); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_bone_create(node_id = %u bone_id = %u weight = %s reference = %s parent = %u pos_x = %f pos_y = %f pos_z = %f position_label = %s rotation_label = %s scale_label = %s );\n", node_id, bone_id, weight, reference, parent, pos_x, pos_y, pos_z, position_label, rotation_label, scale_label); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], bone_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], weight, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], reference, 16); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], parent); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos_x); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos_y); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos_z); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], position_label, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], rotation_label, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], scale_label, 16); - if(node_id == (uint32) ~0u || bone_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_g_bone_destroy(VNodeID node_id, uint16 bone_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_160);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 64); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_g_bone_destroy(node_id = %u bone_id = %u );\n", node_id, bone_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], bone_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - if(node_id == (uint32) ~0u || bone_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_g_bone_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_g_bone_create)(void *user_data, VNodeID node_id, uint16 bone_id, const char *weight, const char *reference, uint16 parent, real64 pos_x, real64 pos_y, real64 pos_z, const char *position_label, const char *rotation_label, const char *scale_label); - VNodeID node_id; - uint16 bone_id; - char weight[16]; - char reference[16]; - uint16 parent; - real64 pos_x; - real64 pos_y; - real64 pos_z; - char position_label[16]; - char rotation_label[16]; - char scale_label[16]; - - func_g_bone_create = v_fs_get_user_func(64); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &bone_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], weight, 16, buffer_length - buffer_pos); - if(buffer_length < 0 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], reference, 16, buffer_length - buffer_pos); - if(buffer_length < 26 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &parent); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pos_x); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pos_y); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pos_z); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], position_label, 16, buffer_length - buffer_pos); - if(buffer_length < 0 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], rotation_label, 16, buffer_length - buffer_pos); - if(buffer_length < 0 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], scale_label, 16, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - if(weight[0] == 0) - printf("receive: verse_send_g_bone_destroy(node_id = %u bone_id = %u ); callback = %p\n", node_id, bone_id, v_fs_get_alias_user_func(64)); - else - printf("receive: verse_send_g_bone_create(node_id = %u bone_id = %u weight = %s reference = %s parent = %u pos_x = %f pos_y = %f pos_z = %f position_label = %s rotation_label = %s scale_label = %s ); callback = %p\n", node_id, bone_id, weight, reference, parent, pos_x, pos_y, pos_z, position_label, rotation_label, scale_label, v_fs_get_user_func(64)); -#endif - if(weight[0] == 0) - { - void (* alias_g_bone_destroy)(void *user_data, VNodeID node_id, uint16 bone_id); - alias_g_bone_destroy = v_fs_get_alias_user_func(64); - if(alias_g_bone_destroy != NULL) - alias_g_bone_destroy(v_fs_get_alias_user_data(64), node_id, bone_id); - return buffer_pos; - } - if(func_g_bone_create != NULL) - func_g_bone_create(v_fs_get_user_data(64), node_id, bone_id, weight, reference, parent, pos_x, pos_y, pos_z, position_label, rotation_label, scale_label); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_init.c b/extern/verse/dist/v_gen_pack_init.c deleted file mode 100644 index e568cb989cb..00000000000 --- a/extern/verse/dist/v_gen_pack_init.c +++ /dev/null @@ -1,95 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -#include "v_gen_unpack_func.h" - -#include "verse.h" - - -extern void verse_send_packet_ack(uint32 packet_id); -extern void verse_send_packet_nak(uint32 packet_id); - -void init_pack_and_unpack(void) -{ - v_fs_add_func(0, v_unpack_connect, (void *) verse_send_connect, NULL); - v_fs_add_func(1, v_unpack_connect_accept, (void *) verse_send_connect_accept, NULL); - v_fs_add_func(2, v_unpack_connect_terminate, (void *) verse_send_connect_terminate, NULL); - v_fs_add_func(5, v_unpack_ping, (void *) verse_send_ping, NULL); - v_fs_add_func(7, v_unpack_packet_ack, verse_send_packet_ack, NULL); - v_fs_add_func(8, v_unpack_packet_nak, verse_send_packet_nak, NULL); - v_fs_add_func(9, v_unpack_node_index_subscribe, verse_send_node_index_subscribe, NULL); - v_fs_add_func(10, v_unpack_node_create, verse_send_node_create, verse_send_node_destroy); - v_fs_add_func(11, v_unpack_node_subscribe, verse_send_node_subscribe, verse_send_node_unsubscribe); - v_fs_add_func(16, v_unpack_tag_group_create, verse_send_tag_group_create, verse_send_tag_group_destroy); - v_fs_add_func(17, v_unpack_tag_group_subscribe, verse_send_tag_group_subscribe, verse_send_tag_group_unsubscribe); - v_fs_add_func(18, v_unpack_tag_create, verse_send_tag_create, verse_send_tag_destroy); - v_fs_add_func(19, v_unpack_node_name_set, verse_send_node_name_set, NULL); - v_fs_add_func(32, v_unpack_o_transform_pos_real32, verse_send_o_transform_pos_real32, NULL); - v_fs_add_func(33, v_unpack_o_transform_rot_real32, verse_send_o_transform_rot_real32, NULL); - v_fs_add_func(34, v_unpack_o_transform_scale_real32, verse_send_o_transform_scale_real32, NULL); - v_fs_add_func(35, v_unpack_o_transform_pos_real64, verse_send_o_transform_pos_real64, NULL); - v_fs_add_func(36, v_unpack_o_transform_rot_real64, verse_send_o_transform_rot_real64, NULL); - v_fs_add_func(37, v_unpack_o_transform_scale_real64, verse_send_o_transform_scale_real64, NULL); - v_fs_add_func(38, v_unpack_o_transform_subscribe, verse_send_o_transform_subscribe, verse_send_o_transform_unsubscribe); - v_fs_add_func(39, v_unpack_o_light_set, verse_send_o_light_set, NULL); - v_fs_add_func(40, v_unpack_o_link_set, verse_send_o_link_set, verse_send_o_link_destroy); - v_fs_add_func(41, v_unpack_o_method_group_create, verse_send_o_method_group_create, verse_send_o_method_group_destroy); - v_fs_add_func(42, v_unpack_o_method_group_subscribe, verse_send_o_method_group_subscribe, verse_send_o_method_group_unsubscribe); - v_fs_add_func(43, v_unpack_o_method_create, verse_send_o_method_create, verse_send_o_method_destroy); - v_fs_add_func(44, v_unpack_o_method_call, verse_send_o_method_call, NULL); - v_fs_add_func(45, v_unpack_o_anim_run, verse_send_o_anim_run, NULL); - v_fs_add_func(46, v_unpack_o_hide, verse_send_o_hide, NULL); - v_fs_add_func(48, v_unpack_g_layer_create, verse_send_g_layer_create, verse_send_g_layer_destroy); - v_fs_add_func(49, v_unpack_g_layer_subscribe, verse_send_g_layer_subscribe, verse_send_g_layer_unsubscribe); - v_fs_add_func(50, v_unpack_g_vertex_set_xyz_real32, verse_send_g_vertex_set_xyz_real32, verse_send_g_vertex_delete_real32); - v_fs_add_func(51, v_unpack_g_vertex_set_xyz_real64, verse_send_g_vertex_set_xyz_real64, verse_send_g_vertex_delete_real64); - v_fs_add_func(52, v_unpack_g_vertex_set_uint32, verse_send_g_vertex_set_uint32, NULL); - v_fs_add_func(53, v_unpack_g_vertex_set_real64, verse_send_g_vertex_set_real64, NULL); - v_fs_add_func(54, v_unpack_g_vertex_set_real32, verse_send_g_vertex_set_real32, NULL); - v_fs_add_func(55, v_unpack_g_polygon_set_corner_uint32, verse_send_g_polygon_set_corner_uint32, verse_send_g_polygon_delete); - v_fs_add_func(56, v_unpack_g_polygon_set_corner_real64, verse_send_g_polygon_set_corner_real64, NULL); - v_fs_add_func(57, v_unpack_g_polygon_set_corner_real32, verse_send_g_polygon_set_corner_real32, NULL); - v_fs_add_func(58, v_unpack_g_polygon_set_face_uint8, verse_send_g_polygon_set_face_uint8, NULL); - v_fs_add_func(59, v_unpack_g_polygon_set_face_uint32, verse_send_g_polygon_set_face_uint32, NULL); - v_fs_add_func(60, v_unpack_g_polygon_set_face_real64, verse_send_g_polygon_set_face_real64, NULL); - v_fs_add_func(61, v_unpack_g_polygon_set_face_real32, verse_send_g_polygon_set_face_real32, NULL); - v_fs_add_func(62, v_unpack_g_crease_set_vertex, verse_send_g_crease_set_vertex, NULL); - v_fs_add_func(63, v_unpack_g_crease_set_edge, verse_send_g_crease_set_edge, NULL); - v_fs_add_func(64, v_unpack_g_bone_create, verse_send_g_bone_create, verse_send_g_bone_destroy); - v_fs_add_func(68, v_unpack_m_fragment_create, verse_send_m_fragment_create, verse_send_m_fragment_destroy); - v_fs_add_func(80, v_unpack_b_dimensions_set, verse_send_b_dimensions_set, NULL); - v_fs_add_func(81, v_unpack_b_layer_create, verse_send_b_layer_create, verse_send_b_layer_destroy); - v_fs_add_func(82, v_unpack_b_layer_subscribe, verse_send_b_layer_subscribe, verse_send_b_layer_unsubscribe); - v_fs_add_func(83, v_unpack_b_tile_set, (void *) verse_send_b_tile_set, NULL); - v_fs_add_func(96, v_unpack_t_language_set, verse_send_t_language_set, NULL); - v_fs_add_func(97, v_unpack_t_buffer_create, verse_send_t_buffer_create, verse_send_t_buffer_destroy); - v_fs_add_func(98, v_unpack_t_buffer_subscribe, verse_send_t_buffer_subscribe, verse_send_t_buffer_unsubscribe); - v_fs_add_func(99, v_unpack_t_text_set, (void *) verse_send_t_text_set, NULL); - v_fs_add_func(128, v_unpack_c_curve_create, verse_send_c_curve_create, verse_send_c_curve_destroy); - v_fs_add_func(129, v_unpack_c_curve_subscribe, verse_send_c_curve_subscribe, verse_send_c_curve_unsubscribe); - v_fs_add_func(130, v_unpack_c_key_set, (void *) verse_send_c_key_set, (void *) verse_send_c_key_destroy); - v_fs_add_func(160, v_unpack_a_buffer_create, verse_send_a_buffer_create, verse_send_a_buffer_destroy); - v_fs_add_func(161, v_unpack_a_buffer_subscribe, verse_send_a_buffer_subscribe, verse_send_a_buffer_unsubscribe); - v_fs_add_func(162, v_unpack_a_block_set, verse_send_a_block_set, verse_send_a_block_clear); - v_fs_add_func(163, v_unpack_a_stream_create, verse_send_a_stream_create, verse_send_a_stream_destroy); - v_fs_add_func(164, v_unpack_a_stream_subscribe, verse_send_a_stream_subscribe, verse_send_a_stream_unsubscribe); - v_fs_add_func(165, v_unpack_a_stream, verse_send_a_stream, NULL); -} -#endif - diff --git a/extern/verse/dist/v_gen_pack_m_node.c b/extern/verse/dist/v_gen_pack_m_node.c deleted file mode 100644 index 376b6c51c39..00000000000 --- a/extern/verse/dist/v_gen_pack_m_node.c +++ /dev/null @@ -1,352 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_m_fragment_create(VNodeID node_id, VNMFragmentID frag_id, VNMFragmentType type, const VMatFrag *fragment) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 68); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_m_fragment_create(node_id = %u frag_id = %u type = %u fragment = %p );\n", node_id, frag_id, type, fragment); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], frag_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - switch(type) - { - case VN_M_FT_COLOR : - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.red); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.green); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->color.blue); - break; - case VN_M_FT_LIGHT : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->light.type); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->light.normal_falloff); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->light.brdf); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_r, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_g, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->light.brdf_b, 16); - break; - case VN_M_FT_REFLECTION : - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->reflection.normal_falloff); - break; - case VN_M_FT_TRANSPARENCY : - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.normal_falloff); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->transparency.refraction_index); - break; - case VN_M_FT_GEOMETRY : - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_r, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_g, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->geometry.layer_b, 16); - break; - case VN_M_FT_VOLUME : - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.diffusion); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_r); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_g); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->volume.col_b); - break; - case VN_M_FT_VIEW : - break; - case VN_M_FT_TEXTURE : - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], fragment->texture.bitmap); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_r, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_g, 16); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->texture.layer_b, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->texture.filtered); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->texture.mapping); - break; - case VN_M_FT_NOISE : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->noise.type); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->noise.mapping); - break; - case VN_M_FT_BLENDER : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->blender.type); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_a); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.data_b); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->blender.control); - break; - case VN_M_FT_CLAMP : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->clamp.min); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.red); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.green); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->clamp.blue); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->clamp.data); - break; - case VN_M_FT_MATRIX : - { - unsigned int i; - for(i = 0; i < 16; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->matrix.matrix[i]); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->matrix.data); - } - break; - case VN_M_FT_RAMP : - if(fragment->ramp.point_count == 0) - return; - { - unsigned int i, pos; - double last; - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.type); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)fragment->ramp.channel); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->ramp.mapping); - pos = buffer_pos; - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], fragment->ramp.point_count); - last = fragment->ramp.ramp[0].pos - 1; - for(i = 0; i < fragment->ramp.point_count && fragment->ramp.ramp[i].pos > last && i < 48; i++) - { - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].pos); - last = fragment->ramp.ramp[i].pos; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].red); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].green); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], fragment->ramp.ramp[i].blue); - } - if(i != fragment->ramp.point_count) - vnp_raw_pack_uint8(&buf[pos], i); - } - break; - case VN_M_FT_ANIMATION : - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->animation.label, 16); - break; - case VN_M_FT_ALTERNATIVE : - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_a); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->alternative.alt_b); - break; - case VN_M_FT_OUTPUT : - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], fragment->output.label, 16); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.front); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], fragment->output.back); - break; - } - if(node_id == (uint32) ~0u || frag_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_m_fragment_destroy(VNodeID node_id, VNMFragmentID frag_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 68); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_m_fragment_destroy(node_id = %u frag_id = %u );\n", node_id, frag_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], frag_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - if(node_id == (uint32) ~0u || frag_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_m_fragment_create(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_m_fragment_create)(void *user_data, VNodeID node_id, VNMFragmentID frag_id, VNMFragmentType type, const VMatFrag *fragment); - VNodeID node_id; - VNMFragmentID frag_id; - VNMFragmentType type; - const VMatFrag *fragment; - - func_m_fragment_create = v_fs_get_user_func(68); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNMFragmentType)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - if(type > VN_M_FT_OUTPUT) - printf("receive: verse_send_m_fragment_destroy(node_id = %u frag_id = %u ); callback = %p\n", node_id, frag_id, v_fs_get_alias_user_func(68)); - else - printf("receive: verse_send_m_fragment_create(node_id = %u frag_id = %u type = %u ); callback = %p\n", node_id, frag_id, type, v_fs_get_user_func(68)); -#endif - if(type <= VN_M_FT_OUTPUT) - { - VMatFrag frag; - uint8 temp; - switch(type) - { - case VN_M_FT_COLOR : - if(buffer_pos + 3 * 8 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.red); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.green); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.color.blue); - break; - case VN_M_FT_LIGHT : - if(buffer_pos + 13 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.light.type = (VNMLightType)temp; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.light.normal_falloff); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.light.brdf); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_r, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_g, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.light.brdf_b, 16, buffer_length - buffer_pos); - break; - case VN_M_FT_REFLECTION : - if(buffer_pos + 8 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.reflection.normal_falloff); - break; - case VN_M_FT_TRANSPARENCY : - if(buffer_pos + 16 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.normal_falloff); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.transparency.refraction_index); - break; - case VN_M_FT_VOLUME : - if(buffer_pos + 32 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.diffusion); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_r); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_g); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.volume.col_b); - break; - case VN_M_FT_VIEW : - break; - case VN_M_FT_GEOMETRY : - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_r, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_g, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.geometry.layer_b, 16, buffer_length - buffer_pos); - break; - case VN_M_FT_TEXTURE : - if(buffer_pos + 10 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &frag.texture.bitmap); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_r, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_g, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.texture.layer_b, 16, buffer_length - buffer_pos); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.texture.filtered = (VNMNoiseType)temp; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.texture.mapping); - break; - case VN_M_FT_NOISE : - if(buffer_pos + 3 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.noise.type = (VNMNoiseType)temp; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.noise.mapping); - break; - case VN_M_FT_BLENDER : - if(buffer_pos + 7 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.blender.type = (VNMBlendType)temp; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_a); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.data_b); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.blender.control); - break; - case VN_M_FT_CLAMP : - if(buffer_pos + 27 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.clamp.min = (VNMBlendType)temp; - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.red); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.green); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.clamp.blue); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.clamp.data); - break; - case VN_M_FT_MATRIX : - if(buffer_pos + 8 * 16 + 2 > buffer_length) - return -1; - else - { - unsigned int i; - for(i = 0; i < 16; i++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.matrix.matrix[i]); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.matrix.data); - } - break; - case VN_M_FT_RAMP : - if(buffer_pos + 5 + 4 * 8 > buffer_length) - return -1; - else - { - unsigned int i, pos; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.ramp.type = (VNMRampType)temp; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &temp); - frag.ramp.channel = (VNMRampChannel)temp; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.ramp.mapping); - pos = buffer_pos; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &frag.ramp.point_count); - for(i = 0; i < frag.ramp.point_count && buffer_pos + 8 * 4 <= buffer_length && i < 48; i++) - { - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].pos); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].red); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].green); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frag.ramp.ramp[i].blue); - }if(i != frag.ramp.point_count) - frag.ramp.point_count = i; - } - break; - case VN_M_FT_ANIMATION : - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.animation.label, 16, buffer_length - buffer_pos); - break; - case VN_M_FT_ALTERNATIVE : - if(buffer_pos + 4 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_a); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.alternative.alt_b); - break; - case VN_M_FT_OUTPUT : - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], frag.output.label, 16, buffer_length - buffer_pos); - if(buffer_pos + 4 > buffer_length) - return -1; - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.front); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &frag.output.back); - break; - } - if(func_m_fragment_create != NULL) - func_m_fragment_create(v_fs_get_user_data(68), node_id, frag_id, type, &frag); - return buffer_pos; - } - - if(type > VN_M_FT_OUTPUT) - { - void (* alias_m_fragment_destroy)(void *user_data, VNodeID node_id, VNMFragmentID frag_id); - alias_m_fragment_destroy = v_fs_get_alias_user_func(68); - if(alias_m_fragment_destroy != NULL) - alias_m_fragment_destroy(v_fs_get_alias_user_data(68), node_id, frag_id); - return buffer_pos; - } - if(func_m_fragment_create != NULL) - func_m_fragment_create(v_fs_get_user_data(68), node_id, frag_id, (VNMFragmentType) type, fragment); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_o_node.c b/extern/verse/dist/v_gen_pack_o_node.c deleted file mode 100644 index 5d60bafe1d0..00000000000 --- a/extern/verse/dist/v_gen_pack_o_node.c +++ /dev/null @@ -1,1297 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_o_transform_pos_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const real32 *pos, const real32 *speed, const real32 *accelerate, const real32 *drag_normal, real32 drag) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 32); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_pos_real32(node_id = %u time_s = %u time_f = %u pos = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f); - { - unsigned char mask = 0; - unsigned int cmd; - cmd = buffer_pos++; - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[0]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[1]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], pos[2]); - if(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001)) - { - mask |= 1; - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[0]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[1]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], speed[2]); - } - if(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001)) - { - mask |= 2; - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[0]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[1]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], accelerate[2]); - } - if(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001)) - { - mask |= 4; - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[0]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[1]); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag_normal[2]); - } - if(drag > 0.0000001 || drag < -0.0000001) - { - mask |= 8; - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag); - } - vnp_raw_pack_uint8(&buf[cmd], mask); - }if(FALSE) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_pos_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_transform_pos_real32)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const real32 *pos, const real32 *speed, const real32 *accelerate, const real32 *drag_normal, real32 drag); - VNodeID node_id; - uint32 time_s; - uint32 time_f; - const real32 *pos; - const real32 *speed; - const real32 *accelerate; - const real32 *drag_normal; - real32 drag; - - func_o_transform_pos_real32 = v_fs_get_user_func(32); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_transform_pos_real32(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(32)); -#endif - { - float output[4][3]; - unsigned int i, j; - char mask, pow = 1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask); - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[0][j]); - for(i = 1; i < 4; i++) - { - if((mask & pow) != 0) - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &output[i][j]); - else - for(j = 0; j < 3; j++) - output[i][j] = 0; - pow *= 2; - } - if((mask & pow) != 0) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag); - else - drag = 0.0f; - if(func_o_transform_pos_real32 != NULL) - func_o_transform_pos_real32(v_fs_get_user_data(32), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag); - return buffer_pos; - } - - if(func_o_transform_pos_real32 != NULL) - func_o_transform_pos_real32(v_fs_get_user_data(32), node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag); - - return buffer_pos; -} - -void verse_send_o_transform_rot_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 33); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_rot_real32(node_id = %u time_s = %u time_f = %u rot = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f); - { - uint8 mask = 0; - unsigned int maskpos; - maskpos = buffer_pos++; /* Remember location, and reserve a byte for the mask. */ - buffer_pos += vnp_pack_quat32(&buf[buffer_pos], rot); - if(v_quat32_valid(speed)) - { - mask |= 1; - buffer_pos += vnp_pack_quat32(&buf[buffer_pos], speed); - } - if(v_quat32_valid(accelerate)) - { - mask |= 2; - buffer_pos += vnp_pack_quat32(&buf[buffer_pos], accelerate); - } - if(v_quat32_valid(drag_normal)) - { - mask |= 4; - buffer_pos += vnp_pack_quat32(&buf[buffer_pos], drag_normal); - } - if(drag > 0.0000001 || drag < -0.0000001) - { - mask |= 8; - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag); - } - vnp_raw_pack_uint8(&buf[maskpos], mask); /* Write the mask into start of command. */ - } - if(FALSE) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], drag); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_rot_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_transform_rot_real32)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag); - VNodeID node_id; - uint32 time_s; - uint32 time_f; - const VNQuat32 *rot; - const VNQuat32 *speed; - const VNQuat32 *accelerate; - const VNQuat32 *drag_normal; - real32 drag; - - func_o_transform_rot_real32 = v_fs_get_user_func(33); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_transform_rot_real32(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(33)); -#endif - { - VNQuat32 trot, temp[3], *q[3]; - unsigned int i; - uint8 mask, test; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask); - buffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &trot); - for(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1) - { - if(mask & test) /* Field present? */ - { - buffer_pos += vnp_unpack_quat32(&buf[buffer_pos], &temp[i]); - q[i] = &temp[i]; - } - else - q[i] = NULL; - } - if(mask & test) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &drag); - else - drag = 0.0; - if(func_o_transform_rot_real32 != NULL) - func_o_transform_rot_real32(v_fs_get_user_data(33), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag); - return buffer_pos; - } - - if(func_o_transform_rot_real32 != NULL) - func_o_transform_rot_real32(v_fs_get_user_data(33), node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag); - - return buffer_pos; -} - -void verse_send_o_transform_scale_real32(VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 34); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_scale_real32(node_id = %u scale_x = %f scale_y = %f scale_z = %f );\n", node_id, scale_x, scale_y, scale_z); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], scale_x); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], scale_y); - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], scale_z); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_scale_real32(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_transform_scale_real32)(void *user_data, VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z); - VNodeID node_id; - real32 scale_x; - real32 scale_y; - real32 scale_z; - - func_o_transform_scale_real32 = v_fs_get_user_func(34); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &scale_x); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &scale_y); - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], &scale_z); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_transform_scale_real32(node_id = %u scale_x = %f scale_y = %f scale_z = %f ); callback = %p\n", node_id, scale_x, scale_y, scale_z, v_fs_get_user_func(34)); -#endif - if(func_o_transform_scale_real32 != NULL) - func_o_transform_scale_real32(v_fs_get_user_data(34), node_id, scale_x, scale_y, scale_z); - - return buffer_pos; -} - -void verse_send_o_transform_pos_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 35); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_pos_real64(node_id = %u time_s = %u time_f = %u pos = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f); - { - unsigned char mask = 0; - unsigned int cmd; - cmd = buffer_pos++; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[0]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[1]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[2]); - if(speed != NULL && (speed[0] > 0.0000001 || speed[0] < -0.0000001 || speed[1] > 0.0000001 || speed[1] < -0.0000001 || speed[2] > 0.0000001 || speed[2] < -0.0000001)) - { - mask |= 1; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[0]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[1]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[2]); - } - if(accelerate != NULL && (accelerate[0] > 0.0000001 || accelerate[0] < -0.0000001 || accelerate[1] > 0.0000001 || accelerate[1] < -0.0000001 || accelerate[2] > 0.0000001 || accelerate[2] < -0.0000001)) - { - mask |= 2; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[0]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[1]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accelerate[2]); - } - if(drag_normal != NULL && (drag > 0.0000001 || drag < -0.0000001) && (drag_normal[0] > 0.0000001 || drag_normal[0] < -0.0000001 || drag_normal[1] > 0.0000001 || drag_normal[1] < -0.0000001 || drag_normal[2] > 0.0000001 || drag_normal[2] < -0.0000001)) - { - mask |= 4; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[0]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[1]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag_normal[2]); - } - if(drag > 0.0000001 || drag < -0.0000001) - { - mask |= 8; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag); - } - vnp_raw_pack_uint8(&buf[cmd], mask); - }if(FALSE) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_pos_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_transform_pos_real64)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag); - VNodeID node_id; - uint32 time_s; - uint32 time_f; - const real64 *pos; - const real64 *speed; - const real64 *accelerate; - const real64 *drag_normal; - real64 drag; - - func_o_transform_pos_real64 = v_fs_get_user_func(35); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_transform_pos_real64(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(35)); -#endif - { - double output[4][3]; - unsigned int i, j; - char mask, pow = 1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask); - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]); - for(i = 1; i < 4; i++) - { - if((mask & pow) != 0) - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]); - else - for(j = 0; j < 3; j++) - output[i][j] = 0; - pow *= 2; - } - if((mask & pow) != 0) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag); - else - drag = 0.0; - if(func_o_transform_pos_real64 != NULL) - func_o_transform_pos_real64(v_fs_get_user_data(35), node_id, time_s, time_f, &output[0][0], &output[1][0], &output[2][0], &output[3][0], drag); - return buffer_pos; - } - - if(func_o_transform_pos_real64 != NULL) - func_o_transform_pos_real64(v_fs_get_user_data(35), node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag); - - return buffer_pos; -} - -void verse_send_o_transform_rot_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 36); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_rot_real64(node_id = %u time_s = %u time_f = %u rot = %p speed = %p accelerate = %p drag_normal = %p drag = %f );\n", node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f); - { - uint8 mask = 0; - unsigned int maskpos; - maskpos = buffer_pos++; /* Remember location, and reserve a byte for the mask. */ - buffer_pos += vnp_pack_quat64(&buf[buffer_pos], rot); - if(v_quat64_valid(speed)) - { - mask |= 1; - buffer_pos += vnp_pack_quat64(&buf[buffer_pos], speed); - } - if(v_quat64_valid(accelerate)) - { - mask |= 2; - buffer_pos += vnp_pack_quat64(&buf[buffer_pos], accelerate); - } - if(v_quat64_valid(drag_normal)) - { - mask |= 4; - buffer_pos += vnp_pack_quat64(&buf[buffer_pos], drag_normal); - } - if(drag > 0.0000001 || drag < -0.0000001) - { - mask |= 8; - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag); - } - vnp_raw_pack_uint8(&buf[maskpos], mask); /* Write the mask into start of command. */ - } - if(FALSE) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], drag); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_rot_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_transform_rot_real64)(void *user_data, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag); - VNodeID node_id; - uint32 time_s; - uint32 time_f; - const VNQuat64 *rot; - const VNQuat64 *speed; - const VNQuat64 *accelerate; - const VNQuat64 *drag_normal; - real64 drag; - - func_o_transform_rot_real64 = v_fs_get_user_func(36); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_transform_rot_real64(node_id = %u time_s = %u time_f = %u drag = %f ); callback = %p\n", node_id, time_s, time_f, drag, v_fs_get_user_func(36)); -#endif - { - VNQuat64 trot, temp[3], *q[3]; - unsigned int i; - uint8 mask, test; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask); - buffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &trot); - for(i = 0, test = 1; i < sizeof temp / sizeof *temp; i++, test <<= 1) - { - if(mask & test) /* Field present? */ - { - buffer_pos += vnp_unpack_quat64(&buf[buffer_pos], &temp[i]); - q[i] = &temp[i]; - } - else - q[i] = NULL; - } - if(mask & test) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &drag); - else - drag = 0.0; - if(func_o_transform_rot_real64 != NULL) - func_o_transform_rot_real64(v_fs_get_user_data(36), node_id, time_s, time_f, &trot, q[0], q[1], q[2], drag); - return buffer_pos; - } - - if(func_o_transform_rot_real64 != NULL) - func_o_transform_rot_real64(v_fs_get_user_data(36), node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag); - - return buffer_pos; -} - -void verse_send_o_transform_scale_real64(VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 37); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_scale_real64(node_id = %u scale_x = %f scale_y = %f scale_z = %f );\n", node_id, scale_x, scale_y, scale_z); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_x); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_y); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_z); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_scale_real64(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_transform_scale_real64)(void *user_data, VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z); - VNodeID node_id; - real64 scale_x; - real64 scale_y; - real64 scale_z; - - func_o_transform_scale_real64 = v_fs_get_user_func(37); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &scale_x); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &scale_y); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &scale_z); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_transform_scale_real64(node_id = %u scale_x = %f scale_y = %f scale_z = %f ); callback = %p\n", node_id, scale_x, scale_y, scale_z, v_fs_get_user_func(37)); -#endif - if(func_o_transform_scale_real64 != NULL) - func_o_transform_scale_real64(v_fs_get_user_data(37), node_id, scale_x, scale_y, scale_z); - - return buffer_pos; -} - -void verse_send_o_transform_subscribe(VNodeID node_id, VNRealFormat type) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 38); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_subscribe(node_id = %u type = %u );\n", node_id, type); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_o_transform_unsubscribe(VNodeID node_id, VNRealFormat type) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 38); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_transform_unsubscribe(node_id = %u type = %u );\n", node_id, type); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_transform_subscribe(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_o_transform_subscribe)(void *user_data, VNodeID node_id, VNRealFormat type); - VNodeID node_id; - VNRealFormat type; - uint8 alias_bool; - - func_o_transform_subscribe = v_fs_get_user_func(38); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNRealFormat)enum_temp; - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_o_transform_unsubscribe(node_id = %u type = %u ); callback = %p\n", node_id, type, v_fs_get_alias_user_func(38)); - else - printf("receive: verse_send_o_transform_subscribe(node_id = %u type = %u ); callback = %p\n", node_id, type, v_fs_get_user_func(38)); -#endif - if(!alias_bool) - { - void (* alias_o_transform_unsubscribe)(void *user_data, VNodeID node_id, VNRealFormat type); - alias_o_transform_unsubscribe = v_fs_get_alias_user_func(38); - if(alias_o_transform_unsubscribe != NULL) - alias_o_transform_unsubscribe(v_fs_get_alias_user_data(38), node_id, (VNRealFormat)type); - return buffer_pos; - } - if(func_o_transform_subscribe != NULL) - func_o_transform_subscribe(v_fs_get_user_data(38), node_id, (VNRealFormat) type); - - return buffer_pos; -} - -void verse_send_o_light_set(VNodeID node_id, real64 light_r, real64 light_g, real64 light_b) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 39); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_light_set(node_id = %u light_r = %f light_g = %f light_b = %f );\n", node_id, light_r, light_g, light_b); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], light_r); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], light_g); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], light_b); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_light_set(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_light_set)(void *user_data, VNodeID node_id, real64 light_r, real64 light_g, real64 light_b); - VNodeID node_id; - real64 light_r; - real64 light_g; - real64 light_b; - - func_o_light_set = v_fs_get_user_func(39); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &light_r); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &light_g); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &light_b); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_light_set(node_id = %u light_r = %f light_g = %f light_b = %f ); callback = %p\n", node_id, light_r, light_g, light_b, v_fs_get_user_func(39)); -#endif - if(func_o_light_set != NULL) - func_o_light_set(v_fs_get_user_data(39), node_id, light_r, light_g, light_b); - - return buffer_pos; -} - -void verse_send_o_link_set(VNodeID node_id, uint16 link_id, VNodeID link, const char *label, uint32 target_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 40); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_link_set(node_id = %u link_id = %u link = %u label = %s target_id = %u );\n", node_id, link_id, link, label, target_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], link_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], link); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], label, 16); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], target_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || link_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_o_link_destroy(VNodeID node_id, uint16 link_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 40); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_link_destroy(node_id = %u link_id = %u );\n", node_id, link_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], link_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], -1); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || link_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_link_set(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_link_set)(void *user_data, VNodeID node_id, uint16 link_id, VNodeID link, const char *label, uint32 target_id); - VNodeID node_id; - uint16 link_id; - VNodeID link; - char label[16]; - uint32 target_id; - uint8 alias_bool; - - func_o_link_set = v_fs_get_user_func(40); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &link_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &link); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], label, 16, buffer_length - buffer_pos); - if(buffer_length < 4 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &target_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_o_link_destroy(node_id = %u link_id = %u ); callback = %p\n", node_id, link_id, v_fs_get_alias_user_func(40)); - else - printf("receive: verse_send_o_link_set(node_id = %u link_id = %u link = %u label = %s target_id = %u ); callback = %p\n", node_id, link_id, link, label, target_id, v_fs_get_user_func(40)); -#endif - if(!alias_bool) - { - void (* alias_o_link_destroy)(void *user_data, VNodeID node_id, uint16 link_id); - alias_o_link_destroy = v_fs_get_alias_user_func(40); - if(alias_o_link_destroy != NULL) - alias_o_link_destroy(v_fs_get_alias_user_data(40), node_id, link_id); - return buffer_pos; - } - if(func_o_link_set != NULL) - func_o_link_set(v_fs_get_user_data(40), node_id, link_id, link, label, target_id); - - return buffer_pos; -} - -void verse_send_o_method_group_create(VNodeID node_id, uint16 group_id, const char *name) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 41); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_group_create(node_id = %u group_id = %u name = %s );\n", node_id, group_id, name); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_o_method_group_destroy(VNodeID node_id, uint16 group_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 41); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_group_destroy(node_id = %u group_id = %u );\n", node_id, group_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_method_group_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_method_group_create)(void *user_data, VNodeID node_id, uint16 group_id, const char *name); - VNodeID node_id; - uint16 group_id; - char name[16]; - - func_o_method_group_create = v_fs_get_user_func(41); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_o_method_group_destroy(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(41)); - else - printf("receive: verse_send_o_method_group_create(node_id = %u group_id = %u name = %s ); callback = %p\n", node_id, group_id, name, v_fs_get_user_func(41)); -#endif - if(name[0] == 0) - { - void (* alias_o_method_group_destroy)(void *user_data, VNodeID node_id, uint16 group_id); - alias_o_method_group_destroy = v_fs_get_alias_user_func(41); - if(alias_o_method_group_destroy != NULL) - alias_o_method_group_destroy(v_fs_get_alias_user_data(41), node_id, group_id); - return buffer_pos; - } - if(func_o_method_group_create != NULL) - func_o_method_group_create(v_fs_get_user_data(41), node_id, group_id, name); - - return buffer_pos; -} - -void verse_send_o_method_group_subscribe(VNodeID node_id, uint16 group_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 42); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_group_subscribe(node_id = %u group_id = %u );\n", node_id, group_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_o_method_group_unsubscribe(VNodeID node_id, uint16 group_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 42); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_group_unsubscribe(node_id = %u group_id = %u );\n", node_id, group_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_method_group_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_method_group_subscribe)(void *user_data, VNodeID node_id, uint16 group_id); - VNodeID node_id; - uint16 group_id; - uint8 alias_bool; - - func_o_method_group_subscribe = v_fs_get_user_func(42); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_o_method_group_unsubscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(42)); - else - printf("receive: verse_send_o_method_group_subscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_user_func(42)); -#endif - if(!alias_bool) - { - void (* alias_o_method_group_unsubscribe)(void *user_data, VNodeID node_id, uint16 group_id); - alias_o_method_group_unsubscribe = v_fs_get_alias_user_func(42); - if(alias_o_method_group_unsubscribe != NULL) - alias_o_method_group_unsubscribe(v_fs_get_alias_user_data(42), node_id, group_id); - return buffer_pos; - } - if(func_o_method_group_subscribe != NULL) - func_o_method_group_subscribe(v_fs_get_user_data(42), node_id, group_id); - - return buffer_pos; -} - -void verse_send_o_method_create(VNodeID node_id, uint16 group_id, uint16 method_id, const char *name, uint8 param_count, const VNOParamType *param_types, const char * *param_names) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 43); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_create(node_id = %u group_id = %u method_id = %u name = %s param_count = %u param_types = %p param_names = %p );\n", node_id, group_id, method_id, name, param_count, param_types, param_names); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], method_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 512); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], param_count); - { - unsigned int i, j, sum = 1; - for(i = 0; i < param_count; i++) - { - sum += 3; - for(j = 0; param_names[i][j] != 0; j++); - } - if(sum + buffer_pos > 1500) - return; - for(i = 0; i < param_count; i++) - { - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], param_types[i]); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], param_names[i], 1500 - buffer_pos); - } - } - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || method_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 9); - else - v_cmd_buf_set_address_size(head, 9); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_o_method_destroy(VNodeID node_id, uint16 group_id, uint16 method_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 43); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_destroy(node_id = %u group_id = %u method_id = %u );\n", node_id, group_id, method_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], method_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 512); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], -1); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || method_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 9); - else - v_cmd_buf_set_address_size(head, 9); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_method_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_method_create)(void *user_data, VNodeID node_id, uint16 group_id, uint16 method_id, const char *name, uint8 param_count, const VNOParamType *param_types, const char * *param_names); - VNodeID node_id; - uint16 group_id; - uint16 method_id; - char name[512]; - uint8 param_count; - const VNOParamType *param_types; - const char * *param_names; - - func_o_method_create = v_fs_get_user_func(43); - if(buffer_length < 8) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &method_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos); - if(buffer_length < 1 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], ¶m_count); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_o_method_destroy(node_id = %u group_id = %u method_id = %u ); callback = %p\n", node_id, group_id, method_id, v_fs_get_alias_user_func(43)); - else - printf("receive: verse_send_o_method_create(node_id = %u group_id = %u method_id = %u name = %s param_count = %u ); callback = %p\n", node_id, group_id, method_id, name, param_count, v_fs_get_user_func(43)); -#endif - if(param_count != 255) - { - unsigned int i, size, text = 0; - VNOParamType types[256]; - uint8 t; - char name_buf[1500], *names[256]; - for(i = 0; i < param_count; i++) - { - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &t); - types[i] = t; - names[i] = &name_buf[text]; - size = vnp_raw_unpack_string(&buf[buffer_pos], names[i], 1500 - buffer_pos, buffer_length - buffer_pos); - buffer_pos += size; - text += size; - } - if(func_o_method_create != NULL) - func_o_method_create(v_fs_get_user_data(43), node_id, group_id, method_id, name, param_count, types, (const char **) names); - return buffer_pos; - } - - if(name[0] == 0) - { - void (* alias_o_method_destroy)(void *user_data, VNodeID node_id, uint16 group_id, uint16 method_id); - alias_o_method_destroy = v_fs_get_alias_user_func(43); - if(alias_o_method_destroy != NULL) - alias_o_method_destroy(v_fs_get_alias_user_data(43), node_id, group_id, method_id); - return buffer_pos; - } - if(func_o_method_create != NULL) - func_o_method_create(v_fs_get_user_data(43), node_id, group_id, method_id, name, param_count, param_types, param_names); - - return buffer_pos; -} - -void verse_send_o_method_call(VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, const VNOPackedParams *params) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 44); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_method_call(node_id = %u group_id = %u method_id = %u sender = %u params = %p );\n", node_id, group_id, method_id, sender, params); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], method_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], sender); - { - unsigned int i; - uint16 size; - vnp_raw_unpack_uint16(params, &size); - for(i = 0; i < size; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)params)[i]); - free((void *) params); /* Drop the const. */ - } - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_method_call(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_method_call)(void *user_data, VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, const VNOPackedParams *params); - VNodeID node_id; - uint16 group_id; - uint16 method_id; - VNodeID sender; - const VNOPackedParams *params; - - func_o_method_call = v_fs_get_user_func(44); - if(buffer_length < 12) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &method_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &sender); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_method_call(node_id = %u group_id = %u method_id = %u sender = %u ); callback = %p\n", node_id, group_id, method_id, sender, v_fs_get_user_func(44)); -#endif - { - unsigned int i; - uint8 par[1500]; - uint16 size; - vnp_raw_unpack_uint16(&buf[buffer_pos], &size); - for(i = 0; i < size; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &par[i]); - if(func_o_method_call != NULL) - func_o_method_call(v_fs_get_user_data(44), node_id, group_id, method_id, sender, par); - return buffer_pos; - } - - if(func_o_method_call != NULL) - func_o_method_call(v_fs_get_user_data(44), node_id, group_id, method_id, sender, params); - - return buffer_pos; -} - -void verse_send_o_anim_run(VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, const real64 *pos, const real64 *speed, const real64 *accel, const real64 *scale, const real64 *scale_speed) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 45); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_anim_run(node_id = %u link_id = %u time_s = %u time_f = %u dimensions = %u pos = %p speed = %p accel = %p scale = %p scale_speed = %p );\n", node_id, link_id, time_s, time_f, dimensions, pos, speed, accel, scale, scale_speed); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], link_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions); - { - unsigned char mask = 0; - unsigned int cmd, i; - cmd = buffer_pos++; - if(dimensions > 4) - dimensions = 4; - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos[i]); - if(speed != NULL) - { - mask |= 1; - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], speed[i]); - } - if(accel != NULL) - { - mask |= 2; - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], accel[i]); - } - if(scale != NULL) - { - mask |= 3; - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale[i]); - } - if(scale_speed != NULL) - { - mask |= 4; - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], scale_speed[i]); - } - vnp_raw_pack_uint8(&buf[cmd], mask); - } - if(node_id == (uint32) ~0u || link_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_anim_run(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_anim_run)(void *user_data, VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, const real64 *pos, const real64 *speed, const real64 *accel, const real64 *scale, const real64 *scale_speed); - VNodeID node_id; - uint16 link_id; - uint32 time_s; - uint32 time_f; - uint8 dimensions; - const real64 *pos; - const real64 *speed; - const real64 *accel; - const real64 *scale; - const real64 *scale_speed; - - func_o_anim_run = v_fs_get_user_func(45); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &link_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &dimensions); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_anim_run(node_id = %u link_id = %u time_s = %u time_f = %u dimensions = %u ); callback = %p\n", node_id, link_id, time_s, time_f, dimensions, v_fs_get_user_func(45)); -#endif - { - double output[5][4]; - unsigned int i, j; - char mask, pow = 1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &mask); - if(dimensions > 4) - dimensions = 4; - for(j = 0; j < dimensions; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[0][j]); - for(i = 1; i < 5; i++) - { - if((mask & pow) != 0) - for(j = 0; j < dimensions; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &output[i][j]); - else - for(j = 0; j < dimensions; j++) - output[i][j] = 0; - pow *= 2; - } - if(func_o_anim_run != NULL) - func_o_anim_run(v_fs_get_user_data(45), node_id, link_id, time_s, time_f, dimensions, &output[0][0], &output[1][0], &output[2][0], &output[3][0], &output[4][0]); - return buffer_pos; - } - - if(func_o_anim_run != NULL) - func_o_anim_run(v_fs_get_user_data(45), node_id, link_id, time_s, time_f, dimensions, pos, speed, accel, scale, scale_speed); - - return buffer_pos; -} - -void verse_send_o_hide(VNodeID node_id, uint8 hidden) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 46); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_o_hide(node_id = %u hidden = %u );\n", node_id, hidden); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], hidden); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_o_hide(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_o_hide)(void *user_data, VNodeID node_id, uint8 hidden); - VNodeID node_id; - uint8 hidden; - - func_o_hide = v_fs_get_user_func(46); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &hidden); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_o_hide(node_id = %u hidden = %u ); callback = %p\n", node_id, hidden, v_fs_get_user_func(46)); -#endif - if(func_o_hide != NULL) - func_o_hide(v_fs_get_user_data(46), node_id, hidden); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_s_node.c b/extern/verse/dist/v_gen_pack_s_node.c deleted file mode 100644 index 6a9f4a05a0b..00000000000 --- a/extern/verse/dist/v_gen_pack_s_node.c +++ /dev/null @@ -1,711 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_packet_ack(uint32 packet_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 7); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id); - v_cmd_buf_set_unique_address_size(head, buffer_pos); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_ack_nak_buf(v_con_get_network_queue(), head); - return; - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_packet_ack(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_packet_ack)(void *user_data, uint32 packet_id); - uint32 packet_id; - - func_packet_ack = v_fs_get_user_func(7); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &packet_id); -#if defined V_PRINT_RECEIVE_COMMANDS -#endif - if(func_packet_ack != NULL) - func_packet_ack(v_fs_get_user_data(7), packet_id); - - return buffer_pos; -} - -void verse_send_packet_nak(uint32 packet_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 8); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], packet_id); - v_cmd_buf_set_unique_address_size(head, buffer_pos); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_ack_nak_buf(v_con_get_network_queue(), head); - return; - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_packet_nak(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_packet_nak)(void *user_data, uint32 packet_id); - uint32 packet_id; - - func_packet_nak = v_fs_get_user_func(8); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &packet_id); -#if defined V_PRINT_RECEIVE_COMMANDS -#endif - if(func_packet_nak != NULL) - func_packet_nak(v_fs_get_user_data(8), packet_id); - - return buffer_pos; -} - -void verse_send_node_index_subscribe(uint32 mask) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 9); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_node_index_subscribe(mask = %u );\n", mask); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], mask); - if(mask == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_node_index_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_node_index_subscribe)(void *user_data, uint32 mask); - uint32 mask; - - func_node_index_subscribe = v_fs_get_user_func(9); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &mask); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_node_index_subscribe(mask = %u ); callback = %p\n", mask, v_fs_get_user_func(9)); -#endif - if(func_node_index_subscribe != NULL) - func_node_index_subscribe(v_fs_get_user_data(9), mask); - - return buffer_pos; -} - -void verse_send_node_create(VNodeID node_id, VNodeType type, VNodeOwner owner) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 10); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_node_create(node_id = %u type = %u owner = %u );\n", node_id, type, owner); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)owner); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_node_destroy(VNodeID node_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 10); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_node_destroy(node_id = %u );\n", node_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_node_create(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_node_create)(void *user_data, VNodeID node_id, VNodeType type, VNodeOwner owner); - VNodeID node_id; - VNodeType type; - VNodeOwner owner; - - func_node_create = v_fs_get_user_func(10); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNodeType)enum_temp; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - owner = (VNodeOwner)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES) - printf("receive: verse_send_node_destroy(node_id = %u ); callback = %p\n", node_id, v_fs_get_alias_user_func(10)); - else - printf("receive: verse_send_node_create(node_id = %u type = %u owner = %u ); callback = %p\n", node_id, type, owner, v_fs_get_user_func(10)); -#endif - if(owner == (uint8) ~0u || type >= V_NT_NUM_TYPES) - { - void (* alias_node_destroy)(void *user_data, VNodeID node_id); - alias_node_destroy = v_fs_get_alias_user_func(10); - if(alias_node_destroy != NULL) - alias_node_destroy(v_fs_get_alias_user_data(10), node_id); - return buffer_pos; - } - if(func_node_create != NULL) - func_node_create(v_fs_get_user_data(10), node_id, (VNodeType) type, (VNodeOwner) owner); - - return buffer_pos; -} - -void verse_send_node_subscribe(VNodeID node_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 11); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_node_subscribe(node_id = %u );\n", node_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_node_unsubscribe(VNodeID node_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 11); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_node_unsubscribe(node_id = %u );\n", node_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_node_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_node_subscribe)(void *user_data, VNodeID node_id); - VNodeID node_id; - uint8 alias_bool; - - func_node_subscribe = v_fs_get_user_func(11); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_node_unsubscribe(node_id = %u ); callback = %p\n", node_id, v_fs_get_alias_user_func(11)); - else - printf("receive: verse_send_node_subscribe(node_id = %u ); callback = %p\n", node_id, v_fs_get_user_func(11)); -#endif - if(!alias_bool) - { - void (* alias_node_unsubscribe)(void *user_data, VNodeID node_id); - alias_node_unsubscribe = v_fs_get_alias_user_func(11); - if(alias_node_unsubscribe != NULL) - alias_node_unsubscribe(v_fs_get_alias_user_data(11), node_id); - return buffer_pos; - } - if(func_node_subscribe != NULL) - func_node_subscribe(v_fs_get_user_data(11), node_id); - - return buffer_pos; -} - -void verse_send_tag_group_create(VNodeID node_id, uint16 group_id, const char *name) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 16); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_tag_group_create(node_id = %u group_id = %u name = %s );\n", node_id, group_id, name); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_tag_group_destroy(VNodeID node_id, uint16 group_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 16); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_tag_group_destroy(node_id = %u group_id = %u );\n", node_id, group_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_tag_group_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_tag_group_create)(void *user_data, VNodeID node_id, uint16 group_id, const char *name); - VNodeID node_id; - uint16 group_id; - char name[16]; - - func_tag_group_create = v_fs_get_user_func(16); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_tag_group_destroy(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(16)); - else - printf("receive: verse_send_tag_group_create(node_id = %u group_id = %u name = %s ); callback = %p\n", node_id, group_id, name, v_fs_get_user_func(16)); -#endif - if(name[0] == 0) - { - void (* alias_tag_group_destroy)(void *user_data, VNodeID node_id, uint16 group_id); - alias_tag_group_destroy = v_fs_get_alias_user_func(16); - if(alias_tag_group_destroy != NULL) - alias_tag_group_destroy(v_fs_get_alias_user_data(16), node_id, group_id); - return buffer_pos; - } - if(func_tag_group_create != NULL) - func_tag_group_create(v_fs_get_user_data(16), node_id, group_id, name); - - return buffer_pos; -} - -void verse_send_tag_group_subscribe(VNodeID node_id, uint16 group_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 17); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_tag_group_subscribe(node_id = %u group_id = %u );\n", node_id, group_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_tag_group_unsubscribe(VNodeID node_id, uint16 group_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 17); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_tag_group_unsubscribe(node_id = %u group_id = %u );\n", node_id, group_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_tag_group_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_tag_group_subscribe)(void *user_data, VNodeID node_id, uint16 group_id); - VNodeID node_id; - uint16 group_id; - uint8 alias_bool; - - func_tag_group_subscribe = v_fs_get_user_func(17); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_tag_group_unsubscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_alias_user_func(17)); - else - printf("receive: verse_send_tag_group_subscribe(node_id = %u group_id = %u ); callback = %p\n", node_id, group_id, v_fs_get_user_func(17)); -#endif - if(!alias_bool) - { - void (* alias_tag_group_unsubscribe)(void *user_data, VNodeID node_id, uint16 group_id); - alias_tag_group_unsubscribe = v_fs_get_alias_user_func(17); - if(alias_tag_group_unsubscribe != NULL) - alias_tag_group_unsubscribe(v_fs_get_alias_user_data(17), node_id, group_id); - return buffer_pos; - } - if(func_tag_group_subscribe != NULL) - func_tag_group_subscribe(v_fs_get_user_data(17), node_id, group_id); - - return buffer_pos; -} - -void verse_send_tag_create(VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 18); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_tag_create(node_id = %u group_id = %u tag_id = %u name = %s type = %u tag = %p );\n", node_id, group_id, tag_id, name, type, tag); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tag_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - if(type > VN_TAG_BLOB) - { - v_cmd_buf_free(head); - return; - } - switch(type) - { - case VN_TAG_BOOLEAN : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vboolean); - break; - case VN_TAG_UINT32 : - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vuint32); - break; - case VN_TAG_REAL64 : - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64); - break; - case VN_TAG_STRING : - { - unsigned int i; - for(i = 0; ((VNTag *)tag)->vstring[i] != 0 && i < VN_TAG_MAX_BLOB_SIZE; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((VNTag *)tag)->vstring[i]); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0); - } - break; - case VN_TAG_REAL64_VEC3 : - { - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[0]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[1]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], ((VNTag *)tag)->vreal64_vec3[2]); - } - break; - case VN_TAG_LINK : - { - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vlink); - } - break; - case VN_TAG_ANIMATION : - { - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.curve); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.start); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], ((VNTag *)tag)->vanimation.end); - } - break; - case VN_TAG_BLOB : - { - unsigned int i; - if(((VNTag *)tag)->vblob.size > VN_TAG_MAX_BLOB_SIZE) - ((VNTag *)tag)->vblob.size = VN_TAG_MAX_BLOB_SIZE; - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], ((VNTag *)tag)->vblob.size); - for(i = 0; i < ((VNTag *)tag)->vblob.size; i++) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], ((uint8 *)((VNTag *)tag)->vblob.blob)[i]); - } - break; - default : - ; - } - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || tag_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 9); - else - v_cmd_buf_set_address_size(head, 9); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_tag_destroy(VNodeID node_id, uint16 group_id, uint16 tag_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 18); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_tag_destroy(node_id = %u group_id = %u tag_id = %u );\n", node_id, group_id, tag_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], group_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tag_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1); - if(node_id == (uint32) ~0u || group_id == (uint16) ~0u || tag_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 9); - else - v_cmd_buf_set_address_size(head, 9); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_tag_create(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_tag_create)(void *user_data, VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag); - VNodeID node_id; - uint16 group_id; - uint16 tag_id; - char name[16]; - VNTagType type; - const VNTag *tag; - - func_tag_create = v_fs_get_user_func(18); - if(buffer_length < 8) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &group_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); - if(buffer_length < 1 + buffer_pos) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNTagType)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - if(type >= VN_TAG_TYPE_COUNT) - printf("receive: verse_send_tag_destroy(node_id = %u group_id = %u tag_id = %u ); callback = %p\n", node_id, group_id, tag_id, v_fs_get_alias_user_func(18)); - else - printf("receive: verse_send_tag_create(node_id = %u group_id = %u tag_id = %u name = %s type = %u ); callback = %p\n", node_id, group_id, tag_id, name, type, v_fs_get_user_func(18)); -#endif - if(type < VN_TAG_TYPE_COUNT) - { - VNTag tag; - unsigned int i; - char string[VN_TAG_MAX_BLOB_SIZE]; - switch(type) - { - case VN_TAG_BOOLEAN : - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &tag.vboolean); - break; - case VN_TAG_UINT32 : - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vuint32); - break; - case VN_TAG_REAL64 : - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64); - break; - case VN_TAG_STRING : - { - tag.vstring = string; - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], string, VN_TAG_MAX_BLOB_SIZE, buffer_length - buffer_pos); - } - break; - case VN_TAG_REAL64_VEC3 : - { - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[0]); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[1]); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &tag.vreal64_vec3[2]); - } - break; - case VN_TAG_LINK : - { - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vlink); - } - break; - case VN_TAG_ANIMATION : - { - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.curve); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.start); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &tag.vanimation.end); - } - break; - case VN_TAG_BLOB : - { - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tag.vblob.size); - if(tag.vblob.size > VN_TAG_MAX_BLOB_SIZE) - tag.vblob.size = VN_TAG_MAX_BLOB_SIZE; - tag.vblob.blob = string; - for(i = 0; i < tag.vblob.size; i++) - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &string[i]); - } - break; - default : - ; - } - if(func_tag_create != NULL) - func_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, type, &tag); - return buffer_pos; - } - - if(type >= VN_TAG_TYPE_COUNT) - { - void (* alias_tag_destroy)(void *user_data, VNodeID node_id, uint16 group_id, uint16 tag_id); - alias_tag_destroy = v_fs_get_alias_user_func(18); - if(alias_tag_destroy != NULL) - alias_tag_destroy(v_fs_get_alias_user_data(18), node_id, group_id, tag_id); - return buffer_pos; - } - if(func_tag_create != NULL) - func_tag_create(v_fs_get_user_data(18), node_id, group_id, tag_id, name, (VNTagType) type, tag); - - return buffer_pos; -} - -void verse_send_node_name_set(VNodeID node_id, const char *name) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 19); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_node_name_set(node_id = %u name = %s );\n", node_id, name); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 512); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_node_name_set(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_node_name_set)(void *user_data, VNodeID node_id, const char *name); - VNodeID node_id; - char name[512]; - - func_node_name_set = v_fs_get_user_func(19); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 512, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_node_name_set(node_id = %u name = %s ); callback = %p\n", node_id, name, v_fs_get_user_func(19)); -#endif - if(func_node_name_set != NULL) - func_node_name_set(v_fs_get_user_data(19), node_id, name); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_pack_t_node.c b/extern/verse/dist/v_gen_pack_t_node.c deleted file mode 100644 index 0cfbf8b7f21..00000000000 --- a/extern/verse/dist/v_gen_pack_t_node.c +++ /dev/null @@ -1,226 +0,0 @@ -/* -** This is automatically generated source code -- do not edit. -** Changes are affected either by editing the corresponding protocol -** definition file (v_cmd_def_X.c where X=node type), or by editing -** the code generator itself, in v_cmd_gen.c. -*/ - -#include <stdlib.h> -#include <stdio.h> - -#include "v_cmd_gen.h" -#if !defined(V_GENERATE_FUNC_MODE) -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_util.h" - -void verse_send_t_language_set(VNodeID node_id, const char *language) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 96); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_t_language_set(node_id = %u language = %s );\n", node_id, language); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], language, 512); - if(node_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 5); - else - v_cmd_buf_set_address_size(head, 5); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_t_language_set(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_t_language_set)(void *user_data, VNodeID node_id, const char *language); - VNodeID node_id; - char language[512]; - - func_t_language_set = v_fs_get_user_func(96); - if(buffer_length < 4) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], language, 512, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_t_language_set(node_id = %u language = %s ); callback = %p\n", node_id, language, v_fs_get_user_func(96)); -#endif - if(func_t_language_set != NULL) - func_t_language_set(v_fs_get_user_data(96), node_id, language); - - return buffer_pos; -} - -void verse_send_t_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 97); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_t_buffer_create(node_id = %u buffer_id = %u name = %s );\n", node_id, buffer_id, name); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_t_buffer_destroy(VNodeID node_id, VBufferID buffer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 97); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_t_buffer_destroy(node_id = %u buffer_id = %u );\n", node_id, buffer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_t_buffer_create(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_t_buffer_create)(void *user_data, VNodeID node_id, VBufferID buffer_id, const char *name); - VNodeID node_id; - VBufferID buffer_id; - char name[16]; - - func_t_buffer_create = v_fs_get_user_func(97); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos); -#if defined V_PRINT_RECEIVE_COMMANDS - if(name[0] == 0) - printf("receive: verse_send_t_buffer_destroy(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(97)); - else - printf("receive: verse_send_t_buffer_create(node_id = %u buffer_id = %u name = %s ); callback = %p\n", node_id, buffer_id, name, v_fs_get_user_func(97)); -#endif - if(name[0] == 0) - { - void (* alias_t_buffer_destroy)(void *user_data, VNodeID node_id, VBufferID buffer_id); - alias_t_buffer_destroy = v_fs_get_alias_user_func(97); - if(alias_t_buffer_destroy != NULL) - alias_t_buffer_destroy(v_fs_get_alias_user_data(97), node_id, buffer_id); - return buffer_pos; - } - if(func_t_buffer_create != NULL) - func_t_buffer_create(v_fs_get_user_data(97), node_id, buffer_id, name); - - return buffer_pos; -} - -void verse_send_t_buffer_subscribe(VNodeID node_id, VBufferID buffer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 98); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_t_buffer_subscribe(node_id = %u buffer_id = %u );\n", node_id, buffer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_t_buffer_unsubscribe(VNodeID node_id, VBufferID buffer_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 98); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_t_buffer_unsubscribe(node_id = %u buffer_id = %u );\n", node_id, buffer_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE); - if(node_id == (uint32) ~0u || buffer_id == (uint16) ~0u) - v_cmd_buf_set_unique_address_size(head, 7); - else - v_cmd_buf_set_address_size(head, 7); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_t_buffer_subscribe(const char *buf, size_t buffer_length) -{ - unsigned int buffer_pos = 0; - void (* func_t_buffer_subscribe)(void *user_data, VNodeID node_id, VBufferID buffer_id); - VNodeID node_id; - VBufferID buffer_id; - uint8 alias_bool; - - func_t_buffer_subscribe = v_fs_get_user_func(98); - if(buffer_length < 6) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id); - if(buffer_length < buffer_pos + 1) - return -1; - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool); -#if defined V_PRINT_RECEIVE_COMMANDS - if(!alias_bool) - printf("receive: verse_send_t_buffer_unsubscribe(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(98)); - else - printf("receive: verse_send_t_buffer_subscribe(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_user_func(98)); -#endif - if(!alias_bool) - { - void (* alias_t_buffer_unsubscribe)(void *user_data, VNodeID node_id, VBufferID buffer_id); - alias_t_buffer_unsubscribe = v_fs_get_alias_user_func(98); - if(alias_t_buffer_unsubscribe != NULL) - alias_t_buffer_unsubscribe(v_fs_get_alias_user_data(98), node_id, buffer_id); - return buffer_pos; - } - if(func_t_buffer_subscribe != NULL) - func_t_buffer_subscribe(v_fs_get_user_data(98), node_id, buffer_id); - - return buffer_pos; -} - -#endif - diff --git a/extern/verse/dist/v_gen_unpack_func.h b/extern/verse/dist/v_gen_unpack_func.h deleted file mode 100644 index 462777608c7..00000000000 --- a/extern/verse/dist/v_gen_unpack_func.h +++ /dev/null @@ -1,63 +0,0 @@ -extern unsigned int v_unpack_connect(const char *data, size_t length); -extern unsigned int v_unpack_connect_accept(const char *data, size_t length); -extern unsigned int v_unpack_connect_terminate(const char *data, size_t length); -extern unsigned int v_unpack_ping(const char *data, size_t length); -extern unsigned int v_unpack_packet_ack(const char *data, size_t length); -extern unsigned int v_unpack_packet_nak(const char *data, size_t length); -extern unsigned int v_unpack_node_index_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_node_create(const char *data, size_t length); -extern unsigned int v_unpack_node_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_tag_group_create(const char *data, size_t length); -extern unsigned int v_unpack_tag_group_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_tag_create(const char *data, size_t length); -extern unsigned int v_unpack_node_name_set(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_pos_real32(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_rot_real32(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_scale_real32(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_pos_real64(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_rot_real64(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_scale_real64(const char *data, size_t length); -extern unsigned int v_unpack_o_transform_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_o_light_set(const char *data, size_t length); -extern unsigned int v_unpack_o_link_set(const char *data, size_t length); -extern unsigned int v_unpack_o_method_group_create(const char *data, size_t length); -extern unsigned int v_unpack_o_method_group_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_o_method_create(const char *data, size_t length); -extern unsigned int v_unpack_o_method_call(const char *data, size_t length); -extern unsigned int v_unpack_o_anim_run(const char *data, size_t length); -extern unsigned int v_unpack_o_hide(const char *data, size_t length); -extern unsigned int v_unpack_g_layer_create(const char *data, size_t length); -extern unsigned int v_unpack_g_layer_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_g_vertex_set_xyz_real32(const char *data, size_t length); -extern unsigned int v_unpack_g_vertex_set_xyz_real64(const char *data, size_t length); -extern unsigned int v_unpack_g_vertex_set_uint32(const char *data, size_t length); -extern unsigned int v_unpack_g_vertex_set_real64(const char *data, size_t length); -extern unsigned int v_unpack_g_vertex_set_real32(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_corner_uint32(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_corner_real64(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_corner_real32(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_face_uint8(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_face_uint32(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_face_real64(const char *data, size_t length); -extern unsigned int v_unpack_g_polygon_set_face_real32(const char *data, size_t length); -extern unsigned int v_unpack_g_crease_set_vertex(const char *data, size_t length); -extern unsigned int v_unpack_g_crease_set_edge(const char *data, size_t length); -extern unsigned int v_unpack_g_bone_create(const char *data, size_t length); -extern unsigned int v_unpack_m_fragment_create(const char *data, size_t length); -extern unsigned int v_unpack_b_dimensions_set(const char *data, size_t length); -extern unsigned int v_unpack_b_layer_create(const char *data, size_t length); -extern unsigned int v_unpack_b_layer_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_b_tile_set(const char *data, size_t length); -extern unsigned int v_unpack_t_language_set(const char *data, size_t length); -extern unsigned int v_unpack_t_buffer_create(const char *data, size_t length); -extern unsigned int v_unpack_t_buffer_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_t_text_set(const char *data, size_t length); -extern unsigned int v_unpack_c_curve_create(const char *data, size_t length); -extern unsigned int v_unpack_c_curve_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_c_key_set(const char *data, size_t length); -extern unsigned int v_unpack_a_buffer_create(const char *data, size_t length); -extern unsigned int v_unpack_a_buffer_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_a_block_set(const char *data, size_t length); -extern unsigned int v_unpack_a_stream_create(const char *data, size_t length); -extern unsigned int v_unpack_a_stream_subscribe(const char *data, size_t length); -extern unsigned int v_unpack_a_stream(const char *data, size_t length); diff --git a/extern/verse/dist/v_gen_unpack_funcs.h b/extern/verse/dist/v_gen_unpack_funcs.h deleted file mode 100644 index e69de29bb2d..00000000000 --- a/extern/verse/dist/v_gen_unpack_funcs.h +++ /dev/null diff --git a/extern/verse/dist/v_internal_verse.h b/extern/verse/dist/v_internal_verse.h deleted file mode 100644 index ce838351437..00000000000 --- a/extern/verse/dist/v_internal_verse.h +++ /dev/null @@ -1,2 +0,0 @@ -extern void verse_send_packet_ack(uint32 packet_id); -extern void verse_send_packet_nak(uint32 packet_id); diff --git a/extern/verse/dist/v_man_pack_node.c b/extern/verse/dist/v_man_pack_node.c deleted file mode 100644 index cc85c4383df..00000000000 --- a/extern/verse/dist/v_man_pack_node.c +++ /dev/null @@ -1,498 +0,0 @@ -/* -** -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "v_cmd_buf.h" -#include "v_network_out_que.h" -#include "v_network.h" -#include "v_connection.h" -#include "v_encryption.h" - -unsigned int v_unpack_connect(const char *buf, unsigned int buffer_length) -{ - return -1; /* this command is illegal to send */ -} - -unsigned int v_unpack_connect_accept(const char *buf, unsigned int buffer_length) -{ - return -1; /* this command is illegal to send */ -} - -extern void v_callback_connect_terminate(const char *bye); - -unsigned int v_unpack_connect_terminate(const char *buf, unsigned int buffer_length) -{ - unsigned int buffer_pos = 0; - char bye[512]; - - buffer_pos = vnp_raw_unpack_string(buf, bye, sizeof bye, buffer_length); - v_callback_connect_terminate(bye); - - return buffer_pos; -} - -static unsigned int pack_b_tile_set_head(VCMDBufHead *head, VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile) -{ - unsigned int buffer_pos = 0; - uint8 *buf; - buf = ((VCMDBuffer30 *)head)->buf; - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 83); /* Pack the command. */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_b_tile_set(node_id = %u layer_id = %u tile_x = %u tile_y = %u z = %u type = %u tile = %p );\n", node_id, layer_id, tile_x, tile_y, z, type, tile); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tile_x); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tile_y); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], z); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type); - return buffer_pos; - v_cmd_buf_set_address_size(head, 13); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_b_tile_set(VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - - switch(type) - { - case VN_B_LAYER_UINT1 : - head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */ - buf = ((VCMDBuffer30 *)head)->buf; - buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile); - buffer_pos += vnp_raw_pack_uint8_vector(&buf[buffer_pos], tile->vuint1, VN_B_TILE_SIZE * VN_B_TILE_SIZE / 8); - break; - case VN_B_LAYER_UINT8 : - head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */ - buf = ((VCMDBuffer80 *)head)->buf; - buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile); - buffer_pos += vnp_raw_pack_uint8_vector(&buf[buffer_pos], tile->vuint8, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - case VN_B_LAYER_UINT16 : - head = v_cmd_buf_allocate(VCMDBS_160);/* Allocating the buffer */ - buf = ((VCMDBuffer160 *)head)->buf; - buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile); - buffer_pos += vnp_raw_pack_uint16_vector(&buf[buffer_pos], tile->vuint16, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - case VN_B_LAYER_REAL32 : - head = v_cmd_buf_allocate(VCMDBS_320);/* Allocating the buffer */ - buf = ((VCMDBuffer320 *)head)->buf; - buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile); - buffer_pos += vnp_raw_pack_real32_vector(&buf[buffer_pos], tile->vreal32, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - case VN_B_LAYER_REAL64 : - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - buffer_pos += pack_b_tile_set_head(head, node_id, layer_id, tile_x, tile_y, z, type, tile); - buffer_pos += vnp_raw_pack_real64_vector(&buf[buffer_pos], tile->vreal64, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - default: - head = NULL; - } - v_cmd_buf_set_address_size(head, 13); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_b_tile_set(const char *buf, size_t buffer_length) -{ - uint8 enum_temp; - unsigned int buffer_pos = 0; - void (* func_b_tile_set)(void *user_data, VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile); - VNodeID node_id; - VLayerID layer_id; - uint16 tile_x; - uint16 tile_y; - uint16 z; - VNBLayerType type; - const VNBTile *tile; - - func_b_tile_set = v_fs_get_user_func(83); - if(buffer_length < 12) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tile_x); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &tile_y); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &z); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp); - type = (VNBLayerType)enum_temp; -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_b_tile_set(node_id = %u layer_id = %u tile_x = %u tile_y = %u z = %u type = %u ); callback = %p\n", node_id, layer_id, tile_x, tile_y, z, type, v_fs_get_user_func(83)); -#endif - { - VNBTile tile; - switch(type) - { - case VN_B_LAYER_UINT1 : - buffer_pos += vnp_raw_unpack_uint8_vector(&buf[buffer_pos], tile.vuint1, VN_B_TILE_SIZE * VN_B_TILE_SIZE / 8); - break; - case VN_B_LAYER_UINT8 : - buffer_pos += vnp_raw_unpack_uint8_vector(&buf[buffer_pos], tile.vuint8, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - case VN_B_LAYER_UINT16 : - buffer_pos += vnp_raw_unpack_uint16_vector(&buf[buffer_pos], tile.vuint16, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - case VN_B_LAYER_REAL32 : - buffer_pos += vnp_raw_unpack_real32_vector(&buf[buffer_pos], tile.vreal32, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - case VN_B_LAYER_REAL64 : - buffer_pos += vnp_raw_unpack_real64_vector(&buf[buffer_pos], tile.vreal64, VN_B_TILE_SIZE * VN_B_TILE_SIZE); - break; - } - if(func_b_tile_set != NULL && type <= VN_B_LAYER_REAL64) - func_b_tile_set(v_fs_get_user_data(83), node_id, layer_id, tile_x, tile_y, z, type, &tile); - return buffer_pos; - } - - if(func_b_tile_set != NULL) - func_b_tile_set(v_fs_get_user_data(83), node_id, layer_id, tile_x, tile_y, z, (VNBLayerType)type, tile); - - return buffer_pos; -} - -typedef struct VTempText VTempText; - -struct VTempText { - VNodeID node_id; - VBufferID buffer_id; - uint32 pos; - uint32 length; - uint16 index; - char *text; - VTempText *next; -}; - -typedef struct { - VTempText *text_temp; - uint16 text_send_id; - uint16 text_receive_id; -} VOrderedStorage; - -VOrderedStorage * v_create_ordered_storage(void) -{ - VOrderedStorage *s; - - s = malloc(sizeof *s); - s->text_temp = NULL; - s->text_send_id = 0; - s->text_receive_id = 0; - return s; -} - -void v_destroy_ordered_storage(VOrderedStorage *s) -{ - VTempText *line, *next; - - for(line = s->text_temp; line != NULL; line = next) - { - next = line->next; - if(line->text != NULL) - free(line->text); - free(line); - } - free(s); -} - -void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text) -{ - uint8 *buf; - VOrderedStorage *s; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 99);/* Packing the command */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_t_text_set(node_id = %u buffer_id = %u pos = %u length = %u text = %s );\n", node_id, buffer_id, pos, length, text); -#endif - s = v_con_get_ordered_storage(); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], pos); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], length); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], s->text_send_id++); - if(text == NULL) - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0); - else - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], text, VN_T_MAX_TEXT_CMD_SIZE); - v_cmd_buf_set_unique_address_size(head, buffer_pos); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -static void call_text_set(VTempText *line) -{ - const char *t; - void (* func_t_text_set)(void *user_data, VNodeID node_id, VBufferID buffer_id, uint32 pos, uint16 length, const char *text); - - func_t_text_set = v_fs_get_user_func(99); -#if defined V_PRINT_RECEIVE_COMMANDS - printf("receive: verse_send_t_text_set(node_id = %u buffer_id = %u pos = %u length = %u text = %s ); callback = %p\n", line->node_id, line->buffer_id, line->pos, line->length, line->text, v_fs_get_user_func(99)); -#endif - if(line->text == NULL) - t = ""; - else - t = line->text; - if(func_t_text_set != NULL) - func_t_text_set(v_fs_get_user_data(99), line->node_id, line->buffer_id, line->pos, line->length, t); -} - -unsigned int v_unpack_t_text_set(const char *buf, size_t buffer_length) -{ - unsigned int i, buffer_pos = 0; - VOrderedStorage *s; - VTempText l, *line, *past = NULL; - char text[1500]; - - if(buffer_length < 12) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &l.node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &l.buffer_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &l.pos); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &l.length); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &l.index); - buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], text, sizeof text, buffer_length - buffer_pos); - if(text[0] == 0) - l.text = NULL; - else - l.text = text; - s = v_con_get_ordered_storage(); - if(s->text_receive_id == l.index) - { - call_text_set(&l); - s->text_receive_id++; - line = s->text_temp; - while(line != NULL) - { - if(line->index == s->text_receive_id) - { - call_text_set(line); - if(past == NULL) - s->text_temp = line->next; - else - past->next = line->next; - if(line->text != NULL) - free(line->text); - past = NULL; - free(line); - line = s->text_temp; - s->text_receive_id++; - } - else - { - past = line; - line = line->next; - } - } - } - else - { - line = malloc(sizeof *line); - *line = l; - line->next = s->text_temp; - s->text_temp = line; - i = strlen(text); - if(i > 0) - { - line->text = malloc(i + 1); - strcpy(line->text, text); - } - else - line->text = NULL; - } - return buffer_pos; -} - -void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, - const real64 *pre_value, const uint32 *pre_pos, - const real64 *value, real64 pos, - const real64 *post_value, const uint32 *post_pos) -{ - uint8 *buf; - unsigned int i, buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - if(dimensions == 0 || dimensions > 4) - return; - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 130);/* Packing the command */ -#if defined V_PRINT_SEND_COMMANDS - switch(dimensions) - { - case 1: - printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = %f pre_pos = %u value = %f pos = %f, pre_value = %f pre_pos = %u ); callback = %p\n", node_id, curve_id, key_id, dimensions, pre_value[0], pre_pos[0], value[0], pos, pre_value[0], pre_pos[0], v_fs_get_user_func(130)); - break; - case 2: - printf("sende: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f} pre_pos = {%u, %u} value = {%f, %f} pos = %f, pre_value = {%f, %f} pre_pos = {%u, %u}); callback = %p\n", - node_id, curve_id, key_id, dimensions, - pre_value[0], pre_value[1], - pre_pos[0], pre_pos[1], - value[0], value[1], pos, - pre_value[0], pre_value[1], - pre_pos[0], pre_pos[1], v_fs_get_user_func(130)); - break; - case 3: - printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u} value = {%f, %f, %f} pos = %f, pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u}); callback = %p\n", - node_id, curve_id, key_id, dimensions, - pre_value[0], pre_value[1], pre_value[2], - pre_pos[0], pre_pos[1], pre_pos[2], - value[0], value[1], value[2], pos, - pre_value[0], pre_value[1], pre_value[2], - pre_pos[0], pre_pos[1], pre_pos[2], v_fs_get_user_func(130)); - - break; - case 4: - printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u} value = {%f, %f, %f, %f} pos = %f, pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u}); callback = %p\n", - node_id, curve_id, key_id, dimensions, - pre_value[0], pre_value[1], pre_value[2], pre_value[3], - pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], - value[0], value[1], value[2], value[3], pos, - pre_value[0], pre_value[1], pre_value[2], pre_value[3], - pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], v_fs_get_user_func(130)); - break; - } -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], key_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions); - - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pre_value[i]); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], pre_pos[i]); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], value[i]); - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], post_value[i]); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], post_pos[i]); - - if(key_id == (uint32) ~0u) - v_cmd_buf_set_unique_address_size(head, 11); - else - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, uint32 key_id) -{ - uint8 *buf; - unsigned int buffer_pos = 0; - VCMDBufHead *head; - head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */ - buf = ((VCMDBuffer10 *)head)->buf; - - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 130);/* Packing the command */ -#if defined V_PRINT_SEND_COMMANDS - printf("send: verse_send_c_key_destroy(node_id = %u curve_id = %u key_id = %u );\n", node_id, curve_id, key_id); -#endif - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id); - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id); - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], key_id); - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0); - v_cmd_buf_set_address_size(head, 11); - v_cmd_buf_set_size(head, buffer_pos); - v_noq_send_buf(v_con_get_network_queue(), head); -} - -unsigned int v_unpack_c_key_set(const char *buf, size_t buffer_length) -{ - unsigned int i, buffer_pos = 0; - VNodeID node_id; - VLayerID curve_id; - uint32 key_id; - uint8 dimensions; - real64 pre_value[4], value[4], pos, post_value[4]; - uint32 post_pos[4], pre_pos[4]; - - if(buffer_length < 11) - return -1; - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id); - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &curve_id); - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &key_id); - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &dimensions); - if(dimensions != 0 && dimensions < 5) - { - void (* func_c_key_set)(void *user_data, VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, real64 *pre_value, uint32 *pre_pos, real64 *value, real64 pos, real64 *post_value, uint32 *post_pos); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pre_value[i]); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &pre_pos[i]); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &value[i]); - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &pos); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &post_value[i]); - for(i = 0; i < dimensions; i++) - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &post_pos[i]); - #if defined V_PRINT_RECEIVE_COMMANDS - switch(dimensions) - { - case 1: - printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = %f pre_pos = %u value = %f pos = %f, pre_value = %f pre_pos = %u ); callback = %p\n", node_id, curve_id, key_id, dimensions, pre_value[0], pre_pos[0], value[0], pos, pre_value[0], pre_pos[0], v_fs_get_user_func(130)); - break; - case 2: - printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f} pre_pos = {%u, %u} value = {%f, %f} pos = %f, pre_value = {%f, %f} pre_pos = {%u, %u}); callback = %p\n", - node_id, curve_id, key_id, dimensions, - pre_value[0], pre_value[1], - pre_pos[0], pre_pos[1], - value[0], value[1], pos, - pre_value[0], pre_value[1], - pre_pos[0], pre_pos[1], v_fs_get_user_func(130)); - break; - case 3: - printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u} value = {%f, %f, %f} pos = %f, pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u}); callback = %p\n", - node_id, curve_id, key_id, dimensions, - pre_value[0], pre_value[1], pre_value[2], - pre_pos[0], pre_pos[1], pre_pos[2], - value[0], value[1], value[2], pos, - pre_value[0], pre_value[1], pre_value[2], - pre_pos[0], pre_pos[1], pre_pos[2], v_fs_get_user_func(130)); - - break; - case 4: - printf("receive: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u} value = {%f, %f, %f, %f} pos = %f, pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u}); callback = %p\n", - node_id, curve_id, key_id, dimensions, - pre_value[0], pre_value[1], pre_value[2], pre_value[3], - pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], - value[0], value[1], value[2], value[3], pos, - pre_value[0], pre_value[1], pre_value[2], pre_value[3], - pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], v_fs_get_user_func(130)); - break; - } - #endif - func_c_key_set = v_fs_get_user_func(130); - if(func_c_key_set != NULL) - func_c_key_set(v_fs_get_user_data(130), node_id, curve_id, key_id, dimensions, pre_value, pre_pos, value, pos, post_value, post_pos); - return buffer_pos; - }else - { - void (* alias_c_key_destroy)(void *user_data, VNodeID node_id, VLayerID curve_id, uint32 key_id); - alias_c_key_destroy = v_fs_get_alias_user_func(130); - printf("receive: verse_send_c_key_destroy(node_id = %u curve_id = %u key_id = %u); callback = %p\n", node_id, curve_id, key_id, alias_c_key_destroy); - if(alias_c_key_destroy != NULL) - alias_c_key_destroy(v_fs_get_alias_user_data(130), node_id, curve_id, key_id); - return buffer_pos; - } -} - -#endif diff --git a/extern/verse/dist/v_network.c b/extern/verse/dist/v_network.c deleted file mode 100644 index 408cc20e393..00000000000 --- a/extern/verse/dist/v_network.c +++ /dev/null @@ -1,274 +0,0 @@ -/* -** -*/ - -#if defined _WIN32 -#include <winsock.h> -typedef unsigned int uint; -typedef SOCKET VSocket; -#else -typedef int VSocket; -#include <fcntl.h> -#include <netdb.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/time.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/wait.h> -#include <signal.h> -#endif -#include <stdio.h> -#include <stdlib.h> - -typedef unsigned int uint32; -typedef int int32; -typedef unsigned short uint16; -typedef short int16; -typedef unsigned char uint8; -typedef char int8; -typedef unsigned char boolean; - -#include "v_cmd_gen.h" -#include "v_network.h" - -#if !defined socklen_t -#define socklen_t int -#endif - -#define TRUE 1 -#define FALSE 0 - -typedef struct{ - struct sockaddr_in address; - struct hostent *he; -} VNetworkConnection; - -#define VERSE_STD_CONNECT_TO_PORT 4950 - -static VSocket my_socket = -1; -static uint16 my_port = 0; - -void v_n_set_port(unsigned short port) -{ - my_port = port; -} - -VSocket v_n_socket_create(void) -{ - static boolean initialized = FALSE; - struct sockaddr_in address; - int buffer_size = 1 << 20; - - if(my_socket != -1) - return my_socket; -#if defined _WIN32 - if(!initialized) - { - WSADATA wsaData; - - if(WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) - { - fprintf(stderr, "WSAStartup failed.\n"); - exit(1); - } - - } -#endif - initialized = TRUE; - if((my_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) - return -1; -#if defined _WIN32 - { - unsigned long one = 1UL; - if(ioctlsocket(my_socket, FIONBIO, &one) != 0) - return -1; - } -#else - if(fcntl(my_socket, F_SETFL, O_NONBLOCK) != 0) - { - fprintf(stderr, "v_network: Couldn't make socket non-blocking\n"); - return -1; - } -#endif - address.sin_family = AF_INET; /* host byte order */ - address.sin_port = htons(my_port); /* short, network byte order */ - address.sin_addr.s_addr = INADDR_ANY; - if(bind(my_socket, (struct sockaddr *) &address, sizeof(struct sockaddr)) != 0) - { - fprintf(stderr, "v_network: Failed to bind(), code %d (%s)\n", errno, strerror(errno)); - exit(0); /* FIX ME */ - } - if(setsockopt(my_socket, SOL_SOCKET, SO_SNDBUF, (const char *) &buffer_size, sizeof buffer_size) != 0) - fprintf(stderr, "v_network: Couldn't set send buffer size of socket to %d\n", buffer_size); - if(setsockopt(my_socket, SOL_SOCKET, SO_RCVBUF, (const char *) &buffer_size, sizeof buffer_size) != 0) - fprintf(stderr, "v_network: Couldn't set receive buffer size of socket to %d\n", buffer_size); - return my_socket; -} - -void v_n_socket_destroy(void) -{ -#if defined _WIN32 - closesocket(my_socket); -#else - close(my_socket); -#endif - my_socket = -1; -} - -boolean v_n_set_network_address(VNetworkAddress *address, const char *host_name) -{ - struct hostent *he; - char *colon = NULL, *buf = NULL; - boolean ok = FALSE; - - v_n_socket_create(); - address->port = VERSE_STD_CONNECT_TO_PORT; - /* If a port number is included, as indicated by a colon, we need to work a bit more. */ - if((colon = strchr(host_name, ':')) != NULL) - { - size_t hl = strlen(host_name); - - if((buf = malloc(hl + 1)) != NULL) - { - unsigned int tp; - - strcpy(buf, host_name); - colon = buf + (colon - host_name); - *colon = '\0'; - host_name = buf; - if(sscanf(colon + 1, "%u", &tp) == 1) - { - address->port = (unsigned short) tp; - if(address->port != tp) /* Protect against overflow. */ - host_name = NULL; - } - else - host_name = NULL; /* Protect against parse error. */ - } - else - return FALSE; - } - if(host_name != NULL && (he = gethostbyname(host_name)) != NULL) - { - memcpy(&address->ip, he->h_addr_list[0], he->h_length); - address->ip = ntohl(address->ip); - ok = TRUE; - } - if(buf != NULL) - free(buf); - - return ok; -} - -int v_n_send_data(VNetworkAddress *address, const char *data, size_t length) -{ - struct sockaddr_in address_in; - VSocket sock; - int ret; - - if((sock = v_n_socket_create()) == -1 || length == 0) - return 0; - address_in.sin_family = AF_INET; /* host byte order */ - address_in.sin_port = htons(address->port); /* short, network byte order */ - address_in.sin_addr.s_addr = htonl(address->ip); - memset(&address_in.sin_zero, 0, sizeof address_in.sin_zero); - ret = sendto(sock, data, length, 0, (struct sockaddr *) &address_in, sizeof(struct sockaddr_in)); - if(ret < 0) - fprintf(stderr, "Socket sendto() of %u bytes failed, code %d (%s)\n", (unsigned int) length, errno, strerror(errno)); - return ret; -} - -#if !defined V_GENERATE_FUNC_MODE - -extern void *v_con_get_network_address_id(unsigned int id); -extern unsigned int v_con_get_network_address_count(); - -unsigned int v_n_wait_for_incoming(unsigned int microseconds) -{ - struct timeval tv; - fd_set fd_select; - unsigned int s1, f1, s2, f2; - - if(microseconds == 0) - return 0; - v_n_socket_create(); - tv.tv_sec = microseconds / 1000000; - tv.tv_usec = microseconds % 1000000; - FD_ZERO(&fd_select); - FD_SET(my_socket, &fd_select); - v_n_get_current_time(&s1, &f1); - select(1, &fd_select, NULL, NULL, &tv); - v_n_get_current_time(&s2, &f2); - return (unsigned int) (1000000 * (s2 - s1) + (1000000.0 / 0xffffffffu) * (long) (f2 - f1)); /* Must cast to (long) for f1 > f2 case! */ -} - -#endif - -int v_n_receive_data(VNetworkAddress *address, char *data, size_t length) -{ - struct sockaddr_in address_in; - socklen_t from_length = sizeof address_in; - size_t len; - - if(v_n_socket_create() == -1) - return 0; - memset(&address_in, 0, sizeof address_in); - address_in.sin_family = AF_INET; - address_in.sin_port = htons(my_port); - address_in.sin_addr.s_addr = INADDR_ANY; - len = recvfrom(v_n_socket_create(), data, length, 0, (struct sockaddr *) &address_in, &from_length); - if(len > 0) - { - address->ip = ntohl(address_in.sin_addr.s_addr); - address->port = ntohs(address_in.sin_port); - } - return len; -} - -#if defined _WIN32 - -void v_n_get_current_time(uint32 *seconds, uint32 *fractions) -{ - static LARGE_INTEGER frequency; - static boolean init = FALSE; - LARGE_INTEGER counter; - - if(!init) - { - init = TRUE; - QueryPerformanceFrequency(&frequency); - } - - QueryPerformanceCounter(&counter); - if(seconds != NULL) - *seconds = (uint32) (counter.QuadPart / frequency.QuadPart); - if(fractions != NULL) - *fractions = (uint32) ((0xffffffffUL * (counter.QuadPart % frequency.QuadPart)) / frequency.QuadPart); -} - -#else - -void v_n_get_current_time(uint32 *seconds, uint32 *fractions) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - if(seconds != NULL) - *seconds = tv.tv_sec; - if(fractions != NULL) - *fractions = tv.tv_usec * 1E-6 * (double) (uint32)~0; -} - -#endif - -void v_n_get_address_string(const VNetworkAddress *address, char *string) -{ - sprintf(string, "%u.%u.%u.%u:%u", address->ip >> 24, (address->ip >> 16) & 0xff, - (address->ip >> 8) & 0xff, address->ip & 0xff, address->port); -} diff --git a/extern/verse/dist/v_network.h b/extern/verse/dist/v_network.h deleted file mode 100644 index 52233cbe2bb..00000000000 --- a/extern/verse/dist/v_network.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -** -*/ - -#if !defined V_NETWORK_H -#define V_NETWORK_H - -#define VERSE_STD_CONNECT_PORT 4950 - -typedef struct{ - unsigned int ip; - unsigned short port; -}VNetworkAddress; - -extern void v_n_set_port(unsigned short port); -extern unsigned int v_n_wait_for_incoming(unsigned int microseconds); -extern boolean v_n_set_network_address(VNetworkAddress *address, const char *host_name); -extern int v_n_send_data(VNetworkAddress *address, const char *data, size_t length); -extern int v_n_receive_data(VNetworkAddress *address, char *data, size_t length); -extern void v_n_get_address_string(const VNetworkAddress *address, char *string); - -extern void v_n_get_current_time(unsigned int *seconds, unsigned int *fractions); - -#endif /* V_NETWORK_H */ diff --git a/extern/verse/dist/v_network_in_que.c b/extern/verse/dist/v_network_in_que.c deleted file mode 100644 index d99a4ad11ec..00000000000 --- a/extern/verse/dist/v_network_in_que.c +++ /dev/null @@ -1,140 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "verse_header.h" - -#include "v_cmd_buf.h" -#include "v_cmd_gen.h" -#include "v_connection.h" -#include "v_internal_verse.h" -#include "v_network.h" -#include "v_pack.h" - - -#if !defined(V_GENERATE_FUNC_MODE) - -#include "v_network_in_que.h" - -static VNetInPacked *v_niq_temp = NULL; - -void v_niq_clear(VNetInQueue *queue) -{ - queue->oldest = NULL; - queue->newest = NULL; - queue->packet_id = 2; - v_niq_timer_update(queue); -} - -/* Set queue's last-used timestamp to "now". */ -void v_niq_timer_update(VNetInQueue *queue) -{ - v_n_get_current_time(&queue->seconds, &queue->fractions); - queue->acc_seconds = queue->acc_fractions = 0; -} - -uint32 v_niq_time_out(VNetInQueue *queue) -{ - uint32 fractions, f; - - /* Magic code to disregard if the clock moves forward more than one second at a time. - * This should help keep Verse alive on e.g. a notebook that is suspended. - */ - v_n_get_current_time(NULL, &fractions); - if(fractions < queue->fractions) - f = 0xffffffffu - queue->fractions + fractions; - else - f = fractions - queue->fractions; -/* printf("now=%u last=%u -> f=%u\n", fractions, queue->fractions, f);*/ - if(queue->acc_fractions + f < queue->acc_fractions) - queue->acc_seconds += 1; - queue->acc_fractions += f; - queue->fractions = fractions; - -/* printf("queue at %p has seconds=%u, now=%u -> diff=%u\n", queue, queue->seconds, seconds, seconds - queue->seconds);*/ - return queue->acc_seconds; -} - -VNetInPacked * v_niq_get(VNetInQueue *queue, size_t *length) -{ - VNetInPacked *p; - - if(queue->oldest == NULL) - { - *length = 0; - return NULL; - } - /* pop oldest package */ - p = queue->oldest; - queue->oldest = p->newer; - if(queue->oldest == NULL) - queue->newest = NULL; - else - ((VNetInPacked *)queue->oldest)->older = NULL; - *length = p->size; - - return p; -} - -unsigned int v_niq_free(VNetInQueue *queue) -{ - unsigned int i; - size_t length; - - for(i = 0; v_niq_get(queue, &length) != NULL; i++) - ; - return i; -} - -void v_niq_release(VNetInQueue *queue, VNetInPacked *p) -{ - /* push on v_niq_temp for re-use */ - p->older = v_niq_temp; - v_niq_temp = p; -} - -char *v_niq_store(VNetInQueue *queue, size_t length, unsigned int packet_id) -{ - VNetInPacked *p; - - v_niq_timer_update(queue); - - if(packet_id < queue->packet_id) - return NULL; - - while(queue->packet_id != packet_id) - { - verse_send_packet_nak(queue->packet_id++); - if(queue->packet_id == 0) - queue->packet_id++; - } - queue->packet_id++; - if(queue->packet_id == 0) - queue->packet_id++; - verse_send_packet_ack(packet_id); - - if(v_niq_temp == NULL) - p = malloc(sizeof *p); - else - { - /* pop off v_niq_temp */ - p = v_niq_temp; - v_niq_temp = p->older; - } - /* push as newest */ - p->older = queue->newest; - p->newer = NULL; - - if(queue->newest == NULL) - queue->oldest = p; - else - ((VNetInPacked *)queue->newest)->newer = p; - queue->newest = p; - - p->size = length; - - return p->data; -} - -#endif diff --git a/extern/verse/dist/v_network_in_que.h b/extern/verse/dist/v_network_in_que.h deleted file mode 100644 index 9241fe18fe8..00000000000 --- a/extern/verse/dist/v_network_in_que.h +++ /dev/null @@ -1,24 +0,0 @@ - -typedef struct{ - void *oldest; - void *newest; - uint32 packet_id; - uint32 seconds, fractions; /* Current time. */ - uint32 acc_seconds, acc_fractions; /* Accumulated time. */ -}VNetInQueue; - -typedef struct{ - void *newer; - void *older; - char data[1500]; - size_t size; -}VNetInPacked; - -extern void v_niq_clear(VNetInQueue *queue); -extern void v_niq_timer_update(VNetInQueue *queue); - -extern VNetInPacked * v_niq_get(VNetInQueue *queue, size_t *length); -extern void v_niq_release(VNetInQueue *queue, VNetInPacked *p); -extern char * v_niq_store(VNetInQueue *queue, size_t length, unsigned int packet_id); -unsigned int v_niq_free(VNetInQueue *queue); -extern uint32 v_niq_time_out(VNetInQueue *queue); diff --git a/extern/verse/dist/v_network_out_que.c b/extern/verse/dist/v_network_out_que.c deleted file mode 100644 index 10126a59779..00000000000 --- a/extern/verse/dist/v_network_out_que.c +++ /dev/null @@ -1,396 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "verse_header.h" - -#include "v_cmd_buf.h" -#include "v_cmd_gen.h" -#include "v_connection.h" -#include "v_network.h" -#include "v_pack.h" -#include "v_encryption.h" -#include "v_network_out_que.h" -#include "v_util.h" - -#if !defined(V_GENERATE_FUNC_MODE) - -#define STD_QUE_SIZE 64 - -#define V_NOQ_OPTIMIZATION_SLOTS 2048 - -#define V_NOQ_WINDOW_SIZE 100000 -#define V_NOQ_MAX_SORTED_COMMANDS 5000 - -typedef struct{ - void *next; - char *data; - size_t size; -} NetPacked; - -struct VNetOutQueue{ - uint8 packet_buffer[V_NOQ_MAX_PACKET_SIZE]; - size_t packet_buffer_use; - NetPacked *packed; - NetPacked *last; - VCMDBufHead *unsent[V_NOQ_OPTIMIZATION_SLOTS]; - VCMDBufHead *history[V_NOQ_OPTIMIZATION_SLOTS]; - VCMDBufHead *ack_nak; - VCMDBufHead *unsorted; - VCMDBufHead *unsorted_end; - uint32 unsorted_count; /* debug only */ - uint32 unsent_comands; - size_t unsent_size; - size_t sent_size; - unsigned int packet_id; - unsigned int slot; - uint32 seconds; - uint32 fractions; -}; - -size_t verse_session_get_size(void) -{ - const VNetOutQueue *queue; - - queue = v_con_get_network_queue(); - return queue->unsent_size + queue->sent_size; -} - -VNetOutQueue * v_noq_create_network_queue(void) -{ - VNetOutQueue *queue; - unsigned int i; - - queue = malloc(sizeof *queue); - for(i = 0; i < V_NOQ_OPTIMIZATION_SLOTS; i++) - { - queue->unsent[i] = NULL; - queue->history[i] = NULL; - } - queue->unsent_comands = 0; - queue->unsent_size = 0; - queue->sent_size = 0; - queue->packet_id = 2; - queue->slot = 0; - queue->packed = NULL; - queue->last = NULL; - queue->ack_nak = NULL; - queue->unsorted = NULL; - queue->unsorted_end = NULL; - queue->unsorted_count = 0; - queue->packet_buffer_use = 0; - v_n_get_current_time(&queue->seconds, &queue->fractions); - return queue; -} - -unsigned int v_noq_get_next_out_packet_id(VNetOutQueue *queue) -{ - queue->packet_id++; - if(queue->packet_id == 0) - queue->packet_id++; - return queue->packet_id; -} - -void v_noq_destroy_network_queue(VNetOutQueue *queue) -{ - VCMDBufHead *buf, *b; - unsigned int i; - for(i = 0; i < V_NOQ_OPTIMIZATION_SLOTS; i++) - { - for(buf = queue->history[i]; buf != NULL; buf = b) - { - b = buf->next; - v_cmd_buf_free(buf); - } - for(buf = queue->unsent[i]; buf != NULL; buf = b) - { - b = buf->next; - v_cmd_buf_free(buf); - } - } - for(buf = queue->unsorted; buf != NULL; buf = b) - { - b = buf->next; - v_cmd_buf_free(buf); - } - free(queue); -} - - -void v_noq_sort_and_collapse_buf(VNetOutQueue *queue, VCMDBufHead *buf) -{ - VCMDBufHead *b, *last = NULL; - unsigned int slot; - - slot = buf->address_sum % V_NOQ_OPTIMIZATION_SLOTS; - queue->unsent_size += buf->size; - queue->unsent_comands++; - if(queue->unsent[slot] != NULL) - { - for(b = queue->unsent[slot]; !v_cmd_buf_compare(buf, b) && b->next != NULL; b = b->next) - last = b; - if(v_cmd_buf_compare(buf, b)) /* found a command to replace */ - { - queue->unsent_size -= b->size; - queue->unsent_comands--; - if(last != NULL) /* if its not the first */ - last->next = buf; - else - queue->unsent[slot] = buf; - buf->next = b->next; - v_cmd_buf_free(b); - }else /* inserting the command last in queue */ - { - buf->next = NULL; - b->next = buf; - } - }else /* inserting the first command */ - { - queue->unsent[slot] = buf; - buf->next = NULL; - } - if(queue->history[slot] != NULL) /* if there is a history clear it from any commnds with same address */ - { - last = NULL; - for(b = queue->history[slot]; b != NULL && !v_cmd_buf_compare(buf, b); b = b->next) - last = b; - if(b != NULL) /* found a command to replace */ - { - if(last == NULL) - queue->history[slot] = b->next; - else - last->next = b->next; - queue->sent_size -= b->size; - v_cmd_buf_free(b); - } - } -} - -void v_noq_send_buf(VNetOutQueue *queue, VCMDBufHead *buf) -{ - static int count = 0; -/* if(queue->unsent_comands > V_NOQ_MAX_SORTED_COMMANDS) - { - -*/ if(queue->unsorted == NULL) - { - queue->unsorted_end = buf; - queue->unsorted = buf; - }else - { - queue->unsorted_end->next = buf; - queue->unsorted_end = buf; - } - queue->unsorted_count++; -/* }else - v_noq_sort_and_colapse_buf(queue, buf); -*/ count = (count + 1) % 30; - if(count == 0) - { - v_con_network_listen(); - v_noq_send_queue(queue, v_con_get_network_address()); - } -} - -void v_noq_sort_unsorted(VNetOutQueue *queue) -{ - VCMDBufHead *buf; - - while(queue->unsent_comands < V_NOQ_MAX_SORTED_COMMANDS && queue->unsorted != NULL) - { - buf = queue->unsorted; - if(queue->unsorted == queue->unsorted_end) - { - queue->unsorted_end = NULL; - queue->unsorted = NULL; - }else - { - queue->unsorted = buf->next; - buf->next = NULL; - } - queue->unsorted_count--; - v_noq_sort_and_collapse_buf(queue, buf); - } -} - -boolean v_noq_send_queue(VNetOutQueue *queue, void *address) -{ - static unsigned int my_counter = 0; - VCMDBufHead *buf; - unsigned int size; - uint8 *data; - uint32 seconds, fractions; - double delta; - - data = queue->packet_buffer; - v_n_get_current_time(&seconds, &fractions); - delta = seconds - queue->seconds + (fractions - queue->fractions) / (double) 0xffffffff; - - if(queue->unsorted != NULL) - v_noq_sort_unsorted(queue); - - if(queue->unsent_size == 0 && delta < 1.0 && (queue->ack_nak == NULL || queue->ack_nak->next == NULL)) - return FALSE; - - if(delta > 3.0 && queue->unsent_size == 0 && queue->ack_nak == NULL && queue->packet_buffer_use != 0) - { -/* printf("A) re-sending last delta=%g\n", delta);*/ - v_n_send_data(address, data, queue->packet_buffer_use); - queue->seconds = seconds; - queue->fractions = fractions; - return TRUE; - } - - size = 4; - buf = queue->ack_nak; - while(buf != NULL && size + buf->size < V_NOQ_MAX_PACKET_SIZE) - { - vnp_raw_pack_uint32(data, queue->packet_id); - queue->ack_nak = buf->next; - buf->next = queue->history[queue->slot]; - queue->history[queue->slot] = buf; - buf->packet = queue->packet_id; - v_e_data_encrypt_command(data, size, ((VCMDBuffer1500 *)buf)->buf, buf->size, v_con_get_data_key()); - size += buf->size; - queue->sent_size += buf->size; - buf = queue->ack_nak; - } - if(queue->unsent_size == 0 || queue->sent_size >= V_NOQ_WINDOW_SIZE) - { - if(size > 5) - { -/* printf("ACK: sending actual size=%u id=%u\n", size, queue->packet_id);*/ - v_n_send_data(address, data, size); - queue->packet_buffer_use = size; - queue->seconds = seconds; - queue->fractions = fractions; - queue->packet_id++; - return TRUE; - } -/* printf("returning FALSE from send_queue()\n");*/ - return FALSE; - } -/* if(queue->sent_size < V_NOQ_WINDOW_SIZE && queue->unsent_size != 0)*/ - { - vnp_raw_pack_uint32(data, queue->packet_id); - while(queue->unsent_size != 0) - { - queue->slot = ((1 + queue->slot) % V_NOQ_OPTIMIZATION_SLOTS); - buf = queue->unsent[queue->slot]; - if(buf != NULL) - { - if(buf->size + size > V_NOQ_MAX_PACKET_SIZE) - break; - queue->unsent[queue->slot] = buf->next; - buf->next = queue->history[queue->slot]; - queue->history[queue->slot] = buf; - buf->packet = queue->packet_id; - - v_e_data_encrypt_command(data, size, ((VCMDBuffer1500 *)buf)->buf, buf->size, v_con_get_data_key()); - size += buf->size; - queue->unsent_comands--; - queue->unsent_size -= buf->size; - queue->sent_size += buf->size; - my_counter++; - } - } - v_n_send_data(address, data, size); - queue->packet_buffer_use = size; - queue->packet_id++; -/* size = vnp_raw_pack_uint32(data, queue->packet_id);*/ - queue->seconds = seconds; - queue->fractions = fractions; - } - return TRUE; -} - -void v_noq_send_ack_nak_buf(VNetOutQueue *queue, VCMDBufHead *buf) -{ - buf->next = queue->ack_nak; - queue->ack_nak = buf; -} - -void callback_send_packet_ack(void *user, uint32 packet_id) -{ - VNetOutQueue *queue; - VCMDBufHead *buf, *last; - unsigned int slot; - - queue = v_con_get_network_queue(); - for(slot = 0; slot < V_NOQ_OPTIMIZATION_SLOTS; slot++) - { - last = NULL; - for(buf = queue->history[slot]; buf != NULL && buf->packet != packet_id; buf = buf->next) - last = buf; - - if(buf != NULL) - { - if(last == NULL) - { - while(queue->history[slot] != NULL && queue->history[slot]->packet == packet_id) - { - queue->sent_size -= queue->history[slot]->size; - buf = queue->history[slot]->next; - v_cmd_buf_free(queue->history[slot]); - queue->history[slot] = buf; - } - }else - { - for(; buf != NULL && buf->packet == packet_id; buf = last->next) - { - queue->sent_size -= buf->size; - last->next = buf->next; - v_cmd_buf_free(buf); - } - } - } - } -} - -void callback_send_packet_nak(void *user, uint32 packet_id) -{ - VNetOutQueue *queue; - VCMDBufHead *buf, *last; - unsigned int slot; - - queue = v_con_get_network_queue(); - for(slot = 0; slot < V_NOQ_OPTIMIZATION_SLOTS; slot++) - { - last = NULL; - for(buf = queue->history[slot]; buf != NULL && buf->packet != packet_id; buf = buf->next) - last = buf; - if(buf != NULL) - { - if(last == NULL) - { - for(; queue->history[slot] != NULL && queue->history[slot]->packet == packet_id; queue->history[slot] = buf) - { - queue->unsent_comands++; - queue->unsent_size += queue->history[slot]->size; - queue->sent_size -= queue->history[slot]->size; - buf = queue->history[slot]->next; - queue->history[slot]->next = queue->unsent[slot]; - queue->unsent[slot] = queue->history[slot]; - } - }else - { - for(; last->next != NULL && ((VCMDBufHead *)last->next)->packet == packet_id;) - { - queue->unsent_comands++; - queue->unsent_size += ((VCMDBufHead *)last->next)->size; - queue->sent_size -= ((VCMDBufHead *)last->next)->size; - buf = last->next; - last->next = buf->next; - buf->next = queue->unsent[slot]; - queue->unsent[slot] = buf; - } - } - } - } -} - -#endif diff --git a/extern/verse/dist/v_network_out_que.h b/extern/verse/dist/v_network_out_que.h deleted file mode 100644 index 6746475e84f..00000000000 --- a/extern/verse/dist/v_network_out_que.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -** -*/ - -typedef struct VNetOutQueue VNetOutQueue; - -extern VNetOutQueue * v_noq_create_network_queue(void); -extern void v_noq_destroy_network_queue(VNetOutQueue *queue); -extern void v_noq_send_buf(VNetOutQueue *queue, VCMDBufHead *buf); -extern void v_noq_send_ack_nak_buf(VNetOutQueue *queue, VCMDBufHead *buf); - -extern void v_noq_send_ack(VNetOutQueue *queue, unsigned int id); -extern void v_noq_send_nak(VNetOutQueue *queue, unsigned int id); - -extern boolean v_noq_send_queue(VNetOutQueue *queue, void *address); - -extern unsigned int v_noq_get_next_out_packet_id(VNetOutQueue *queue); diff --git a/extern/verse/dist/v_pack.c b/extern/verse/dist/v_pack.c deleted file mode 100644 index f521360b11f..00000000000 --- a/extern/verse/dist/v_pack.c +++ /dev/null @@ -1,386 +0,0 @@ -/* -** v_pack.c -** -** These functions are used to pack and unpack various quantities to/from network -** packet buffers. They do not care about alignment, operating at byte level internally. -** The external byte-ordering used is big-endian (aka "network byte order") for all -** quantities larger than a single byte. -*/ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "v_pack.h" - -size_t vnp_raw_pack_uint8(void *buffer, uint8 data) -{ - *(uint8 *) buffer = data; - - return sizeof data; -} - -size_t vnp_raw_unpack_uint8(const void *buffer, uint8 *data) -{ - *data = *(uint8 *) buffer; - - return sizeof *data; -} - -size_t vnp_raw_pack_uint8_vector(void *buffer, const uint8 *data, unsigned int length) -{ - memcpy(buffer, data, length); - return length; -} - -size_t vnp_raw_unpack_uint8_vector(const void *buffer, uint8 *data, unsigned int length) -{ - memcpy(data, buffer, length); - return length; -} - -size_t vnp_raw_pack_uint16(void *buffer, uint16 data) -{ - *(uint8 *) buffer = (data & 0xFF00) >> 8; - *((uint8 *) buffer + 1) = data & 0xFF; - return sizeof data; -} - -size_t vnp_raw_unpack_uint16(const void *buffer, uint16 *data) -{ - register const uint8 *b = buffer; - register uint16 tmp; - - tmp = ((uint16) *b++) << 8; - tmp |= (uint16) *b; - *data = tmp; - return sizeof *data; -} - -size_t vnp_raw_pack_uint16_vector(void *buffer, const uint16 *data, unsigned int length) -{ - register uint8 *b = buffer; - unsigned int i; - for(i = 0; i < length; i++) - { - *b++ = (*data & 0xFF00) >> 8; - *b++ = *data & 0xFF; - data++; - } - return length * 2; -} - -size_t vnp_raw_unpack_uint16_vector(const void *buffer, uint16 *data, unsigned int length) -{ - register const uint8 *b = buffer; - uint16 *end; - - for(end = data + length; end != data; data++) - { - *data = ((uint16) *b++) << 8; - *data |= (uint16) *b++; - } - return length * 2; -} - -size_t vnp_raw_pack_uint24(void *buffer, uint32 data) -{ - register uint8 *p = buffer; - - data >>= 8; - *(p++) = (data >> 24) & 0xFF; - *(p++) = (data >> 16) & 0xFF; - *(p++) = (data >> 8) & 0xFF; - - return 3; -} - -size_t vnp_raw_unpack_uint24(const void *buffer, uint32 *data) -{ - register const uint8 *p = buffer; - register uint32 tmp = 0; - - tmp |= ((uint32) *p++) << 24; - tmp |= ((uint32) *p++) << 16; - tmp |= ((uint32) *p++) << 8; - tmp |= tmp >> 24; - - return 3; -} - -size_t vnp_raw_pack_uint24_vector(void *buffer, const uint32 *data, unsigned int length) -{ - register uint8 *b = buffer; - unsigned int i; - - for(i = 0; i < length; i++) - { - *b++ = (*data >> 24) & 0xFF; - *b++ = (*data >> 16) & 0xFF; - *b++ = (*data >> 8) & 0xFF; - data++; - } - return length * 3; -} - -size_t vnp_raw_unpack_uint24_vector(const void *buffer, uint32 *data, unsigned int length) -{ - register const uint8 *b = buffer; - register uint32 tmp; - uint32 *end; - for(end = data + length; end != data; data++) - { - tmp = ((uint32) *b++) << 24; - tmp |= ((uint32) *b++) << 16; - tmp |= ((uint32) *b++) << 8; - tmp |= tmp >> 24; - *data = tmp; - } - return length * 3; -} - -size_t vnp_raw_pack_uint32(void *buffer, uint32 data) -{ - register uint8 *b = buffer; - - *b++ = (data >> 24) & 0xFF; - *b++ = (data >> 16) & 0xFF; - *b++ = (data >> 8) & 0xFF; - *b++ = data & 0xFF; - - return sizeof data; -} - -size_t vnp_raw_unpack_uint32(const void *buffer, uint32 *data) -{ - register const uint8 *b = buffer; - - *data = ((uint32) *b++) << 24; - *data |= ((uint32) *b++) << 16; - *data |= ((uint32) *b++) << 8; - *data |= *b; - return sizeof *data; -} - -size_t vnp_raw_pack_uint32_vector(void *buffer, const uint32 *data, unsigned int length) -{ - register uint8 *b = buffer; - unsigned int i; - - for(i = 0; i < length; i++) - { - *b++ = (*data >> 24) & 0xFF; - *b++ = (*data >> 16) & 0xFF; - *b++ = (*data >> 8) & 0xFF; - *b++ = *data & 0xFF; - data++; - } - return length * 4; -} - -size_t vnp_raw_unpack_uint32_vector(const void *buffer, uint32 *data, unsigned int length) -{ - register const uint8 *b = buffer; - uint32 *end; - for(end = data + length; end != data; data++) - { - *data = ((uint32) *b++) << 24; - *data |= ((uint32) *b++) << 16; - *data |= ((uint32) *b++) << 8; - *data |= ((uint32) *b++); - } - return length * 4; -} - -size_t vnp_raw_pack_real32(void *buffer, real32 data) -{ - union { uint32 uint; real32 real; } punt; - punt.real = data; - return vnp_raw_pack_uint32(buffer, punt.uint); -} - -size_t vnp_raw_unpack_real32(const void *buffer, real32 *data) -{ - return vnp_raw_unpack_uint32(buffer, (uint32 *) data); -} - -size_t vnp_raw_pack_real32_vector(void *buffer, const real32 *data, unsigned int length) -{ - uint32 i; - for(i = 0; i < length; i++) - vnp_raw_pack_real32(&((uint8 *)buffer)[i * 4], data[i]); - return length * 4; -} - -size_t vnp_raw_unpack_real32_vector(const void *buffer, real32 *data, unsigned int length) -{ - uint32 i; - for(i = 0; i < length; i++) - vnp_raw_unpack_real32(&((uint8 *)buffer)[i * 4], &data[i]); - return length * 4; -} - -size_t vnp_raw_pack_real64(void *buffer, real64 data) -{ - union { uint32 uint[2]; real64 real; } punt; - uint32 size; - - punt.real = data; - size = vnp_raw_pack_uint32(buffer, punt.uint[0]); - buffer = (uint8 *) buffer + size; - size += vnp_raw_pack_uint32(buffer, punt.uint[1]); - return size; -} - -size_t vnp_raw_unpack_real64(const void *buffer, real64 *data) -{ - union { uint32 uint[2]; real64 real; } punt; - uint32 size; - - size = vnp_raw_unpack_uint32(buffer, &punt.uint[0]); - size += vnp_raw_unpack_uint32(((uint8 *)buffer) + size, &punt.uint[1]); - *data = punt.real; - return size; -} - -size_t vnp_raw_pack_real64_vector(void *buffer, const real64 *data, unsigned int length) -{ - uint32 i; - for(i = 0; i < length; i++) - vnp_raw_pack_real64(&((uint8 *)buffer)[i * 8], data[i]); - return length * 8; -} - -size_t vnp_raw_unpack_real64_vector(const void *buffer, real64 *data, unsigned int length) -{ - uint32 i; - for(i = 0; i < length; i++) - vnp_raw_unpack_real64(&((uint8 *)buffer)[i * 8], &data[i]); - return length * 8; -} - -size_t vnp_raw_pack_string(void *buffer, const char *string, size_t max_size) -{ - unsigned int i = 0; - char *p = buffer; - if(string != 0) - for(; i < max_size && string[i] != 0; i++) - p[i] = string[i]; - p[i] = 0; - return ++i; -} - -size_t vnp_raw_unpack_string(const void *buffer, char *string, size_t max_size, size_t max_size2) -{ - unsigned int i; - const char *p = buffer; - - max_size--; - max_size2--; - for(i = 0; i < max_size && i < max_size2 && p[i] != 0; i++) - string[i] = p[i]; - string[i] = 0; - return ++i; -} - -/* --------------------------------------------------------------------------------------------------- */ - -size_t vnp_pack_quat32(void *buffer, const VNQuat32 *data) -{ - uint8 *out = buffer; - - if(data == NULL) - return 0; - out += vnp_raw_pack_real32(out, data->x); - out += vnp_raw_pack_real32(out, data->y); - out += vnp_raw_pack_real32(out, data->z); - out += vnp_raw_pack_real32(out, data->w); - - return out - (uint8 *) buffer; -} - -size_t vnp_unpack_quat32(const void *buffer, VNQuat32 *data) -{ - const uint8 *in = buffer; - - if(data == NULL) - return 0; - in += vnp_raw_unpack_real32(in, &data->x); - in += vnp_raw_unpack_real32(in, &data->y); - in += vnp_raw_unpack_real32(in, &data->z); - in += vnp_raw_unpack_real32(in, &data->w); - - return in - (uint8 *) buffer; -} - -size_t vnp_pack_quat64(void *buffer, const VNQuat64 *data) -{ - uint8 *out = buffer; - - if(data == NULL) - return 0; - out += vnp_raw_pack_real64(out, data->x); - out += vnp_raw_pack_real64(out, data->y); - out += vnp_raw_pack_real64(out, data->z); - out += vnp_raw_pack_real64(out, data->w); - - return out - (uint8 *) buffer; -} - -size_t vnp_unpack_quat64(const void *buffer, VNQuat64 *data) -{ - const uint8 *in = buffer; - - if(data == NULL) - return 0; - in += vnp_raw_unpack_real64(in, &data->x); - in += vnp_raw_unpack_real64(in, &data->y); - in += vnp_raw_unpack_real64(in, &data->z); - in += vnp_raw_unpack_real64(in, &data->w); - - return in - (uint8 *) buffer; -} - -size_t vnp_pack_audio_block(void *buffer, VNABlockType type, const VNABlock *block) -{ - if(block == NULL) - return 0; - switch(type) - { - case VN_A_BLOCK_INT8: - return vnp_raw_pack_uint8_vector(buffer, block->vint8, sizeof block->vint8 / sizeof *block->vint8); - case VN_A_BLOCK_INT16: - return vnp_raw_pack_uint16_vector(buffer, block->vint16, sizeof block->vint16 / sizeof *block->vint16); - case VN_A_BLOCK_INT24: - return vnp_raw_pack_uint24_vector(buffer, block->vint24, sizeof block->vint24 / sizeof *block->vint24); - case VN_A_BLOCK_INT32: - return vnp_raw_pack_uint32_vector(buffer, block->vint32, sizeof block->vint32 / sizeof *block->vint32); - case VN_A_BLOCK_REAL32: - return vnp_raw_pack_real32_vector(buffer, block->vreal32, sizeof block->vreal32 / sizeof *block->vreal32); - case VN_A_BLOCK_REAL64: - return vnp_raw_pack_real64_vector(buffer, block->vreal64, sizeof block->vreal64 / sizeof *block->vreal64); - } - return 0; -} - -size_t vnp_unpack_audio_block(const void *buffer, VNABlockType type, VNABlock *block) -{ - if(block == NULL) - return 0; - switch(type) - { - case VN_A_BLOCK_INT8: - return vnp_raw_unpack_uint8_vector(buffer, block->vint8, sizeof block->vint8 / sizeof *block->vint8); - case VN_A_BLOCK_INT16: - return vnp_raw_unpack_uint16_vector(buffer, block->vint16, sizeof block->vint16 / sizeof *block->vint16); - case VN_A_BLOCK_INT24: - return vnp_raw_unpack_uint24_vector(buffer, block->vint24, sizeof block->vint24 / sizeof *block->vint24); - case VN_A_BLOCK_INT32: - return vnp_raw_unpack_uint32_vector(buffer, block->vint32, sizeof block->vint32 / sizeof *block->vint32); - case VN_A_BLOCK_REAL32: - return vnp_raw_unpack_real32_vector(buffer, block->vreal32, sizeof block->vreal32 / sizeof *block->vreal32); - case VN_A_BLOCK_REAL64: - return vnp_raw_unpack_real64_vector(buffer, block->vreal64, sizeof block->vreal64 / sizeof *block->vreal64); - } - return 0; -} diff --git a/extern/verse/dist/v_pack.h b/extern/verse/dist/v_pack.h deleted file mode 100644 index 60cb7225642..00000000000 --- a/extern/verse/dist/v_pack.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -** v_pack.h -** -** These functions are used to pack and unpack various quantities to/from network -** packet buffers. They do not care about alignment, operating at byte level internally. -** The external byte-ordering used is big-endian (aka "network byte order") for all -** quantities larger than a single byte. -*/ - -#include "verse_header.h" - -extern size_t vnp_raw_pack_uint8(void *buffer, uint8 data); -extern size_t vnp_raw_unpack_uint8(const void *buffer, uint8 *data); - -extern size_t vnp_raw_pack_uint16(void *buffer, uint16 data); -extern size_t vnp_raw_unpack_uint16(const void *buffer, uint16 *data); - -extern size_t vnp_raw_pack_uint24(void *buffer, uint32 data); -extern size_t vnp_raw_unpack_uint24(const void *buffer, uint32 *data); - -extern size_t vnp_raw_pack_uint32(void *buffer, uint32 data); -extern size_t vnp_raw_unpack_uint32(const void *buffer, uint32 *data); - -extern size_t vnp_raw_pack_real32(void *buffer, real32 data); -extern size_t vnp_raw_unpack_real32(const void *buffer, real32 *data); - -extern size_t vnp_raw_pack_real64(void *buffer, real64 data); -extern size_t vnp_raw_unpack_real64(const void *buffer, real64 *data); - -extern size_t vnp_raw_pack_string(void *buffer, const char *string, size_t max_size); -extern size_t vnp_raw_unpack_string(const void *buffer, char *string, size_t max_size, size_t max_size2); - -extern size_t vnp_raw_pack_uint8_vector(void *buffer, const uint8 *data, unsigned int length); -extern size_t vnp_raw_unpack_uint8_vector(const void *buffer, uint8 *data, unsigned int length); - -extern size_t vnp_raw_pack_uint16_vector(void *buffer, const uint16 *data, unsigned int length); -extern size_t vnp_raw_unpack_uint16_vector(const void *buffer, uint16 *data, unsigned int length); - -extern size_t vnp_raw_pack_uint24_vector(void *buffer, const uint32 *data, unsigned int length); -extern size_t vnp_raw_unpack_uint24_vector(const void *buffer, uint32 *data, unsigned int length); - -extern size_t vnp_raw_pack_uint32_vector(void *buffer, const uint32 *data, unsigned int length); -extern size_t vnp_raw_unpack_uint32_vector(const void *buffer, uint32 *data, unsigned int length); - -extern size_t vnp_raw_pack_real32_vector(void *buffer, const real32 *data, unsigned int length); -extern size_t vnp_raw_unpack_real32_vector(const void *buffer, real32 *data, unsigned int length); - -extern size_t vnp_raw_pack_real64_vector(void *buffer, const real64 *data, unsigned int length); -extern size_t vnp_raw_unpack_real64_vector(const void *buffer, real64 *data, unsigned int length); - -/* --------------------------------------------------------------------------------------------------- */ - -extern size_t vnp_pack_quat32(void *buffer, const VNQuat32 *data); -extern size_t vnp_unpack_quat32(const void *buffer, VNQuat32 *data); -extern size_t vnp_pack_quat64(void *buffer, const VNQuat64 *data); -extern size_t vnp_unpack_quat64(const void *buffer, VNQuat64 *data); - -extern size_t vnp_pack_audio_block(void *buffer, VNABlockType type, const VNABlock *block); -extern size_t vnp_unpack_audio_block(const void *buffer, VNABlockType type, VNABlock *block); diff --git a/extern/verse/dist/v_pack_method.c b/extern/verse/dist/v_pack_method.c deleted file mode 100644 index c79ae92ba31..00000000000 --- a/extern/verse/dist/v_pack_method.c +++ /dev/null @@ -1,219 +0,0 @@ -/* -** -*/ - -#include <stdlib.h> - -#include "v_cmd_gen.h" - -#if !defined(V_GENERATE_FUNC_MODE) - -#include "verse.h" -#include "v_pack.h" - -VNOPackedParams * verse_method_call_pack(unsigned int param_count, const VNOParamType *param_type, const VNOParam *params) -{ - unsigned int i, j, buffer_pos; - uint8 *buf; - - buf = malloc(1500 + 8 * 16); - buffer_pos = vnp_raw_pack_uint16(buf, 0); - for(i = 0; i < param_count; i++) - { - switch(param_type[i]) - { - case VN_O_METHOD_PTYPE_INT8 : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], params[i].vint8); - break; - case VN_O_METHOD_PTYPE_INT16 : - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], params[i].vint16); - break; - case VN_O_METHOD_PTYPE_INT32 : - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], params[i].vint32); - break; - case VN_O_METHOD_PTYPE_UINT8 : - buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], params[i].vuint8); - break; - case VN_O_METHOD_PTYPE_UINT16 : - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], params[i].vuint16); - break; - case VN_O_METHOD_PTYPE_UINT32 : - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], params[i].vuint32); - break; - case VN_O_METHOD_PTYPE_REAL32 : - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32); - break; - case VN_O_METHOD_PTYPE_REAL64 : - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64); - break; - case VN_O_METHOD_PTYPE_STRING : - buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], params[i].vstring, (1500 + 8 * 16) - buffer_pos); - break; - case VN_O_METHOD_PTYPE_NODE : - buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], params[i].vnode); - break; - case VN_O_METHOD_PTYPE_LAYER : - buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], params[i].vlayer); - break; - case VN_O_METHOD_PTYPE_REAL32_VEC2 : - for(j = 0; j < 2; j++) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_VEC3 : - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_VEC4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_VEC2 : - for(j = 0; j < 2; j++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_VEC3 : - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_VEC4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_MAT4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_MAT9 : - for(j = 0; j < 9; j++) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_MAT16 : - for(j = 0; j < 16; j++) - buffer_pos += vnp_raw_pack_real32(&buf[buffer_pos], params[i].vreal32_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_MAT4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_MAT9 : - for(j = 0; j < 9; j++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_MAT16 : - for(j = 0; j < 16; j++) - buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], params[i].vreal64_mat[j]); - break; - } - if(buffer_pos > 1500) - { - free(buf); - return NULL; - } - } - vnp_raw_pack_uint16(buf, buffer_pos); - return buf; -} - -boolean verse_method_call_unpack(const VNOPackedParams *data, unsigned int param_count, const VNOParamType *param_type, VNOParam *params) -{ - unsigned int i, j, buffer_pos = 0, len; - uint16 size; - const uint8 *buf; - static char string[2048]; - char *stringput = string; - - buf = data; - buffer_pos += vnp_raw_unpack_uint16(buf, &size); - for(i = 0; i < param_count; i++) - { - switch(param_type[i]) - { - case VN_O_METHOD_PTYPE_INT8 : - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], ¶ms[i].vint8); - break; - case VN_O_METHOD_PTYPE_INT16 : - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], ¶ms[i].vint16); - break; - case VN_O_METHOD_PTYPE_INT32 : - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], ¶ms[i].vint32); - break; - case VN_O_METHOD_PTYPE_UINT8 : - buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], ¶ms[i].vuint8); - break; - case VN_O_METHOD_PTYPE_UINT16 : - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], ¶ms[i].vuint16); - break; - case VN_O_METHOD_PTYPE_UINT32 : - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], ¶ms[i].vuint32); - break; - case VN_O_METHOD_PTYPE_REAL32 : - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32); - break; - case VN_O_METHOD_PTYPE_REAL64 : - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64); - break; - case VN_O_METHOD_PTYPE_STRING : - params[i].vstring = stringput; - len = vnp_raw_unpack_string(&buf[buffer_pos], stringput, (1500 + 8 * 16) - buffer_pos, -1); - stringput += len; - buffer_pos += len; - break; - case VN_O_METHOD_PTYPE_NODE : - buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], ¶ms[i].vnode); - break; - case VN_O_METHOD_PTYPE_LAYER : - buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], ¶ms[i].vlayer); - break; - case VN_O_METHOD_PTYPE_REAL32_VEC2 : - for(j = 0; j < 2; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_VEC3 : - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_VEC4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_VEC2 : - for(j = 0; j < 2; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_VEC3 : - for(j = 0; j < 3; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_VEC4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64_vec[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_MAT4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_MAT9 : - for(j = 0; j < 9; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL32_MAT16 : - for(j = 0; j < 16; j++) - buffer_pos += vnp_raw_unpack_real32(&buf[buffer_pos], ¶ms[i].vreal32_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_MAT4 : - for(j = 0; j < 4; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_MAT9 : - for(j = 0; j < 9; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64_mat[j]); - break; - case VN_O_METHOD_PTYPE_REAL64_MAT16 : - for(j = 0; j < 16; j++) - buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], ¶ms[i].vreal64_mat[j]); - break; - } - } - return TRUE; -} -#endif diff --git a/extern/verse/dist/v_prime.c b/extern/verse/dist/v_prime.c deleted file mode 100644 index cebdf4fb03d..00000000000 --- a/extern/verse/dist/v_prime.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Program to generate primes of the form p = 2 * q + 1, - * where p and q are both primes. - * - * Originally written by Pontus Nyman <f97-pny@nada.kth.se>, - * ported to Verse's bignums and rewritten from scratch by - * Emil Brink. - */ - -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> - -#include "v_bignum.h" -#include "v_encryption.h" -#include "verse_header.h" - -#define BITS V_ENCRYPTION_LOGIN_KEY_BITS /* Save some typing. */ - -#define CYCLES 10 /* Number of times to apply Miller-Rabin test. */ - -/* Test divisibility of <n> against table of small known primes. Returns 1 if n looks prime, 0 if it IS not. */ -static int quick_filter(const VBigDig *n) -{ - VBigDig VBIGNUM(m, 16), VBIGNUM(tmp, BITS / 2); - const unsigned int prime[] = { 3, 5, 7, 11, 13, 17, 19, 23, 39, 31, 37, 41, 43, 47, 53 }; - unsigned int i; - - for(i = 0; i < sizeof prime / sizeof *prime; i++) - { - v_bignum_set_bignum(tmp, n); - v_bignum_set_digit(m, prime[i]); - v_bignum_mod(tmp, m); - if(v_bignum_eq_zero(tmp)) - return 0; - } - return 1; -} - -/* The Miller-Rabin primality test. Returns 1 if the candidate looks prime, 0 if - * it IS NOT prime. Assumes that n is BITS / 2 bits, so that its square fits in BITS. -*/ -static int miller_rabin(const VBigDig *n, VRandGen *gen) -{ - int i, k; - VBigDig VBIGNUM(a, BITS / 2), VBIGNUM(d, BITS), VBIGNUM(nmo, BITS / 2), VBIGNUM(x, BITS); - const VBigDig *mu; - - mu = v_bignum_reduce_begin(n); - - /* Pick a "witness", a number in the [1, n) range. */ - v_bignum_set_random(a, gen); - v_bignum_reduce(a, n, mu); - - v_bignum_set_one(d); - v_bignum_set_bignum(nmo, n); - v_bignum_sub_digit(nmo, 1); /* nmo = n - 1 (say it). */ - k = v_bignum_bit_msb(nmo); - for(i = k; i >= 0; i--) - { - v_bignum_set_bignum(x, d); - v_bignum_square_half(d); - v_bignum_reduce(d, n, mu); - if(v_bignum_eq_one(d) && !v_bignum_eq_one(x) && !v_bignum_eq(x, nmo)) - { - v_bignum_reduce_end(mu); - return 0; /* Composite found. */ - } - if(v_bignum_bit_test(nmo, i)) - { - v_bignum_mul(d, a); - v_bignum_reduce(d, n, mu); - } - } - v_bignum_reduce_end(mu); - return v_bignum_eq_one(d); /* It might be prime. */ -} - -/* Test q for primality, returning 1 if it seems prime, 0 if it certainly IS not. */ -int v_prime_test(const VBigDig *q, VRandGen *gen) -{ - int i; - - if(!quick_filter(q)) - return 0; - - for(i = 0; i < CYCLES; i++) - { - if(!miller_rabin(q, gen)) - return 0; - } - return 1; -} - -void v_prime_set_random(VBigDig *x) -{ - int bits = v_bignum_bit_size(x); - VRandGen *gen; - - gen = v_randgen_new(); - do - { - /* Create candidate, making sure it's both odd and non-zero. */ - v_bignum_set_random(x, gen); - /* Set topmost two bits, makes sure products are big. */ - v_bignum_bit_set(x, bits - 1); - v_bignum_bit_set(x, bits - 2); - /* Set lowermost bit, makes sure it is odd (better prime candidate that way). */ - v_bignum_bit_set(x, 0); - } while(!v_prime_test(x, gen)); -/* printf("Prime found after %d iterations: ", count); - v_bignum_print_hex_lf(x); -*/ - v_randgen_destroy(gen); -} - -/* Big (small?) primes from <http://www.utm.edu/research/primes/lists/small/small3.html#300>. */ -void v_prime_set_table(VBigDig *x, unsigned int i) -{ - if(i == 0) - v_bignum_set_string_hex(x, "0xCBC2C5536E3D6283FDAF36B1D0F91C3EAAB1D12892B961B866907930F6471851"); - else if(i == 1) - v_bignum_set_string_hex(x, "0xC14F93E7A1543BD57C1DFBE98C29F9E4C13077FD27A0FEC05CCBC913CD213F19"); - else - v_bignum_set_string(x, "65537"); /* It ain't big, but it's prime. */ -} - -#if PRIMEALONE -#include <sys/time.h> - -#define REPS 300 - -static double elapsed(const struct timeval *t1, const struct timeval *t2) -{ - return t2->tv_sec - t1->tv_sec + 1E-6 * (t2->tv_usec - t1->tv_usec); -} - -int main(void) -{ - struct timeval now, then; - VBigDig VBIGNUM(x, BITS / 2); - int i; - - srand(clock()); - -/* gettimeofday(&then, NULL); - for(i = 0; i < REPS; i++) - { - v_prime_set_random_incr(x); - } - gettimeofday(&now, NULL); - printf("incr: %g\n", elapsed(&then, &now)); -*/ - gettimeofday(&then, NULL); - for(i = 0; i < REPS; i++) - { - v_prime_set_random(x); - } - gettimeofday(&now, NULL); - printf("rand: %g\n", elapsed(&then, &now)); - - return EXIT_SUCCESS; -} - -#endif diff --git a/extern/verse/dist/v_randgen.c b/extern/verse/dist/v_randgen.c deleted file mode 100644 index c65b48be60b..00000000000 --- a/extern/verse/dist/v_randgen.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Random number generator module. Defines a simple API to allocate, use and - * destroy a generator of randomness. Relies on platform-specific APIs. -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "v_randgen.h" - -#if defined _WIN32 - -/* This is a fall-back to the old style of simply using rand(). It should - * be replaced by something using the proper Win32 cryptography APIs. - * The CryptAcquireContext() and CryptGenRandom() calls sound interesting. - * - * FIXME: Replace ASAP. -*/ - -VRandGen * v_randgen_new(void) -{ - return (VRandGen *) 1; /* Anything that isn't NULL. */ -} - -void v_randgen_get(VRandGen *gen, void *bytes, size_t num) -{ - if(gen != NULL && bytes != NULL) - { - unsigned char *put = bytes, *get; - size_t i; - int x; - - while(num > 0) - { - x = rand(); - get = (unsigned char *) &x; - for(i = 0; i < sizeof x && num > 0; i++, num--) - *put++ = *get++; - } - } -} - -void v_randgen_destroy(VRandGen *gen) -{ - /* Nothing to do here. */ -} - -#else - -/* On non-Win32 platforms (which is Linux and Darwin, at the moment), we - * read random data from a file, which is assumed to be one of the kernel's - * virtual files. -*/ - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - -struct VRandGen { - int fd; -}; - -#define SOURCE "/dev/urandom" /* Name of file to read random bits from. */ - -VRandGen * v_randgen_new(void) -{ - VRandGen *gen; - - if((gen = malloc(sizeof *gen)) != NULL) - { - gen->fd = open(SOURCE, O_RDONLY); - if(gen->fd < 0) - { - fprintf(stderr, __FILE__ ": Couldn't open " SOURCE " for reading\n"); - free(gen); - gen = NULL; - } - } - return gen; -} - -void v_randgen_get(VRandGen *gen, void *bytes, size_t num) -{ - if(gen != NULL && bytes != NULL) - { - if(read(gen->fd, bytes, num) != (int) num) - fprintf(stderr, __FILE__ ": Failed to read %u bytes of random data from " SOURCE "\n", (unsigned int) num); - } -} - -void v_randgen_destroy(VRandGen *gen) -{ - if(gen != NULL) - { - close(gen->fd); - free(gen); - } -} - -#endif diff --git a/extern/verse/dist/v_randgen.h b/extern/verse/dist/v_randgen.h deleted file mode 100644 index ee14ce6c36f..00000000000 --- a/extern/verse/dist/v_randgen.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Random number generator API. A way to improve over rand(). -*/ - -#if !defined V_RANDGEN_H -#define V_RANDGEN_H - -typedef struct VRandGen VRandGen; - -extern VRandGen * v_randgen_new(void); -extern void v_randgen_get(VRandGen *gen, void *bytes, size_t num); -extern void v_randgen_destroy(VRandGen *gen); - -#endif /* V_RANDGEN_H */ diff --git a/extern/verse/dist/v_util.c b/extern/verse/dist/v_util.c deleted file mode 100644 index a36f4c77791..00000000000 --- a/extern/verse/dist/v_util.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Utility functions. -*/ - -#include <stdio.h> - -#include "verse_header.h" -#include "v_network.h" -#include "v_util.h" - -/* Safe string copy. Copies from <src> to <dst>, not using more than <size> - * bytes of destination space. Always 0-terminates the destination. Returns - * the beginning of the destination string. -*/ -char * v_strlcpy(char *dst, const char *src, size_t size) -{ - char *base = dst; - - if(size == 0) - return NULL; - for(size--; size > 0 && *src != '\0'; size--) - *dst++ = *src++; - *dst = '\0'; - - return base; -} - -void v_timer_start(VUtilTimer *timer) -{ - v_n_get_current_time(&timer->seconds, &timer->fractions); -} - -void v_timer_advance(VUtilTimer *timer, double seconds) -{ - if(timer == NULL) - return; - timer->seconds += (uint32) seconds; - timer->fractions += (uint32) ((seconds - (int) seconds) * (double) 0xffffffff); -} - -double v_timer_elapsed(const VUtilTimer *timer) -{ - uint32 cur_seconds, cur_fractions; - - v_n_get_current_time(&cur_seconds, &cur_fractions); - return (double)(cur_seconds - timer->seconds) + ((double)cur_fractions - (double)timer->fractions) / (double) 0xffffffff; -} - -void v_timer_print(const VUtilTimer *timer) -{ - uint32 cur_seconds, cur_fractions; - - v_n_get_current_time(&cur_seconds, &cur_fractions); - printf("%f", (double)(cur_seconds - timer->seconds) + ((double)cur_fractions - (double)timer->fractions) / (double) 0xffffffff); -} - -/* Compare |x| against built-in semi-magical constant, and return 1 if it's larger, 0 if not. */ -static int quat_valid(real64 x) -{ - const real64 EPSILON = 0.0000001; - return x > 0.0 ? x > EPSILON : x < -EPSILON; -} - -int v_quat32_valid(const VNQuat32 *q) -{ - if(q == NULL) - return 0; - return quat_valid(q->x) && quat_valid(q->y) && quat_valid(q->z) && quat_valid(q->w); -} - -int v_quat64_valid(const VNQuat64 *q) -{ - if(q == NULL) - return 0; - return quat_valid(q->x) && quat_valid(q->y) && quat_valid(q->z) && quat_valid(q->w); -} - -VNQuat32 * v_quat32_from_quat64(VNQuat32 *dst, const VNQuat64 *src) -{ - if(dst == NULL || src == NULL) - return NULL; - dst->x = (real32) src->x; - dst->y = (real32) src->y; - dst->z = (real32) src->z; - dst->w = (real32) src->w; - return dst; -} - -VNQuat64 * v_quat64_from_quat32(VNQuat64 *dst, const VNQuat32 *src) -{ - if(dst == NULL || src == NULL) - return NULL; - dst->x = src->x; - dst->y = src->y; - dst->z = src->z; - dst->w = src->w; - return dst; -} diff --git a/extern/verse/dist/v_util.h b/extern/verse/dist/v_util.h deleted file mode 100644 index d252d958549..00000000000 --- a/extern/verse/dist/v_util.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Miscellaneous utility routines for generic use throughout the code. -*/ - -/* Safe, buffer size limited, string copy. */ -extern char * v_strlcpy(char *dst, const char *src, size_t size); - -typedef struct { - uint32 seconds; - uint32 fractions; -} VUtilTimer; - -extern void v_timer_start(VUtilTimer *timer); -extern void v_timer_advance(VUtilTimer *timer, double seconds); -extern double v_timer_elapsed(const VUtilTimer *timer); -extern void v_timer_print(const VUtilTimer *timer); - -extern int v_quat32_valid(const VNQuat32 *q); -extern int v_quat64_valid(const VNQuat64 *q); -extern VNQuat32*v_quat32_from_quat64(VNQuat32 *dst, const VNQuat64 *src); -extern VNQuat64*v_quat64_from_quat32(VNQuat64 *dst, const VNQuat32 *src); diff --git a/extern/verse/dist/verse.h b/extern/verse/dist/verse.h deleted file mode 100644 index 53ce674725a..00000000000 --- a/extern/verse/dist/verse.h +++ /dev/null @@ -1,530 +0,0 @@ -/* -** Verse API Header file (for use with libverse.a). -** This is automatically generated code; do not edit. -*/ - - -#if !defined VERSE_H - -#if defined __cplusplus /* Declare as C symbols for C++ users. */ -extern "C" { -#endif - -#define VERSE_H - -#if !defined VERSE_TYPES -#define VERSE_TYPES - -#include <stdlib.h> - -/* Release information. */ -#define V_RELEASE_NUMBER 6 -#define V_RELEASE_PATCH 1 -#define V_RELEASE_LABEL "" - -typedef unsigned char boolean; -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef float real32; -typedef double real64; - -#define V_REAL64_MAX 1.7976931348623158e+308 -#define V_REAL32_MAX 3.402823466e+38f - -#if !defined TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#define V_HOST_ID_SIZE (3 * (512 / 8)) /* The size of host IDs (keys), in 8-bit bytes. */ - -typedef enum { - V_NT_OBJECT = 0, - V_NT_GEOMETRY, - V_NT_MATERIAL, - V_NT_BITMAP, - V_NT_TEXT, - V_NT_CURVE, - V_NT_AUDIO, - V_NT_NUM_TYPES, - V_NT_SYSTEM = V_NT_NUM_TYPES, - V_NT_NUM_TYPES_NETPACK -} VNodeType; - -typedef uint32 VNodeID; -typedef uint16 VLayerID; /* Commonly used to identify layers, nodes that have them. */ -typedef uint16 VBufferID; /* Commonly used to identify buffers, nodes that have them. */ -typedef uint16 VNMFragmentID; - -typedef void * VSession; - -#define V_MAX_NAME_LENGTH_SHORT 16 -#define V_MAX_NAME_LENGTH_LONG 48 -#define V_MAX_NAME_PASS_LENGTH 128 - -typedef enum { - VN_OWNER_OTHER = 0, - VN_OWNER_MINE -} VNodeOwner; - -typedef enum { - VN_O_METHOD_PTYPE_INT8 = 0, - VN_O_METHOD_PTYPE_INT16, - VN_O_METHOD_PTYPE_INT32, - - VN_O_METHOD_PTYPE_UINT8, - VN_O_METHOD_PTYPE_UINT16, - VN_O_METHOD_PTYPE_UINT32, - - VN_O_METHOD_PTYPE_REAL32, - VN_O_METHOD_PTYPE_REAL64, - - VN_O_METHOD_PTYPE_REAL32_VEC2, - VN_O_METHOD_PTYPE_REAL32_VEC3, - VN_O_METHOD_PTYPE_REAL32_VEC4, - - VN_O_METHOD_PTYPE_REAL64_VEC2, - VN_O_METHOD_PTYPE_REAL64_VEC3, - VN_O_METHOD_PTYPE_REAL64_VEC4, - - VN_O_METHOD_PTYPE_REAL32_MAT4, - VN_O_METHOD_PTYPE_REAL32_MAT9, - VN_O_METHOD_PTYPE_REAL32_MAT16, - - VN_O_METHOD_PTYPE_REAL64_MAT4, - VN_O_METHOD_PTYPE_REAL64_MAT9, - VN_O_METHOD_PTYPE_REAL64_MAT16, - - VN_O_METHOD_PTYPE_STRING, - - VN_O_METHOD_PTYPE_NODE, - VN_O_METHOD_PTYPE_LAYER -} VNOParamType; - -typedef union { - int8 vint8; - int16 vint16; - int32 vint32; - uint8 vuint8; - uint16 vuint16; - uint32 vuint32; - real32 vreal32; - real64 vreal64; - real32 vreal32_vec[4]; - real32 vreal32_mat[16]; - real64 vreal64_vec[4]; - real64 vreal64_mat[16]; - char *vstring; - VNodeID vnode; - VLayerID vlayer; -} VNOParam; - -#define VN_TAG_MAX_BLOB_SIZE 500 - -typedef enum { - VN_TAG_BOOLEAN = 0, - VN_TAG_UINT32, - VN_TAG_REAL64, - VN_TAG_STRING, - VN_TAG_REAL64_VEC3, - VN_TAG_LINK, - VN_TAG_ANIMATION, - VN_TAG_BLOB, - VN_TAG_TYPE_COUNT -} VNTagType; - -typedef enum { - VN_TAG_GROUP_SIZE = 16, - VN_TAG_NAME_SIZE = 16, - VN_TAG_FULL_NAME_SIZE = 64, - VN_TAG_STRING_SIZE = 128 -} VNTagConstants; - -typedef union { - boolean vboolean; - uint32 vuint32; - real64 vreal64; - char *vstring; - real64 vreal64_vec3[3]; - VNodeID vlink; - struct { - VNodeID curve; - uint32 start; - uint32 end; - } vanimation; - struct { - uint16 size; - void *blob; - } vblob; -} VNTag; - -typedef enum { - VN_S_CONNECT_NAME_SIZE = 32, - VN_S_CONNECT_KEY_SIZE = 4, - VN_S_CONNECT_DATA_SIZE = 32, - VS_S_CONNECT_HOSTID_PRIVATE_SIZE = 3 * 2048 / 8, - VS_S_CONNECT_HOSTID_PUBLIC_SIZE = 2 * 2048 / 8 -} VNSConnectConstants; - -typedef enum { - VN_FORMAT_REAL32, - VN_FORMAT_REAL64 -} VNRealFormat; - -typedef struct { - real32 x, y, z, w; -} VNQuat32; - -typedef struct { - real64 x, y, z, w; -} VNQuat64; - -typedef enum { - VN_O_METHOD_GROUP_NAME_SIZE = 16, - VN_O_METHOD_NAME_SIZE = 16, - VN_O_METHOD_SIG_SIZE = 256 -} VNOMethodConstants; - -typedef void VNOPackedParams; /* Opaque type. */ - -typedef enum { - VN_G_LAYER_VERTEX_XYZ = 0, - VN_G_LAYER_VERTEX_UINT32, - VN_G_LAYER_VERTEX_REAL, - VN_G_LAYER_POLYGON_CORNER_UINT32 = 128, - VN_G_LAYER_POLYGON_CORNER_REAL, - VN_G_LAYER_POLYGON_FACE_UINT8, - VN_G_LAYER_POLYGON_FACE_UINT32, - VN_G_LAYER_POLYGON_FACE_REAL -} VNGLayerType; - -typedef enum { - VN_M_LIGHT_DIRECT = 0, - VN_M_LIGHT_AMBIENT, - VN_M_LIGHT_DIRECT_AND_AMBIENT, - VN_M_LIGHT_BACK_DIRECT, - VN_M_LIGHT_BACK_AMBIENT, - VN_M_LIGHT_BACK_DIRECT_AND_AMBIENT -} VNMLightType; - -typedef enum { - VN_M_NOISE_PERLIN_ZERO_TO_ONE = 0, - VN_M_NOISE_PERLIN_MINUS_ONE_TO_ONE, - VN_M_NOISE_POINT_ZERO_TO_ONE, - VN_M_NOISE_POINT_MINUS_ONE_TO_ONE -} VNMNoiseType; - -typedef enum { - VN_M_RAMP_SQUARE = 0, - VN_M_RAMP_LINEAR, - VN_M_RAMP_SMOOTH -} VNMRampType; - -typedef enum { - VN_M_RAMP_RED = 0, - VN_M_RAMP_GREEN, - VN_M_RAMP_BLUE -} VNMRampChannel; - -typedef struct { - real64 pos; - real64 red; - real64 green; - real64 blue; -} VNMRampPoint; - -typedef enum { - VN_M_BLEND_FADE = 0, - VN_M_BLEND_ADD, - VN_M_BLEND_SUBTRACT, - VN_M_BLEND_MULTIPLY, - VN_M_BLEND_DIVIDE, -} VNMBlendType; - -typedef enum { - VN_M_FT_COLOR = 0, - VN_M_FT_LIGHT, - VN_M_FT_REFLECTION, - VN_M_FT_TRANSPARENCY, - VN_M_FT_VOLUME, - VN_M_FT_VIEW, - VN_M_FT_GEOMETRY, - VN_M_FT_TEXTURE, - VN_M_FT_NOISE, - VN_M_FT_BLENDER, - VN_M_FT_CLAMP, - VN_M_FT_MATRIX, - VN_M_FT_RAMP, - VN_M_FT_ANIMATION, - VN_M_FT_ALTERNATIVE, - VN_M_FT_OUTPUT -} VNMFragmentType; - -typedef union { - struct { - real64 red; - real64 green; - real64 blue; - } color; - struct { - uint8 type; - real64 normal_falloff; - VNodeID brdf; - char brdf_r[16]; - char brdf_g[16]; - char brdf_b[16]; - } light; - struct { - real64 normal_falloff; - } reflection; - struct { - real64 normal_falloff; - real64 refraction_index; - } transparency; - struct { - real64 diffusion; - real64 col_r; - real64 col_g; - real64 col_b; - } volume; - struct { - char layer_r[16]; - char layer_g[16]; - char layer_b[16]; - } geometry; - struct{ - VNodeID bitmap; - char layer_r[16]; - char layer_g[16]; - char layer_b[16]; - boolean filtered; - VNMFragmentID mapping; - } texture; - struct { - uint8 type; - VNMFragmentID mapping; - } noise; - struct { - uint8 type; - VNMFragmentID data_a; - VNMFragmentID data_b; - VNMFragmentID control; - } blender; - struct { - boolean min; - real64 red; - real64 green; - real64 blue; - VNMFragmentID data; - } clamp; - struct { - real64 matrix[16]; - VNMFragmentID data; - } matrix; - struct { - uint8 type; - uint8 channel; - VNMFragmentID mapping; - uint8 point_count; - VNMRampPoint ramp[48]; - } ramp; - struct { - char label[16]; - } animation; - struct { - VNMFragmentID alt_a; - VNMFragmentID alt_b; - } alternative; - struct { - char label[16]; - VNMFragmentID front; - VNMFragmentID back; - } output; -} VMatFrag; - -typedef enum { - VN_B_LAYER_UINT1 = 0, - VN_B_LAYER_UINT8, - VN_B_LAYER_UINT16, - VN_B_LAYER_REAL32, - VN_B_LAYER_REAL64 -} VNBLayerType; - -#define VN_B_TILE_SIZE 8 - -typedef union{ - uint8 vuint1[8]; - uint8 vuint8[64]; - uint16 vuint16[64]; - real32 vreal32[64]; - real64 vreal64[64]; -} VNBTile; - -typedef enum { - VN_T_CONTENT_LANGUAGE_SIZE = 32, - VN_T_CONTENT_INFO_SIZE = 256, - VN_T_BUFFER_NAME_SIZE = 16, - VN_T_MAX_TEXT_CMD_SIZE = 1450 -} VNTConstants; - -/* This is how many *samples* are included in a block of the given type. Not bytes. */ -typedef enum { - VN_A_BLOCK_SIZE_INT8 = 1024, - VN_A_BLOCK_SIZE_INT16 = 512, - VN_A_BLOCK_SIZE_INT24 = 384, - VN_A_BLOCK_SIZE_INT32 = 256, - VN_A_BLOCK_SIZE_REAL32 = 256, - VN_A_BLOCK_SIZE_REAL64 = 128 -} VNAConstants; - -typedef enum { - VN_A_BLOCK_INT8, - VN_A_BLOCK_INT16, - VN_A_BLOCK_INT24, - VN_A_BLOCK_INT32, - VN_A_BLOCK_REAL32, - VN_A_BLOCK_REAL64 -} VNABlockType; - -/* Audio commands take pointers to blocks of these. They are not packed as unions. */ -typedef union { - int8 vint8[VN_A_BLOCK_SIZE_INT8]; - int16 vint16[VN_A_BLOCK_SIZE_INT16]; - int32 vint24[VN_A_BLOCK_SIZE_INT24]; - int32 vint32[VN_A_BLOCK_SIZE_INT32]; - real32 vreal32[VN_A_BLOCK_SIZE_REAL32]; - real64 vreal64[VN_A_BLOCK_SIZE_REAL64]; -} VNABlock; - -extern void verse_set_port(uint16 port); -extern void verse_host_id_create(uint8 *id); -extern void verse_host_id_set(uint8 *id); -extern void verse_callback_set(void *send_func, void *callback, void *user_data); -extern void verse_callback_update(uint32 microseconds); -extern void verse_session_set(VSession session); -extern VSession verse_session_get(void); -extern void verse_session_destroy(VSession session); -extern size_t verse_session_get_size(void); -extern VNodeID verse_session_get_avatar(void); -extern void verse_session_get_time(uint32 *seconds, uint32 *fractions); - -extern VNOPackedParams * verse_method_call_pack(uint32 param_count, const VNOParamType *param_type, const VNOParam *params); -extern boolean verse_method_call_unpack(const VNOPackedParams *data, uint32 param_count, const VNOParamType *param_type, VNOParam *params); - -/* -#define V_PRINT_SEND_COMMANDS -#define V_PRINT_RECEIVE_COMMANDS -*/ - -#endif /* VERSE_TYPES */ - -/* Command sending functions begin. ----------------------------------------- */ - -extern VSession verse_send_connect(const char *name, const char *pass, const char *address, const uint8 *expected_host_id); -extern VSession verse_send_connect_accept(VNodeID avatar, const char *address, uint8 *host_id); -extern void verse_send_connect_terminate(const char *address, const char *bye); -extern void verse_send_ping(const char *address, const char *message); -extern void verse_send_node_index_subscribe(uint32 mask); -extern void verse_send_node_create(VNodeID node_id, VNodeType type, VNodeOwner owner); -extern void verse_send_node_destroy(VNodeID node_id); -extern void verse_send_node_subscribe(VNodeID node_id); -extern void verse_send_node_unsubscribe(VNodeID node_id); -extern void verse_send_tag_group_create(VNodeID node_id, uint16 group_id, const char *name); -extern void verse_send_tag_group_destroy(VNodeID node_id, uint16 group_id); -extern void verse_send_tag_group_subscribe(VNodeID node_id, uint16 group_id); -extern void verse_send_tag_group_unsubscribe(VNodeID node_id, uint16 group_id); -extern void verse_send_tag_create(VNodeID node_id, uint16 group_id, uint16 tag_id, const char *name, VNTagType type, const VNTag *tag); -extern void verse_send_tag_destroy(VNodeID node_id, uint16 group_id, uint16 tag_id); -extern void verse_send_node_name_set(VNodeID node_id, const char *name); - -extern void verse_send_o_transform_pos_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const real32 *pos, const real32 *speed, const real32 *accelerate, const real32 *drag_normal, real32 drag); -extern void verse_send_o_transform_rot_real32(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag); -extern void verse_send_o_transform_scale_real32(VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z); -extern void verse_send_o_transform_pos_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag); -extern void verse_send_o_transform_rot_real64(VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag); -extern void verse_send_o_transform_scale_real64(VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z); -extern void verse_send_o_transform_subscribe(VNodeID node_id, VNRealFormat type); -extern void verse_send_o_transform_unsubscribe(VNodeID node_id, VNRealFormat type); -extern void verse_send_o_light_set(VNodeID node_id, real64 light_r, real64 light_g, real64 light_b); -extern void verse_send_o_link_set(VNodeID node_id, uint16 link_id, VNodeID link, const char *label, uint32 target_id); -extern void verse_send_o_link_destroy(VNodeID node_id, uint16 link_id); -extern void verse_send_o_method_group_create(VNodeID node_id, uint16 group_id, const char *name); -extern void verse_send_o_method_group_destroy(VNodeID node_id, uint16 group_id); -extern void verse_send_o_method_group_subscribe(VNodeID node_id, uint16 group_id); -extern void verse_send_o_method_group_unsubscribe(VNodeID node_id, uint16 group_id); -extern void verse_send_o_method_create(VNodeID node_id, uint16 group_id, uint16 method_id, const char *name, uint8 param_count, const VNOParamType *param_types, const char * *param_names); -extern void verse_send_o_method_destroy(VNodeID node_id, uint16 group_id, uint16 method_id); -extern void verse_send_o_method_call(VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, const VNOPackedParams *params); -extern void verse_send_o_anim_run(VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, const real64 *pos, const real64 *speed, const real64 *accel, const real64 *scale, const real64 *scale_speed); -extern void verse_send_o_hide(VNodeID node_id, uint8 hidden); - -extern void verse_send_g_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNGLayerType type, uint32 def_uint, real64 def_real); -extern void verse_send_g_layer_destroy(VNodeID node_id, VLayerID layer_id); -extern void verse_send_g_layer_subscribe(VNodeID node_id, VLayerID layer_id, VNRealFormat type); -extern void verse_send_g_layer_unsubscribe(VNodeID node_id, VLayerID layer_id); -extern void verse_send_g_vertex_set_xyz_real32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 x, real32 y, real32 z); -extern void verse_send_g_vertex_delete_real32(VNodeID node_id, uint32 vertex_id); -extern void verse_send_g_vertex_set_xyz_real64(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 x, real64 y, real64 z); -extern void verse_send_g_vertex_delete_real64(VNodeID node_id, uint32 vertex_id); -extern void verse_send_g_vertex_set_uint32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, uint32 value); -extern void verse_send_g_vertex_set_real64(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 value); -extern void verse_send_g_vertex_set_real32(VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real32 value); -extern void verse_send_g_polygon_set_corner_uint32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 v0, uint32 v1, uint32 v2, uint32 v3); -extern void verse_send_g_polygon_delete(VNodeID node_id, uint32 polygon_id); -extern void verse_send_g_polygon_set_corner_real64(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 v0, real64 v1, real64 v2, real64 v3); -extern void verse_send_g_polygon_set_corner_real32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 v0, real32 v1, real32 v2, real32 v3); -extern void verse_send_g_polygon_set_face_uint8(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint8 value); -extern void verse_send_g_polygon_set_face_uint32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 value); -extern void verse_send_g_polygon_set_face_real64(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 value); -extern void verse_send_g_polygon_set_face_real32(VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real32 value); -extern void verse_send_g_crease_set_vertex(VNodeID node_id, const char *layer, uint32 def_crease); -extern void verse_send_g_crease_set_edge(VNodeID node_id, const char *layer, uint32 def_crease); -extern void verse_send_g_bone_create(VNodeID node_id, uint16 bone_id, const char *weight, const char *reference, uint16 parent, real64 pos_x, real64 pos_y, real64 pos_z, const char *position_label, const char *rotation_label, const char *scale_label); -extern void verse_send_g_bone_destroy(VNodeID node_id, uint16 bone_id); - -extern void verse_send_m_fragment_create(VNodeID node_id, VNMFragmentID frag_id, VNMFragmentType type, const VMatFrag *fragment); -extern void verse_send_m_fragment_destroy(VNodeID node_id, VNMFragmentID frag_id); - -extern void verse_send_b_dimensions_set(VNodeID node_id, uint16 width, uint16 height, uint16 depth); -extern void verse_send_b_layer_create(VNodeID node_id, VLayerID layer_id, const char *name, VNBLayerType type); -extern void verse_send_b_layer_destroy(VNodeID node_id, VLayerID layer_id); -extern void verse_send_b_layer_subscribe(VNodeID node_id, VLayerID layer_id, uint8 level); -extern void verse_send_b_layer_unsubscribe(VNodeID node_id, VLayerID layer_id); -extern void verse_send_b_tile_set(VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile); - -extern void verse_send_t_language_set(VNodeID node_id, const char *language); -extern void verse_send_t_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name); -extern void verse_send_t_buffer_destroy(VNodeID node_id, VBufferID buffer_id); -extern void verse_send_t_buffer_subscribe(VNodeID node_id, VBufferID buffer_id); -extern void verse_send_t_buffer_unsubscribe(VNodeID node_id, VBufferID buffer_id); -extern void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text); - -extern void verse_send_c_curve_create(VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions); -extern void verse_send_c_curve_destroy(VNodeID node_id, VLayerID curve_id); -extern void verse_send_c_curve_subscribe(VNodeID node_id, VLayerID curve_id); -extern void verse_send_c_curve_unsubscribe(VNodeID node_id, VLayerID curve_id); -extern void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, const real64 *pre_value, const uint32 *pre_pos, const real64 *value, real64 pos, const real64 *post_value, const uint32 *post_pos); -extern void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, uint32 key_id); - -extern void verse_send_a_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency); -extern void verse_send_a_buffer_destroy(VNodeID node_id, VBufferID buffer_id); -extern void verse_send_a_buffer_subscribe(VNodeID node_id, VBufferID layer_id); -extern void verse_send_a_buffer_unsubscribe(VNodeID node_id, VBufferID layer_id); -extern void verse_send_a_block_set(VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples); -extern void verse_send_a_block_clear(VNodeID node_id, VLayerID buffer_id, uint32 block_index); -extern void verse_send_a_stream_create(VNodeID node_id, VLayerID stream_id, const char *name); -extern void verse_send_a_stream_destroy(VNodeID node_id, VLayerID stream_id); -extern void verse_send_a_stream_subscribe(VNodeID node_id, VLayerID stream_id); -extern void verse_send_a_stream_unsubscribe(VNodeID node_id, VLayerID stream_id); -extern void verse_send_a_stream(VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples); - - -#if defined __cplusplus -} -#endif - -#endif /* VERSE_H */ diff --git a/extern/verse/dist/verse_header.h b/extern/verse/dist/verse_header.h deleted file mode 100644 index 3f3403265fd..00000000000 --- a/extern/verse/dist/verse_header.h +++ /dev/null @@ -1,409 +0,0 @@ -#if !defined VERSE_TYPES -#define VERSE_TYPES - -#include <stdlib.h> - -/* Release information. */ -#define V_RELEASE_NUMBER 6 -#define V_RELEASE_PATCH 1 -#define V_RELEASE_LABEL "" - -typedef unsigned char boolean; -typedef signed char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef float real32; -typedef double real64; - -#define V_REAL64_MAX 1.7976931348623158e+308 -#define V_REAL32_MAX 3.402823466e+38f - -#if !defined TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#define V_HOST_ID_SIZE (3 * (512 / 8)) /* The size of host IDs (keys), in 8-bit bytes. */ - -typedef enum { - V_NT_OBJECT = 0, - V_NT_GEOMETRY, - V_NT_MATERIAL, - V_NT_BITMAP, - V_NT_TEXT, - V_NT_CURVE, - V_NT_AUDIO, - V_NT_NUM_TYPES, - V_NT_SYSTEM = V_NT_NUM_TYPES, - V_NT_NUM_TYPES_NETPACK -} VNodeType; - -typedef uint32 VNodeID; -typedef uint16 VLayerID; /* Commonly used to identify layers, nodes that have them. */ -typedef uint16 VBufferID; /* Commonly used to identify buffers, nodes that have them. */ -typedef uint16 VNMFragmentID; - -typedef void * VSession; - -#define V_MAX_NAME_LENGTH_SHORT 16 -#define V_MAX_NAME_LENGTH_LONG 48 -#define V_MAX_NAME_PASS_LENGTH 128 - -typedef enum { - VN_OWNER_OTHER = 0, - VN_OWNER_MINE -} VNodeOwner; - -typedef enum { - VN_O_METHOD_PTYPE_INT8 = 0, - VN_O_METHOD_PTYPE_INT16, - VN_O_METHOD_PTYPE_INT32, - - VN_O_METHOD_PTYPE_UINT8, - VN_O_METHOD_PTYPE_UINT16, - VN_O_METHOD_PTYPE_UINT32, - - VN_O_METHOD_PTYPE_REAL32, - VN_O_METHOD_PTYPE_REAL64, - - VN_O_METHOD_PTYPE_REAL32_VEC2, - VN_O_METHOD_PTYPE_REAL32_VEC3, - VN_O_METHOD_PTYPE_REAL32_VEC4, - - VN_O_METHOD_PTYPE_REAL64_VEC2, - VN_O_METHOD_PTYPE_REAL64_VEC3, - VN_O_METHOD_PTYPE_REAL64_VEC4, - - VN_O_METHOD_PTYPE_REAL32_MAT4, - VN_O_METHOD_PTYPE_REAL32_MAT9, - VN_O_METHOD_PTYPE_REAL32_MAT16, - - VN_O_METHOD_PTYPE_REAL64_MAT4, - VN_O_METHOD_PTYPE_REAL64_MAT9, - VN_O_METHOD_PTYPE_REAL64_MAT16, - - VN_O_METHOD_PTYPE_STRING, - - VN_O_METHOD_PTYPE_NODE, - VN_O_METHOD_PTYPE_LAYER -} VNOParamType; - -typedef union { - int8 vint8; - int16 vint16; - int32 vint32; - uint8 vuint8; - uint16 vuint16; - uint32 vuint32; - real32 vreal32; - real64 vreal64; - real32 vreal32_vec[4]; - real32 vreal32_mat[16]; - real64 vreal64_vec[4]; - real64 vreal64_mat[16]; - char *vstring; - VNodeID vnode; - VLayerID vlayer; -} VNOParam; - -#define VN_TAG_MAX_BLOB_SIZE 500 - -typedef enum { - VN_TAG_BOOLEAN = 0, - VN_TAG_UINT32, - VN_TAG_REAL64, - VN_TAG_STRING, - VN_TAG_REAL64_VEC3, - VN_TAG_LINK, - VN_TAG_ANIMATION, - VN_TAG_BLOB, - VN_TAG_TYPE_COUNT -} VNTagType; - -typedef enum { - VN_TAG_GROUP_SIZE = 16, - VN_TAG_NAME_SIZE = 16, - VN_TAG_FULL_NAME_SIZE = 64, - VN_TAG_STRING_SIZE = 128 -} VNTagConstants; - -typedef union { - boolean vboolean; - uint32 vuint32; - real64 vreal64; - char *vstring; - real64 vreal64_vec3[3]; - VNodeID vlink; - struct { - VNodeID curve; - uint32 start; - uint32 end; - } vanimation; - struct { - uint16 size; - void *blob; - } vblob; -} VNTag; - -typedef enum { - VN_S_CONNECT_NAME_SIZE = 32, - VN_S_CONNECT_KEY_SIZE = 4, - VN_S_CONNECT_DATA_SIZE = 32, - VS_S_CONNECT_HOSTID_PRIVATE_SIZE = 3 * 2048 / 8, - VS_S_CONNECT_HOSTID_PUBLIC_SIZE = 2 * 2048 / 8 -} VNSConnectConstants; - -typedef enum { - VN_FORMAT_REAL32, - VN_FORMAT_REAL64 -} VNRealFormat; - -typedef struct { - real32 x, y, z, w; -} VNQuat32; - -typedef struct { - real64 x, y, z, w; -} VNQuat64; - -typedef enum { - VN_O_METHOD_GROUP_NAME_SIZE = 16, - VN_O_METHOD_NAME_SIZE = 16, - VN_O_METHOD_SIG_SIZE = 256 -} VNOMethodConstants; - -typedef void VNOPackedParams; /* Opaque type. */ - -typedef enum { - VN_G_LAYER_VERTEX_XYZ = 0, - VN_G_LAYER_VERTEX_UINT32, - VN_G_LAYER_VERTEX_REAL, - VN_G_LAYER_POLYGON_CORNER_UINT32 = 128, - VN_G_LAYER_POLYGON_CORNER_REAL, - VN_G_LAYER_POLYGON_FACE_UINT8, - VN_G_LAYER_POLYGON_FACE_UINT32, - VN_G_LAYER_POLYGON_FACE_REAL -} VNGLayerType; - -typedef enum { - VN_M_LIGHT_DIRECT = 0, - VN_M_LIGHT_AMBIENT, - VN_M_LIGHT_DIRECT_AND_AMBIENT, - VN_M_LIGHT_BACK_DIRECT, - VN_M_LIGHT_BACK_AMBIENT, - VN_M_LIGHT_BACK_DIRECT_AND_AMBIENT -} VNMLightType; - -typedef enum { - VN_M_NOISE_PERLIN_ZERO_TO_ONE = 0, - VN_M_NOISE_PERLIN_MINUS_ONE_TO_ONE, - VN_M_NOISE_POINT_ZERO_TO_ONE, - VN_M_NOISE_POINT_MINUS_ONE_TO_ONE -} VNMNoiseType; - -typedef enum { - VN_M_RAMP_SQUARE = 0, - VN_M_RAMP_LINEAR, - VN_M_RAMP_SMOOTH -} VNMRampType; - -typedef enum { - VN_M_RAMP_RED = 0, - VN_M_RAMP_GREEN, - VN_M_RAMP_BLUE -} VNMRampChannel; - -typedef struct { - real64 pos; - real64 red; - real64 green; - real64 blue; -} VNMRampPoint; - -typedef enum { - VN_M_BLEND_FADE = 0, - VN_M_BLEND_ADD, - VN_M_BLEND_SUBTRACT, - VN_M_BLEND_MULTIPLY, - VN_M_BLEND_DIVIDE, -} VNMBlendType; - -typedef enum { - VN_M_FT_COLOR = 0, - VN_M_FT_LIGHT, - VN_M_FT_REFLECTION, - VN_M_FT_TRANSPARENCY, - VN_M_FT_VOLUME, - VN_M_FT_VIEW, - VN_M_FT_GEOMETRY, - VN_M_FT_TEXTURE, - VN_M_FT_NOISE, - VN_M_FT_BLENDER, - VN_M_FT_CLAMP, - VN_M_FT_MATRIX, - VN_M_FT_RAMP, - VN_M_FT_ANIMATION, - VN_M_FT_ALTERNATIVE, - VN_M_FT_OUTPUT -} VNMFragmentType; - -typedef union { - struct { - real64 red; - real64 green; - real64 blue; - } color; - struct { - uint8 type; - real64 normal_falloff; - VNodeID brdf; - char brdf_r[16]; - char brdf_g[16]; - char brdf_b[16]; - } light; - struct { - real64 normal_falloff; - } reflection; - struct { - real64 normal_falloff; - real64 refraction_index; - } transparency; - struct { - real64 diffusion; - real64 col_r; - real64 col_g; - real64 col_b; - } volume; - struct { - char layer_r[16]; - char layer_g[16]; - char layer_b[16]; - } geometry; - struct{ - VNodeID bitmap; - char layer_r[16]; - char layer_g[16]; - char layer_b[16]; - boolean filtered; - VNMFragmentID mapping; - } texture; - struct { - uint8 type; - VNMFragmentID mapping; - } noise; - struct { - uint8 type; - VNMFragmentID data_a; - VNMFragmentID data_b; - VNMFragmentID control; - } blender; - struct { - boolean min; - real64 red; - real64 green; - real64 blue; - VNMFragmentID data; - } clamp; - struct { - real64 matrix[16]; - VNMFragmentID data; - } matrix; - struct { - uint8 type; - uint8 channel; - VNMFragmentID mapping; - uint8 point_count; - VNMRampPoint ramp[48]; - } ramp; - struct { - char label[16]; - } animation; - struct { - VNMFragmentID alt_a; - VNMFragmentID alt_b; - } alternative; - struct { - char label[16]; - VNMFragmentID front; - VNMFragmentID back; - } output; -} VMatFrag; - -typedef enum { - VN_B_LAYER_UINT1 = 0, - VN_B_LAYER_UINT8, - VN_B_LAYER_UINT16, - VN_B_LAYER_REAL32, - VN_B_LAYER_REAL64 -} VNBLayerType; - -#define VN_B_TILE_SIZE 8 - -typedef union{ - uint8 vuint1[8]; - uint8 vuint8[64]; - uint16 vuint16[64]; - real32 vreal32[64]; - real64 vreal64[64]; -} VNBTile; - -typedef enum { - VN_T_CONTENT_LANGUAGE_SIZE = 32, - VN_T_CONTENT_INFO_SIZE = 256, - VN_T_BUFFER_NAME_SIZE = 16, - VN_T_MAX_TEXT_CMD_SIZE = 1450 -} VNTConstants; - -/* This is how many *samples* are included in a block of the given type. Not bytes. */ -typedef enum { - VN_A_BLOCK_SIZE_INT8 = 1024, - VN_A_BLOCK_SIZE_INT16 = 512, - VN_A_BLOCK_SIZE_INT24 = 384, - VN_A_BLOCK_SIZE_INT32 = 256, - VN_A_BLOCK_SIZE_REAL32 = 256, - VN_A_BLOCK_SIZE_REAL64 = 128 -} VNAConstants; - -typedef enum { - VN_A_BLOCK_INT8, - VN_A_BLOCK_INT16, - VN_A_BLOCK_INT24, - VN_A_BLOCK_INT32, - VN_A_BLOCK_REAL32, - VN_A_BLOCK_REAL64 -} VNABlockType; - -/* Audio commands take pointers to blocks of these. They are not packed as unions. */ -typedef union { - int8 vint8[VN_A_BLOCK_SIZE_INT8]; - int16 vint16[VN_A_BLOCK_SIZE_INT16]; - int32 vint24[VN_A_BLOCK_SIZE_INT24]; - int32 vint32[VN_A_BLOCK_SIZE_INT32]; - real32 vreal32[VN_A_BLOCK_SIZE_REAL32]; - real64 vreal64[VN_A_BLOCK_SIZE_REAL64]; -} VNABlock; - -extern void verse_set_port(uint16 port); -extern void verse_host_id_create(uint8 *id); -extern void verse_host_id_set(uint8 *id); -extern void verse_callback_set(void *send_func, void *callback, void *user_data); -extern void verse_callback_update(uint32 microseconds); -extern void verse_session_set(VSession session); -extern VSession verse_session_get(void); -extern void verse_session_destroy(VSession session); -extern size_t verse_session_get_size(void); -extern VNodeID verse_session_get_avatar(void); -extern void verse_session_get_time(uint32 *seconds, uint32 *fractions); - -extern VNOPackedParams * verse_method_call_pack(uint32 param_count, const VNOParamType *param_type, const VNOParam *params); -extern boolean verse_method_call_unpack(const VNOPackedParams *data, uint32 param_count, const VNOParamType *param_type, VNOParam *params); - -/* -#define V_PRINT_SEND_COMMANDS -#define V_PRINT_RECEIVE_COMMANDS -*/ - -#endif /* VERSE_TYPES */ diff --git a/extern/verse/dist/verse_ms.c b/extern/verse/dist/verse_ms.c deleted file mode 100644 index 84f3fdb837b..00000000000 --- a/extern/verse/dist/verse_ms.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * A helper library to send and parse master server pings. See the relevant - * header for details. - * - * This code was written in 2006 by Emil Brink. It is released as public domain. -*/ - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "verse.h" -#include "verse_ms.h" - -/* Build and send a MS:GET packet. */ -void verse_ms_get_send(const char *address, int fields, const char *tags) -{ - char req[128]; - - strcpy(req, "MS:GET IP="); - if(fields & VERSE_MS_FIELD_DESCRIPTION) - strcat(req, "DE"); - if(tags != NULL) - { - strcat(req, " TA="); - strcat(req, tags); - } - verse_send_ping(address, req); -} - -/* Skip assign, i.e. "NAME=" string, at <msg>. Stores name into <put>, and then updates - * it. Returns NULL on parse error, in which case the <put> pointer is not advanced. -*/ -static const char * skip_assign(char **put, const char *msg) -{ - if(isalpha(*msg)) - { - char *p = put != NULL ? *put : NULL; - - if(p != NULL) - *p++ = *msg; - msg++; - while(*msg && (isalnum(*msg) || *msg == '_')) - { - if(p != NULL) - *p++ = *msg; - msg++; - } - if(*msg == '=') - { - if(p != NULL) - *p++ = '\0'; - if(put != NULL) - *put = p; - return msg + 1; - } - } - return NULL; -} - -/** Skip value at <msg>, optionally storing de-quoted version through <put>, - * which is advanced. Returns NULL on parse error, without updating <put>. -*/ -static const char * skip_value(char **put, const char *msg) -{ - char *p = (put != NULL) ? *put : NULL; - - if(*msg == '"') - { - msg++; - while(*msg != '\0' && *msg != '"') - { - if(*msg == '\\') - { - if(msg[1] != '\0') - msg++; - else - return NULL; - } - if(p != NULL) - *p++ = *msg; - msg++; - } - if(*msg == '"') - { - if(p != NULL) - *p++ = '\0'; - if(put != NULL) - *put = p; - msg++; - if(*msg == '\0' || isspace(*msg)) - return msg; - } - return NULL; - } - while(*msg && !isspace(*msg)) - { - if(*msg == '"') - return NULL; - if(p != NULL) - *p++ = *msg; - msg++; - } - if(p != NULL) - *p++ = '\0'; - if(put != NULL) - *put = p; - return msg; -} - -static const char * put_field(VMSField *field, char **put, const char *src) -{ - const char *ptr; - char *base = *put; - - if((ptr = skip_assign(put, src)) != NULL && ptr - src > 1) - { - field->name = base; - src = ptr; - base = *put; - if((ptr = skip_value(put, src)) != NULL) - { - field->value = base; - return ptr; - } - } - return NULL; -} - -static int cmp_fields(const void *a, const void *b) -{ - return strcmp(((const VMSField *) a)->name, ((const VMSField *) b)->name); -} - -VMSServer ** verse_ms_list_parse(const char *msg) -{ - const char *word[384]; /* Takes quite a lot of stack space. */ - const char *ptr; - char *put; - size_t num_word = 0, i, j, num_ip = 0, num_field, space = 0; - VMSServer **desc, *next; - VMSField *field; - - if(strncmp(msg, "MS:LIST", 7) == 0) - msg += 7; - if(*msg != ' ') - return NULL; - - /* Step one: split the string into words, at whitespace. Split is aware - * of quoting rules for value assignment, this is crucial. This split is - * non-invasive, meaning each "word" will be a suffix. - */ - while(*msg) - { - while(isspace(*msg)) - msg++; - ptr = skip_assign(NULL, msg); - if(ptr != NULL) - { - space += ptr - msg; - word[num_word++] = msg; - msg = ptr; - ptr = skip_value(NULL, msg); - if(ptr == NULL) - { - fprintf(stderr, "Parse error\n"); - return NULL; - } - space += ptr - msg + 1; - msg = ptr; - } - else if(*msg != '\0') - { - fprintf(stderr, "Parse error\n"); - return NULL; - } - } - /* Now, count how many words begin with "IP=". */ - for(i = 0; i < num_word; i++) - { - if(strncmp(word[i], "IP=", 3) == 0) - num_ip++; - } -/* printf("found %u IPs, %u bytes\n", num_ip, space); - printf("%u IP and %u words -> %u fields total\n", num_ip, num_word, num_word - num_ip); -*/ num_field = num_word - num_ip; - /* Allocate the descriptions. */ -/* printf("allocating %u bytes\n", (num_ip + 1) * (sizeof *desc) + num_ip * sizeof **desc + num_field * sizeof (VMSField) + space); - printf(" %u for pointers, %u for structs, %u for fields, %u string\n", - (num_ip + 1) * (sizeof *desc), num_ip * sizeof **desc, num_field * sizeof (VMSField), space); -*/ desc = malloc((num_ip + 1) * (sizeof *desc) + num_ip * sizeof **desc + num_field * sizeof (VMSField) + space); - next = (VMSServer *) (desc + (num_ip + 1)); -/* printf("desc store at %u\n", (char *) next - (char *) desc);*/ - field = (VMSField *) (next + num_ip); -/* printf("field store at %u\n", (char *) field - (char *) desc);*/ - put = (char *) (field + num_field); -/* printf("string store at %u\n", put - (char *) desc);*/ - for(i = j = 0; i < num_word;) - { - if(strncmp(word[i], "IP=", 3) == 0) - { - desc[j] = next; - next->ip = put; - ptr = skip_value(&put, word[i] + 3); - next->num_fields = 0; - next->field = field; - for(i++; i < num_word && strncmp(word[i], "IP=", 3) != 0; i++, next->num_fields++, field++) - put_field(&next->field[next->num_fields], &put, word[i]); - if(next->num_fields > 0) /* Sort the fields, for binary search later. */ - qsort(next->field, next->num_fields, sizeof *next->field, cmp_fields); - j++; - next++; - } - else - i++; - } - desc[j] = NULL; - return desc; -} - -/* A binary search, exploiting that the fields are sorted. */ -static const VMSField * field_find(const VMSServer *ms, const char *name) -{ - int lo, hi, mid, rel; - - if(ms == NULL || name == NULL) - return NULL; - lo = 0; - hi = ms->num_fields; - while(lo <= hi) - { - mid = (lo + hi) / 2; - rel = strcmp(name, ms->field[mid].name); - if(rel == 0) - return &ms->field[mid]; - if(rel < 0) - hi = mid - 1; - else - lo = mid + 1; - } - return NULL; -} - -int verse_ms_field_exists(const VMSServer *ms, const char *name) -{ - if(ms == NULL || name == NULL) - return 0; - return field_find(ms, name) != NULL; -} - -const char * verse_ms_field_value(const VMSServer *ms, const char *name) -{ - const VMSField *f; - - if((f = field_find(ms, name)) != NULL) - return f->value; - return NULL; -} - -#if defined VERSE_MS_STANDALONE - -int main(void) -{ - VMSServer **servers = verse_ms_list_parse("MS:LIST IP=127.0.0.1:4951 DE=\"A test server, mainly for Eskil\" COOL=yes BACKUP=daily LANG=sv_SE " - "IP=130.237.221.74 DE=\"Test server on a puny laptop\" COOL=yes DORKY=no OPEN=absolutely " - "IP=127.0.0.1:5151 DE=\"This is a back slash: '\\\\', cool huh?\" " - "IP=127.0.0.1:6676 DE=\"a quote looks like this: \\\"\" IP=127.0.0.1:1122 "); - - if(servers != NULL) - { - int i, j; - - printf("Server info:\n"); - for(i = 0; servers[i] != NULL; i++) - { - printf("%u: IP=%s\n", i, servers[i]->ip); - for(j = 0; j < servers[i]->num_fields; j++) - printf(" %s='%s'\n", servers[i]->field[j].name, servers[i]->field[j].value); - } - free(servers); - } - return EXIT_SUCCESS; -} - -#endif /* VERSE_MS_STANDALONE */ diff --git a/extern/verse/dist/verse_ms.h b/extern/verse/dist/verse_ms.h deleted file mode 100644 index 5a27d3fd446..00000000000 --- a/extern/verse/dist/verse_ms.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This is Verse Master Server, a small help library to aid application developers - * make their applications interact with a Verse master server. - * - * There are two steps to the process: - * - * 1) Send a MS:GET request to a master server. This is done by the verse_ms_get_send() - * function, which calls verse_send_ping() internally. - * - * 2) Parse any returned MS:LIST packets. This is a two-step process. The application - * still owns the ping callback, and will need to check for received pings that - * start with MS:LIST, and call the verse_ms_list_parse() function to parse those. - * - * A successfully parsed MS:LIST packet will result in an array of VMSServer pointers - * being returned. Each VMSServer instance describes one server. Use the provided - * functions to query each server structure. - * - * The application should call free() on the returned vector, whenever it is done with - * the data (perhaps after copying it into application-defined data structures). - * - * For a lot more detail about the Verse master server protocol, please see - * the spec at <http://verse.blender.org/cms/Master_Server__v2.775.0.html>. - * - * This code was written in 2006 by Emil Brink. It is released as public domain. - * -*/ - -#define VERSE_MS_VERSION "1.0" - -#if defined __cplusplus -extern "C" { -#endif - -typedef struct { - const char *name; /* Field name. Upper-case. */ - const char *value; /* Field value. Fully parsed, might contain spaces. */ -} VMSField; - -typedef struct { - const char *ip; /* IP address of server, in dotted decimal:port. */ - unsigned int num_fields; /* Number of fields of extra info. */ - VMSField *field; /* Vector of fields, or NULL if none. */ -} VMSServer; - -/* Formats and sends a MS:GET ping packet to the master server. The <fields> argument - * should be a combination of VERSE_MS_FIELD_ mask values. If <tags> is set, it should - * be a comma-separated set of include/exclude tags, like "a,b,-c,d,-e". -*/ -#define VERSE_MS_FIELD_DESCRIPTION (1 << 0) -extern void verse_ms_get_send(const char *address, int fields, const char *tags); - -/* Parses a master server response. This will be a string of the form "MS:LIST IP=blah ...", - * which is split into one struct per IP, and any additional fields parsed (unquoted etc). - * Returns an array of VMSServer pointers, which is NULL-terminated. Returns NULL if there - * was a parse error somewhere in the string, no partial success is possible. -*/ -extern VMSServer ** verse_ms_list_parse(const char *list); - -/* This is the only standard field name, currently. */ -#define VERSE_MS_FIELD_DESCRIPTION_NAME "DE" /* Human-readable server description. */ - -/* Checks wether the given server has a field with the given name. */ -extern int verse_ms_field_exists(const VMSServer *ms, const char *name); - -/* Returns the value for the named field in the given server, if present. - * If not, NULL is returned. -*/ -extern const char * verse_ms_field_value(const VMSServer *ms, const char *name); - -#if defined __cplusplus -} -#endif diff --git a/extern/verse/dist/vs_connection.c b/extern/verse/dist/vs_connection.c deleted file mode 100644 index 06614a5dc66..00000000000 --- a/extern/verse/dist/vs_connection.c +++ /dev/null @@ -1,179 +0,0 @@ -#include <stdlib.h> - -#include "v_cmd_gen.h" - -#if !defined(V_GENERATE_FUNC_MODE) - -#include "verse.h" -#include "v_util.h" - -#define VS_CONNECTION_CHUNK_SIZE 64 - -typedef struct{ - VSession *session; - unsigned int session_count; -} VSSubscriptionList; - -typedef struct{ - VSession session; - uint32 node_id; - char name[128]; - char pass[128]; -} VSConnection; - -static struct { - VSConnection *connection; - unsigned int connection_length; - VSSubscriptionList **list; - unsigned int list_length; - unsigned int current_session; -} VSConnectionStorage; - -void vs_init_connection_storage(void) -{ - VSConnectionStorage.connection = NULL; - VSConnectionStorage.connection_length = 0; - VSConnectionStorage.list = NULL; - VSConnectionStorage.list_length = 0; - VSConnectionStorage.current_session = 0; -} - -void vs_add_new_connection(VSession session, const char *name, const char *pass, VNodeID node_id) -{ - VSConnection *conn; - - if(VSConnectionStorage.connection_length % VS_CONNECTION_CHUNK_SIZE == 0) - VSConnectionStorage.connection = realloc(VSConnectionStorage.connection, (sizeof *VSConnectionStorage.connection) * (VSConnectionStorage.connection_length + VS_CONNECTION_CHUNK_SIZE)); - conn = &VSConnectionStorage.connection[VSConnectionStorage.connection_length]; - - conn->session = session; - conn->node_id = node_id; - v_strlcpy(conn->name, name, sizeof conn->name); - v_strlcpy(conn->pass, pass, sizeof conn->pass); - - VSConnectionStorage.connection_length++; -} - -uint32 vs_get_avatar(void) -{ - return VSConnectionStorage.connection[VSConnectionStorage.current_session].node_id; -} - -VSession vs_get_session(void) -{ - return VSConnectionStorage.connection[VSConnectionStorage.current_session].session; -} - -const char * vs_get_user_name(void) -{ - return VSConnectionStorage.connection[VSConnectionStorage.current_session].name; -} - -const char * vs_get_user_pass(void) -{ - return VSConnectionStorage.connection[VSConnectionStorage.current_session].pass; -} - - -void vs_remove_connection(void) -{ - unsigned int i, j; - VSession *session; - VSSubscriptionList *list; - - session = VSConnectionStorage.connection[VSConnectionStorage.current_session].session; - for(i = 0; i < VSConnectionStorage.list_length; i++) - { - list = VSConnectionStorage.list[i]; - for(j = 0; j < list->session_count && list->session[j] != session; j++); - if(j < list->session_count) - list->session[j] = list->session[--list->session_count]; - } - j = --VSConnectionStorage.connection_length; - - if(VSConnectionStorage.current_session < j) - { - VSConnectionStorage.connection[VSConnectionStorage.current_session].session = VSConnectionStorage.connection[j].session; - VSConnectionStorage.connection[VSConnectionStorage.current_session].node_id = VSConnectionStorage.connection[j].node_id; - } - else - VSConnectionStorage.current_session = 0; -} - -void vs_set_next_session(void) -{ - if(++VSConnectionStorage.current_session >= VSConnectionStorage.connection_length) - VSConnectionStorage.current_session = 0; - if(VSConnectionStorage.connection_length != 0) - verse_session_set(VSConnectionStorage.connection[VSConnectionStorage.current_session].session); -} - -VSSubscriptionList *vs_create_subscription_list(void) -{ - VSSubscriptionList *list; - list = malloc(sizeof *list); - if(VSConnectionStorage.list_length % VS_CONNECTION_CHUNK_SIZE == 0) - VSConnectionStorage.list = realloc(VSConnectionStorage.list, (sizeof *VSConnectionStorage.list) * (VSConnectionStorage.list_length + VS_CONNECTION_CHUNK_SIZE)); - VSConnectionStorage.list[VSConnectionStorage.list_length] = list; - list->session = NULL; - list->session_count = 0; - VSConnectionStorage.list_length++; - return list; -} - -void vs_destroy_subscription_list(VSSubscriptionList *list) -{ - unsigned int i; - - if(list == NULL) - return; - if(list->session != NULL) - free(list->session); - for(i = 0; i < VSConnectionStorage.list_length && VSConnectionStorage.list[i] != list; i++) - ; - if(i < VSConnectionStorage.list_length) - VSConnectionStorage.list[i] = VSConnectionStorage.list[--VSConnectionStorage.list_length]; - free(list); -} - -/* Returns 1 if subscriber was added, 0 if not (typically meaning it was already on the list). */ -int vs_add_new_subscriptor(VSSubscriptionList *list) -{ - unsigned int i; - if(list->session_count % VS_CONNECTION_CHUNK_SIZE == 0) - list->session = realloc(list->session, (sizeof *list->session) * (list->session_count + VS_CONNECTION_CHUNK_SIZE)); - for(i = 0; i < list->session_count; i++) - if(list->session[i] == VSConnectionStorage.connection[VSConnectionStorage.current_session].session) - return 0; - list->session[list->session_count] = VSConnectionStorage.connection[VSConnectionStorage.current_session].session; - list->session_count++; - return 1; -} - - -void vs_remove_subscriptor(VSSubscriptionList *list) -{ - unsigned int i; - VSession *session; - session = VSConnectionStorage.connection[VSConnectionStorage.current_session].session; - for(i = 0; i < list->session_count && list->session[i] != session; i++); - if(i < list->session_count) - list->session[i] = list->session[--list->session_count]; -} - -size_t vs_get_subscript_count(const VSSubscriptionList *list) -{ - return list != NULL ? list->session_count : 0; -} - -void vs_set_subscript_session(VSSubscriptionList *list, unsigned int session) -{ - verse_session_set(list->session[session]); -} - -void vs_reset_subscript_session(void) -{ - verse_session_set(VSConnectionStorage.connection[VSConnectionStorage.current_session].session); -} - -#endif diff --git a/extern/verse/dist/vs_main.c b/extern/verse/dist/vs_main.c deleted file mode 100644 index 3b388eecc56..00000000000 --- a/extern/verse/dist/vs_main.c +++ /dev/null @@ -1,180 +0,0 @@ -/* -** A simple Verse server. -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "v_network.h" -#include "v_util.h" -#include "vs_server.h" - -extern VNodeID vs_node_create(VNodeID owner_id, unsigned int type); -extern void callback_send_node_destroy(void *user_data, VNodeID node_id); -extern void vs_reset_owner(VNodeID owner_id); - -static void callback_send_connect(void *user, const char *name, const char *pass, const char *address, const uint8 *host_id) -{ - VNodeID avatar; - VSession *session; - - printf("Connecting '%s'\n", name); - if(TRUE) - { - avatar = vs_node_create(~0, V_NT_OBJECT); - session = verse_send_connect_accept(avatar, address, NULL); - vs_add_new_connection(session, name, pass, avatar); -/* vs_avatar_init(avatar, name);*/ - } - else - { - verse_send_connect_terminate(address, "I'm sorry but you are not welcome here."); - } -} - -static void callback_send_connect_terminate(void *user, char *address, char *bye) -{ - printf("callback_send_connect_terminate\n"); - vs_reset_owner(vs_get_avatar()); - callback_send_node_destroy(NULL, vs_get_avatar()); - verse_session_destroy(vs_get_session()); - vs_remove_connection(); -} - -static void vs_load_host_id(const char *file_name) -{ - FILE *f; - uint8 id[V_HOST_ID_SIZE]; - size_t got; - - /* Attempt to read key from given filename. Fails silently. */ - if((f = fopen(file_name, "rb")) != NULL) - { - if((got = fread(id, 1, sizeof id, f)) > 0) - { - printf("Loaded %u-bit host ID key successfully\n", 8 * (got / 3)); - verse_host_id_set(id); - } - fclose(f); - if(got) - return; - } - /* If file didn't open, or reading failed, generate a new key and write it out. */ - verse_host_id_create(id); - verse_host_id_set(id); - if((f = fopen(file_name, "wb")) != NULL) - { - if(fwrite(id, sizeof id, 1, f) != 1) - fprintf(stderr, "Warning: Couldn't write host ID to \"%s\"\n", file_name); - fclose(f); - } - else - fprintf(stderr, "Warning: Couldn't open \"%s\" for host ID writing\n", file_name); -} - -static void cb_sigint_handler(int sig) -{ - if(sig == SIGINT) - { - printf("Verse server terminating\n"); - exit(EXIT_SUCCESS); - } -} - -static void callback_send_ping(void *user, const char *address, const char *message) -{ - if(strncmp(message, "DESCRIBE", 8) == 0 && message[8] == ' ') - vs_master_handle_describe(address, message + 9); -} - -static void usage(void) -{ - printf("Verse server usage:\n"); - printf(" -h\t\t\tShow this usage information.\n"); - printf(" -ms\t\t\tRegisters the server with a master server at the address\n"); - printf(" \t\t\tgiven with the -ms:ip= option. Off by default.\n"); - printf(" -ms:ip=IP[:PORT]\tSet master server to register with. Implies -ms.\n"); - printf(" \t\t\tThe default address is <%s>.\n", vs_master_get_address()); - printf(" -ms:de=DESC\t\tSet description, sent to master server.\n"); - printf(" -ms:ta=TAGS\t\tSet tags, sent to master server.\n"); - printf(" -port=PORT\t\tSet port to use for incoming connections.\n"); - printf(" -version\t\tPrint version information and exit.\n"); -} - -int main(int argc, char **argv) -{ - uint32 i, seconds, fractions, port = VERSE_STD_CONNECT_PORT; - - signal(SIGINT, cb_sigint_handler); - - vs_master_set_address("master.uni-verse.org"); /* The default master address. */ - vs_master_set_enabled(FALSE); /* Make sure master server support is disabled. */ - for(i = 1; i < (uint32) argc; i++) - { - if(strcmp(argv[i], "-h") == 0) - { - usage(); - return EXIT_SUCCESS; - } - else if(strcmp(argv[i], "-ms") == 0) - vs_master_set_enabled(TRUE); - else if(strncmp(argv[i], "-ms:ip=", 7) == 0) - { - vs_master_set_address(argv[i] + 7); - vs_master_set_enabled(TRUE); - } - else if(strncmp(argv[i], "-ms:de=", 7) == 0) - vs_master_set_desc(argv[i] + 7); - else if(strncmp(argv[i], "-ms:ta=", 7) == 0) - vs_master_set_tags(argv[i] + 7); - else if(strncmp(argv[i], "-port=", 6) == 0) - port = strtoul(argv[i] + 6, NULL, 0); - else if(strcmp(argv[i], "-version") == 0) - { - printf("r%up%u%s\n", V_RELEASE_NUMBER, V_RELEASE_PATCH, V_RELEASE_LABEL); - return EXIT_SUCCESS; - } - else - fprintf(stderr, "Ignoring unknown argument \"%s\", try -h for help\n", argv[i]); - } - - printf("Verse Server r%up%u%s by Eskil Steenberg <http://verse.blender.org/>\n", V_RELEASE_NUMBER, V_RELEASE_PATCH, V_RELEASE_LABEL); - verse_set_port(port); /* The Verse standard port. */ - printf(" Listening on port %d\n", port); - - /* Seed the random number generator. Still rather too weak for crypto, I guess. */ - v_n_get_current_time(&seconds, &fractions); - srand(seconds ^ fractions); - - vs_load_host_id("host_id.rsa"); - vs_init_node_storage(); - vs_o_callback_init(); - vs_g_callback_init(); - vs_m_callback_init(); - vs_b_callback_init(); - vs_t_callback_init(); - vs_c_callback_init(); - vs_a_callback_init(); - vs_h_callback_init(); - init_callback_node_storage(); - verse_callback_set(verse_send_ping, callback_send_ping, NULL); - verse_callback_set(verse_send_connect, callback_send_connect, NULL); - verse_callback_set(verse_send_connect_terminate, callback_send_connect_terminate, NULL); - - while(TRUE) - { - vs_set_next_session(); - verse_callback_update(1000000); - vs_master_update(); - } - return EXIT_SUCCESS; -} - -#endif /* V_GENERATE_FUNC_MODE */ diff --git a/extern/verse/dist/vs_master.c b/extern/verse/dist/vs_master.c deleted file mode 100644 index 4fa020d58b6..00000000000 --- a/extern/verse/dist/vs_master.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Master server communication code. -*/ - -#include <stdio.h> -#include <string.h> - -#include "verse.h" -#include "v_util.h" -#include "vs_server.h" - -#define MASTER_SERVER_PERIOD (60.0) /* Period between ANNOUNCE to master server, in seconds. */ - -static struct { - boolean enabled; - boolean started; - const char *master; - char desc[64]; - const char *tags; - VUtilTimer timer; -} server_info; - -#define LEFT(d) (sizeof server_info.desc - (d - server_info.desc) - 1) - -void vs_master_set_enabled(boolean enabled) -{ - server_info.enabled = enabled; -} - -const char * vs_master_get_address(void) -{ - return server_info.master; -} - -void vs_master_set_address(const char *address) -{ - server_info.master = address; -} - -void vs_master_set_desc(const char *desc) -{ - const char *src = desc; - char *dst = server_info.desc; - - for(; *src != '\0' && LEFT(dst) > 0;) - { - if(*src == '"') - { - if(LEFT(dst) < 2) - break; - *dst++ = '\\'; - } - else if(*src == '\\') - { - if(LEFT(dst) < 2) - break; - *dst++ = '\\'; - } - *dst++ = *src++; - } - *dst = '\0'; -} - -void vs_master_set_tags(const char *tags) -{ - server_info.tags = tags; /* This needs more protection, instead of relying on the master server. */ -} - -void vs_master_update(void) -{ - if(!server_info.enabled || server_info.master == NULL) - return; - - if(!server_info.started) - { - v_timer_start(&server_info.timer); - v_timer_advance(&server_info.timer, MASTER_SERVER_PERIOD); - server_info.started = TRUE; - return; - } - if(v_timer_elapsed(&server_info.timer) < MASTER_SERVER_PERIOD) - return; - verse_send_ping(server_info.master, "MS:ANNOUNCE"); - v_timer_start(&server_info.timer); -/* printf("MS:ANNOUNCE sent to %s\n", server_info.master);*/ -} - -/* Check if a description request, of the form "A,B,C,...,D" includes the given keyword. This needs to - * do more than just a simple strstr(), since the keyword may be a prefix. Shades of OpenGL extensions. -*/ -static int desc_has_keyword(const char *desc, const char *keyword) -{ - const char *ptr; - - if(desc == NULL || *desc == '\0') /* Quick-check for empty description. */ - return 0; - - if((ptr = strstr(desc, keyword)) != NULL) - { - size_t kl = strlen(keyword); - - return ptr[kl] == ',' || ptr[kl] == '\0'; - } - return 0; -} - -static int keyword_fits(size_t used, size_t max, const char *key, const char *value) -{ - size_t vsize = 0; - - if(key != NULL && value != NULL) - vsize += 1 + strlen(key) + 1 + 1 + strlen(value) + 1; - - return max - 1 - used >= vsize; -} - -static char * append_desc(char *buf, const char *key, const char *value) -{ - return buf + sprintf(buf, " %s=\"%s\"", key, value); -} - -void vs_master_handle_describe(const char *address, const char *message) -{ - char desc[1380] = "DESCRIPTION", *put = desc + 11; - - if(desc_has_keyword(message, "DE") && server_info.desc != NULL && keyword_fits(put - desc, sizeof desc, "DE", server_info.desc)) - put = append_desc(put, "DE", server_info.desc); - if(desc_has_keyword(message, "TA") && server_info.tags != NULL && keyword_fits(put - desc, sizeof desc, "TA", server_info.tags)) - put = append_desc(put, "TA", server_info.tags); - verse_send_ping(address, desc); -} diff --git a/extern/verse/dist/vs_node_audio.c b/extern/verse/dist/vs_node_audio.c deleted file mode 100644 index e69d3d9b3ec..00000000000 --- a/extern/verse/dist/vs_node_audio.c +++ /dev/null @@ -1,420 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -typedef struct { - void **data; - unsigned int length; - char name[16]; - VNABlockType type; - real64 frequency; - VSSubscriptionList *subscribers; -} VSNLayer; - -typedef struct { - char name[16]; - VSSubscriptionList *subscribers; -} VSNStream; - -typedef struct{ - VSNodeHead head; - VSNLayer *buffers; - unsigned int buffer_count; - VSNStream *streams; - unsigned int stream_count; -} VSNodeAudio; - -VSNodeAudio * vs_a_create_node(unsigned int owner) -{ - VSNodeAudio *node; - char name[48]; - unsigned int i; - - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_AUDIO); - sprintf(name, "Audio_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - node->buffer_count = 16; - node->buffers = malloc((sizeof *node->buffers) * node->buffer_count); - for(i = 0; i < node->buffer_count; i++) - node->buffers[i].name[0] = 0; - node->stream_count = 16; - node->streams = malloc((sizeof *node->streams) * node->stream_count); - for(i = 0; i < node->stream_count; i++) - node->streams[i].name[0] = 0; - - return node; -} - -void vs_a_destroy_node(VSNodeAudio *node) -{ - unsigned int i, j; - destroy_node_head(&node->head); - - for(i = 0; i < node->buffer_count; i++) - { - if(node->buffers[i].name[0] != 0) - { - for(j = 0; j < node->buffers[i].length; j++) - if(node->buffers[i].data[j] != NULL) - free(node->buffers[i].data[j]); - free(node->buffers[i].data); - } - } - free(node->buffers); - free(node->streams); - free(node); -} - -void vs_a_subscribe(VSNodeAudio *node) -{ - unsigned int i; - if(node == NULL) - return; - for(i = 0; i < node->buffer_count; i++) - if(node->buffers[i].name[0] != 0) - verse_send_a_buffer_create(node->head.id, i, node->buffers[i].name, node->buffers[i].type, - node->buffers[i].frequency); - for(i = 0; i < node->stream_count; i++) - if(node->streams[i].name[0] != 0) - verse_send_a_stream_create(node->head.id, i, node->streams[i].name); -} - -void vs_a_unsubscribe(VSNodeAudio *node) -{ - unsigned int i; - for(i = 0; i < node->buffer_count; i++) - if(node->buffers[i].name[0] != 0) - vs_remove_subscriptor(node->buffers[i].subscribers); - for(i = 0; i < node->stream_count; i++) - if(node->streams[i].name[0] != 0) - vs_remove_subscriptor(node->streams[i].subscribers); -} - -static void callback_send_a_stream_create(void *user, VNodeID node_id, VLayerID stream_id, const char *name) -{ - VSNodeAudio *node; - unsigned int i, j, count; - - node = (VSNodeAudio *) vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - - for(i = 0; i < node->stream_count; i++) - { - if(stream_id != i) - { - for(j = 0; name[j] == node->streams[i].name[j] && name[j] != 0; j++); - if(name[j] == node->streams[i].name[j]) - return; - } - } - if(stream_id >= node->stream_count || node->streams[stream_id].name[0] == 0) - { - for(stream_id = 0; stream_id < node->stream_count && node->streams[stream_id].name[0] != 0; stream_id++); - if(stream_id == node->stream_count) - { - stream_id = node->stream_count; - node->stream_count += 16; - node->streams = realloc(node->streams, (sizeof *node->streams) * node->stream_count); - for(i = stream_id; i < node->stream_count; i++) - node->streams[i].name[0] = 0; - } - node->streams[stream_id].subscribers = vs_create_subscription_list(); - } - for(i = 0; name[i] != 0 && i < 15; i++) - node->streams[stream_id].name[i] = name[i]; - node->streams[stream_id].name[i] = 0; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_a_stream_create(node_id, stream_id, name); - } - vs_reset_subscript_session(); -} - -static void callback_send_a_stream_destroy(void *user, VNodeID node_id, VLayerID stream_id) -{ - VSNodeAudio *node; - unsigned int i, count; - - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL || stream_id >= node->stream_count || node->streams[stream_id].name[0] == 0) - return; - vs_remove_subscriptor(node->streams[stream_id].subscribers); - node->streams[stream_id].name[0] = 0; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_a_stream_destroy(node_id, stream_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_a_buffer_create(void *user, VNodeID node_id, VBufferID buffer_id, const char *name, - VNABlockType type, real64 frequency) -{ - VSNodeAudio *node; - unsigned int i, j, count; - - if(frequency < 0.0) - return; - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - - for(i = 0; i < node->buffer_count; i++) - { - if(buffer_id != i) - { - for(j = 0; name[j] == node->buffers[i].name[j] && name[j] != 0; j++); - if(name[j] == node->buffers[i].name[j]) - return; - } - } - - if(buffer_id < node->buffer_count && node->buffers[buffer_id].name[0] != 0 && type != node->buffers[buffer_id].type) - { - free(node->buffers[buffer_id].data); - vs_destroy_subscription_list(node->buffers[buffer_id].subscribers); - node->buffers[buffer_id].name[0] = 0; - } - - if(buffer_id >= node->buffer_count || node->buffers[buffer_id].name[0] == 0) - { - for(buffer_id = 0; buffer_id < node->buffer_count && node->buffers[buffer_id].name[0] != 0; buffer_id++); - if(buffer_id == node->buffer_count) - { - buffer_id = node->buffer_count; - node->buffer_count += 16; - node->buffers = realloc(node->buffers, (sizeof *node->buffers) * node->buffer_count); - for(i = buffer_id; i < node->buffer_count; i++) - node->buffers[i].name[0] = 0; - } - node->buffers[buffer_id].subscribers = vs_create_subscription_list(); - node->buffers[buffer_id].type = type; - node->buffers[buffer_id].frequency = frequency; - node->buffers[buffer_id].length = 64; - node->buffers[buffer_id].data = malloc(sizeof(*node->buffers[buffer_id].data) * node->buffers[buffer_id].length); - for(i = 0; i < node->buffers[buffer_id].length; i++) - node->buffers[buffer_id].data[i] = NULL; - } - for(i = 0; name[i] != 0 && i < 15; i++) - node->buffers[buffer_id].name[i] = name[i]; - node->buffers[buffer_id].name[i] = 0; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_a_buffer_create(node_id, buffer_id, name, type, frequency); - } - vs_reset_subscript_session(); -} - -static void callback_send_a_buffer_destroy(void *user, VNodeID node_id, VBufferID buffer_id) -{ - VSNodeAudio *node; - unsigned int i, count; - - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL || buffer_id >= node->buffer_count || node->buffers[buffer_id].name[0] == 0) - return; - vs_remove_subscriptor(node->buffers[buffer_id].subscribers); - node->buffers[buffer_id].name[0] = 0; - free(node->buffers[buffer_id].data); - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_a_buffer_destroy(node_id, buffer_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_a_buffer_subscribe(void *user, VNodeID node_id, VLayerID buffer_id) -{ - VSNodeAudio *node; - unsigned int i; - - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->buffer_count <= buffer_id) - return; - if(node->buffers[buffer_id].name[0] == 0) - return; - vs_add_new_subscriptor(node->buffers[buffer_id].subscribers); - for(i = 0; i < node->buffers[buffer_id].length; i++) - { - if(node->buffers[buffer_id].data[i] != NULL) - verse_send_a_block_set(node_id, buffer_id, i, node->buffers[buffer_id].type, node->buffers[buffer_id].data[i]); - } -} - -static void callback_send_a_buffer_unsubscribe(void *user, VNodeID node_id, VLayerID buffer_id) -{ - VSNodeAudio *node; - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->buffer_count <= buffer_id) - return; - if(node->buffers[buffer_id].name[0] == 0) - return; - vs_remove_subscriptor(node->buffers[buffer_id].subscribers); -} - -static void callback_send_a_block_set(void *user, VNodeID node_id, VLayerID buffer_id, uint32 block_index, - VNABlockType type, const VNABlock *data) -{ - static const size_t blocksize[] = { - VN_A_BLOCK_SIZE_INT8 * sizeof (int8), - VN_A_BLOCK_SIZE_INT16 * sizeof (int16), - VN_A_BLOCK_SIZE_INT24 * 3 * sizeof (int8), - VN_A_BLOCK_SIZE_INT32 * sizeof (int32), - VN_A_BLOCK_SIZE_REAL32 * sizeof (real32), - VN_A_BLOCK_SIZE_REAL64 * sizeof (real64) - }; - VSNodeAudio *node; - unsigned int i, count; - - if(type > VN_A_BLOCK_REAL64) /* Protect blocksize array. */ - return; - - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->buffers[buffer_id].name[0] == 0) - return; - if(type != node->buffers[buffer_id].type) /* Disregard attempts to set data of wrong type. */ - return; - if(block_index > node->buffers[buffer_id].length) - { - node->buffers[buffer_id].data = realloc(node->buffers[buffer_id].data, - (sizeof *node->buffers[buffer_id].data) * (block_index + 64)); - for(i = node->buffers[buffer_id].length; i < block_index + 64; i++) - node->buffers[buffer_id].data[i] = NULL; - node->buffers[buffer_id].length = block_index + 64; - } - - if(node->buffers[buffer_id].data[block_index] == NULL) - node->buffers[buffer_id].data[block_index] = malloc(blocksize[type]); - if(node->buffers[buffer_id].data[block_index] != NULL) - { - memcpy(node->buffers[buffer_id].data[block_index], data, blocksize[type]); - count = vs_get_subscript_count(node->buffers[buffer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->buffers[buffer_id].subscribers, i); - verse_send_a_block_set(node_id, buffer_id, block_index, type, data); - } - vs_reset_subscript_session(); - } -} - -static void callback_send_a_block_clear(void *user, VNodeID node_id, VLayerID buffer_id, uint32 id) -{ - VSNodeAudio *node; - unsigned int i, count; - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->buffer_count <= buffer_id) - return; - if(node->buffers[buffer_id].name[0] == 0) - return; - if(id >= node->buffers[buffer_id].length) - return; - if(node->buffers[buffer_id].data[id] == NULL) - return; - free(node->buffers[buffer_id].data[id]); - node->buffers[buffer_id].data[id] = NULL; - count = vs_get_subscript_count(node->buffers[buffer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->buffers[buffer_id].subscribers, i); - verse_send_a_block_clear(node_id, buffer_id, id); - } - vs_reset_subscript_session(); -} - -static void callback_send_a_stream_subscribe(void *user, VNodeID node_id, VLayerID stream_id) -{ - VSNodeAudio *node; - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->stream_count <= stream_id) - return; - if(node->streams[stream_id].name[0] == 0) - return; - vs_add_new_subscriptor(node->streams[stream_id].subscribers); -} - -static void callback_send_a_stream_unsubscribe(void *user, VNodeID node_id, VLayerID stream_id) -{ - VSNodeAudio *node; - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->stream_count <= stream_id) - return; - if(node->streams[stream_id].name[0] == 0) - return; - vs_remove_subscriptor(node->streams[stream_id].subscribers); -} - -static void callback_send_a_stream(void *user, VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, - VNABlockType type, real64 frequency, const VNABlock *data) -{ - VSNodeAudio *node; - unsigned int i, count; - - if(frequency < 0) - return; - node = (VSNodeAudio *)vs_get_node(node_id, V_NT_AUDIO); - if(node == NULL) - return; - if(node->stream_count <= stream_id) - return; - if(node->streams[stream_id].name[0] == 0) - return; - count = vs_get_subscript_count(node->streams[stream_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->streams[stream_id].subscribers, i); - verse_send_a_stream(node_id, stream_id, time_s, time_f, type, frequency, data); - } - vs_reset_subscript_session(); -} - -void vs_a_callback_init(void) -{ - verse_callback_set(verse_send_a_buffer_create, callback_send_a_buffer_create, NULL); - verse_callback_set(verse_send_a_buffer_destroy, callback_send_a_buffer_destroy, NULL); - verse_callback_set(verse_send_a_buffer_subscribe, callback_send_a_buffer_subscribe, NULL); - verse_callback_set(verse_send_a_buffer_unsubscribe, callback_send_a_buffer_unsubscribe, NULL); - verse_callback_set(verse_send_a_block_set, callback_send_a_block_set, NULL); - verse_callback_set(verse_send_a_block_clear, callback_send_a_block_clear, NULL); - verse_callback_set(verse_send_a_stream_create, callback_send_a_stream_create, NULL); - verse_callback_set(verse_send_a_stream_destroy, callback_send_a_stream_destroy, NULL); - verse_callback_set(verse_send_a_stream_subscribe, callback_send_a_stream_subscribe, NULL); - verse_callback_set(verse_send_a_stream_unsubscribe, callback_send_a_stream_unsubscribe, NULL); - verse_callback_set(verse_send_a_stream, callback_send_a_stream, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_bitmap.c b/extern/verse/dist/vs_node_bitmap.c deleted file mode 100644 index 566287a86d4..00000000000 --- a/extern/verse/dist/vs_node_bitmap.c +++ /dev/null @@ -1,560 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -typedef struct { - VNBLayerType type; - char name[16]; - void *layer; - VSSubscriptionList *subscribers; -} VSNBLayers; - -typedef struct { - VSNodeHead head; - uint16 size[3]; - uint32 partial_tile_col, partial_tile_row; /* These rows/columns are partial. ~0 for none. */ - VSNBLayers *layers; - unsigned int layer_count; -} VSNodeBitmap; - -static unsigned long tile_counter = 0; - -VSNodeBitmap * vs_b_create_node(unsigned int owner) -{ - VSNodeBitmap *node; - char name[48]; - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_BITMAP); - sprintf(name, "Bitmap_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - - node->size[0] = 0; - node->size[1] = 0; - node->size[2] = 0; - node->partial_tile_col = ~0; - node->partial_tile_row = ~0; - node->layers = NULL; - node->layer_count = 0; - - return node; -} - -void vs_b_destroy_node(VSNodeBitmap *node) -{ - unsigned int i; - destroy_node_head(&node->head); - if(node->layers != NULL) - { - for(i = 0; i < node->layer_count; i++) - if(node->layers[i].layer != NULL) - free(node->layers[i].layer); - free(node->layers); - } - free(node); -} - -void vs_b_subscribe(VSNodeBitmap *node) -{ - unsigned int i; - verse_send_b_dimensions_set(node->head.id, node->size[0], node->size[1], node->size[2]); - for(i = 0; i < node->layer_count; i++) - if(node->layers[i].name[0] != 0) - verse_send_b_layer_create(node->head.id, (uint16)i, node->layers[i].name, (uint8)node->layers[i].type); -} - - -void vs_b_unsubscribe(VSNodeBitmap *node) -{ - unsigned int i; - for(i = 0; i < node->layer_count; i++) - if(node->layers[i].name[0] != 0) - vs_remove_subscriptor(node->layers[i].subscribers); -} - -static void callback_send_b_dimensions_set(void *user, VNodeID node_id, uint16 width, uint16 height, uint16 depth) -{ - VSNodeBitmap *node; - unsigned int i, j, k, count, tiles[2], read, write, end = 0; - - if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL) - return; - tiles[0] = (width + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE; - tiles[1] = (height + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE; - node->size[0] = (node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE; - node->size[1] = (node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE; - if(node->size[0] > tiles[0]) - node->size[0] = tiles[0]; - if(node->size[1] > tiles[1]) - node->size[1] = tiles[1]; - if(node->size[2] > depth) - node->size[2] = depth; - - for(i = 0; i < node->layer_count; i++) - { - if(node->layers[i].name[0] != 0) - { - switch(node->layers[i].type) - { - case VN_B_LAYER_UINT1 : - { - uint16 *array, *old; - write = 0; - old = node->layers[i].layer; - array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth); - for(j = 0; j < node->size[2]; j++) - { - for(k = 0; k < node->size[1]; k++) - { - read = (j * node->size[1] * node->size[0] + k * node->size[0]); - - end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]); - while(write < end) - array[write++] = old[read++]; - - end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]); - while(write < end) - array[write++] = 0; - } - end = ((j + 1) * tiles[1] * tiles[0]); - while(write < end) - array[write++] = 0; - } - k = depth * tiles[1] * tiles[0]; - while(write < end) - array[write++] = 0; - } - break; - case VN_B_LAYER_UINT8 : - { - uint8 *array, *old; - write = 0; - old = node->layers[i].layer; - array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE); - for(j = 0; j < node->size[2]; j++) - { - for(k = 0; k < node->size[1]; k++) - { - read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - - end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = old[read++]; - - end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - break; - case VN_B_LAYER_UINT16 : - { - uint16 *array, *old; - write = 0; - old = node->layers[i].layer; - array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE); - for(j = 0; j < node->size[2]; j++) - { - for(k = 0; k < node->size[1]; k++) - { - read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - - end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = old[read++]; - - end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - break; - case VN_B_LAYER_REAL32 : - { - real32 *array, *old; - write = 0; - old = node->layers[i].layer; - array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE); - for(j = 0; j < node->size[2]; j++) - { - for(k = 0; k < node->size[1]; k++) - { - read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - - end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = old[read++]; - - end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - break; - case VN_B_LAYER_REAL64 : - { - real64 *array, *old; - write = 0; - old = node->layers[i].layer; - array = node->layers[i].layer = malloc((sizeof *array) * tiles[0] * tiles[1] * depth * VN_B_TILE_SIZE * VN_B_TILE_SIZE); - for(j = 0; j < node->size[2]; j++) - { - for(k = 0; k < node->size[1]; k++) - { - read = (j * node->size[1] * node->size[0] + k * node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - - end = (j * tiles[1] * tiles[0] + k * tiles[0] + node->size[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = old[read++]; - - end = (j * tiles[1] * tiles[0] + (k + 1) * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = ((j + 1) * tiles[1] * tiles[0]) * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - end = depth * tiles[1] * tiles[0] * VN_B_TILE_SIZE * VN_B_TILE_SIZE; - while(write < end) - array[write++] = 0; - } - break; - } - } - } - - node->size[0] = width; - node->size[1] = height; - node->size[2] = depth; - node->partial_tile_col = (width % VN_B_TILE_SIZE) != 0 ? (width + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE - 1 : ~0; - node->partial_tile_row = (height % VN_B_TILE_SIZE) != 0 ? (height + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE - 1 : ~0; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_b_dimensions_set(node_id, width, height, depth); - } - vs_reset_subscript_session(); -} - -static void callback_send_b_layer_create(void *user, VNodeID node_id, VLayerID layer_id, char *name, uint8 type) -{ - VSNodeBitmap *node; - unsigned int i, count; - - if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL) - return; - if(node->layer_count <= layer_id || node->layers[layer_id].name[0] == 0) - { - for(layer_id = 0; layer_id < node->layer_count && node->layers[layer_id].name[0] != 0; layer_id++) - ; - if(layer_id == node->layer_count) - { - node->layers = realloc(node->layers, (sizeof *node->layers) * (node->layer_count + 16)); - for(i = node->layer_count; i < node->layer_count + 16; i++) - { - node->layers[i].layer = NULL; - node->layers[i].type = 0; - node->layers[i].name[0] = 0; - node->layers[i].subscribers = NULL; - } - node->layer_count += 16; - } - node->layers[layer_id].subscribers = vs_create_subscription_list(); - node->layers[layer_id].type = type + 1; - } - - if(node->layers[layer_id].type != type || node->layers[layer_id].name[0] == 0) - { - count = ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE) * ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE); - count *= VN_B_TILE_SIZE * VN_B_TILE_SIZE * node->size[2]; - if(node->layers[layer_id].layer != NULL) - free(node->layers[layer_id].layer); - if(count != 0) - { - switch(type) - { - case VN_B_LAYER_UINT1 : - node->layers[layer_id].layer = malloc(sizeof(uint8) * count / 8); - memset(node->layers[layer_id].layer, 0, count * sizeof(uint8) / 8); - break; - case VN_B_LAYER_UINT8 : - node->layers[layer_id].layer = malloc(sizeof(uint8) * count); - memset(node->layers[layer_id].layer, 0, count * sizeof(uint8)); - break; - case VN_B_LAYER_UINT16 : - node->layers[layer_id].layer = malloc(sizeof(uint16) * count); - memset(node->layers[layer_id].layer, 0, count * sizeof(uint16)); - break; - case VN_B_LAYER_REAL32 : - node->layers[layer_id].layer = malloc(sizeof(real32) * count); - memset(node->layers[layer_id].layer, 0, count * sizeof(real32)); - break; - case VN_B_LAYER_REAL64 : - node->layers[layer_id].layer = malloc(sizeof(real64) * count); - memset(node->layers[layer_id].layer, 0, count * sizeof(real64)); - break; - } - }else - node->layers[layer_id].layer = NULL; - } - node->layers[layer_id].type = type; - for(i = 0; i < 15 && name[i] != 0; i++) - node->layers[layer_id].name[i] = name[i]; - node->layers[layer_id].name[i] = 0; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_b_layer_create(node_id, layer_id, name, type); - } - vs_reset_subscript_session(); -} - -static void callback_send_b_layer_destroy(void *user, VNodeID node_id, VLayerID layer_id) -{ - VSNodeBitmap *node; - unsigned int i, count; - if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL) - return; - if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL) - return; - if(node->layers[layer_id].layer != NULL) - free(node->layers[layer_id].layer); - node->layers[layer_id].layer = NULL; - node->layers[layer_id].type = 0; - node->layers[layer_id].name[0] = 0; - vs_destroy_subscription_list(node->layers[layer_id].subscribers); - node->layers[layer_id].subscribers = NULL; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_b_layer_destroy(node_id, layer_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_b_layer_subscribe(void *user, VNodeID node_id, VLayerID layer_id, uint8 level) -{ - VSNodeBitmap *node; - const void *data; - unsigned int i, j, k, tile[3]; - - if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL) - return; - if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL) - return; - if(vs_add_new_subscriptor(node->layers[layer_id].subscribers) == 0) - return; - tile[0] = ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE); - tile[1] = ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE); - tile[2] = node->size[2]; - data = node->layers[layer_id].layer; - switch(node->layers[layer_id].type) - { - case VN_B_LAYER_UINT1: - for(i = 0; i < tile[0]; i++) - for(j = 0; j < tile[1]; j++) - for(k = 0; k < tile[2]; k++) - verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_UINT1, (VNBTile *) &((uint8*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE / 8]); - break; - case VN_B_LAYER_UINT8 : - for(i = 0; i < tile[0]; i++) - for(j = 0; j < tile[1]; j++) - for(k = 0; k < tile[2]; k++) - verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_UINT8, (VNBTile *) &((uint8*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]); - break; - case VN_B_LAYER_UINT16 : - for(i = 0; i < tile[0]; i++) - for(j = 0; j < tile[1]; j++) - for(k = 0; k < tile[2]; k++) - verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_UINT16, (VNBTile *) &((uint16*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]); - break; - case VN_B_LAYER_REAL32 : - for(i = 0; i < tile[0]; i++) - for(j = 0; j < tile[1]; j++) - for(k = 0; k < tile[2]; k++) - verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_REAL32, (VNBTile *) &((real32*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]); - break; - case VN_B_LAYER_REAL64 : - for(i = 0; i < tile[0]; i++) - for(j = 0; j < tile[1]; j++) - for(k = 0; k < tile[2]; k++) - verse_send_b_tile_set(node_id, layer_id, i, j, k, VN_B_LAYER_REAL64, (VNBTile *) &((real64*)data)[(tile[0] * tile[1] * k + j * tile[0] + i) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]); - break; - } -} - -static void callback_send_b_layer_unsubscribe(void *user, VNodeID node_id, VLayerID layer_id) -{ - VSNodeBitmap *node; - if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL) - return; - if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL) - return; - vs_remove_subscriptor(node->layers[layer_id].subscribers); -} - -/* Clear any pixels that lie outside the image, so we don't violoate specs when - * sending (stored version of) the tile out to subscribers. -*/ -static void clear_outside(const VSNodeBitmap *node, uint16 tile_x, uint16 tile_y, uint8 type, VNBTile *tile) -{ - int x, y, bx, by, p; - - by = tile_y * VN_B_TILE_SIZE; - for(y = p = 0; y < VN_B_TILE_SIZE; y++, by++) - { - bx = tile_x * VN_B_TILE_SIZE; - for(x = 0; x < VN_B_TILE_SIZE; x++, bx++, p++) - { - /* Simply test current pixel against bitmap size. Not quick, but simple. */ - if(bx >= node->size[0] || by >= node->size[1]) - { - switch(type) - { - case VN_B_LAYER_UINT1: - tile->vuint1[y] &= ~(128 >> x); - break; - case VN_B_LAYER_UINT8: - tile->vuint8[p] = 0; - break; - case VN_B_LAYER_UINT16: - tile->vuint16[p] = 0; - break; - case VN_B_LAYER_REAL32: - tile->vreal32[p] = 0.0f; - break; - case VN_B_LAYER_REAL64: - tile->vreal64[p] = 0.0; - break; - } - } - } - } -} - -static void callback_send_b_tile_set(void *user, VNodeID node_id, VLayerID layer_id, - uint16 tile_x, uint16 tile_y, uint16 tile_z, uint8 type, VNBTile *data) -{ - VSNodeBitmap *node; - unsigned int i, count, tile[3]; - - if((node = (VSNodeBitmap *)vs_get_node(node_id, V_NT_BITMAP)) == NULL) - { - printf("got tile for unknown bitmpa node %u, aborting\n", node_id); - return; - } - if(layer_id >= node->layer_count || node->layers[layer_id].layer == NULL || node->layers[layer_id].type != type) - { - printf("node %u got tile for bad layer %u (have %u) %p\n", node_id, layer_id, node->layer_count, layer_id < node->layer_count ? node->layers[layer_id].layer : NULL); - return; - } - if(tile_x >= ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE) || tile_y >= ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE) || tile_z >= node->size[2]) - { - printf("got tile that is outside image, at (%u,%u,%u)\n", tile_x, tile_y, tile_z); - return; - } - - tile_counter++; - - tile[0] = ((node->size[0] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE); - tile[1] = ((node->size[1] + VN_B_TILE_SIZE - 1) / VN_B_TILE_SIZE); - tile[2] = node->size[2]; - - /* If tile is in a partial column or row, clear the "outside" pixels. */ - if((uint32) tile_x == node->partial_tile_col || (uint32) tile_y == node->partial_tile_row) - clear_outside(node, tile_x, tile_y, type, data); - - switch(node->layers[layer_id].type) - { - case VN_B_LAYER_UINT1 : - { - uint8 *p; - p = &((uint8 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE/8]; - memcpy(p, data->vuint1, VN_B_TILE_SIZE * sizeof(uint8)); - } - break; - case VN_B_LAYER_UINT8 : - { - uint8 *p; - p = &((uint8 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]; - memcpy(p, data->vuint8, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(uint8)); - } - break; - case VN_B_LAYER_UINT16 : - { - uint16 *p; - p = &((uint16 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]; - memcpy(p, data->vuint16, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(uint16)); - } - break; - case VN_B_LAYER_REAL32 : - { - real32 *p; - p = &((real32 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]; - memcpy(p, data->vreal32, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(real32)); - } - break; - case VN_B_LAYER_REAL64 : - { - real64 *p; - p = &((real64 *)node->layers[layer_id].layer)[(tile[0] * tile[1] * tile_z + tile_y * tile[0] + tile_x) * VN_B_TILE_SIZE * VN_B_TILE_SIZE]; - memcpy(p, data->vreal64, VN_B_TILE_SIZE * VN_B_TILE_SIZE * sizeof(real64)); - } - break; - } - count = vs_get_subscript_count(node->layers[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layers[layer_id].subscribers, i); - verse_send_b_tile_set(node_id, layer_id, tile_x, tile_y, tile_z, type, data); - } - vs_reset_subscript_session(); -} - -void vs_b_callback_init(void) -{ - verse_callback_set(verse_send_b_dimensions_set, callback_send_b_dimensions_set, NULL); - verse_callback_set(verse_send_b_layer_create, callback_send_b_layer_create, NULL); - verse_callback_set(verse_send_b_layer_destroy, callback_send_b_layer_destroy, NULL); - verse_callback_set(verse_send_b_layer_subscribe, callback_send_b_layer_subscribe, NULL); - verse_callback_set(verse_send_b_layer_unsubscribe, callback_send_b_layer_unsubscribe, NULL); - verse_callback_set(verse_send_b_tile_set, callback_send_b_tile_set, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_curve.c b/extern/verse/dist/vs_node_curve.c deleted file mode 100644 index 3787526202d..00000000000 --- a/extern/verse/dist/vs_node_curve.c +++ /dev/null @@ -1,258 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -typedef struct { - real64 pre_value[4]; - uint32 pre_pos[4]; - real64 value[4]; - real64 pos; - real64 post_value[4]; - uint32 post_pos[4]; -} VSNKey; - -typedef struct { - VSNKey *keys; - unsigned int length; - char name[16]; - uint8 dimensions; - VSSubscriptionList *subscribers; -} VSNCurve; - -typedef struct{ - VSNodeHead head; - VSNCurve *curves; - unsigned int curve_count; -} VSNodeCurve; - -VSNodeCurve * vs_c_create_node(unsigned int owner) -{ - VSNodeCurve *node; - char name[48]; - unsigned int i; - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_CURVE); - sprintf(name, "Curve_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - node->curves = malloc((sizeof *node->curves) * 16); - node->curve_count = 16; - for(i = 0; i < 16; i++) - node->curves[i].name[0] = 0; - return node; -} - -void vs_c_destroy_node(VSNodeCurve *node) -{ - destroy_node_head(&node->head); - free(node); -} - -void vs_c_subscribe(VSNodeCurve *node) -{ - unsigned int i; - if(node == NULL) - return; - for(i = 0; i < node->curve_count; i++) - if(node->curves[i].name[0] != 0) - verse_send_c_curve_create(node->head.id, i, node->curves[i].name, node->curves[i].dimensions); - -} - -void vs_c_unsubscribe(VSNodeCurve *node) -{ - unsigned int i; - for(i = 0; i < node->curve_count; i++) - if(node->curves[i].name[0] != 0) - vs_remove_subscriptor(node->curves[i].subscribers); -} - -static void callback_send_c_curve_create(void *user, VNodeID node_id, VLayerID curve_id, const char *name, uint8 dimensions) -{ - VSNodeCurve *node; - unsigned int i, j, count; - node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE); - if(node == NULL) - return; - - for(i = 0; i < node->curve_count; i++) - { - if(curve_id != i) - { - for(j = 0; name[j] == node->curves[i].name[j] && name[j] != 0; j++); - if(name[j] == node->curves[i].name[j]) - return; - } - } - if(curve_id >= node->curve_count || node->curves[curve_id].name[0] == 0) - { - for(curve_id = 0; curve_id < node->curve_count && node->curves[curve_id].name[0] != 0; curve_id++); - if(curve_id == node->curve_count) - { - curve_id = node->curve_count; - node->curve_count += 16; - node->curves = realloc(node->curves, (sizeof *node->curves) * node->curve_count); - for(i = curve_id; i < node->curve_count; i++) - node->curves[i].name[0] = 0; - } - node->curves[curve_id].subscribers = vs_create_subscription_list(); - node->curves[curve_id].length = 64; - node->curves[curve_id].keys = malloc((sizeof *node->curves[curve_id].keys) * 64); - for(i = 0; i < 64; i++) - node->curves[curve_id].keys[i].pos = V_REAL64_MAX; - - }else if(node->curves[curve_id].dimensions != dimensions) - { - for(i = 0; i < node->curves[curve_id].length; i++) - { - if(node->curves[curve_id].keys[i].pos != V_REAL64_MAX) - { - for(j = node->curves[curve_id].dimensions; j < dimensions; j++) - { - node->curves[curve_id].keys[i].pre_value[j] = node->curves[curve_id].keys[i].pre_value[0]; - node->curves[curve_id].keys[i].pre_pos[j] = node->curves[curve_id].keys[i].pre_pos[0]; - node->curves[curve_id].keys[i].value[j] = node->curves[curve_id].keys[i].value[0]; - node->curves[curve_id].keys[i].post_value[j] = node->curves[curve_id].keys[i].post_value[0]; - node->curves[curve_id].keys[i].post_pos[j] = node->curves[curve_id].keys[i].post_pos[0]; - } - } - } - vs_destroy_subscription_list(node->curves[curve_id].subscribers); - node->curves[curve_id].subscribers = vs_create_subscription_list(); - } - for(i = 0; name[i] != 0 && i < 15; i++) - node->curves[curve_id].name[i] = name[i]; - node->curves[curve_id].name[i] = 0; - node->curves[curve_id].dimensions = dimensions; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_c_curve_create(node_id, curve_id, name, dimensions); - } - vs_reset_subscript_session(); -} - -static void callback_send_c_curve_destroy(void *user, VNodeID node_id, VLayerID curve_id) -{ - VSNodeCurve *node; - unsigned int i, count; - node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE); - if(node == NULL || node->curve_count >= curve_id || node->curves[curve_id].name[0] == 0) - return; - vs_remove_subscriptor(node->curves[curve_id].subscribers); - node->curves[curve_id].name[0] = 0; - free(node->curves[curve_id].keys); - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_c_curve_destroy(node_id, curve_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_c_key_set(void *user, VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions, real64 *pre_value, uint32 *pre_pos, real64 *value, real64 pos, real64 *post_value, uint32 *post_pos) -{ - VSNodeCurve *node; - unsigned int i, count; - node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE); - if(node == NULL) - return; - if(node->curve_count <= curve_id) - return; - if(node->curves[curve_id].name[0] == 0) - return; - if(node == NULL || node->curve_count <= curve_id || node->curves[curve_id].name[0] == 0 || node->curves[curve_id].dimensions != dimensions) - return; - if(node->curves[curve_id].length <= key_id || node->curves[curve_id].keys[key_id].pos == V_REAL64_MAX) - { - for(key_id = 0; key_id < node->curves[curve_id].length && node->curves[curve_id].keys[key_id].pos != V_REAL64_MAX; key_id++); - if(key_id == node->curves[curve_id].length) - for(i = 0; i < 64; i++) - node->curves[curve_id].keys[node->curves[curve_id].length++].pos = V_REAL64_MAX; - } - for(i = 0; i < dimensions; i++) - node->curves[curve_id].keys[key_id].pre_value[i] = pre_value[i]; - for(i = 0; i < dimensions; i++) - node->curves[curve_id].keys[key_id].pre_pos[i] = pre_pos[i]; - for(i = 0; i < dimensions; i++) - node->curves[curve_id].keys[key_id].value[i] = value[i]; - node->curves[curve_id].keys[key_id].pos = pos; - for(i = 0; i < dimensions; i++) - node->curves[curve_id].keys[key_id].post_value[i] = post_value[i]; - for(i = 0; i < dimensions; i++) - node->curves[curve_id].keys[key_id].post_pos[i] = post_pos[i]; - count = vs_get_subscript_count(node->curves[curve_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->curves[curve_id].subscribers, i); - verse_send_c_key_set(node_id, curve_id, key_id, dimensions, pre_value, pre_pos, value, pos, post_value, post_pos); - } - vs_reset_subscript_session(); -} - -static void callback_send_c_key_destroy(void *user, VNodeID node_id, VLayerID curve_id, uint32 key_id) -{ - VSNodeCurve *node; - unsigned int i, count; - node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE); - if(node == NULL || node->curve_count <= curve_id || node->curves[curve_id].name[0] == 0) - return; - if(node->curves[curve_id].length <= key_id || node->curves[curve_id].keys[key_id].pos == V_REAL64_MAX) - return; - node->curves[curve_id].keys[key_id].pos = V_REAL64_MAX; - count = vs_get_subscript_count(node->curves[curve_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->curves[curve_id].subscribers, i); - verse_send_c_key_destroy(node_id, curve_id, key_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_c_curve_subscribe(void *user, VNodeID node_id, VLayerID curve_id) -{ - VSNodeCurve *node; - unsigned int i; - node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE); - if(node == NULL || node->curve_count <= curve_id || node->curves[curve_id].name[0] == 0) - return; - - vs_add_new_subscriptor(node->curves[curve_id].subscribers); - - for(i = 0; i < node->curves[curve_id].length; i++) - if(node->curves[curve_id].keys[i].pos != V_REAL64_MAX) - verse_send_c_key_set(node_id, curve_id, i, node->curves[curve_id].dimensions, node->curves[curve_id].keys[i].pre_value, node->curves[curve_id].keys[i].pre_pos, node->curves[curve_id].keys[i].value, node->curves[curve_id].keys[i].pos, node->curves[curve_id].keys[i].post_value, node->curves[curve_id].keys[i].post_pos); -} - -static void callback_send_c_curve_unsubscribe(void *user, VNodeID node_id, VLayerID curve_id) -{ - VSNodeCurve *node; - - node = (VSNodeCurve *)vs_get_node(node_id, V_NT_CURVE); - if(node == NULL || curve_id >= node->curve_count || node->curves[curve_id].name[0] == 0) - return; - vs_remove_subscriptor(node->curves[curve_id].subscribers); -} - -void vs_c_callback_init(void) -{ - verse_callback_set(verse_send_c_curve_create, callback_send_c_curve_create, NULL); - verse_callback_set(verse_send_c_curve_destroy, callback_send_c_curve_destroy, NULL); - verse_callback_set(verse_send_c_curve_subscribe, callback_send_c_curve_subscribe, NULL); - verse_callback_set(verse_send_c_curve_unsubscribe, callback_send_c_curve_unsubscribe, NULL); - verse_callback_set(verse_send_c_key_set, callback_send_c_key_set, NULL); - verse_callback_set(verse_send_c_key_destroy, callback_send_c_key_destroy, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_geometry.c b/extern/verse/dist/vs_node_geometry.c deleted file mode 100644 index 4b1f88c8ac2..00000000000 --- a/extern/verse/dist/vs_node_geometry.c +++ /dev/null @@ -1,1047 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "v_util.h" -#include "vs_server.h" - -#define VS_G_LAYER_CHUNK 32 - -typedef struct { - VNGLayerType type; - char name[16]; - void *layer; - VSSubscriptionList *subscribers; - VSSubscriptionList *subscribersd; - union{ - uint32 integer; - real64 real; - } def; -} VSNGLayer; - -typedef struct { - char weight[16]; - char reference[16]; - uint16 parent; - real64 pos_x; - real64 pos_y; - real64 pos_z; - char position_label[16]; - char rotation_label[16]; - char scale_label[16]; -} VSNGBone; - -typedef struct { - VSNodeHead head; - VSNGLayer *layer; - uint16 layer_count; - uint32 vertex_size; - uint32 poly_size; - uint32 vertex_hole; - uint32 polygon_hole; - uint32 crease_vertex; - char crease_vertex_layer[16]; - uint32 crease_edge; - char crease_edge_layer[16]; - VSNGBone *bones; - uint32 bone_count; -} VSNodeGeometry; - -VSNodeGeometry * vs_g_create_node(unsigned int owner) -{ - VSNodeGeometry *node; - unsigned int i; - char name[48]; - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_GEOMETRY); - sprintf(name, "Geometry_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - - node->bones = malloc((sizeof *node->bones) * 16); - node->bone_count = 16; - for(i = 0; i < node->bone_count; i++) - node->bones[i].weight[0] = '\0'; - - node->layer = malloc((sizeof *node->layer) * 16); - node->layer_count = 16; - node->vertex_size = VS_G_LAYER_CHUNK; - node->poly_size = VS_G_LAYER_CHUNK; - - strcpy(node->layer[0].name, "vertex"); - node->layer[0].type = VN_G_LAYER_VERTEX_XYZ; - node->layer[0].layer = malloc(sizeof(real64) * VS_G_LAYER_CHUNK * 3); - for(i = 0; i < VS_G_LAYER_CHUNK * 3; i++) - ((real64 *)node->layer[0].layer)[i] = V_REAL64_MAX; - node->layer[0].subscribers = NULL;/*vs_create_subscription_list();*/ - node->layer[0].subscribersd = NULL;/*vs_create_subscription_list();*/ - node->layer[0].def.real = 0; - - strcpy(node->layer[1].name, "polygon"); - node->layer[1].type = VN_G_LAYER_POLYGON_CORNER_UINT32; - node->layer[1].layer = malloc(sizeof(uint32) * VS_G_LAYER_CHUNK * 4); - for(i = 0; i < VS_G_LAYER_CHUNK * 4; i++) - ((uint32 *)node->layer[1].layer)[i] = -1; - node->layer[1].subscribers = NULL;/*vs_create_subscription_list();*/ - node->layer[1].subscribersd = NULL; - node->layer[1].def.integer = 0; - node->layer[1].def.real = 0.0; - - for(i = 2; i < 16; i++) - { - node->layer[i].type = -1; - node->layer[i].name[0] = 0; - node->layer[i].layer = NULL; - node->layer[i].subscribers = NULL; - node->layer[i].subscribersd = NULL; - node->layer[i].def.real = 0; - } - node->crease_vertex = 0; - node->crease_vertex_layer[0] = 0; - node->crease_edge = 0; - node->crease_edge_layer[0] = 0; - node->vertex_hole = 0; - node->polygon_hole = 0; - return node; -} - -void vs_g_destroy_node(VSNodeGeometry *node) -{ - destroy_node_head(&node->head); - free(node); -} - -void vs_g_subscribe(VSNodeGeometry *node) -{ - unsigned int i; - for(i = 0; i < node->layer_count; i++) - { - if(node->layer[i].layer != NULL) - { - verse_send_g_layer_create(node->head.id, (uint16)i, node->layer[i].name, node->layer[i].type, - node->layer[i].def.integer, node->layer[i].def.real); - } - } - verse_send_g_crease_set_vertex(node->head.id, node->crease_vertex_layer, node->crease_vertex); - verse_send_g_crease_set_edge(node->head.id, node->crease_edge_layer, node->crease_edge); - for(i = 0; i < node->bone_count; i++) - { - if(node->bones[i].weight[0] != 0) - verse_send_g_bone_create(node->head.id, (uint16)i, node->bones[i].weight, node->bones[i].reference, node->bones[i].parent, - node->bones[i].pos_x, node->bones[i].pos_y, node->bones[i].pos_z, node->bones[i].position_label, - node->bones[i].rotation_label, node->bones[i].scale_label); - } -} - - -void vs_g_unsubscribe(VSNodeGeometry *node) -{ - unsigned int i; - for(i = 0; i < node->layer_count; i++) { - if(node->layer[i].layer != NULL) { - if(node->layer[i].subscribers) - vs_remove_subscriptor(node->layer[i].subscribers); - if(node->layer[i].subscribersd) - vs_remove_subscriptor(node->layer[i].subscribersd); - } - } -} - -static void callback_send_g_layer_create(void *user, VNodeID node_id, VLayerID layer_id, char *name, uint8 type, uint32 def_uint, real64 def_real) -{ - VSNodeGeometry *node; - unsigned int i, j, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - - if(node == NULL) - return; - if((type < VN_G_LAYER_POLYGON_CORNER_UINT32 && type > VN_G_LAYER_VERTEX_REAL) || - (type > VN_G_LAYER_POLYGON_FACE_REAL)) - return; - - if(layer_id < 2) - layer_id = -1; - for(i = 0; i < node->layer_count; i++) - { - if(node->layer[i].layer != NULL && i != layer_id) - { - for(j = 0; name[j] == node->layer[i].name[j] && name[j] != 0; j++); - if(name[j] == node->layer[i].name[j]) - return; - } - } - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL) - { - for(layer_id = 0; layer_id < node->layer_count && node->layer[layer_id].layer != NULL; layer_id++); - if(layer_id == node->layer_count) - { - layer_id = node->layer_count; - node->layer_count += 16; - node->layer = realloc(node->layer, (sizeof *node->layer) * node->layer_count); - for(i = layer_id; i < node->layer_count; i++) - { - node->layer[i].type = -1; - node->layer[i].name[0] = 0; - node->layer[i].layer = 0; - node->layer[i].subscribers = NULL; - node->layer[i].subscribersd = NULL; - } - } - } - for(i = 0; i < 16; i++) - node->layer[layer_id].name[i] = name[i]; - - if(node->layer[layer_id].type != type) - { - if(node->layer[layer_id].subscribers) { - vs_destroy_subscription_list(node->layer[layer_id].subscribers); - node->layer[layer_id].subscribers = NULL; - } - if(node->layer[layer_id].subscribersd) { - vs_destroy_subscription_list(node->layer[layer_id].subscribersd); - node->layer[layer_id].subscribersd = NULL; - } - node->layer[layer_id].type = type; - free(node->layer[layer_id].layer); - switch(type) - { - case VN_G_LAYER_VERTEX_XYZ : - node->layer[layer_id].layer = malloc(sizeof(real64) * node->vertex_size * 3); - for(i = 0; i < node->vertex_size * 3; i++) - ((real64 *)node->layer[layer_id].layer)[i] = ((real64 *)node->layer[0].layer)[i]; - break; - case VN_G_LAYER_VERTEX_UINT32 : - node->layer[layer_id].layer = malloc(sizeof(uint32) * node->vertex_size); - for(i = 0; i < node->vertex_size; i++) - ((uint32 *)node->layer[layer_id].layer)[i] = def_uint; - node->layer[layer_id].def.integer = def_uint; - break; - case VN_G_LAYER_VERTEX_REAL : - node->layer[layer_id].layer = malloc(sizeof(real64) * node->vertex_size); - for(i = 0; i < node->vertex_size; i++) - ((real64 *)node->layer[layer_id].layer)[i] = def_real; - node->layer[layer_id].def.real = def_real; - break; - case VN_G_LAYER_POLYGON_CORNER_UINT32 : - node->layer[layer_id].layer = malloc(sizeof(uint32) * node->poly_size * 4); - for(i = 0; i < node->poly_size * 4; i++) - ((uint32 *)node->layer[layer_id].layer)[i] = def_uint; - node->layer[layer_id].def.integer = def_uint; - break; - case VN_G_LAYER_POLYGON_CORNER_REAL : - node->layer[layer_id].layer = malloc(sizeof(real64) * node->poly_size * 4); - for(i = 0; i < node->poly_size * 4; i++) - ((real64 *)node->layer[layer_id].layer)[i] = def_real; - node->layer[layer_id].def.real = def_real; - break; - case VN_G_LAYER_POLYGON_FACE_UINT8 : - node->layer[layer_id].layer = malloc(sizeof(uint8) * node->poly_size); - for(i = 0; i < node->poly_size; i++) - ((uint8 *)node->layer[layer_id].layer)[i] = def_uint; - node->layer[layer_id].def.integer = def_uint; - break; - case VN_G_LAYER_POLYGON_FACE_UINT32 : - node->layer[layer_id].layer = malloc(sizeof(uint32) * node->poly_size); - for(i = 0; i < node->poly_size; i++) - ((uint32 *)node->layer[layer_id].layer)[i] = def_uint; - node->layer[layer_id].def.integer = def_uint; - break; - case VN_G_LAYER_POLYGON_FACE_REAL : - node->layer[layer_id].layer = malloc(sizeof(real64) * node->poly_size); - for(i = 0; i < node->poly_size; i++) - ((real64 *)node->layer[layer_id].layer)[i] = def_real; - node->layer[layer_id].def.real = def_real; - break; - } - } - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_g_layer_create(node_id, layer_id, name, type, def_uint, def_real); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_layer_destroy(void *user, VNodeID node_id, VLayerID layer_id) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || layer_id < 2) - return; - free(node->layer[layer_id].layer); - node->layer[layer_id].layer = NULL; - node->layer[layer_id].name[0] = 0; - node->layer[layer_id].type = -1; - if(node->layer[layer_id].subscribers) { - vs_destroy_subscription_list(node->layer[layer_id].subscribers); - node->layer[layer_id].subscribers = NULL; - } - if(node->layer[layer_id].subscribersd) { - vs_destroy_subscription_list(node->layer[layer_id].subscribersd); - node->layer[layer_id].subscribersd = NULL; - } - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_g_layer_destroy(node_id, layer_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_layer_subscribe(void *user, VNodeID node_id, VLayerID layer_id, uint8 type) -{ - VSNodeGeometry *node; - VSNGLayer *layer; - VSSubscriptionList **list = NULL; - unsigned int i; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL) - return; - /* Pick subscription list to add subscriber to. */ - layer = &node->layer[layer_id]; - if(type == VN_FORMAT_REAL64 && (layer->type == VN_G_LAYER_VERTEX_XYZ || layer->type == VN_G_LAYER_VERTEX_REAL || - layer->type == VN_G_LAYER_POLYGON_CORNER_REAL || layer->type == VN_G_LAYER_POLYGON_FACE_REAL)) - { - list = &node->layer[layer_id].subscribersd; - } - else - list = &node->layer[layer_id].subscribers; - - /* Add new subscriptor to whichever list was chosen by precision-test above. Create list if necessary. */ - if(list == NULL) - return; - if(*list == NULL) - *list = vs_create_subscription_list(); - vs_add_new_subscriptor(*list); - - switch(layer->type) - { - case VN_G_LAYER_VERTEX_XYZ : - if(type == VN_FORMAT_REAL64) - { - for(i = 0; i < node->vertex_size; i++) - if(((real64 *)node->layer[0].layer)[i * 3] != V_REAL64_MAX) - verse_send_g_vertex_set_xyz_real64(node_id, layer_id, i, ((real64 *)layer->layer)[i * 3], ((real64 *)layer->layer)[i * 3 + 1], ((real64 *)layer->layer)[i * 3 + 2]); - }else - { - for(i = 0; i < node->vertex_size; i++) - if(((real64 *)node->layer[0].layer)[i * 3] != V_REAL64_MAX) - verse_send_g_vertex_set_xyz_real32(node_id, layer_id, i, (float)((real64 *)layer->layer)[i * 3], (float)((real64 *)layer->layer)[i * 3 + 1], (float)((real64 *)layer->layer)[i * 3 + 2]); - } - break; - case VN_G_LAYER_VERTEX_UINT32 : - for(i = 0; i < node->vertex_size; i++) - if(((real64 *)node->layer[0].layer)[i * 3] != V_REAL64_MAX && ((uint32 *)layer->layer)[i] != layer->def.integer) - verse_send_g_vertex_set_uint32(node_id, layer_id, i, ((uint32 *)layer->layer)[i]); - break; - case VN_G_LAYER_VERTEX_REAL : - if(type == VN_FORMAT_REAL64) - { - for(i = 0; i < node->vertex_size; i++) - if(((real64 *)node->layer[0].layer)[i * 3] != V_REAL64_MAX && ((real64 *)layer->layer)[i] != layer->def.real) - verse_send_g_vertex_set_real64(node_id, layer_id, i, ((real64 *)layer->layer)[i]); - }else - { - for(i = 0; i < node->vertex_size; i++) - if(((real64 *)node->layer[0].layer)[i * 3] != V_REAL64_MAX && ((real64 *)layer->layer)[i] != layer->def.real) - verse_send_g_vertex_set_real32(node_id, layer_id, i, (float)((real64 *)layer->layer)[i]); - } - break; - case VN_G_LAYER_POLYGON_CORNER_UINT32 : - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && !(((uint32 *)layer->layer)[i * 4] == layer->def.integer && ((uint32 *)layer->layer)[i * 4 + 1] == layer->def.integer && ((uint32 *)layer->layer)[i * 4 + 2] == layer->def.integer && ((uint32 *)layer->layer)[i * 4 + 3] == layer->def.integer)) - verse_send_g_polygon_set_corner_uint32(node_id, layer_id, i, ((uint32 *)layer->layer)[i * 4], ((uint32 *)layer->layer)[i * 4 + 1], ((uint32 *)layer->layer)[i * 4 + 2], ((uint32 *)layer->layer)[i * 4 + 3]); - break; - case VN_G_LAYER_POLYGON_CORNER_REAL : - if(type == VN_FORMAT_REAL64) - { - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && !(((real64 *)layer->layer)[i * 4] == layer->def.real && ((real64 *)layer->layer)[i * 4 + 1] == layer->def.real && ((real64 *)layer->layer)[i * 4 + 2] == layer->def.real && ((real64 *)layer->layer)[i * 4 + 3] == layer->def.real)) - verse_send_g_polygon_set_corner_real64(node_id, layer_id, i, ((real64 *)layer->layer)[i * 4], ((real64 *)layer->layer)[i * 4 + 1], ((real64 *)layer->layer)[i * 4 + 2], ((real64 *)layer->layer)[i * 4 + 3]); - }else - { - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && !(((real64 *)layer->layer)[i * 4] == layer->def.real && ((real64 *)layer->layer)[i * 4 + 1] == layer->def.real && ((real64 *)layer->layer)[i * 4 + 2] == layer->def.real && ((real64 *)layer->layer)[i * 4 + 3] == layer->def.real)) - verse_send_g_polygon_set_corner_real32(node_id, layer_id, i, (float)((real64 *)layer->layer)[i * 4], (float)((real64 *)layer->layer)[i * 4 + 1], (float)((real64 *)layer->layer)[i * 4 + 2], (float)((real64 *)layer->layer)[i * 4 + 3]); - } - break; - case VN_G_LAYER_POLYGON_FACE_UINT8 : - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && ((uint8 *)layer->layer)[i] != layer->def.integer) - verse_send_g_polygon_set_face_uint8(node_id, layer_id, i, ((uint8 *)layer->layer)[i]); - break; - case VN_G_LAYER_POLYGON_FACE_UINT32 : - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && ((uint32 *)layer->layer)[i] != layer->def.integer) - verse_send_g_polygon_set_face_uint32(node_id, layer_id, i, ((uint32 *)layer->layer)[i]); - break; - case VN_G_LAYER_POLYGON_FACE_REAL : - if(type == VN_FORMAT_REAL64) - { - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && ((real64 *)layer->layer)[i] != layer->def.real) - verse_send_g_polygon_set_face_real64(node_id, layer_id, i, ((real64 *)layer->layer)[i]); - }else - { - for(i = 0; i < node->poly_size; i++) - if(((uint32 *)node->layer[1].layer)[i * 4] != (uint32) ~0u && ((real64 *)layer->layer)[i] != layer->def.real) - verse_send_g_polygon_set_face_real32(node_id, layer_id, i, (float)((real64 *)layer->layer)[i]); - } - break; - } -} - -static void callback_send_g_layer_unsubscribe(void *user, VNodeID node_id, VLayerID layer_id) -{ - VSNodeGeometry *node; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL) - return; - if(node->layer[layer_id].subscribers) - vs_remove_subscriptor(node->layer[layer_id].subscribers); - if(node->layer[layer_id].subscribersd) - vs_remove_subscriptor(node->layer[layer_id].subscribersd); -} - - -static unsigned int vs_g_extend_arrays(VSNodeGeometry *node, boolean vertex, boolean base_layer, unsigned int id) -{ - unsigned int i, j; - - if(base_layer && id == ~0u) - { - if(vertex) - { - while(node->vertex_hole < node->vertex_size && ((real64 *)node->layer[0].layer)[node->vertex_hole * 3] != V_REAL64_MAX) - node->vertex_hole++; - id = node->vertex_hole; - }else - { - while(node->polygon_hole < node->poly_size && ((uint32 *)node->layer[1].layer)[node->polygon_hole * 4] != ~0u) - node->polygon_hole++; - id = node->polygon_hole; - } - } - - if(vertex) - { - if(node->vertex_size + 4096 < id) - return -1; - if(node->vertex_size > id) - return id; - }else - { - if(node->poly_size + 4096 < id) - return -1; - if(node->poly_size > id) - return id; - } - - for(i = 0; i < node->layer_count; i++) - { - if((vertex && node->layer[i].type < VN_G_LAYER_POLYGON_CORNER_UINT32) || (!vertex && node->layer[i].type >= VN_G_LAYER_POLYGON_CORNER_UINT32)) - { - switch(node->layer[i].type) - { - case VN_G_LAYER_VERTEX_XYZ : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(real64) * (id + VS_G_LAYER_CHUNK) * 3); - for(j = node->vertex_size * 3; j < (id + VS_G_LAYER_CHUNK) * 3; j++) - ((real64 *)node->layer[i].layer)[j] = V_REAL64_MAX; - break; - case VN_G_LAYER_VERTEX_UINT32 : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(uint32) * (id + VS_G_LAYER_CHUNK)); - for(j = node->vertex_size; j < (id + VS_G_LAYER_CHUNK); j++) - ((uint32 *)node->layer[i].layer)[j] = node->layer[i].def.integer; - break; - case VN_G_LAYER_VERTEX_REAL : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(real64) * (id + VS_G_LAYER_CHUNK)); - for(j = node->vertex_size; j < (id + VS_G_LAYER_CHUNK); j++) - ((real64 *)node->layer[i].layer)[j] = node->layer[i].def.real; - break; - case VN_G_LAYER_POLYGON_CORNER_UINT32 : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(uint32) * (id + VS_G_LAYER_CHUNK) * 4); - for(j = node->poly_size * 4; j < (id + VS_G_LAYER_CHUNK) * 4; j++) - ((uint32 *)node->layer[i].layer)[j] = node->layer[i].def.integer; - break; - case VN_G_LAYER_POLYGON_CORNER_REAL : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(real64) * (id + VS_G_LAYER_CHUNK) * 4); - for(j = node->poly_size * 4; j < (id + VS_G_LAYER_CHUNK) * 4; j++) - ((real64 *)node->layer[i].layer)[j] = node->layer[i].def.real; - break; - case VN_G_LAYER_POLYGON_FACE_UINT8 : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(uint8) * (id + VS_G_LAYER_CHUNK)); - for(j = node->poly_size; j < (id + VS_G_LAYER_CHUNK); j++) - ((uint8 *)node->layer[i].layer)[j] = node->layer[i].def.integer; - break; - case VN_G_LAYER_POLYGON_FACE_UINT32 : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(uint32) * (id + VS_G_LAYER_CHUNK)); - for(j = node->poly_size; j < (id + VS_G_LAYER_CHUNK); j++) - ((uint32 *)node->layer[i].layer)[j] = node->layer[i].def.integer; - break; - case VN_G_LAYER_POLYGON_FACE_REAL : - node->layer[i].layer = realloc(node->layer[i].layer, sizeof(real64) * (id + VS_G_LAYER_CHUNK)); - for(j = node->poly_size; j < (id + VS_G_LAYER_CHUNK); j++) - ((real64 *)node->layer[i].layer)[j] = node->layer[i].def.real; - break; - } - } - } - if(vertex) - node->vertex_size = id + VS_G_LAYER_CHUNK; - else - node->poly_size = id + VS_G_LAYER_CHUNK; - return id; -} - - -static void callback_send_g_vertex_set_xyz_real32(void *user, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, float x, float y, float z) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_VERTEX_XYZ) - return; - if((vertex_id = vs_g_extend_arrays(node, TRUE, layer_id == 0, vertex_id)) == ~0u) - return; - if(((real64 *)node->layer[0].layer)[vertex_id * 3] == V_REAL64_MAX) - { - for(i = 0; i < node->layer_count; i++) - { - if(node->layer[i].name[0] != 0 && node->layer[i].type == VN_G_LAYER_VERTEX_XYZ && node->layer[i].layer != NULL) - { - ((real64 *)node->layer[i].layer)[vertex_id * 3] = x; - ((real64 *)node->layer[i].layer)[vertex_id * 3 + 1] = y; - ((real64 *)node->layer[i].layer)[vertex_id * 3 + 2] = z; - } - } - layer_id = 0; - }else - { - ((real64 *)node->layer[layer_id].layer)[vertex_id * 3] = x; - ((real64 *)node->layer[layer_id].layer)[vertex_id * 3 + 1] = y; - ((real64 *)node->layer[layer_id].layer)[vertex_id * 3 + 2] = z; - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_vertex_set_xyz_real64(node_id, layer_id, vertex_id, (real64)x, (real64)y, (real64)z); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_vertex_set_xyz_real32(node_id, layer_id, vertex_id, x, y, z); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_vertex_set_xyz_real64(void *user, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 x, real64 y, real64 z) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_VERTEX_XYZ) - return; - if((vertex_id = vs_g_extend_arrays(node, TRUE, layer_id == 0, vertex_id)) == ~0u) - return; - if(((real64 *)node->layer[0].layer)[vertex_id * 3] == V_REAL64_MAX) - { - for(i = 0; i < node->layer_count; i++) - { - if(node->layer[i].name[0] != 0 && node->layer[i].type == VN_G_LAYER_VERTEX_XYZ && node->layer[i].layer != NULL) - { - ((real64 *)node->layer[i].layer)[vertex_id * 3] = x; - ((real64 *)node->layer[i].layer)[vertex_id * 3 + 1] = y; - ((real64 *)node->layer[i].layer)[vertex_id * 3 + 2] = z; - } - } - layer_id = 0; - }else - { - ((real64 *)node->layer[layer_id].layer)[vertex_id * 3] = x; - ((real64 *)node->layer[layer_id].layer)[vertex_id * 3 + 1] = y; - ((real64 *)node->layer[layer_id].layer)[vertex_id * 3 + 2] = z; - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_vertex_set_xyz_real64(node_id, layer_id, vertex_id, x, y, z); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_vertex_set_xyz_real32(node_id, layer_id, vertex_id, (float)x, (float)y, (float)z); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_vertex_delete_real(void *user, VNodeID node_id, uint32 vertex_id) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(vertex_id >= node->vertex_size) - return; - if(vertex_id < node->vertex_hole) - node->vertex_hole = vertex_id; - for(i = 0; i < node->layer_count; i++) - if(node->layer[i].name[0] != 0 && node->layer[i].type == VN_G_LAYER_VERTEX_XYZ && node->layer[i].layer != NULL) - ((real64 *)node->layer[i].layer)[vertex_id * 3] = V_REAL64_MAX; - count = vs_get_subscript_count(node->layer[0].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[0].subscribers, i); - verse_send_g_vertex_delete_real32(node_id, vertex_id); - } - count = vs_get_subscript_count(node->layer[0].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[0].subscribersd, i); - verse_send_g_vertex_delete_real64(node_id, vertex_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_vertex_set_uint32(void *user, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, uint32 value) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_VERTEX_UINT32) - return; - if((vertex_id = vs_g_extend_arrays(node, TRUE, FALSE, vertex_id)) == ~0u) - return; - ((uint32 *)node->layer[layer_id].layer)[vertex_id] = value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_vertex_set_uint32(node_id, layer_id, vertex_id, value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_vertex_set_real64(void *user, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, real64 value) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_VERTEX_REAL) - return; - if((vertex_id = vs_g_extend_arrays(node, TRUE, FALSE, vertex_id)) == ~0u) - return; - ((real64 *)node->layer[layer_id].layer)[vertex_id] = value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_vertex_set_real32(node_id, layer_id, vertex_id, (float)value); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_vertex_set_real64(node_id, layer_id, vertex_id, value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_vertex_set_real32(void *user, VNodeID node_id, VLayerID layer_id, uint32 vertex_id, float value) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_VERTEX_REAL) - return; - if((vertex_id = vs_g_extend_arrays(node, TRUE, FALSE, vertex_id)) == ~0u) - return; - ((real64 *)node->layer[layer_id].layer)[vertex_id] = (real64)value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_vertex_set_real32(node_id, layer_id, vertex_id, value); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_vertex_set_real64(node_id, layer_id, vertex_id, (real64)value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_corner_uint32(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 v0, uint32 v1, uint32 v2, uint32 v3) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_CORNER_UINT32) - return; - if(layer_id == 1 && (v0 == v1 || v1 == v2 || v2 == v3 || v3 == v0 || v0 == v2 || v1 == v3)) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, layer_id == 1, polygon_id)) == ~0u) - return; - ((uint32 *)node->layer[layer_id].layer)[polygon_id * 4] = v0; - ((uint32 *)node->layer[layer_id].layer)[polygon_id * 4 + 1] = v1; - ((uint32 *)node->layer[layer_id].layer)[polygon_id * 4 + 2] = v2; - ((uint32 *)node->layer[layer_id].layer)[polygon_id * 4 + 3] = v3; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_corner_uint32(node_id, layer_id, polygon_id, v0, v1, v2, v3); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_corner_real64(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 v0, real64 v1, real64 v2, real64 v3) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_CORNER_REAL) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, FALSE, polygon_id)) == ~0u) - return; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4] = v0; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4 + 1] = v1; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4 + 2] = v2; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4 + 3] = v3; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_corner_real32(node_id, layer_id, polygon_id, (float)v0, (float)v1, (float)v2, (float)v3); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_polygon_set_corner_real64(node_id, layer_id, polygon_id, v0, v1, v2, v3); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_corner_real32(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, float v0, float v1, float v2, float v3) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_CORNER_REAL) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, FALSE, polygon_id)) == ~0u) - return; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4] = v0; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4 + 1] = v1; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4 + 2] = v2; - ((real64 *)node->layer[layer_id].layer)[polygon_id * 4 + 3] = v3; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_corner_real32(node_id, layer_id, polygon_id, v0, v1, v2, v3); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_polygon_set_corner_real64(node_id, layer_id, polygon_id, (real64)v0, (real64)v1, (real64)v2, (real64)v3); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_face_uint8(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint8 value) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_FACE_UINT8) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, FALSE, polygon_id)) == ~0u) - return; - ((uint8 *)node->layer[layer_id].layer)[polygon_id] = value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_face_uint8(node_id, layer_id, polygon_id, value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_face_uint32(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, uint32 value) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_FACE_UINT32) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, FALSE, polygon_id)) == ~0u) - return; - ((uint32 *)node->layer[layer_id].layer)[polygon_id] = value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_face_uint32(node_id, layer_id, polygon_id, value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_face_real64(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, real64 value) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_FACE_REAL) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, FALSE, polygon_id)) == ~0u) - return; - ((real64 *)node->layer[layer_id].layer)[polygon_id] = value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_face_real32(node_id, layer_id, polygon_id, (float)value); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_polygon_set_face_real64(node_id, layer_id, polygon_id, value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_set_face_real32(void *user, VNodeID node_id, VLayerID layer_id, uint32 polygon_id, float value) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(layer_id >= node->layer_count || node->layer[layer_id].layer == NULL || node->layer[layer_id].type != VN_G_LAYER_POLYGON_FACE_REAL) - return; - if((polygon_id = vs_g_extend_arrays(node, FALSE, FALSE, polygon_id)) == ~0u) - return; - ((real64 *)node->layer[layer_id].layer)[polygon_id] = (real64)value; - count = vs_get_subscript_count(node->layer[layer_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribers, i); - verse_send_g_polygon_set_face_real32(node_id, layer_id, polygon_id, value); - } - count = vs_get_subscript_count(node->layer[layer_id].subscribersd); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[layer_id].subscribersd, i); - verse_send_g_polygon_set_face_real64(node_id, layer_id, polygon_id, (real64)value); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_polygon_delete(void *user, VNodeID node_id, uint32 polygon_id) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - - if(polygon_id >= node->poly_size || ((uint32 *)node->layer[1].layer)[polygon_id * 4] == ~0u) - return; - if(polygon_id < node->polygon_hole) - node->polygon_hole = polygon_id; - - ((uint32 *)node->layer[1].layer)[polygon_id * 4] = ~0u; - count = vs_get_subscript_count(node->layer[1].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->layer[1].subscribers, i); - verse_send_g_polygon_delete(node_id, polygon_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_crease_set_vertex(void *user, VNodeID node_id, const char *layer, uint32 def_crease) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - node->crease_vertex = def_crease; - v_strlcpy(node->crease_vertex_layer, layer, sizeof node->crease_vertex_layer); - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_g_crease_set_vertex(node_id, layer, def_crease); - } - vs_reset_subscript_session(); -} - -static void callback_send_g_crease_set_edge(void *user, VNodeID node_id, const char *layer, uint32 def_crease) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - node->crease_edge = def_crease; - v_strlcpy(node->crease_edge_layer, layer, sizeof node->crease_edge_layer); - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_g_crease_set_edge(node_id, layer, def_crease); - } - vs_reset_subscript_session(); -} - -void callback_send_g_bone_create(void *user, VNodeID node_id, uint16 bone_id, const char *weight, - const char *reference, uint16 parent, - real64 pos_x, real64 pos_y, real64 pos_z, - const char *position_label, const char *rotation_label, const char *scale_label) -{ - VSNodeGeometry *node; - unsigned int i, count; - - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(bone_id >= node->bone_count || node->bones[bone_id].weight[0] == '\0') - { - /* Find free bone to re-use, if any. */ - for(bone_id = 0; bone_id < node->bone_count && node->bones[bone_id].weight[0] != '\0'; bone_id++) - ; - if(bone_id == node->bone_count) - { - bone_id = node->bone_count; - node->bone_count += 16; - node->bones = realloc(node->bones, (sizeof *node->bones) * node->bone_count); - for(i = bone_id; i < node->bone_count; i++) - node->bones[i].weight[0] = '\0'; - } - } - v_strlcpy(node->bones[bone_id].weight, weight, sizeof node->bones[bone_id].weight); - v_strlcpy(node->bones[bone_id].reference, reference, sizeof node->bones[bone_id].reference); - node->bones[bone_id].parent = parent; - node->bones[bone_id].pos_x = pos_x; - node->bones[bone_id].pos_y = pos_y; - node->bones[bone_id].pos_z = pos_z; - v_strlcpy(node->bones[bone_id].position_label, position_label, sizeof node->bones[bone_id].position_label); - v_strlcpy(node->bones[bone_id].rotation_label, rotation_label, sizeof node->bones[bone_id].rotation_label); - v_strlcpy(node->bones[bone_id].scale_label, scale_label, sizeof node->bones[bone_id].scale_label); - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_g_bone_create(node_id, bone_id, weight, reference, parent, pos_x, pos_y, pos_z, position_label, rotation_label, scale_label); - } - vs_reset_subscript_session(); -} - -void callback_send_g_bone_destroy(void *user, VNodeID node_id, uint32 bone_id) -{ - VSNodeGeometry *node; - unsigned int i, count; - node = (VSNodeGeometry *)vs_get_node(node_id, V_NT_GEOMETRY); - if(node == NULL) - return; - if(bone_id >= node->bone_count || node->bones[bone_id].weight[0] == 0) - return; - node->bones[bone_id].weight[0] = 0; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_g_bone_destroy(node_id, bone_id); - } - vs_reset_subscript_session(); -} - -void vs_g_callback_init(void) -{ - verse_callback_set(verse_send_g_layer_create, callback_send_g_layer_create, NULL); - verse_callback_set(verse_send_g_layer_destroy, callback_send_g_layer_destroy, NULL); - verse_callback_set(verse_send_g_layer_subscribe, callback_send_g_layer_subscribe, NULL); - verse_callback_set(verse_send_g_layer_unsubscribe, callback_send_g_layer_unsubscribe, NULL); - verse_callback_set(verse_send_g_vertex_set_xyz_real32, callback_send_g_vertex_set_xyz_real32, NULL); - verse_callback_set(verse_send_g_vertex_set_xyz_real64, callback_send_g_vertex_set_xyz_real64, NULL); - verse_callback_set(verse_send_g_vertex_set_uint32, callback_send_g_vertex_set_uint32, NULL); - verse_callback_set(verse_send_g_vertex_set_real32, callback_send_g_vertex_set_real32, NULL); - verse_callback_set(verse_send_g_vertex_set_real64, callback_send_g_vertex_set_real64, NULL); - verse_callback_set(verse_send_g_vertex_delete_real32, callback_send_g_vertex_delete_real, NULL); - verse_callback_set(verse_send_g_vertex_delete_real64, callback_send_g_vertex_delete_real, NULL); - verse_callback_set(verse_send_g_polygon_set_corner_uint32, callback_send_g_polygon_set_corner_uint32, NULL); - verse_callback_set(verse_send_g_polygon_set_corner_real32, callback_send_g_polygon_set_corner_real32, NULL); - verse_callback_set(verse_send_g_polygon_set_corner_real64, callback_send_g_polygon_set_corner_real64, NULL); - verse_callback_set(verse_send_g_polygon_set_face_uint8, callback_send_g_polygon_set_face_uint8, NULL); - verse_callback_set(verse_send_g_polygon_set_face_uint32, callback_send_g_polygon_set_face_uint32, NULL); - verse_callback_set(verse_send_g_polygon_set_face_real32, callback_send_g_polygon_set_face_real32, NULL); - verse_callback_set(verse_send_g_polygon_set_face_real64, callback_send_g_polygon_set_face_real64, NULL); - verse_callback_set(verse_send_g_polygon_delete, callback_send_g_polygon_delete, NULL); - verse_callback_set(verse_send_g_crease_set_vertex, callback_send_g_crease_set_vertex, NULL); - verse_callback_set(verse_send_g_crease_set_edge, callback_send_g_crease_set_edge, NULL); - verse_callback_set(verse_send_g_bone_create, callback_send_g_bone_create, NULL); - verse_callback_set(verse_send_g_bone_destroy, callback_send_g_bone_destroy, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_head.c b/extern/verse/dist/vs_node_head.c deleted file mode 100644 index 9e926411542..00000000000 --- a/extern/verse/dist/vs_node_head.c +++ /dev/null @@ -1,414 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined(V_GENERATE_FUNC_MODE) - -#include "verse.h" -#include "v_util.h" -#include "vs_server.h" - -typedef struct { - VNTag tag; - VNTagType type; - char tag_name[16]; -} VSTag; - -typedef struct { - VSTag *tags; - unsigned int tag_count; - char group_name[16]; - VSSubscriptionList *subscribers; -} VSTagGroup; - -void create_node_head(VSNodeHead *node, const char *name, unsigned int owner) -{ - size_t len; - - len = strlen(name) + 1; - node->name = malloc(len); - v_strlcpy(node->name, name, len); - node->owner = owner; - node->tag_groups = NULL; - node->group_count = 0; - node->subscribers = vs_create_subscription_list(); -} - -void destroy_node_head(VSNodeHead *node) -{ - unsigned int i, j; - if(node->name != NULL) - free(node->name); - if(node->tag_groups != NULL) - { - for(i = 0; i < node->group_count; i++) - { - for(j = 0; j < ((VSTagGroup *)node->tag_groups)[i].tag_count; j++) - { - if(((VSTagGroup *)node->tag_groups)[i].tags[j].type == VN_TAG_STRING) - free(((VSTagGroup *)node->tag_groups)[i].tags[j].tag.vstring); - if(((VSTagGroup *)node->tag_groups)[i].tags[j].type == VN_TAG_BLOB) - free(((VSTagGroup *)node->tag_groups)[i].tags[j].tag.vblob.blob); - } - if(((VSTagGroup *)node->tag_groups)[i].tags != NULL) - free(((VSTagGroup *)node->tag_groups)[i].tags); - } - if(node->tag_groups != NULL) - free(node->tag_groups); - } -} - - void callback_send_tag_group_create(void *user, VNodeID node_id, uint16 group_id, const char *name) -{ - VSNodeHead *node; - unsigned int count, i, j, element; - - if((node = vs_get_node_head(node_id)) == 0) - return; - if(name[0] == 0) - return; - - for(i = 0; i < node->group_count; i++) /* see if a tag group with this name alredy exists*/ - { - if(((VSTagGroup *)node->tag_groups)[i].group_name[0] != 0) - { - for(j = 0; name[j] == ((VSTagGroup *)node->tag_groups)[i].group_name[j] && name[j] != 0; j++); - if(name[j] == ((VSTagGroup *)node->tag_groups)[i].group_name[j]) - return; - } - } - if(group_id < node->group_count && ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] != 0) /* rename existing group */ - { - element = group_id; - }else /* create new game group */ - { - for(element = 0; element < node->group_count && ((VSTagGroup *)node->tag_groups)[element].group_name[0] != 0; element++); - if(element == node->group_count) - { - node->tag_groups = realloc(node->tag_groups, sizeof(VSTagGroup) * (node->group_count + 16)); - for(i = node->group_count; i < node->group_count + 16U; i++) - { - ((VSTagGroup *)node->tag_groups)[i].group_name[0] = 0; - ((VSTagGroup *)node->tag_groups)[i].tags = NULL; - ((VSTagGroup *)node->tag_groups)[i].tag_count = 0; - ((VSTagGroup *)node->tag_groups)[i].subscribers = NULL; - } - node->group_count += 16; - } - ((VSTagGroup *)node->tag_groups)[element].subscribers = vs_create_subscription_list(); - } - v_strlcpy(((VSTagGroup *)node->tag_groups)[element].group_name, name, - sizeof ((VSTagGroup *)node->tag_groups)[element].group_name); - - count = vs_get_subscript_count(node->subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->subscribers, i); - verse_send_tag_group_create(node_id, element, name); - } - vs_reset_subscript_session(); -} - -static void callback_send_tag_group_destroy(void *user, VNodeID node_id, uint16 group_id) -{ - VSNodeHead *node; - unsigned int count, i; - if((node = vs_get_node_head(node_id)) == 0) - return; - - if(node->group_count <= group_id || ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] == 0) - return; - - vs_destroy_subscription_list(((VSTagGroup *)node->tag_groups)[group_id].subscribers); - for(i = 0; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count; i++) - { - if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].type == VN_TAG_STRING) - free(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag.vstring); - if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].type == VN_TAG_BLOB) - free(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag.vblob.blob); - } - if(((VSTagGroup *)node->tag_groups)[group_id].tags != NULL) - free(((VSTagGroup *)node->tag_groups)[group_id].tags); - ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] = 0; - ((VSTagGroup *)node->tag_groups)[group_id].tags = NULL; - ((VSTagGroup *)node->tag_groups)[group_id].tag_count = 0; - - count = vs_get_subscript_count(node->subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->subscribers, i); - verse_send_tag_group_destroy(node_id, group_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_tag_group_subscribe(void *user, VNodeID node_id, uint16 group_id) -{ - VSNodeHead *node; - unsigned int i; - if((node = vs_get_node_head(node_id)) == 0) - return; - - if(group_id < node->group_count && ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] != 0) - { - vs_add_new_subscriptor(((VSTagGroup *)node->tag_groups)[group_id].subscribers); - for(i = 0; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count; i++) - { - if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[0] != 0) - { - verse_send_tag_create(node_id, group_id, (uint16)i, ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name, ((VSTagGroup *)node->tag_groups)[group_id].tags[i].type, &((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag); - } - } - } -} - -static void callback_send_tag_group_unsubscribe(void *user, VNodeID node_id, uint16 group_id) -{ - VSNodeHead *node; - if((node = vs_get_node_head(node_id)) == 0) - return; - if(group_id < node->group_count && ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] != 0) - vs_remove_subscriptor(((VSTagGroup *)node->tag_groups)[group_id].subscribers); -} - -static void callback_send_tag_create(void *user, VNodeID node_id, uint16 group_id, uint16 tag_id, char *name, uint8 type, void *tag) -{ - VSNodeHead *node; - VSTag *t = NULL; - unsigned int i, count; - - if((node = vs_get_node_head(node_id)) == 0) - return; - if(group_id >= node->group_count || ((VSTagGroup *)node->tag_groups)[group_id].group_name[0] == 0) - return; - -/* for(i = 0; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count; i++) - { - if(((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name != NULL && i != tag_id) - { - for(j = 0; name[j] == ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[j] && name[j] != 0; j++); - if(name[j] == ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[j]) - return; - } - }*/ - if(tag_id < ((VSTagGroup *)node->tag_groups)[group_id].tag_count && ((VSTagGroup *)node->tag_groups)[group_id].tags[tag_id].tag_name[0] != 0) - ; - else - { - for(tag_id = 0; tag_id < ((VSTagGroup *)node->tag_groups)[group_id].tag_count && ((VSTagGroup *)node->tag_groups)[group_id].tags[tag_id].tag_name[0] != 0; tag_id++) - ; - if(tag_id == ((VSTagGroup *)node->tag_groups)[group_id].tag_count) - { - ((VSTagGroup *)node->tag_groups)[group_id].tags = realloc(((VSTagGroup *)node->tag_groups)[group_id].tags, sizeof(VSTag) * (((VSTagGroup *)node->tag_groups)[group_id].tag_count + 16)); - for(i = tag_id; i < ((VSTagGroup *)node->tag_groups)[group_id].tag_count + 16; i++) - ((VSTagGroup *)node->tag_groups)[group_id].tags[i].tag_name[0] = 0; - ((VSTagGroup *)node->tag_groups)[group_id].tag_count += 16; - } - } - t = &((VSTagGroup *)node->tag_groups)[group_id].tags[tag_id]; - if(t->tag_name[0] != '\0') /* Old tag being re-set? */ - { - if(t->type == VN_TAG_STRING) - free(t->tag.vstring); - else if(t->type == VN_TAG_BLOB) - free(t->tag.vblob.blob); - } - t->type = type; - v_strlcpy(t->tag_name, name, sizeof t->tag_name); - switch(type) - { - case VN_TAG_BOOLEAN : - t->tag.vboolean = ((VNTag *)tag)->vboolean; - break; - case VN_TAG_UINT32 : - t->tag.vuint32 = ((VNTag *)tag)->vuint32; - break; - case VN_TAG_REAL64 : - t->tag.vreal64 = ((VNTag *)tag)->vreal64; - break; - case VN_TAG_STRING : - i = strlen(((VNTag *) tag)->vstring); - t->tag.vstring = malloc(i + 1); - strcpy(t->tag.vstring, ((VNTag *) tag)->vstring); - break; - case VN_TAG_REAL64_VEC3 : - t->tag.vreal64_vec3[0] = ((VNTag *)tag)->vreal64_vec3[0]; - t->tag.vreal64_vec3[1] = ((VNTag *)tag)->vreal64_vec3[1]; - t->tag.vreal64_vec3[2] = ((VNTag *)tag)->vreal64_vec3[2]; - break; - case VN_TAG_LINK : - t->tag.vlink = ((VNTag *)tag)->vlink; - break; - case VN_TAG_ANIMATION : - t->tag.vanimation.curve = ((VNTag *)tag)->vanimation.curve; - t->tag.vanimation.start = ((VNTag *)tag)->vanimation.start; - t->tag.vanimation.end = ((VNTag *)tag)->vanimation.end; - break; - case VN_TAG_BLOB : - t->tag.vblob.blob = malloc(((VNTag *)tag)->vblob.size); - t->tag.vblob.size = ((VNTag *)tag)->vblob.size; - memcpy(t->tag.vblob.blob, ((VNTag *)tag)->vblob.blob, ((VNTag *)tag)->vblob.size); - break; - } - - count = vs_get_subscript_count(((VSTagGroup *) node->tag_groups)[group_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(((VSTagGroup *) node->tag_groups)[group_id].subscribers, i); - verse_send_tag_create(node_id, group_id, tag_id, name, type, tag); - } - vs_reset_subscript_session(); -} - -static void callback_send_tag_destroy(void *user, VNodeID node_id, uint16 group_id, uint16 tag_id) -{ - VSNodeHead *node; - unsigned int count, i; - if((node = vs_get_node_head(node_id)) == 0) - return; - - count = vs_get_subscript_count(((VSTagGroup *) node->tag_groups)[group_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(((VSTagGroup *) node->tag_groups)[group_id].subscribers, i); - verse_send_tag_destroy(node_id, group_id, tag_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_node_name_set(void *user, VNodeID node_id, char *name) -{ - VSNodeHead *node; - unsigned int count, i; - size_t len; - - if((node = vs_get_node_head(node_id)) == 0) - return; - len = strlen(name); - if(len == 0) - return; - free(node->name); - len++; - node->name = malloc(len); - v_strlcpy(node->name, name, len); - count = vs_get_subscript_count(node->subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->subscribers, i); - verse_send_node_name_set(node_id, name); - } - vs_reset_subscript_session(); -} - -extern void vs_o_subscribe(VSNodeHead *node); -extern void vs_g_subscribe(VSNodeHead *node); -extern void vs_m_subscribe(VSNodeHead *node); -extern void vs_b_subscribe(VSNodeHead *node); -extern void vs_t_subscribe(VSNodeHead *node); -extern void vs_c_subscribe(VSNodeHead *node); -extern void vs_a_subscribe(VSNodeHead *node); - -static void callback_send_node_subscribe(void *user, VNodeID node_id) -{ - unsigned int i; - VSNodeHead *node; - - if((node = vs_get_node_head(node_id)) == NULL) - return; - switch(node->type) - { - case V_NT_OBJECT : - vs_o_subscribe(node); - break; - case V_NT_GEOMETRY : - vs_g_subscribe(node); - break; - case V_NT_MATERIAL : - vs_m_subscribe(node); - break; - case V_NT_BITMAP : - vs_b_subscribe(node); - break; - case V_NT_TEXT: - vs_t_subscribe(node); - break; - case V_NT_CURVE: - vs_c_subscribe(node); - break; - case V_NT_AUDIO: - vs_a_subscribe(node); - break; - default: - fprintf(stderr, "Not subscribing to node type %d\n", node->type); - } - verse_send_node_name_set(node->id, node->name); - for(i = 0; i < node->group_count; i++) - if(((VSTagGroup *)node->tag_groups)[i].group_name[0] != 0) - verse_send_tag_group_create(node->id, (uint16)i, ((VSTagGroup *)node->tag_groups)[i].group_name); - vs_add_new_subscriptor(node->subscribers); -} - -extern void vs_o_unsubscribe(VSNodeHead *node); -extern void vs_g_unsubscribe(VSNodeHead *node); -extern void vs_m_unsubscribe(VSNodeHead *node); -extern void vs_b_unsubscribe(VSNodeHead *node); -extern void vs_t_unsubscribe(VSNodeHead *node); -extern void vs_c_unsubscribe(VSNodeHead *node); -extern void vs_a_unsubscribe(VSNodeHead *node); - -static void callback_send_node_unsubscribe(void *user, VNodeID node_id) -{ - VSNodeHead *node; - - if((node = vs_get_node_head(node_id)) == NULL) - return; - vs_remove_subscriptor(node->subscribers); - - switch(node->type) - { - case V_NT_OBJECT : - vs_o_unsubscribe(node); - break; - case V_NT_GEOMETRY : - vs_g_unsubscribe(node); - break; - case V_NT_MATERIAL : - vs_m_unsubscribe(node); - break; - case V_NT_BITMAP : - vs_b_unsubscribe(node); - break; - case V_NT_TEXT: - vs_t_unsubscribe(node); - break; - case V_NT_CURVE: - vs_c_unsubscribe(node); - break; - case V_NT_AUDIO: - vs_a_unsubscribe(node); - break; - default: - fprintf(stderr, "Not unsubscribing from node type %d\n", node->type); - } -} - -void vs_h_callback_init(void) -{ - verse_callback_set(verse_send_tag_group_create, callback_send_tag_group_create, NULL); - verse_callback_set(verse_send_tag_group_destroy, callback_send_tag_group_destroy, NULL); - verse_callback_set(verse_send_tag_group_subscribe, callback_send_tag_group_subscribe, NULL); - verse_callback_set(verse_send_tag_group_unsubscribe, callback_send_tag_group_unsubscribe, NULL); - verse_callback_set(verse_send_tag_create, callback_send_tag_create, NULL); - verse_callback_set(verse_send_tag_destroy, callback_send_tag_destroy, NULL); - verse_callback_set(verse_send_node_name_set, callback_send_node_name_set, NULL); - verse_callback_set(verse_send_node_subscribe, callback_send_node_subscribe, NULL); - verse_callback_set(verse_send_node_unsubscribe, callback_send_node_unsubscribe, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_material.c b/extern/verse/dist/vs_node_material.c deleted file mode 100644 index b22c070e348..00000000000 --- a/extern/verse/dist/vs_node_material.c +++ /dev/null @@ -1,116 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -typedef struct { - VNMFragmentType type; - VMatFrag frag; -} VSMatFrag; - -typedef struct{ - VSNodeHead head; - VSMatFrag *frag; - unsigned int frag_count; -} VSNodeMaterial; - -VSNodeMaterial * vs_m_create_node(unsigned int owner) -{ - VSNodeMaterial *node; - char name[48]; - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_MATERIAL); - sprintf(name, "Material_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - node->frag = NULL; - node->frag_count = 0; - return node; -} - -void vs_m_destroy_node(VSNodeMaterial *node) -{ - destroy_node_head(&node->head); - free(node->frag); - free(node); -} - -void vs_m_subscribe(VSNodeMaterial *node) -{ - uint16 i; - for(i = 0; i < node->frag_count; i++) - if(node->frag[i].type <= VN_M_FT_OUTPUT) - verse_send_m_fragment_create(node->head.id, (uint16)i, (uint8)node->frag[i].type, &node->frag[i].frag); -} - -void vs_m_unsubscribe(VSNodeMaterial *node) -{ -} - -static void callback_send_m_fragment_create(void *user, VNodeID node_id, VNMFragmentID frag_id, uint8 type, VMatFrag *fragment) -{ - unsigned int count; - uint16 i; - VSNodeMaterial *node; - node = (VSNodeMaterial *)vs_get_node(node_id, V_NT_MATERIAL); - if(node == NULL) - return; - if(node->frag_count + 32 < frag_id) - frag_id = (uint16)-1; - if(frag_id == (uint16) ~0u) - for(frag_id = 0; frag_id < node->frag_count && node->frag[frag_id].type < VN_M_FT_OUTPUT + 1; frag_id++) - ; - if(frag_id >= node->frag_count) - { - node->frag = realloc(node->frag, (sizeof *node->frag) * (node->frag_count + 32)); - for(i = node->frag_count; i < (node->frag_count + 32); i++) - node->frag[i].type = 255; - node->frag_count += 32; - } - node->frag[frag_id].type = type; - node->frag[frag_id].frag = *fragment; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_m_fragment_create(node_id, frag_id, type, fragment); - } - vs_reset_subscript_session(); -} - -static void callback_send_m_fragment_destroy(void *user, VNodeID node_id, VNMFragmentID frag_id) -{ - unsigned int count, i; - VSNodeMaterial *node; - node = (VSNodeMaterial *)vs_get_node(node_id, V_NT_MATERIAL); - printf("callback_send_m_fragment_destroy %p\n", node); - if(node == NULL) - return; - if(node->frag_count <= frag_id || node->frag[frag_id].type > VN_M_FT_OUTPUT) - return; - node->frag[frag_id].type = 255; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_m_fragment_destroy(node_id, frag_id); - } - vs_reset_subscript_session(); -} - -void vs_m_callback_init(void) -{ - verse_callback_set(verse_send_m_fragment_create, callback_send_m_fragment_create, NULL); - verse_callback_set(verse_send_m_fragment_destroy, callback_send_m_fragment_destroy, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_object.c b/extern/verse/dist/vs_node_object.c deleted file mode 100644 index d269a8ddb99..00000000000 --- a/extern/verse/dist/vs_node_object.c +++ /dev/null @@ -1,837 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "v_util.h" -#include "vs_server.h" - -extern void verse_send_o_link_set(VNodeID node_id, uint16 link_id, VNodeID link, const char *name, uint32 target_id); -extern void verse_send_o_link_destroy(VNodeID node_id, uint16 link_id); - -typedef struct { - VNodeID link; - char name[16]; - uint32 target_id; - /* Animation parameters. */ - uint32 time_s; - uint32 time_f; - uint32 dimensions; - real64 pos[4]; - real64 speed[4]; - real64 accel[4]; - real64 scale[4]; - real64 scale_speed[4]; -} VSLink; - -typedef struct { - char name[16]; - uint8 param_count; - VNOParamType *param_types; - char *param_names; -} VSMethod; - -typedef struct { - char name[VN_O_METHOD_GROUP_NAME_SIZE]; - VSMethod *methods; - unsigned int method_count; - VSSubscriptionList *subscribers; -} VSMethodGroup; - -typedef struct { - real64 position[3]; - VNQuat64 rotation; - real64 scale[3]; -/* VSSubscriptionList *subscribers;*/ -} VSTransform; - -typedef struct { - VSNodeHead head; - VSTransform transform; - VSSubscriptionList *trans_sub64; - VSSubscriptionList *trans_sub32; - real64 light[3]; - VSMethodGroup *groups; - uint16 group_count; - VSLink *links; - uint16 link_count; - boolean hidden; -} VSNodeObject; - -VSNodeObject * vs_o_create_node(unsigned int owner) -{ - VSNodeObject *node; - unsigned int i, j; - char name[48]; - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_OBJECT); - sprintf(name, "Object_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - node->trans_sub64 = vs_create_subscription_list(); - node->trans_sub32 = vs_create_subscription_list(); - node->transform.position[0] = node->transform.position[1] = node->transform.position[2] = 0; - node->transform.rotation.x = node->transform.rotation.y = node->transform.rotation.z = 0.0; - node->transform.rotation.w = 1.0; - node->transform.scale[0] = node->transform.scale[1] = node->transform.scale[2] = 1.0; - node->light[0] = node->light[1] = node->light[2] = V_REAL64_MAX; - node->groups = malloc((sizeof *node->groups) * 16); - node->group_count = 16; - for(i = 0; i < 16; i++) - { - node->groups[i].name[0] = 0; - node->groups[i].methods = NULL; - node->groups[i].method_count = 0; - node->groups[i].subscribers = NULL; - } - - node->link_count = 16; - node->links = malloc((sizeof *node->links) * node->link_count); - for(i = 0; i < node->link_count; i++) - { - node->links[i].link = -1; - node->links[i].name[0] = 0; - node->links[i].target_id = -1; - node->links[i].dimensions = 0; - for(j = 0; j < 4; j++) - { - node->links[i].pos[j] = 0.0; - node->links[i].speed[j] = 0.0; - node->links[i].accel[j] = 0.0; - node->links[i].scale[j] = 0.0; - node->links[i].scale_speed[j] = 0.0; - } - } - node->hidden = FALSE; - return node; -} - -void vs_o_destroy_node(VSNodeObject *node) -{ - unsigned int i, j; - destroy_node_head(&node->head); - for(i = 0; i < node->group_count; i++) - { - if(node->groups[i].name[0] != 0) - { - for(j = 0; j < node->groups[i].method_count; j++) - { - if(node->groups[i].methods[j].name[0] != 0 && node->groups[i].methods[j].param_count != 0) - { - free(node->groups[i].methods[j].param_types); - free(node->groups[i].methods[j].param_names); - } - } - if(node->groups[i].methods != NULL) - free(node->groups[i].methods); - } - } - free(node->groups); - free(node); -} - -void vs_o_subscribe(VSNodeObject *node) -{ - unsigned int i; - for(i = 0; i < node->link_count; i++) - { - const VSLink *lnk = node->links + i; - - if(lnk->name[0] != 0) - { - verse_send_o_link_set(node->head.id, i, lnk->link, lnk->name, lnk->target_id); - if(lnk->dimensions != 0) - { - verse_send_o_anim_run(node->head.id, i, lnk->time_s, lnk->time_f, lnk->dimensions, - lnk->pos, lnk->speed, lnk->accel, - lnk->scale, lnk->scale_speed); - } - } - } - if(node->light[0] != V_REAL64_MAX || node->light[1] != V_REAL64_MAX || node->light[2] != V_REAL64_MAX) - verse_send_o_light_set(node->head.id, node->light[0], node->light[1], node->light[2]); - for(i = 0; i < node->group_count; i++) - { - if(node->groups[i].name[0] != 0) - verse_send_o_method_group_create(node->head.id, i, node->groups[i].name); - } - if(node->hidden) - verse_send_o_hide(node->head.id, TRUE); -} - -void vs_o_unsubscribe(VSNodeObject *node) -{ - unsigned int i; - for(i = 0; i < node->group_count; i++) - if(node->groups[i].name[0] != 0) - vs_remove_subscriptor(node->groups[i].subscribers); - vs_remove_subscriptor(node->trans_sub64); - vs_remove_subscriptor(node->trans_sub32); -} - -static void callback_send_o_transform_pos_real32(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, real32 *pos, real32 *speed, real32 *accelerate, real32 *drag_normal, real32 drag) -{ - VSNodeObject *node; - unsigned int i, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->transform.position[0] = pos[0]; - node->transform.position[1] = pos[1]; - node->transform.position[2] = pos[2]; - - if((count = vs_get_subscript_count(node->trans_sub64)) > 0) /* Anyone listening at 64 bits? */ - { - real64 spd[3], acc[3], drn[3], *pspd = NULL, *pacc = NULL, *pdrn = NULL; - - pspd = (speed != NULL) ? spd : NULL; - pacc = (accelerate != NULL) ? acc : NULL; - pdrn = (drag_normal != NULL) ? drn : NULL; - /* Convert non-position values to 64-bit. */ - for(i = 0; i < 3; i++) - { - if(speed != NULL) - spd[i] = speed[i]; - if(accelerate != NULL) - acc[i] = accelerate[i]; - if(drag_normal != NULL) - drn[i] = drag_normal[i]; - } - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub64, i); - verse_send_o_transform_pos_real64(node_id, time_s, time_f, node->transform.position, pspd, pacc, pdrn, drag); - } - } - count = vs_get_subscript_count(node->trans_sub32); - for(i = 0; i < count; i++) - { - - vs_set_subscript_session(node->trans_sub32, i); - verse_send_o_transform_pos_real32(node_id, time_s, time_f, pos, speed, accelerate, drag_normal, drag); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_transform_rot_real32(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat32 *rot, - const VNQuat32 *speed, const VNQuat32 *accelerate, const VNQuat32 *drag_normal, real32 drag) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->transform.rotation.x = rot->x; - node->transform.rotation.y = rot->y; - node->transform.rotation.z = rot->z; - node->transform.rotation.w = rot->w; - if((count = vs_get_subscript_count(node->trans_sub64)) > 0) - { - VNQuat64 spd, acc, drn, *p[3]; - - /* Convert 32-bit quaternions to 64-bit. Converter handles NULLs, has nice return semantics. */ - p[0] = v_quat64_from_quat32(&spd, speed); - p[1] = v_quat64_from_quat32(&acc, accelerate); - p[2] = v_quat64_from_quat32(&drn, drag_normal); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub64, i); - verse_send_o_transform_rot_real64(node_id, time_s, time_f, &node->transform.rotation, p[0], p[1], p[2], drag); - } - } - count = vs_get_subscript_count(node->trans_sub32); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub32, i); - verse_send_o_transform_rot_real32(node_id, time_s, time_f, rot, speed, accelerate, drag_normal, drag); - } - vs_reset_subscript_session(); -} - - -static void callback_send_o_transform_scale_real32(void *user, VNodeID node_id, real32 scale_x, real32 scale_y, real32 scale_z) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->transform.scale[0] = scale_x; - node->transform.scale[1] = scale_y; - node->transform.scale[2] = scale_z; - count = vs_get_subscript_count(node->trans_sub64); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub64, i); - verse_send_o_transform_scale_real64(node_id, scale_x, scale_y, scale_z); - } - count = vs_get_subscript_count(node->trans_sub32); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub32, i); - verse_send_o_transform_scale_real32(node_id, scale_x, scale_y, scale_z); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_transform_pos_real64(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, const real64 *pos, - const real64 *speed, const real64 *accelerate, const real64 *drag_normal, real64 drag) -{ - VSNodeObject *node; - unsigned int i, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->transform.position[0] = pos[0]; - node->transform.position[1] = pos[1]; - node->transform.position[2] = pos[2]; - count = vs_get_subscript_count(node->trans_sub64); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub64, i); - verse_send_o_transform_pos_real64(node_id, time_s, time_f, node->transform.position, speed, accelerate, drag_normal, drag); - } - if((count = vs_get_subscript_count(node->trans_sub32)) > 0) /* Anyone listening at 32 bits? */ - { - real32 ps[3], spd[3], acc[3], drn[3], *p[] = { NULL, NULL, NULL }; - - ps[0] = pos[0]; - ps[1] = pos[1]; - ps[2] = pos[2]; - if(speed != NULL) - { - p[0] = spd; - spd[0] = speed[0]; - spd[1] = speed[1]; - spd[2] = speed[2]; - } - else - p[0] = NULL; - if(accelerate != NULL) - { - p[1] = acc; - acc[0] = accelerate[0]; - acc[1] = accelerate[1]; - acc[2] = accelerate[2]; - } - else - p[1] = NULL; - if(drag_normal != NULL) - { - p[1] = drn; - drn[0] = drag_normal[0]; - drn[1] = drag_normal[1]; - drn[2] = drag_normal[2]; - } - else - p[2] = NULL; - - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub32, i); - verse_send_o_transform_pos_real32(node_id, time_s, time_f, ps, p[0], p[1], p[2], (real32) drag); - } - } - vs_reset_subscript_session(); -} - -static void callback_send_o_transform_rot_real64(void *user, VNodeID node_id, uint32 time_s, uint32 time_f, const VNQuat64 *rot, - const VNQuat64 *speed, const VNQuat64 *accelerate, const VNQuat64 *drag_normal, real64 drag) -{ - VSNodeObject *node; - unsigned int i, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->transform.rotation = *rot; - count = vs_get_subscript_count(node->trans_sub64); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub64, i); - verse_send_o_transform_rot_real64(node_id, time_s, time_f, &node->transform.rotation, speed, accelerate, drag_normal, drag); - } - if((count = vs_get_subscript_count(node->trans_sub32)) > 0) /* Anyone listening at 32 bits? */ - { - VNQuat32 rt, spd, acc, drn, *p[3]; - - v_quat32_from_quat64(&rt, rot); - p[0] = v_quat32_from_quat64(&spd, speed); - p[1] = v_quat32_from_quat64(&acc, accelerate); - p[2] = v_quat32_from_quat64(&drn, drag_normal); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub32, i); - verse_send_o_transform_rot_real32(node_id, time_s, time_f, &rt, p[0], p[1], p[2], (real32) drag); - } - } - vs_reset_subscript_session(); -} - -static void callback_send_o_transform_scale_real64(void *user, VNodeID node_id, real64 scale_x, real64 scale_y, real64 scale_z) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->transform.scale[0] = scale_x; - node->transform.scale[1] = scale_y; - node->transform.scale[2] = scale_z; - count = vs_get_subscript_count(node->trans_sub64); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub64, i); - verse_send_o_transform_scale_real64(node_id, scale_x, scale_y, scale_z); - } - count = vs_get_subscript_count(node->trans_sub32); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->trans_sub32, i); - verse_send_o_transform_scale_real32(node_id, (real32) scale_x, (real32) scale_y, (real32) scale_z); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_transform_subscribe(void *user, VNodeID node_id, VNRealFormat type) -{ - VSNodeObject *node; - uint32 time_s, time_f; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - verse_session_get_time(&time_s, &time_f); - if(type == VN_FORMAT_REAL32) - { - real32 tpos[3]; - VNQuat32 rot; - - vs_add_new_subscriptor(node->trans_sub32); - tpos[0] = node->transform.position[0]; - tpos[1] = node->transform.position[1]; - tpos[2] = node->transform.position[2]; - verse_send_o_transform_pos_real32(node_id, time_s, time_f, tpos, NULL, NULL, NULL, 0.0f); - v_quat32_from_quat64(&rot, &node->transform.rotation); - verse_send_o_transform_rot_real32(node_id, time_s, time_f, &rot, NULL, NULL, NULL, 0.0f); - verse_send_o_transform_scale_real32(node_id, (real32) node->transform.scale[0], (real32) node->transform.scale[1], (real32) node->transform.scale[2]); - } - else - { - vs_add_new_subscriptor(node->trans_sub64); - verse_send_o_transform_pos_real64(node_id, time_s, time_f, node->transform.position, NULL, NULL, NULL, 0); - verse_send_o_transform_rot_real64(node_id, time_s, time_f, &node->transform.rotation, NULL, NULL, NULL, 0); - verse_send_o_transform_scale_real64(node_id, node->transform.scale[0], node->transform.scale[1], node->transform.scale[2]); - } -} - -static void callback_send_o_transform_unsubscribe(void *user, VNodeID node_id, VNRealFormat type) -{ - VSNodeObject *node; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - if(type == VN_FORMAT_REAL32) - vs_remove_subscriptor(node->trans_sub32); - else - vs_remove_subscriptor(node->trans_sub64); -} - -static void callback_send_o_light_set(void *user, VNodeID node_id, real64 light_r, real64 light_g, real64 light_b) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - node->light[0] = light_r; - node->light[1] = light_g; - node->light[2] = light_b; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_light_set(node_id, light_r, light_g, light_b); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_link_set(void *user, VNodeID node_id, uint16 link_id, VNodeID link, const char *name, uint32 target_id) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - - if(node == NULL) - return; - - if(name[0] == 0) - return; - if(vs_get_node_head(link) == 0) - link = 0; - - if(link_id >= node->link_count || node->links[link_id].name[0] == 0) - { - for(link_id = 0; link_id < node->link_count && node->links[link_id].name[0] != 0; link_id++); - - if(link_id == node->link_count) - { - i = node->link_count; - node->link_count += 16; - node->links = realloc(node->links, (sizeof *node->links) * node->link_count); - for(; i < node->link_count; i++) - { - node->links[i].name[0] = 0; - node->links[i].dimensions = 0; - } - } - } - - node->links[link_id].link = link; - for(i = 0; i < 15 && name[i] != 0; i++) - node->links[link_id].name[i] = name[i]; - node->links[link_id].name[i] = 0; - node->links[link_id].target_id = target_id; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_link_set(node_id, link_id, link, name, target_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_link_destroy(void *user, VNodeID node_id, uint16 link_id) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - - if(link_id >= node->link_count || node->links[link_id].name[0] == 0) - return; - - node->links[link_id].name[0] = 0; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_link_destroy(node_id, link_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_method_group_create(void *user, VNodeID node_id, uint16 group_id, char *name) -{ - VSNodeObject *node; - unsigned int i, j, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - - for(i = 0; i < node->group_count; i++) - { - for(j = 0; node->groups[i].name[j] == name[j] && node->groups[i].name[j] != 0; j++); - if(node->groups[i].name[j] == name[j]) - return; - } - if(group_id >= node->group_count || node->groups[group_id].name[0] == 0) - { - for(group_id = 0; group_id < node->group_count && node->groups[group_id].name[0] != 0; group_id++) - if(group_id == node->group_count) - { - node->groups = realloc(node->groups, sizeof(*node->groups) * (node->group_count + 16)); - for(i = node->group_count; i < node->group_count + 16u; i++) - { - node->groups[i].name[0] = 0; - node->groups[i].methods = NULL; - node->groups[i].method_count = 0; - } - node->group_count += 16; - } - node->groups[group_id].subscribers = vs_create_subscription_list(); - } - for(i = 0; i < 15 && name[i] != 0; i++) - node->groups[group_id].name[i] = name[i]; - node->groups[group_id].name[i] = 0; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_method_group_create(node_id, group_id, name); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_method_group_destroy(void *user, VNodeID node_id, uint16 group_id) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - - if(group_id >= node->group_count || node->groups[group_id].name[0] == 0) - return; - node->groups[group_id].name[0] = 0; - for(i = 0; i < node->groups[group_id].method_count; i++) - { - if(node->groups[group_id].methods[i].name[0] != 0 && node->groups[group_id].methods[i].param_count > 0) - { - free(node->groups[group_id].methods[i].param_names); - free(node->groups[group_id].methods[i].param_types); - } - } - free(node->groups[group_id].methods); - node->groups[group_id].methods = NULL; - node->groups[group_id].method_count = 0; - vs_destroy_subscription_list(node->groups[group_id].subscribers); - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_method_group_destroy(node_id, group_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_method_group_subscribe(void *user, VNodeID node_id, uint16 group_id) -{ - VSNodeObject *node; - unsigned int i, j; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - if(group_id < node->group_count && node->groups[group_id].name[0] != 0) - vs_add_new_subscriptor(node->groups[group_id].subscribers); - for(i = 0; i < node->groups[group_id].method_count; i++) - { - if(node->groups[group_id].methods[i].name[0] != 0) - { - char *names[255]; - for(j = 0; j < node->groups[group_id].methods[i].param_count; j++) - names[j] = &node->groups[group_id].methods[i].param_names[j * 16]; - verse_send_o_method_create(node_id, group_id, i, node->groups[group_id].methods[i].name, node->groups[group_id].methods[i].param_count, node->groups[group_id].methods[i].param_types, (const char **) names); - } - } -} - -static void callback_send_o_method_group_unsubscribe(void *user, VNodeID node_id, uint16 group_id) -{ - VSNodeObject *node; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - if(group_id < node->group_count && node->groups[group_id].name[0] != 0) - vs_remove_subscriptor(node->groups[group_id].subscribers); -} - -static void callback_send_o_method_create(void *user, VNodeID node_id, uint16 group_id, uint16 method_id, char *name, uint8 param_count, VNOParamType *param_types, char * *param_names) -{ - VSNodeObject *node; - unsigned int i, j, count; - VSMethodGroup *group; - - node = (VSNodeObject *) vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - if(group_id >= node->group_count || node->groups[group_id].name[0] == 0) - return; - group = &node->groups[group_id]; - for(i = 0; i < group->method_count; i++) - { - if(i != method_id) - { - for(j = 0; group->methods[i].name[j] == name[j] && group->methods[i].name[j] != 0; j++); - if(group->methods[i].name[j] == name[j]) - return; - } - } - if(method_id < group->method_count && group->methods[method_id].name[0] != 0) - { - for(i = 0; i < 16; i++) - group->methods[method_id].name[i] = name[i]; - if(group->methods[method_id].param_count != 0) - { - free(group->methods[method_id].param_names); - free(group->methods[method_id].param_types); - } - }else - { - for(method_id = 0; method_id < group->method_count && group->methods[method_id].name[0] != 0; method_id++); - if(method_id == group->method_count) - { - group->methods = realloc(group->methods, sizeof(*group->methods) * (group->method_count + 16)); - for(i = group->method_count; i < group->method_count + 16; i++) - group->methods[i].name[0] = 0; - group->method_count += 16; - } - } - for(i = 0; i < VN_O_METHOD_NAME_SIZE && name[i] != 0; i++) - group->methods[method_id].name[i] = name[i]; - group->methods[method_id].name[i] = '\0'; - group->methods[method_id].param_count = param_count; - if(param_count > 0) - { - group->methods[method_id].param_types = malloc((sizeof *group->methods[method_id].param_types) * param_count); - group->methods[method_id].param_names = malloc((sizeof *group->methods[method_id].param_names) * param_count * 16); - } - for(i = 0; i < param_count; i++) - { - group->methods[method_id].param_types[i] = param_types[i]; - for(j = 0; j < 15 && param_names[i][j] != 0; j++) - group->methods[method_id].param_names[i * 16 + j] = param_names[i][j]; - group->methods[method_id].param_names[i * 16 + j] = 0; - } - count = vs_get_subscript_count(node->groups[group_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->groups[group_id].subscribers, i); - verse_send_o_method_create(node_id, group_id, method_id, name, param_count, param_types, (const char **) param_names); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_method_destroy(void *user, VNodeID node_id, uint16 group_id, uint16 method_id) -{ - VSNodeObject *node; - unsigned int i, count; - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - if(group_id >= node->group_count || node->groups[group_id].name[0] == 0 || method_id >= node->groups[group_id].method_count || node->groups[group_id].methods[method_id].name[0] == 0) - return; - - node->groups[group_id].methods[method_id].name[0] = 0; - if(node->groups[group_id].methods[method_id].param_count != 0) - { - free(node->groups[group_id].methods[method_id].param_names); - free(node->groups[group_id].methods[method_id].param_types); - } - count = vs_get_subscript_count(node->groups[group_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->groups[group_id].subscribers, i); - verse_send_o_method_destroy(node_id, group_id, method_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_method_call(void *user, VNodeID node_id, uint16 group_id, uint16 method_id, VNodeID sender, void *params) -{ - VNOParam unpacked_params[255]; - void *data; - VSNodeObject *node; - unsigned int i, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || vs_get_node(node_id, V_NT_OBJECT) == NULL) - return; - - if(group_id >= node->group_count || node->groups[group_id].name[0] == 0 || method_id >= node->groups[group_id].method_count || node->groups[group_id].methods[method_id].name[0] == 0) - return; - if(!verse_method_call_unpack(params, node->groups[group_id].methods[method_id].param_count, node->groups[group_id].methods[method_id].param_types, unpacked_params)) - return; - sender = vs_get_avatar(); - count = vs_get_subscript_count(node->groups[group_id].subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->groups[group_id].subscribers, i); - data = verse_method_call_pack(node->groups[group_id].methods[method_id].param_count, node->groups[group_id].methods[method_id].param_types, unpacked_params); - if(data != NULL) - verse_send_o_method_call(node_id, group_id, method_id, sender, data); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_anim_run(void *user, VNodeID node_id, uint16 link_id, uint32 time_s, uint32 time_f, uint8 dimensions, real64 *pos, - real64 *speed, real64 *accel, real64 *scale, real64 *scale_speed) -{ - VSNodeObject *node; - unsigned int i, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL) - return; - if(link_id >= node->link_count || node->links[link_id].name[0] == 0) - return; - if(NULL == vs_get_node(node->links[link_id].link, V_NT_CURVE)) - return; - node->links[link_id].time_s = time_s; - node->links[link_id].time_f = time_f; - node->links[link_id].dimensions = dimensions; - for(i = 0; i < dimensions && i < 4; i++) - { - node->links[link_id].pos[i] = pos[i]; - node->links[link_id].speed[i] = speed[i]; - node->links[link_id].accel[i] = accel[i]; - node->links[link_id].scale[i] = scale[i]; - node->links[link_id].scale_speed[i] = scale_speed[i]; - } - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_anim_run(node_id, link_id, time_s, time_f, dimensions, pos, speed, accel, scale, scale_speed); - } - vs_reset_subscript_session(); -} - -static void callback_send_o_hide(void *user, VNodeID node_id, uint8 hidden) -{ - VSNodeObject *node; - unsigned int i, count; - - node = (VSNodeObject *)vs_get_node(node_id, V_NT_OBJECT); - if(node == NULL || hidden == node->hidden) - return; - node->hidden = hidden; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_o_hide(node_id, hidden); - } - vs_reset_subscript_session(); -} - -void vs_o_callback_init(void) -{ - - verse_callback_set(verse_send_o_transform_pos_real32, callback_send_o_transform_pos_real32, NULL); - verse_callback_set(verse_send_o_transform_rot_real32, callback_send_o_transform_rot_real32, NULL); - verse_callback_set(verse_send_o_transform_scale_real32, callback_send_o_transform_scale_real32, NULL); - verse_callback_set(verse_send_o_transform_pos_real64, callback_send_o_transform_pos_real64, NULL); - verse_callback_set(verse_send_o_transform_rot_real64, callback_send_o_transform_rot_real64, NULL); - verse_callback_set(verse_send_o_transform_scale_real64, callback_send_o_transform_scale_real64, NULL); - verse_callback_set(verse_send_o_transform_subscribe, callback_send_o_transform_subscribe, NULL); - verse_callback_set(verse_send_o_transform_unsubscribe, callback_send_o_transform_unsubscribe, NULL); - verse_callback_set(verse_send_o_link_set, callback_send_o_link_set, NULL); - verse_callback_set(verse_send_o_light_set, callback_send_o_light_set, NULL); - verse_callback_set(verse_send_o_link_set, callback_send_o_link_set, NULL); - verse_callback_set(verse_send_o_link_destroy, callback_send_o_link_destroy, NULL); - verse_callback_set(verse_send_o_method_group_create, callback_send_o_method_group_create, NULL); - verse_callback_set(verse_send_o_method_group_destroy, callback_send_o_method_group_destroy, NULL); - verse_callback_set(verse_send_o_method_group_subscribe, callback_send_o_method_group_subscribe, NULL); - verse_callback_set(verse_send_o_method_group_unsubscribe, callback_send_o_method_group_unsubscribe, NULL); - verse_callback_set(verse_send_o_method_create, callback_send_o_method_create, NULL); - verse_callback_set(verse_send_o_method_destroy, callback_send_o_method_destroy, NULL); - verse_callback_set(verse_send_o_method_call, callback_send_o_method_call, NULL); - verse_callback_set(verse_send_o_anim_run, callback_send_o_anim_run, NULL); - verse_callback_set(verse_send_o_hide, callback_send_o_hide, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_particle.c b/extern/verse/dist/vs_node_particle.c deleted file mode 100644 index 8c7b1ce3c82..00000000000 --- a/extern/verse/dist/vs_node_particle.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -/* -typedef struct { - VSNodeHead head; -} VSNodeObject; - -VSNodeObject *vs_o_create_node(unsigned int owner) -{ - VSNodeObject *node; - node = malloc(sizeof *node); - create_node_head(&node->head, name, owner); - vs_add_new_node(&node->head, V_NT_OBJECT); - return node; -} - -void vs_o_destroy_node(VSNodeObject *node) -{ - destroy_node_head(&node->head); - free(node); -} - -void vs_o_subscribe(VSNodeObject *node) -{ -} - -static void callback_send_o_unsubscribe(void *user, VNodeID node_id) -{ - VSNodeObject *node; - node = (VSNodeObject *)vs_get_node(node_id); - if(node == NULL) - return; - vs_remove_subscriptor(node->head.subscribers); -} - -void vs_o_callback_init(void) -{ -} -*/ -#endif diff --git a/extern/verse/dist/vs_node_storage.c b/extern/verse/dist/vs_node_storage.c deleted file mode 100644 index 480ceb1f900..00000000000 --- a/extern/verse/dist/vs_node_storage.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -#define VS_NODE_STORAGE_CHUNK_SIZE 16 - -static struct { - VSNodeHead **nodes; - unsigned int node_length; - unsigned int node_allocated; - VSSubscriptionList *list[V_NT_NUM_TYPES]; -} VSNodeStorage; - -extern void callback_send_tag_group_create(void *user, VNodeID node_id, uint16 group_id, const char *name); - -void vs_init_node_storage(void) -{ - unsigned int i; - VSNodeStorage.nodes = malloc((sizeof *VSNodeStorage.nodes) * VS_NODE_STORAGE_CHUNK_SIZE); - VSNodeStorage.nodes[0] = NULL; - VSNodeStorage.node_length = 0; - VSNodeStorage.node_allocated = VS_NODE_STORAGE_CHUNK_SIZE; - for(i = 0; i < V_NT_NUM_TYPES; i++) - VSNodeStorage.list[i] = vs_create_subscription_list(); -} - -unsigned int vs_add_new_node(VSNodeHead *node, VNodeType type) -{ - unsigned int i, j; - for(i = 0; i < VSNodeStorage.node_length && VSNodeStorage.nodes[i] != NULL; i++); - if(i >= VSNodeStorage.node_allocated) - { - j = VSNodeStorage.node_allocated; - VSNodeStorage.node_allocated += VS_NODE_STORAGE_CHUNK_SIZE; - VSNodeStorage.nodes = realloc(VSNodeStorage.nodes, (sizeof *VSNodeStorage.nodes) * VSNodeStorage.node_allocated); - while(j < VSNodeStorage.node_allocated) - VSNodeStorage.nodes[j++] = NULL; - } - VSNodeStorage.nodes[i] = node; - if(i >= VSNodeStorage.node_length) - VSNodeStorage.node_length = i + 1; - node->id = i; - node->type = type; - - return node->id; -} - -VSNodeHead *vs_get_node(unsigned int node_id, VNodeType type) -{ - if(VSNodeStorage.node_length > node_id) - { - VSNodeHead *node = VSNodeStorage.nodes[node_id]; - - if(node != NULL && node->type == type) - return node; - } - return NULL; -} - -VSNodeHead *vs_get_node_head(unsigned int node_id) -{ - if(VSNodeStorage.node_length > node_id) - return VSNodeStorage.nodes[node_id]; - return NULL; -} - -extern VSNodeHead *vs_o_create_node(unsigned int owner); -extern VSNodeHead *vs_g_create_node(unsigned int owner); -extern VSNodeHead *vs_m_create_node(unsigned int owner); -extern VSNodeHead *vs_b_create_node(unsigned int owner); -extern VSNodeHead *vs_t_create_node(unsigned int owner); -extern VSNodeHead *vs_c_create_node(unsigned int owner); -extern VSNodeHead *vs_p_create_node(unsigned int owner); -extern VSNodeHead *vs_a_create_node(unsigned int owner); - -extern void vs_o_destroy_node(VSNodeHead *node); -extern void vs_g_destroy_node(VSNodeHead *node); -extern void vs_m_destroy_node(VSNodeHead *node); -extern void vs_b_destroy_node(VSNodeHead *node); -extern void vs_t_destroy_node(VSNodeHead *node); -extern void vs_c_destroy_node(VSNodeHead *node); -extern void vs_p_destroy_node(VSNodeHead *node); -extern void vs_a_destroy_node(VSNodeHead *node); - - -VNodeID vs_node_create(VNodeID owner_id, unsigned int type) -{ - unsigned int count, i; - VSNodeHead *node; - VNodeID node_id; - - printf("vs_node_create(%u, %u)\n", owner_id, type); - switch(type) - { - case V_NT_OBJECT : - node = vs_o_create_node(owner_id); - break; - case V_NT_GEOMETRY : - node = vs_g_create_node(owner_id); - break; - case V_NT_MATERIAL : - node = vs_m_create_node(owner_id); - break; - case V_NT_BITMAP : - node = vs_b_create_node(owner_id); - break; - case V_NT_TEXT : - node = vs_t_create_node(owner_id); - break; - case V_NT_CURVE : - node = vs_c_create_node(owner_id); - break; - case V_NT_AUDIO : - node = vs_a_create_node(owner_id); - break; - default: - fprintf(stderr, "Can't create node of unknown type %u\n", type); - return 0U; - } - node_id = node->id; - - count = vs_get_subscript_count(VSNodeStorage.list[type]); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(VSNodeStorage.list[type], i); - if(owner_id != verse_session_get_avatar()) - verse_send_node_create(node_id, type, VN_OWNER_OTHER); - else - verse_send_node_create(node_id, type, VN_OWNER_MINE); - } - if(count != 0) - vs_reset_subscript_session(); - return node_id; -} - -/* Initialize an object node into being an avatar. */ -void vs_avatar_init(VNodeID id, const char *name) -{ - callback_send_tag_group_create(NULL, id, (short) ~0u, "avatar"); - /* FIXME: Populate the group, too. */ -} - -void vs_reset_owner(VNodeID owner_id) -{ - unsigned int i; - - for(i = 0; i < VSNodeStorage.node_length; i++) - if(VSNodeStorage.nodes[i] != NULL) - if(VSNodeStorage.nodes[i]->owner == owner_id) - VSNodeStorage.nodes[i]->owner = ~0; -} - -static void callback_send_node_create(void *user_data, VNodeID node_id, uint8 type, VNodeOwner owner_id) -{ - vs_node_create(vs_get_avatar(), type); -} - -void callback_send_node_destroy(void *user_data, VNodeID node_id) -{ - unsigned int count, i; - VSNodeHead *node; - VNodeType type; - node = vs_get_node_head(node_id); - if(node == NULL) - return; - VSNodeStorage.nodes[node_id] = NULL; - type = node->type; - switch(type) - { - case V_NT_OBJECT : - vs_o_destroy_node(node); - break; - case V_NT_GEOMETRY : - vs_g_destroy_node(node); - break; - case V_NT_MATERIAL : - vs_m_destroy_node(node); - break; - case V_NT_BITMAP : - vs_b_destroy_node(node); - break; - case V_NT_TEXT : - vs_t_destroy_node(node); - break; - case V_NT_CURVE : - vs_c_destroy_node(node); - break; - case V_NT_AUDIO : - vs_c_destroy_node(node); - break; - default: - fprintf(stderr, __FILE__ " Can't handle node_destroy for type %d--not implemented", type); - return; - } - count = vs_get_subscript_count(VSNodeStorage.list[type]); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(VSNodeStorage.list[type], i); - verse_send_node_destroy(node_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_node_index_subscribe(void *user_data, uint32 mask) -{ - unsigned int i, j, pow = 1; - - for(i = 0; i < V_NT_NUM_TYPES; i++, pow <<= 1) - { - if((mask & pow) != 0) - { - for(j = 0; j < VSNodeStorage.node_length; j++) - { - if(VSNodeStorage.nodes[j] != NULL && VSNodeStorage.nodes[j]->type == (VNodeType)i) - { - if(VSNodeStorage.nodes[j]->owner == verse_session_get_avatar()) - verse_send_node_create(VSNodeStorage.nodes[j]->id, i, VN_OWNER_MINE); - else - verse_send_node_create(VSNodeStorage.nodes[j]->id, i, VN_OWNER_OTHER); - } - } - vs_add_new_subscriptor(VSNodeStorage.list[i]); - } - else - vs_remove_subscriptor(VSNodeStorage.list[i]); - } -} - -void init_callback_node_storage(void) -{ - verse_callback_set(verse_send_node_index_subscribe, callback_send_node_index_subscribe, NULL); - verse_callback_set(verse_send_node_create, callback_send_node_create, NULL); - verse_callback_set(verse_send_node_destroy, callback_send_node_destroy, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_node_text.c b/extern/verse/dist/vs_node_text.c deleted file mode 100644 index ae7c3c737c3..00000000000 --- a/extern/verse/dist/vs_node_text.c +++ /dev/null @@ -1,274 +0,0 @@ -/* -** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "v_cmd_gen.h" - -#if !defined V_GENERATE_FUNC_MODE - -#include "verse.h" -#include "vs_server.h" - -#define VS_TEXT_CHUNK_SIZE 4096 - -typedef struct { - char name[16]; - char *text; - size_t length; - size_t allocated; - VSSubscriptionList *subscribers; -} VSTextBuffer; - -typedef struct { - VSNodeHead head; - char language[512]; - VSTextBuffer *buffer; - unsigned int buffer_count; -} VSNodeText; - -VSNodeText * vs_t_create_node(unsigned int owner) -{ - VSNodeText *node; - char name[48]; - unsigned int i; - node = malloc(sizeof *node); - vs_add_new_node(&node->head, V_NT_TEXT); - sprintf(name, "Text_Node_%u", node->head.id); - create_node_head(&node->head, name, owner); - node->language[0] = 0; - node->buffer_count = 16; - node->buffer = malloc((sizeof *node->buffer) * node->buffer_count); - for(i = 0; i < node->buffer_count; i++) - node->buffer[i].name[0] = 0; - - return node; -} - -void vs_t_destroy_node(VSNodeText *node) -{ - unsigned int i; - destroy_node_head(&node->head); - for(i = 0; i < node->buffer_count; i++) - { - if(node->buffer[i].name[0] != 0) - { - free(node->buffer[i].text); - vs_destroy_subscription_list(node->buffer[i].subscribers); - } - } - free(node->buffer); - free(node); -} - -void vs_t_subscribe(VSNodeText *node) -{ - unsigned int i; - verse_send_t_language_set(node->head.id, node->language); - for(i = 0; i < node->buffer_count; i++) - if(node->buffer[i].name[0] != 0) - verse_send_t_buffer_create(node->head.id, i, node->buffer[i].name); -} - -void vs_t_unsubscribe(VSNodeText *node) -{ - unsigned int i; - for(i = 0; i < node->buffer_count; i++) - if(node->buffer[i].name[0] != 0) - vs_remove_subscriptor(node->buffer[i].subscribers); -} - -static void callback_send_t_language_set(void *user, VNodeID node_id, char *language) -{ - VSNodeText *node; - unsigned int i, count; - node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT); - if(node == NULL) - return; - for(i = 0; i < 511 && language[i]; i++) - node->language[i] = language[i]; - node->language[i] = 0; - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_t_language_set(node_id, language); - } - vs_reset_subscript_session(); - -} - -static void callback_send_t_buffer_create(void *user, VNodeID node_id, VBufferID buffer_id, const char *name) -{ - VSNodeText *node; - unsigned int i, count; - node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT); - if(node == NULL) - return; - - if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] != 0) - { - for(buffer_id = 0; buffer_id < node->buffer_count && node->buffer[buffer_id].name[0] != 0; buffer_id++) - ; - if(buffer_id == node->buffer_count) - { - node->buffer = realloc(node->buffer, (sizeof *node->buffer) * node->buffer_count); - for(i = node->buffer_count; i < node->buffer_count + 16; i++) - node->buffer[i].name[0] = 0; - node->buffer_count = i; - } - } - - if(node->buffer[buffer_id].name[0] == 0) - { - node->buffer[buffer_id].allocated = VS_TEXT_CHUNK_SIZE; - node->buffer[buffer_id].text = malloc(node->buffer[buffer_id].allocated); - node->buffer[buffer_id].length = 0; - node->buffer[buffer_id].subscribers = vs_create_subscription_list(); - } - for(i = 0; i < 15 && name[i] != 0; i++) - node->buffer[buffer_id].name[i] = name[i]; - node->buffer[buffer_id].name[i] = 0; - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_t_buffer_create(node_id, buffer_id, name); - } - vs_reset_subscript_session(); -} - -void callback_send_t_buffer_destroy(void *user, VNodeID node_id, VBufferID buffer_id) -{ - VSNodeText *node; - unsigned int i, count; - node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT); - if(node == NULL) - return; - - if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0) - return; - - node->buffer[buffer_id].name[0] = 0; - free(node->buffer[buffer_id].text); - vs_destroy_subscription_list(node->buffer[buffer_id].subscribers); - - count = vs_get_subscript_count(node->head.subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(node->head.subscribers, i); - verse_send_t_buffer_destroy(node_id, buffer_id); - } - vs_reset_subscript_session(); -} - -static void callback_send_t_buffer_subscribe(void *user, VNodeID node_id, VBufferID buffer_id) -{ - VSNodeText *node; - unsigned int i; - - node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT); - if(node == NULL) - return; - if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0) - return; - if(vs_add_new_subscriptor(node->buffer[buffer_id].subscribers) == 0) - return; - for(i = 0; i < node->buffer[buffer_id].length; i += VN_T_MAX_TEXT_CMD_SIZE) - { - if(i + VN_T_MAX_TEXT_CMD_SIZE > node->buffer[buffer_id].length) - verse_send_t_text_set(node_id, buffer_id, i, node->buffer[buffer_id].length - i, &node->buffer[buffer_id].text[i]); - else - verse_send_t_text_set(node_id, buffer_id, i, VN_T_MAX_TEXT_CMD_SIZE, &node->buffer[buffer_id].text[i]); - } -} - -static void callback_send_t_buffer_unsubscribe(void *user, VNodeID node_id, VBufferID buffer_id) -{ - VSNodeText *node; - node = (VSNodeText *)vs_get_node(node_id, V_NT_TEXT); - if(node == NULL) - return; - if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0) - return; - vs_remove_subscriptor(node->buffer[buffer_id].subscribers); -} - -static void callback_send_t_text_set(void *user, VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text) -{ - VSNodeText *node; - VSTextBuffer *tb; - unsigned int i, count, text_length; - char *buf; - - node = (VSNodeText *) vs_get_node(node_id, V_NT_TEXT); - if(node == NULL) - return; - if(buffer_id >= node->buffer_count || node->buffer[buffer_id].name[0] == 0) - return; - tb = &node->buffer[buffer_id]; - - text_length = strlen(text); - - /* Clamp position and length of deleted region. */ - if(pos > tb->length) - pos = tb->length; - if(pos + length > tb->length) - length = tb->length - pos; - - buf = tb->text; - - if(tb->length + text_length - length > tb->allocated) - { - buf = realloc(buf, tb->length + text_length - length + VS_TEXT_CHUNK_SIZE); - tb->allocated = tb->length + text_length - length + VS_TEXT_CHUNK_SIZE; - } - - if(text_length < length) /* Insert smaller than delete? */ - { - memmove(buf + pos + text_length, buf + pos + length, tb->length - (pos + length)); - memcpy(buf + pos, text, text_length); - } - else /* Insert is larger than delete. */ - { - memmove(buf + pos + text_length, buf + pos + length, tb->length - pos); - memcpy(buf + pos, text, text_length); - } - - tb->length += (int) text_length - length; - buf[tb->length] = '\0'; - - /* Buffer very much larger than content? Then shrink it. */ - if(tb->allocated > VS_TEXT_CHUNK_SIZE * 8 && tb->allocated * 2 > tb->length) - { - buf = realloc(buf, tb->length + VS_TEXT_CHUNK_SIZE); - tb->allocated = tb->length + VS_TEXT_CHUNK_SIZE; - } - - tb->text = buf; - - count = vs_get_subscript_count(tb->subscribers); - for(i = 0; i < count; i++) - { - vs_set_subscript_session(tb->subscribers, i); - verse_send_t_text_set(node_id, buffer_id, pos, length, text); - } - vs_reset_subscript_session(); -} - - -void vs_t_callback_init(void) -{ - verse_callback_set(verse_send_t_language_set, callback_send_t_language_set, NULL); - verse_callback_set(verse_send_t_buffer_create, callback_send_t_buffer_create, NULL); - verse_callback_set(verse_send_t_buffer_destroy, callback_send_t_buffer_destroy, NULL); - verse_callback_set(verse_send_t_buffer_subscribe, callback_send_t_buffer_subscribe, NULL); - verse_callback_set(verse_send_t_buffer_unsubscribe, callback_send_t_buffer_unsubscribe, NULL); - verse_callback_set(verse_send_t_text_set, callback_send_t_text_set, NULL); -} - -#endif diff --git a/extern/verse/dist/vs_server.h b/extern/verse/dist/vs_server.h deleted file mode 100644 index 76e1b482eb9..00000000000 --- a/extern/verse/dist/vs_server.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** -*/ - -#include <stdlib.h> - -extern void vs_init_connection_storage(void); -extern void vs_add_new_connection(VSession session, const char *name, const char *pass, VNodeID node_id); -extern void vs_remove_connection(void); -extern void vs_set_next_session(void); - -typedef void VSSubscriptionList; - -extern VSSubscriptionList * vs_create_subscription_list(void); -extern void vs_destroy_subscription_list(VSSubscriptionList *list); -extern int vs_add_new_subscriptor(VSSubscriptionList *list); -extern void vs_remove_subscriptor(VSSubscriptionList *list); -extern unsigned int vs_get_subscript_count(const VSSubscriptionList *list); -extern void vs_set_subscript_session(VSSubscriptionList *list, unsigned int session); -extern void vs_reset_subscript_session(void); -extern uint32 vs_get_avatar(void); -extern VSession vs_get_session(void); -extern const char * vs_get_user_name(void); -extern const char * vs_get_user_pass(void); - - -typedef struct { - VNodeID id; - VNodeType type; - VNodeID owner; - char *name; - void *tag_groups; - uint16 group_count; - VSSubscriptionList *subscribers; -} VSNodeHead; - -extern void vs_init_node_storage(void); -extern uint32 vs_add_new_node(VSNodeHead *node, VNodeType type); -extern VSNodeHead * vs_get_node(unsigned int node_id, VNodeType type); -extern VSNodeHead * vs_get_node_head(unsigned int node_id); - -extern void create_node_head(VSNodeHead *node, const char *name, unsigned int owner); -extern void destroy_node_head(VSNodeHead *node); -extern void vs_send_node_head(VSNodeHead *node); - -extern void vs_h_callback_init(void); /* "Head", not an actual node type. */ -extern void vs_o_callback_init(void); -extern void vs_g_callback_init(void); -extern void vs_m_callback_init(void); -extern void vs_b_callback_init(void); -extern void vs_t_callback_init(void); -extern void vs_c_callback_init(void); -extern void vs_a_callback_init(void); -extern void init_callback_node_storage(void); - -extern void vs_master_set_enabled(boolean enabled); -extern void vs_master_set_address(const char *address); -extern const char * vs_master_get_address(void); -extern void vs_master_set_desc(const char *desc); -extern void vs_master_set_tags(const char *tags); -extern void vs_master_update(void); -extern void vs_master_handle_describe(const char *address, const char *message); diff --git a/extern/verse/make/msvc_7_0/libverse.vcproj b/extern/verse/make/msvc_7_0/libverse.vcproj deleted file mode 100644 index 1c9bfbfce33..00000000000 --- a/extern/verse/make/msvc_7_0/libverse.vcproj +++ /dev/null @@ -1,279 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="verse" - ProjectGUID="{F9850C15-FF0A-429E-9D47-89FB433C9BD8}" - SccProjectName="" - SccLocalPath=""> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="Blender Debug|Win32" - OutputDirectory="..\..\..\..\..\build\msvc_7\extern\verse\debug" - IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse\debug" - ConfigurationType="4" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include" - PreprocessorDefinitions="_DEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\extern\verse\debug\libverse.pch" - AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\debug\" - ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\debug\" - ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\debug\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - DebugInformationFormat="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="..\..\..\..\..\build\msvc_7\libs\extern\debug\verse.lib" - SuppressStartupBanner="TRUE"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool" - Description="Copying verse files library (debug target) to lib tree." - CommandLine="ECHO Copying header files -IF NOT EXIST ..\..\..\..\..\build\msvc_7\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_7\extern\verse\include -XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_7\extern\verse\include -ECHO Done -"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Blender Release|Win32" - OutputDirectory="..\..\..\..\..\build\msvc_7\extern\verse" - IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse" - ConfigurationType="4" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include" - PreprocessorDefinitions="NDEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC" - StringPooling="TRUE" - RuntimeLibrary="0" - EnableFunctionLevelLinking="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\extern\verse\libverse.pch" - AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\" - ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\" - ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLibrarianTool" - OutputFile="..\..\..\..\..\build\msvc_7\libs\extern\verse.lib" - SuppressStartupBanner="TRUE"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool" - Description="Copying verse files library to lib tree." - CommandLine="ECHO Copying header files -IF NOT EXIST ..\..\..\..\..\build\msvc_7\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_7\extern\verse\include -XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_7\extern\verse\include -ECHO Done -"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> - <File - RelativePath="..\..\dist\v_bignum.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_buf.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_a.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_b.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_c.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_g.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_m.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_o.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_s.c"> - </File> - <File - RelativePath="..\..\dist\v_cmd_def_t.c"> - </File> - <File - RelativePath="..\..\dist\v_connect.c"> - </File> - <File - RelativePath="..\..\dist\v_connection.c"> - </File> - <File - RelativePath="..\..\dist\v_encryption.c"> - </File> - <File - RelativePath="..\..\dist\v_func_storage.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_a_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_b_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_c_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_g_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_init.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_m_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_o_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_s_node.c"> - </File> - <File - RelativePath="..\..\dist\v_gen_pack_t_node.c"> - </File> - <File - RelativePath="..\..\dist\v_man_pack_node.c"> - </File> - <File - RelativePath="..\..\dist\v_network.c"> - </File> - <File - RelativePath="..\..\dist\v_network_in_que.c"> - </File> - <File - RelativePath="..\..\dist\v_network_out_que.c"> - </File> - <File - RelativePath="..\..\dist\v_pack.c"> - </File> - <File - RelativePath="..\..\dist\v_pack_method.c"> - </File> - <File - RelativePath="..\..\dist\v_prime.c"> - </File> - <File - RelativePath="..\..\dist\v_randgen.c"> - </File> - <File - RelativePath="..\..\dist\v_util.c"> - </File> - <File - RelativePath="..\..\dist\verse_ms.c"> - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl"> - <File - RelativePath="..\..\dist\v_bignum.h"> - </File> - <File - RelativePath="..\..\dist\v_cmd_buf.h"> - </File> - <File - RelativePath="..\..\dist\v_connection.h"> - </File> - <File - RelativePath="..\..\dist\v_encryption.h"> - </File> - <File - RelativePath="..\..\dist\v_internal_verse.h"> - </File> - <File - RelativePath="..\..\dist\v_network.h"> - </File> - <File - RelativePath="..\..\dist\v_network_in_que.h"> - </File> - <File - RelativePath="..\..\dist\v_network_out_que.h"> - </File> - <File - RelativePath="..\..\dist\v_pack.h"> - </File> - <File - RelativePath="..\..\dist\v_randgen.h"> - </File> - <File - RelativePath="..\..\dist\v_util.h"> - </File> - </Filter> - <File - RelativePath="..\..\dist\verse_ms.h"> - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/extern/verse/make/msvc_7_0/verse.vcproj b/extern/verse/make/msvc_7_0/verse.vcproj deleted file mode 100644 index 563e33e7be9..00000000000 --- a/extern/verse/make/msvc_7_0/verse.vcproj +++ /dev/null @@ -1,481 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="verse_server" - ProjectGUID="{FC752464-F413-4D4F-842D-A5D3AA0E6A3D}" - SccProjectName="" - SccLocalPath=""> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="3D Plugin Debug|Win32" - OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug" - IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug" - ConfigurationType="1" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include" - PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - DefaultCharIsUnsigned="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\verse.pch" - AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\" - ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\" - ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\debug\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - DebugInformationFormat="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib" - OutputFile=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.exe" - LinkIncremental="2" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern\mtdll\debug;..\..\..\..\build\msvc_7\libs\mtdll\debug" - IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib" - GenerateDebugInformation="TRUE" - ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\debug\DNA_makesdna.pdb" - SubSystem="1"/> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.tlb"/> - <Tool - Name="VCPostBuildEventTool" - Description="Building DNA" - CommandLine="CD ..\..\..\source\blender\makesdna\intern\ -DNA_makesdna.exe dna.c -"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Blender Release|Win32" - OutputDirectory="..\..\..\..\bin" - IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse\server" - ConfigurationType="1" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="" - PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE" - StringPooling="TRUE" - RuntimeLibrary="0" - EnableFunctionLevelLinking="TRUE" - DefaultCharIsUnsigned="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\source\blender\verse\server\verse.pch" - AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\server\" - ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\server\" - ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\server\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="verse.lib ws2_32.lib" - OutputFile="..\..\..\..\bin\verse.exe" - LinkIncremental="1" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_7\libs\extern" - IgnoreDefaultLibraryNames="libc.lib" - ProgramDatabaseFile="..\..\..\..\..\build\msvc_7\extern\verse\server\verse.pdb" - SubSystem="1"/> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="3D Plugin Release|Win32" - OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll" - IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll" - ConfigurationType="1" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include" - PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE" - StringPooling="TRUE" - RuntimeLibrary="2" - EnableFunctionLevelLinking="TRUE" - DefaultCharIsUnsigned="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\verse.pch" - AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\" - ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\" - ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\mtdll\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib" - OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe" - LinkIncremental="1" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern\mtdll;..\..\..\..\build\msvc_7\libs\mtdll" - IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib" - ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\verse.pdb" - SubSystem="1"/> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/> - <Tool - Name="VCPostBuildEventTool" - Description="Building DNA" - CommandLine="CD ..\..\..\source\blender\makesdna\intern\ -verse.exe dna.c -"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Blender Debug|Win32" - OutputDirectory="..\..\..\..\bin\debug" - IntermediateDirectory="..\..\..\..\..\build\msvc_7\extern\verse\server\debug" - ConfigurationType="1" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="" - PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DefaultCharIsUnsigned="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\..\build\msvc_7\source\blender\verse\server\debug\verse.pch" - ExpandAttributedSource="FALSE" - AssemblerListingLocation="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\" - ObjectFile="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\" - ProgramDataBaseFileName="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - DebugInformationFormat="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386 -" - AdditionalDependencies="verse.lib ws2_32.lib" - OutputFile="..\..\..\..\bin\debug\verse.exe" - LinkIncremental="2" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_7\libs\extern\debug" - IgnoreAllDefaultLibraries="FALSE" - IgnoreDefaultLibraryNames="libcd" - GenerateDebugInformation="TRUE" - ProgramDatabaseFile="..\..\..\..\..\build\msvc_7\extern\verse\server\debug\verse.pdb" - SubSystem="1"/> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="BlenderPlayer Debug|Win32" - OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\blenplayer" - IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\blenplayer" - ConfigurationType="1" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include" - PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE" - BasicRuntimeChecks="3" - RuntimeLibrary="1" - DefaultCharIsUnsigned="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\verse.pch" - ExpandAttributedSource="FALSE" - AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\" - ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\" - ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\debug\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - DebugInformationFormat="3" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386 -" - AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib" - OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe" - LinkIncremental="2" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern\debug;..\..\..\..\build\msvc_7\libs\debug" - IgnoreAllDefaultLibraries="FALSE" - IgnoreDefaultLibraryNames="libc.lib, libcd.lib" - GenerateDebugInformation="TRUE" - ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\debug\verse.pdb" - SubSystem="1"/> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/> - <Tool - Name="VCPostBuildEventTool" - Description="Building DNA" - CommandLine="CD ..\..\..\source\blender\makesdna\intern -verse.exe dna.c -"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="BlenderPlayer Release|Win32" - OutputDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\blenplayer" - IntermediateDirectory="..\..\..\..\build\msvc_7\source\blender\makesdna\blenplayer" - ConfigurationType="1" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="FALSE" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include" - PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE" - StringPooling="TRUE" - RuntimeLibrary="0" - EnableFunctionLevelLinking="TRUE" - DefaultCharIsUnsigned="TRUE" - UsePrecompiledHeader="2" - PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\makesdna\verse.pch" - AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\makesdna\" - ObjectFile="..\..\..\..\build\msvc_7\source\blender\makesdna\" - ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\makesdna\" - WarningLevel="2" - SuppressStartupBanner="TRUE" - CompileAs="0"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalOptions="/MACHINE:I386" - AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib" - OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe" - LinkIncremental="1" - SuppressStartupBanner="TRUE" - AdditionalLibraryDirectories="..\..\..\..\build\msvc_7\libs\intern;..\..\..\..\build\msvc_7\libs" - IgnoreDefaultLibraryNames="libc.lib" - ProgramDatabaseFile="..\..\..\..\build\msvc_7\libs\verse.pdb" - SubSystem="1"/> - <Tool - Name="VCMIDLTool" - TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"/> - <Tool - Name="VCPostBuildEventTool" - Description="Building DNA" - CommandLine="CD ..\..\..\source\blender\makesdna\intern\ -verse.exe dna.c -"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1033"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"> - <File - RelativePath="..\..\dist\vs_connection.c"> - </File> - <File - RelativePath="..\..\dist\vs_main.c"> - </File> - <File - RelativePath="..\..\dist\vs_master.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_audio.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_bitmap.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_curve.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_geometry.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_head.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_material.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_object.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_particle.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_storage.c"> - </File> - <File - RelativePath="..\..\dist\vs_node_text.c"> - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl"> - <File - RelativePath="..\..\dist\v_cmd_gen.h"> - </File> - <File - RelativePath="..\..\dist\v_util.h"> - </File> - <File - RelativePath="..\..\dist\verse.h"> - </File> - <File - RelativePath="..\..\dist\vs_server.h"> - </File> - </Filter> - <Filter - Name="Resource Files" - Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/extern/verse/make/msvc_9_0/libverse.vcproj b/extern/verse/make/msvc_9_0/libverse.vcproj deleted file mode 100644 index cbe236d5b55..00000000000 --- a/extern/verse/make/msvc_9_0/libverse.vcproj +++ /dev/null @@ -1,368 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="EXT_verse"
- ProjectGUID="{531D4862-D0E7-4B9B-A0B6-B3A6A25B547A}"
- RootNamespace="verse"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Blender Debug|Win32"
- OutputDirectory="..\..\..\..\..\build\msvc_9\extern\verse\debug"
- IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse\debug"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include"
- PreprocessorDefinitions="_DEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\extern\verse\debug\libverse.pch"
- AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\debug\"
- ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\debug\"
- ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\debug\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="..\..\..\..\..\build\msvc_9\libs\extern\debug\verse.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- Description="Copying verse files library (debug target) to lib tree."
- CommandLine="ECHO Copying header files
IF NOT EXIST ..\..\..\..\..\build\msvc_9\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_9\extern\verse\include
XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_9\extern\verse\include
ECHO Done
"
- />
- </Configuration>
- <Configuration
- Name="Blender Release|Win32"
- OutputDirectory="..\..\..\..\..\build\msvc_9\extern\verse"
- IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse"
- ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\include;..\..\..\..\..\lib\windows\freetype\include"
- PreprocessorDefinitions="NDEBUG;WIN32;_LIB;FTGL_LIBRARY_STATIC"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\extern\verse\libverse.pch"
- AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\"
- ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\"
- ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="..\..\..\..\..\build\msvc_9\libs\extern\verse.lib"
- SuppressStartupBanner="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- Description="Copying verse files library to lib tree."
- CommandLine="ECHO Copying header files
IF NOT EXIST ..\..\..\..\..\build\msvc_9\extern\verse\include\ MKDIR ..\..\..\..\..\build\msvc_9\extern\verse\include
XCOPY /Y ..\..\dist\*.h ..\..\..\..\..\build\msvc_9\extern\verse\include
ECHO Done
"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
- >
- <File
- RelativePath="..\..\dist\v_bignum.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_buf.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_a.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_b.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_c.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_g.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_m.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_o.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_s.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_def_t.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_connect.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_connection.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_encryption.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_func_storage.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_a_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_b_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_c_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_g_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_init.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_m_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_o_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_s_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_gen_pack_t_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_man_pack_node.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_network.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_network_in_que.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_network_out_que.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_pack.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_pack_method.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_prime.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_randgen.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_util.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\verse_ms.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl"
- >
- <File
- RelativePath="..\..\dist\v_bignum.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_cmd_buf.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_connection.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_encryption.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_internal_verse.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_network.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_network_in_que.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_network_out_que.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_pack.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_randgen.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_util.h"
- >
- </File>
- </Filter>
- <File
- RelativePath="..\..\dist\verse_ms.h"
- >
- </File>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/extern/verse/make/msvc_9_0/verse.vcproj b/extern/verse/make/msvc_9_0/verse.vcproj deleted file mode 100644 index 39363156181..00000000000 --- a/extern/verse/make/msvc_9_0/verse.vcproj +++ /dev/null @@ -1,669 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="EXT_verse_server"
- ProjectGUID="{FC752464-F413-4D4F-842D-A5D3AA0E6A3D}"
- RootNamespace="verse_server"
- TargetFrameworkVersion="131072"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="3D Plugin Debug|Win32"
- OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug"
- IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
- PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- DefaultCharIsUnsigned="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\verse.pch"
- AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\"
- ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\"
- ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\debug\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
- OutputFile=".\..\..\..\source\blender\makesdna\intern/DNA_makesdna.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern\mtdll\debug;..\..\..\..\build\msvc_9\libs\mtdll\debug"
- IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\debug\DNA_makesdna.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- Description="Building DNA"
- CommandLine="CD ..\..\..\source\blender\makesdna\intern\
DNA_makesdna.exe dna.c
"
- />
- </Configuration>
- <Configuration
- Name="Blender Release|Win32"
- OutputDirectory="..\..\..\..\bin"
- IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse\server"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- DefaultCharIsUnsigned="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\source\blender\verse\server\verse.pch"
- AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\server\"
- ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\server\"
- ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\server\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="verse.lib ws2_32.lib"
- OutputFile="..\..\..\..\bin\verse.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_9\libs\extern"
- IgnoreDefaultLibraryNames="libc.lib"
- ProgramDatabaseFile="..\..\..\..\..\build\msvc_9\extern\verse\server\verse.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="3D Plugin Release|Win32"
- OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll"
- IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
- PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
- StringPooling="true"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- DefaultCharIsUnsigned="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\verse.pch"
- AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\"
- ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\"
- ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\mtdll\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
- OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern\mtdll;..\..\..\..\build\msvc_9\libs\mtdll"
- IgnoreDefaultLibraryNames=" libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib"
- ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\verse.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- Description="Building DNA"
- CommandLine="CD ..\..\..\source\blender\makesdna\intern\
verse.exe dna.c
"
- />
- </Configuration>
- <Configuration
- Name="Blender Debug|Win32"
- OutputDirectory="..\..\..\..\bin\debug"
- IntermediateDirectory="..\..\..\..\..\build\msvc_9\extern\verse\server\debug"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- DefaultCharIsUnsigned="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\..\build\msvc_9\source\blender\verse\server\debug\verse.pch"
- ExpandAttributedSource="false"
- AssemblerListingLocation="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\"
- ObjectFile="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\"
- ProgramDataBaseFileName="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386
"
- AdditionalDependencies="verse.lib ws2_32.lib"
- OutputFile="..\..\..\..\bin\debug\verse.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories="..\..\..\..\..\build\msvc_9\libs\extern\debug"
- IgnoreAllDefaultLibraries="false"
- IgnoreDefaultLibraryNames="libcd"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="..\..\..\..\..\build\msvc_9\extern\verse\server\debug\verse.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="BlenderPlayer Debug|Win32"
- OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\blenplayer"
- IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\blenplayer"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
- PreprocessorDefinitions="_DEBUG,WIN32,_CONSOLE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- DefaultCharIsUnsigned="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\verse.pch"
- ExpandAttributedSource="false"
- AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\"
- ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\"
- ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\debug\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- DebugInformationFormat="3"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386
"
- AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
- OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
- LinkIncremental="2"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern\debug;..\..\..\..\build\msvc_9\libs\debug"
- IgnoreAllDefaultLibraries="false"
- IgnoreDefaultLibraryNames="libc.lib, libcd.lib"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\debug\verse.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- Description="Building DNA"
- CommandLine="CD ..\..\..\source\blender\makesdna\intern
verse.exe dna.c
"
- />
- </Configuration>
- <Configuration
- Name="BlenderPlayer Release|Win32"
- OutputDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\blenplayer"
- IntermediateDirectory="..\..\..\..\build\msvc_9\source\blender\makesdna\blenplayer"
- ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TypeLibraryName=".\..\..\..\source\blender\makesdna\intern/verse.tlb"
- />
- <Tool
- Name="VCCLCompilerTool"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender;..\..\..\source\blender\blenlib;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\..\lib\windows\pthreads\include"
- PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- DefaultCharIsUnsigned="true"
- UsePrecompiledHeader="0"
- PrecompiledHeaderFile="..\..\..\..\build\msvc_9\source\blender\makesdna\verse.pch"
- AssemblerListingLocation="..\..\..\..\build\msvc_9\source\blender\makesdna\"
- ObjectFile="..\..\..\..\build\msvc_9\source\blender\makesdna\"
- ProgramDataBaseFileName="..\..\..\..\build\msvc_9\source\blender\makesdna\"
- WarningLevel="2"
- SuppressStartupBanner="true"
- CompileAs="0"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="libguardedalloc.lib BLI_blenlib.lib odbc32.lib odbccp32.lib"
- OutputFile="..\..\..\source\blender\makesdna\intern\verse.exe"
- LinkIncremental="1"
- SuppressStartupBanner="true"
- AdditionalLibraryDirectories="..\..\..\..\build\msvc_9\libs\intern;..\..\..\..\build\msvc_9\libs"
- IgnoreDefaultLibraryNames="libc.lib"
- ProgramDatabaseFile="..\..\..\..\build\msvc_9\libs\verse.pdb"
- SubSystem="1"
- RandomizedBaseAddress="1"
- DataExecutionPrevention="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- Description="Building DNA"
- CommandLine="CD ..\..\..\source\blender\makesdna\intern\
verse.exe dna.c
"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
- >
- <File
- RelativePath="..\..\dist\vs_connection.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_main.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_master.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_audio.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_bitmap.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_curve.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_geometry.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_head.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_material.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_object.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_particle.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_storage.c"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_node_text.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl"
- >
- <File
- RelativePath="..\..\dist\v_cmd_gen.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\v_util.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\verse.h"
- >
- </File>
- <File
- RelativePath="..\..\dist\vs_server.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
|