Commit 515c6bdd authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Activating and fixing tests Motion and SceneConfig. Also some more inline...

Activating and fixing tests Motion and SceneConfig. Also some more inline statements and style changes.
parent 3ffa24d1
......@@ -302,4 +302,4 @@ configure_file( "conf/VACore.ini.proto" "${CMAKE_CURRENT_SOURCE_DIR}/conf/${ITA_
# tests
set( VACORE_COMMON_BUILD TRUE )
#add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
......@@ -35,7 +35,8 @@ class CVAMotionState;
* to achieve smooth movement transitions at any given frame rate,
* i.e. at block rate of the audio process
*/
class IVAMotionModel {
class IVAMotionModel
{
public:
inline virtual ~IVAMotionModel() {};
......
......@@ -53,7 +53,7 @@ public:
double dWindowSize; //!< Size of weighting window [s]
double dWindowDelay; //!< Delay of weighting window [s]
void SetDefaults()
inline void SetDefaults()
{
bLogEstimatedOutputEnabled = false;
......@@ -110,7 +110,7 @@ public:
void Reset();
//! Sets the name of the instance (used for logging file name)
void SetName(const std::string& sNewName);
void SetName( const std::string& sNewName );
protected:
//! Data class of keys
......
......@@ -2,14 +2,14 @@
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VAListState.h
* Datei: VAListState.h
*
* Zweck: Klassen fr Zustnde von Listen mit IDs (z.B. Quellen)
*
......@@ -17,7 +17,7 @@
*
* ---------------------------------------------------------------------------------
*/
// $Id: VAContainerState.h 3629 2014-08-13 12:23:44Z fwefers $
#ifndef __VA_CONTAINERSTATE_H__
......@@ -31,7 +31,8 @@
// Datenklasse welche Unterschiede zwischen Kontainern beschreibt
// (Sichtweise = Different A => B, welche neue Elemente in B, welche Elemente gelscht in B, usw.)
class CVAContainerDiff {
class CVAContainerDiff
{
public:
std::vector<int> liNew; // Neue Elemente (in B und nicht in A)
std::vector<int> liDel; // Gelschte Elemente (in A und nicht in B)
......@@ -47,14 +48,15 @@ public:
// Diese Klasse bescheibt eine dynamische! (versionierten) Liste von Objekten gegeben durch IDs
// Wichtig ist vorallem, das Mengenoperationen schnell implementiert werden knnen
class CVAContainerState : public CVASceneStateBase {
class CVAContainerState : public CVASceneStateBase
{
public:
// Initialisieren (in Grundzustand versetzen)
// (Zustand danach: Nicht-finialisiert, Referenzzhler = 0)
void Initialize(double dModificationTime);
void Initialize( double dModificationTime );
// Daten eines anderen Zustand bernehmen
void Copy(const CVAContainerState* pSrc, double dModificationTime);
void Copy( const CVAContainerState* pSrc, double dModificationTime );
// Fixieren (Fixiert alle enthaltenen Objekte)
void Fix();
......@@ -69,59 +71,63 @@ public:
* \param viDel "alte" Objekte, die nur noch im Comperator enthalten sind
* \param viCom "genderte" Objekte der eigenen Daten, die nicht mit dem Comperator bereinstimmen
*/
void Diff(const CVAContainerState* pComp,
std::vector<int>& viNew,
std::vector<int>& viDel,
std::vector<int>& viCom) const;
void Diff( const CVAContainerState* pComp,
std::vector<int>& viNew,
std::vector<int>& viDel,
std::vector<int>& viCom ) const;
// Anzahl der enthaltenen Objekte zurckgeben
int GetSize() const;
// IDs aller Objekte zurckgeben
void GetIDs(std::vector<int>* pviDest) const;
void GetIDs(std::list<int>* pliDest) const;
void GetIDs(std::set<int>* psiDest) const;
void GetIDs( std::vector<int>* pviDest ) const;
void GetIDs( std::list<int>* pliDest ) const;
void GetIDs( std::set<int>* psiDest ) const;
// Gibt zurck ob ein Objekt der angegeben ID enthalten ist
bool HasObject(int iID) const;
bool HasObject( int iID ) const;
// Zeiger auf ein Objekt zurckgeben (nullptr falls nicht vorhanden)
CVASceneStateBase* GetObject(int iID) const;
CVASceneStateBase* GetObject( int iID ) const;
// Objekt unter bekannter ID hinzufgen
void AddObject(int iID, CVASceneStateBase* pObject);
void AddObject( int iID, CVASceneStateBase* pObject );
// Objekt entfernen
void RemoveObject(int iID);
void RemoveObject( int iID );
// Objekt-Instanz setzen/ndern
void SetObject(int iID, CVASceneStateBase* pObject);
void SetObject( int iID, CVASceneStateBase* pObject );
protected:
// Destruktion vor Pool-Release
void PreRelease();
//private:
//private:
public:
// Element data type (ID -> instance)
typedef std::pair<int, CVASceneStateBase*> ElemType;
// Comperator
struct ElemCompare {
bool operator()(const ElemType& lhs, const ElemType& rhs) const {
struct ElemCompare
{
inline bool operator()( const ElemType& lhs, const ElemType& rhs ) const
{
return lhs.first < rhs.first;
}
};
#if (ALGORITHM == 1)
struct {
struct
{
std::set<int> sElements;
} data;
#endif
#if (ALGORITHM == 2)
// Implementierung mittels Arrays
struct {
struct
{
mutable std::vector<ElemType> vElements;
mutable bool bDirty;
} data;
......
......@@ -38,10 +38,10 @@ public:
class CVAPose
{
public:
CVAPose() {};
~CVAPose() {};
inline CVAPose() {};
inline ~CVAPose() {};
void Reset()
inline void Reset()
{
vPos.Set( 0.0f, 0.0f, 0.0f );
oOrientYPR_DEG.Set( 0.0f, 0.0f, 0.0f );
......
......@@ -18,7 +18,7 @@ static char g_pszDebugPrintfBuf[16384];
void VA_DEBUG_PRINTF(const char * format, ... ) {
VistaMutexLock oLock(VALog_getOutputStreamMutex());
VistaMutexLock oLock( VALog_getOutputStreamMutex() );
#ifdef DEBUG_PRINTF_MSVC
g_csDebugPrintf.enter();
......
#include <VAMotionModel.h>
#include "../src/Motion/VAMotionModelBase.h"
#include "../src/Motion/VAMotionModelBase.cpp"
#include "../src/Scene/VASceneStateBase.cpp"
#include "../src/Scene/VAMotionState.h"
#include "../src/Scene/VAMotionState.cpp"
#include "../src/Utils/VAUtils.cpp"
#include "../src/Utils/VADebug.cpp"
#include "../src/VALog.cpp"
#include <VAException.h>
#include <RG_Vector.h>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
std::ostream& operator<<(std::ostream& os, const RG_Vector& v) {
return os << setprecision(3) << fixed << "(" << v.x << ", " << v.y << ", " << v.z << ")";
}
void test()
{
CVABasicMotionModel::Config oConf;
oConf.SetDefaults();
void test() {
CVABasicMotionModel m;
RG_Vector p,u,v;
CVABasicMotionModel m( oConf );
VAVec3 p, u, v;
// Query ohne vorherige Werte
m.EstimatePosition(0, p);
m.EstimatePosition( 0, p );
cout << p << endl << endl;
m.HandlePositionVelocityKey( 0, RG_Vector(0,0,0), RG_Vector(0,0,0) );
m.EstimatePosition(0, p);
CVAMotionState oNewState;
oNewState.SetPosition( VAVec3( 0, 0, 0 ) );
oNewState.Initialize( 0.0f );
m.InputMotionKey( &oNewState );
m.EstimatePosition( 0, p );
cout << p << endl << endl;
m.HandlePositionVelocityKey( 1, RG_Vector(1,0,0), RG_Vector(0,0,0) );
CVAMotionState oNewState2;
oNewState2.Initialize( 1.0f );
m.InputMotionKey( &oNewState2 );
float t;
for (t=1; t<=2; t+=0.100) {
m.EstimatePosition(t, p);
double t;
for( t = 1; t <= 2; t += 0.100 )
{
m.EstimatePosition( t, p );
cout << "t=" << t << ": p = " << p << endl;
}
cout << endl;
m.HandlePositionVelocityKey( 2, RG_Vector(1,0,0), RG_Vector(1,0,0) );
for (; t<=3; t+=0.100) {
m.EstimatePosition(t, p);
CVAMotionState oNewState3;
oNewState3.SetPosition( VAVec3( 1, 0, 0 ) );
oNewState3.Initialize( 2 );
m.InputMotionKey( &oNewState3 );
for( ; t <= 3; t += 0.100 )
{
m.EstimatePosition( t, p );
cout << "t=" << t << ": p = " << p << endl;
}
cout << endl;
m.HandlePositionVelocityKey( 2.5, RG_Vector(2,0,0), RG_Vector(0,0,0) );
CVAMotionState oNewState4;
oNewState4.SetPosition( VAVec3( 2, 0, 0 ) );
oNewState4.Initialize( 2 );
m.InputMotionKey( &oNewState4 );
for (; t<=4; t+=0.100) {
m.EstimatePosition(t, p);
for( ; t <= 4; t += 0.100 )
{
m.EstimatePosition( t, p );
cout << "t=" << t << ": p = " << p << endl;
}
cout << endl;
}
void test2() {
CVABasicMotionModel m;
RG_Vector p,u,v;
void test_to_file()
{
CVABasicMotionModel::Config oConf;
oConf.SetDefaults();
CVABasicMotionModel m( oConf );
VAVec3 p, u, v;
const double timestep = 0.0029;
double t=0;
ofstream fout("motion.dat");
double t = 0;
ofstream fout( "motion.dat" );
for (int i=0; i<60; i++) {
if (i==0) {
for( int i = 0; i < 60; i++ )
{
if( i == 0 )
{
cout << "!!!" << endl;
m.HandlePositionVelocityKey( t, RG_Vector(0,0,0), RG_Vector(100,0,0) );
CVAMotionState oState;
oState.Initialize( t );
oState.SetPosition( VAVec3() );
m.InputMotionKey( &oState );
}
if (i==10) {
//m.HandlePositionVelocityKey( t, RG_Vector(t,0,0), RG_Vector(0,1,0) );
//m.HandlePositionVelocityKey( t, RG_Vector(t,0,0), RG_Vector(2*0.8660,2*0.5,0) );
m.HandlePositionVelocityKey( t, RG_Vector(100*t+0.001,0,0), RG_Vector(100,0,0) );
if( i == 10 )
{
CVAMotionState oState;
oState.Initialize( t );
oState.SetPosition( VAVec3( 100 * t + 0.001, 0, 0 ) );
m.InputMotionKey( &oState );
cout << "!!!" << endl;
}
m.EstimatePosition(t, p);
m.EstimatePosition( t, p );
cout << "t=" << t << ": p = " << p << endl;
fout << t << "\t" << p.x << "\t" << p.y << "\t" << p.z << endl;
......@@ -79,17 +115,17 @@ void test2() {
cout << endl;
fout.close();
}
int main() {
try {
test2();
int main()
{
} catch (CVAException& e) {
try
{
test_to_file();
}
catch( CVAException& e )
{
cerr << "Error: " << e << endl;
return e.GetErrorCode();
}
......
#include <Scene/VAScene.h>
#include "../src/Scene/VAScene.h"
#include "../src/Scene/VASceneState.cpp"
#include "../src/Scene/VASceneManager.cpp"
#include "../src/Scene/VASurfaceState.cpp"
#include "../src/Scene/VASoundSourceState.cpp"
#include "../src/Scene/VASceneStateBase.cpp"
#include "../src/Scene/VAListenerState.cpp"
#include "../src/Scene/VAPortalState.cpp"
#include "../src/Scene/VAContainerState.cpp"
#include "../src/Scene/VAMotionState.cpp"
#include "../src/Utils/VAUtils.cpp"
#include "../src/Utils/VADebug.cpp"
#include "../src/VALog.cpp"
#include <ITAClock.h>
#include <ITAStopwatch.h>
#include <ITAStopWatch.h>
#include <ITAStringUtils.h>
#include <iostream>
......@@ -153,7 +166,7 @@ std::vector<int> randomIndices(int size) {
void benchmarkContainerState() {
// Initialize random seed
srand ( time(NULL) );
srand( (unsigned int) time( NULL ) );
CVASceneManager sm( ITAClock::getDefaultClock() );
sm.Initialize();
......@@ -161,7 +174,7 @@ void benchmarkContainerState() {
// Request times
const int cycles = 100;
ITAStopwatch swRequest;
ITAStopWatch swRequest;
swRequest.start();
for (int i=0; i<cycles; i++) {
CVAContainerState* c = sm.RequestContainerState();
......@@ -169,7 +182,7 @@ void benchmarkContainerState() {
swRequest.stop();
printf("RequestContainerState = %s\n", timeToString(swRequest.mean() / cycles).c_str());
ITAStopwatch swNew;
ITAStopWatch swNew;
swNew.start();
for (int i=0; i<cycles; i++) {
CVAContainerState* c = new CVAContainerState();
......@@ -178,7 +191,7 @@ void benchmarkContainerState() {
printf("NewContainerState = %s\n", timeToString(swNew.mean() / cycles).c_str());
ITAStopwatch sw;
ITAStopWatch sw;
CVAContainerState* c;
std::vector<int> v = randomIndices(1000);
......
# $Id:$
set( RelativeDir "tests" )
set( RelativeSourceGroup "tests" )
set( DirFiles
CoreTest.cpp
MotionModelTest.cpp
ObjectContainerTest.cpp
ObjectPoolTest.cpp
SHTest.cpp
SceneConfigTest.cpp
ThirdOctaveFilterGeneratorTest.cpp
ThirdOctaveFilterbankTest.cpp
UtilsTest.cpp
VALogTest.cpp
VDLTest.cpp
VariableDelayLineTest.cpp
_SourceFiles.cmake
)
set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
set( LocalSourceGroupFiles )
foreach( File ${DirFiles} )
list( APPEND LocalSourceGroupFiles "${RelativeDir}/${File}" )
list( APPEND ProjectSources "${RelativeDir}/${File}" )
endforeach()
source_group( ${DirFiles_SourceGroup} FILES ${LocalSourceGroupFiles} )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment