// environment variable for enabling/disabling fps tracking
#define DALI_ENV_FPS_TRACKING "DALI_FPS_TRACKING"
-// environment variable for enabling/disabling fps tracking
#define DALI_ENV_UPDATE_STATUS_INTERVAL "DALI_UPDATE_STATUS_INTERVAL"
#define DALI_ENV_OBJECT_PROFILER_INTERVAL "DALI_OBJECT_PROFILER_INTERVAL"
oss += "<Animations running> ";
}
- if ( keepUpdatingStatus & Integration::KeepUpdating::DYNAMICS_CHANGED )
- {
- oss += "<Dynamics running> ";
- }
-
if ( keepUpdatingStatus & Integration::KeepUpdating::LOADING_RESOURCES )
{
oss += "<Resources loading> ";
mTrace.PushCall("JoinLoaderThreads", "");
}
-Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory()
-{
- mTrace.PushCall("GetDynamicsFactory", "");
- return NULL;
-}
-
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
case SetDpiFunc: return mTrace.FindMethod("SetDpi");
case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
- case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory");
}
return false;
}
virtual void JoinLoaderThreads();
- virtual Integration::DynamicsFactory* GetDynamicsFactory();
-
public: // TEST FUNCTIONS
// Enumeration of Platform Abstraction methods
IsLoadingFunc,
SetDpiFunc,
JoinLoaderThreadsFunc,
- GetDynamicsFactoryFunc
} TestFuncEnum;
/** Call this every test */
#
-# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+# Copyright (c) 2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
AC_SUBST(DALI_ELDBUS_AVAILABLE)
-PKG_CHECK_EXISTS(bullet, [
- BULLET_CFLAGS=`pkg-config --cflags bullet`
- BULLET_LIBS=`pkg-config --libs bullet`
- BULLET=yes
-], [
- AC_MSG_WARN([BulletPhysics development files not found, not building bullet plugin])
- BULLET_CFLAGS=
- BULLET_LIBS=
- BULLET=no
-])
-
-AC_SUBST(BULLET_CFLAGS)
-AC_SUBST(BULLET_LIBS)
-
-AC_ARG_ENABLE([bullet],
- [AC_HELP_STRING([ --enable-bullet],
- [Enable bullet plugin])],
- [enable_bullet=yes],
- [enable_bullet=no])
-
-
AC_ARG_ENABLE([feedback],
[AC_HELP_STRING([ --enable-feedback],
[Enable feedback plugin])],
[enable_feedback=yes],
[enable_feedback=no])
-AM_CONDITIONAL([USE_BULLET], [test x$BULLET = xyes && test x$enable_bullet = xyes])
AM_CONDITIONAL([USE_FEEDBACK], [test x$enable_feedback = xyes])
DALI_ADAPTOR_CFLAGS="$DALI_ADAPTOR_CFLAGS -DPLATFORM_TIZEN"
adaptor/dali-adaptor-integration.pc
])
-AM_CONDITIONAL([USE_PLUGIN], [test x$enable_feedback = xyes || test x$enable_bullet = xyes])
+AM_CONDITIONAL([USE_PLUGIN], [test x$enable_feedback = xyes])
-if test "x$enable_feedback" = "xyes" || test "x$enable_bullet" = "xyes"; then
+if test "x$enable_feedback" = "xyes"; then
AC_CONFIG_FILES([
plugins/Makefile
])
#
-# Copyright (c) 2014 Samsung Electronics Co., Ltd.
+# Copyright (c) 2015 Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
lib_LTLIBRARIES += libdali-feedback-plugin.la
endif
-if USE_BULLET
-lib_LTLIBRARIES += libdali-bullet-plugin.la
-endif
-
if USE_FEEDBACK
dalisounddir = ${dataReadOnlyDir}/plugins/sounds/
dalisound_DATA = ${dali_plugin_sound_files}
$(FEEDBACK_LIBS)
endif
-
-if USE_BULLET
-
-# Bullet Physics
-libdali_bullet_plugin_la_SOURCES = \
- $(bullet_plugin_src_files)
-
-libdali_bullet_plugin_la_CXXFLAGS = -DDALI_COMPILATION \
- $(DALICORE_CFLAGS) \
- $(DLOG_CFLAGS) \
- $(BULLET_CFLAGS) \
- $(DALI_ADAPTOR_CFLAGS) \
- -I../../.. \
- -Werror -Wall
-
-libdali_bullet_plugin_la_LIBADD = \
- $(DLOG_LIBS) \
- $(BULLET_LIBS)
-
-libdali_bullet_plugin_la_LDFLAGS = \
- -rdynamic
-
-libdali_bullet_plugin_la_DEPENDENCIES =
-endif
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dlfcn.h>
-
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/dynamics/dynamics-body-intf.h>
-#include <dali/integration-api/dynamics/dynamics-body-settings.h>
-#include <dali/integration-api/dynamics/dynamics-joint-intf.h>
-#include <dali/integration-api/dynamics/dynamics-shape-intf.h>
-#include <dali/integration-api/dynamics/dynamics-world-intf.h>
-#include <dali/integration-api/dynamics/dynamics-world-settings.h>
-
-// INTERNAL INCLUDES
-#include "dynamics-factory.h"
-
-namespace Dali
-{
-
-namespace TizenPlatform
-{
-
-namespace
-{
-
-const char* SO_BULLET( "libdali-bullet-plugin.so" );
-
-} // unnamed namespace
-
-DynamicsFactory::DynamicsFactory()
-: mHandle( NULL ),
- mCreateDynamicsWorld( NULL ),
- mCreateDynamicsBody( NULL ),
- mCreateDynamicsJoint( NULL ),
- mCreateDynamicsShape( NULL )
-{
-}
-
-DynamicsFactory::~DynamicsFactory()
-{
- TerminateDynamics();
-}
-
-bool DynamicsFactory::InitializeDynamics( const Integration::DynamicsWorldSettings& worldSettings )
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - type(%d)\n", __PRETTY_FUNCTION__, worldSettings.type );
-
- bool result( true );
-
- if( NULL == mHandle )
- {
- mHandle = dlopen( SO_BULLET, RTLD_NOW | RTLD_GLOBAL );
-
- if( NULL == mHandle )
- {
- DALI_LOG_ERROR( "dlopen error:'%s'\n", dlerror() );
- result = false;
- }
- else
- {
- mCreateDynamicsWorld = reinterpret_cast<CreateDynamicsWorldFunction>(dlsym( mHandle, "CreateDynamicsWorld"));
- if( !mCreateDynamicsWorld )
- {
- DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsWorld(): dlsym error: %s\n", dlerror() );
- result = false;
- }
- else
- {
- mCreateDynamicsBody = reinterpret_cast<CreateDynamicsBodyFunction>(dlsym( mHandle, "CreateDynamicsBody"));
- if( !mCreateDynamicsBody )
- {
- DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsBody(): dlsym error: %s\n", dlerror() );
- result = false;
- }
- else
- {
- mCreateDynamicsJoint = reinterpret_cast<CreateDynamicsJointFunction>(dlsym( mHandle, "CreateDynamicsJoint"));
- if( !mCreateDynamicsJoint )
- {
- DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsJoint(): dlsym error: %s\n", dlerror() );
- result = false;
- }
- else
- {
- mCreateDynamicsShape = reinterpret_cast<CreateDynamicsShapeFunction>(dlsym( mHandle, "CreateDynamicsShape"));
- if( !mCreateDynamicsShape )
- {
- DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsShape(): dlsym error: %s\n", dlerror() );
- result = false;
- }
- }
- }
- }
-
- // Couldn't find all required symbols
- if( !result )
- {
- if( dlclose( mHandle ) )
- {
- DALI_LOG_ERROR( "Error closing Dynamics Plugin:'%s': with error %s\n", SO_BULLET, dlerror() );
- }
- mHandle = NULL;
- }
- }
- }
-
- return result;
-}
-
-void DynamicsFactory::TerminateDynamics()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__ );
-
- if( NULL != mHandle )
- {
- if( dlclose( mHandle ) )
- {
- DALI_LOG_ERROR( "Error closing Dynamics Plugin:'%s': with error %s\n", SO_BULLET, dlerror() );
- }
- mHandle = NULL;
- }
-}
-
-Integration::DynamicsWorld* DynamicsFactory::CreateDynamicsWorld()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__ );
-
- Integration::DynamicsWorld* dynamicsWorld( NULL );
-
- if( mHandle )
- {
- dynamicsWorld = mCreateDynamicsWorld();
- }
-
- return dynamicsWorld;
-}
-
-Integration::DynamicsBody* DynamicsFactory::CreateDynamicsBody()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__ );
-
- Integration::DynamicsBody* dynamicsBody( NULL );
-
- if( mHandle )
- {
- dynamicsBody = mCreateDynamicsBody();
- }
-
- return dynamicsBody;
-}
-
-Integration::DynamicsJoint* DynamicsFactory::CreateDynamicsJoint()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__ );
-
- Integration::DynamicsJoint* dynamicsJoint( NULL );
-
- if( mHandle )
- {
- dynamicsJoint = mCreateDynamicsJoint();
- }
-
- return dynamicsJoint;
-}
-
-Integration::DynamicsShape* DynamicsFactory::CreateDynamicsShape()
-{
- DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__ );
-
- Integration::DynamicsShape* dynamicsShape( NULL );
-
- if( mHandle )
- {
- dynamicsShape = mCreateDynamicsShape();
- }
-
- return dynamicsShape;
-}
-
-} // namespace TizenPlatform
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DYNAMICS_FACTORY_H__
-#define __DYNAMICS_FACTORY_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/dynamics/dynamics-factory-intf.h>
-
-// INTERNAL INCLUDES
-
-namespace Dali
-{
-
-namespace TizenPlatform
-{
-
-/**
- *
- */
-class DynamicsFactory : public Integration::DynamicsFactory
-{
-public:
- /**
- * Constructor
- */
- DynamicsFactory();
-
- /**
- * Destructor
- */
- virtual ~DynamicsFactory();
-
- /**
- * @copydoc Dali::Integration::DynamicsFactory::InitializeDynamics
- */
- bool InitializeDynamics( const Integration::DynamicsWorldSettings& worldSettings );
-
- /**
- * @copydoc Dali::Integration::DynamicsFactory::TerminateDynamics
- */
- void TerminateDynamics();
-
- /**
- * @copydoc Dali::Integration::DynamicsFactory::CreateDynamicsWorld
- */
- Integration::DynamicsWorld* CreateDynamicsWorld();
-
- /**
- * @copydoc Dali::Integration::DynamicsFactory::CreateDynamicsBody
- */
- virtual Integration::DynamicsBody* CreateDynamicsBody();
-
- /**
- * @copydoc Dali::Integration::DynamicsFactory::CreateDynamicsJoint
- */
- virtual Integration::DynamicsJoint* CreateDynamicsJoint();
-
- /**
- * @copydoc Dali::Integration::DynamicsFactory::CreateDynamicsShape
- */
- virtual Integration::DynamicsShape* CreateDynamicsShape();
-
-private:
- void* mHandle; ///< The handle to the open shared object library
-
- typedef Integration::DynamicsWorld* (*CreateDynamicsWorldFunction)();
- typedef Integration::DynamicsBody* (*CreateDynamicsBodyFunction)();
- typedef Integration::DynamicsJoint* (*CreateDynamicsJointFunction)();
- typedef Integration::DynamicsShape* (*CreateDynamicsShapeFunction)();
-
- CreateDynamicsWorldFunction mCreateDynamicsWorld;
- CreateDynamicsBodyFunction mCreateDynamicsBody;
- CreateDynamicsJointFunction mCreateDynamicsJoint;
- CreateDynamicsShapeFunction mCreateDynamicsShape;
-
-}; // class DynamicsFactory
-
-} // namespace TizenPlatform
-
-} // namespace Dali
-
-#endif // __DYNAMICS_FACTORY_H__
$(tizen_platform_abstraction_src_dir)/tizen-platform-abstraction.cpp \
$(tizen_platform_abstraction_src_dir)/tizen-logging.cpp \
$(tizen_platform_abstraction_src_dir)/tizen-font-configuration-parser.cpp \
- $(tizen_platform_abstraction_src_dir)/dynamics/dynamics-factory.cpp \
\
$(tizen_platform_abstraction_src_dir)/resource-loader/resource-loader.cpp \
$(tizen_platform_abstraction_src_dir)/resource-loader/resource-requester-base.cpp \
#include <dali/integration-api/resource-types.h>
#include "resource-loader/resource-loader.h"
-#include "dynamics/dynamics-factory.h"
#include "tizen-font-configuration-parser.h"
#include "image-loaders/image-loader.h"
TizenPlatformAbstraction::TizenPlatformAbstraction()
: mResourceLoader(new ResourceLoader),
- mDynamicsFactory(NULL),
mDataStoragePath( "" )
{
}
TizenPlatformAbstraction::~TizenPlatformAbstraction()
{
delete mResourceLoader;
- delete mDynamicsFactory;
}
void TizenPlatformAbstraction::GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds)
mResourceLoader = NULL;
}
-Integration::DynamicsFactory* TizenPlatformAbstraction::GetDynamicsFactory()
-{
- if( NULL == mDynamicsFactory )
- {
- mDynamicsFactory = new DynamicsFactory;
- }
-
- return mDynamicsFactory;
-}
-
bool TizenPlatformAbstraction::LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
{
bool result = false;
namespace TizenPlatform
{
-class DynamicsFactory;
class ResourceLoader;
/**
virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const;
/**
- * @copydoc PlatformAbstraction::GetDynamicsFactory();
- */
- virtual Integration::DynamicsFactory* GetDynamicsFactory();
-
- /**
* @copydoc PlatformAbstraction::LoadShaderBinFile()
*/
virtual bool LoadShaderBinFile( const std::string& filename, std::vector< unsigned char >& buffer ) const;
private:
ResourceLoader* mResourceLoader;
- DynamicsFactory* mDynamicsFactory;
std::string mDataStoragePath;
};
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#define LOG_TAG "DALI_DYNAMICS"
-
-// EXTERNAL INCLUDES
-#include <dlog.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-# include <btBulletDynamicsCommon.h>
-# include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
-# include "BulletSoftBody/btSoftBodyHelpers.h"
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-#include <dali/integration-api/dynamics/dynamics-body-settings.h>
-#include <dali/devel-api/geometry/mesh.h>
-#include <dali/public-api/math/math-utils.h>
-
-// INTERNAL INCLUDES
-#include "bullet-dynamics-body.h"
-#include "bullet-dynamics-shape.h"
-#include "bullet-dynamics-world.h"
-
-#define DEBUG_PRINTF(fmt, arg...) LOGD(fmt, ##arg)
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-BulletDynamicsBody::BulletDynamicsBody()
-: mSettings( NULL ),
- mBody( NULL ),
- mConserveVolume(false),
- mConserveShape(false),
- mKinematic(false),
- mActivationState(false),
- mCollisionGroup(0),
- mCollisionMask(0)
-{
- DEBUG_PRINTF("%s\n", __func__);
-}
-
-BulletDynamicsBody::~BulletDynamicsBody()
-{
- DEBUG_PRINTF("%s\n", __func__);
-
- delete mBody;
- delete mSettings;
-}
-
-void BulletDynamicsBody::Initialize( const Integration::DynamicsBodySettings& settings, Integration::DynamicsShape* shape,
- Integration::DynamicsWorld& dynamicsWorld,
- const Vector3& startPosition, const Quaternion& startRotation )
-{
- DEBUG_PRINTF("%s type:%d\n", __func__, settings.type );
-
- mSettings = new Integration::DynamicsBodySettings( settings );
- mWorld = static_cast< BulletDynamicsWorld* >( &dynamicsWorld );
-
- if( Dali::DynamicsBodyConfig::RIGID == mSettings->type )
- {
- CreateRigidBody( settings, shape, startPosition, startRotation );
- }
- else
- {
- CreateSoftBody( settings, shape, startPosition, startRotation );
- }
-}
-
-void BulletDynamicsBody::SetMass( float mass )
-{
- DEBUG_PRINTF("%s(%.2f)\n", __func__, mass);
-
- if( Dali::DynamicsBodyConfig::RIGID == mSettings->type )
- {
- btRigidBody* rigidBody( btRigidBody::upcast(mBody) );
- DALI_ASSERT_DEBUG( rigidBody );
-
- btVector3 inertia(0,0,0);
- if( ! EqualsZero( mass ) )
- {
- btCollisionShape* shape = mBody->getCollisionShape();
- shape->calculateLocalInertia(mass, inertia);
- }
- rigidBody->setMassProps(btScalar(mass), inertia);
- }
- else if( Dali::DynamicsBodyConfig::SOFT == mSettings->type )
- {
- btSoftBody* softBody( btSoftBody::upcast(mBody) );
- DALI_ASSERT_DEBUG( softBody );
-
- softBody->setTotalMass(mass);
- }
-}
-
-void BulletDynamicsBody::SetElasticity( float elasticity )
-{
- DEBUG_PRINTF("%s(%.2f)\n", __func__, elasticity);
-
- static_cast<btRigidBody*>(mBody)->setRestitution(elasticity);
-}
-
-void BulletDynamicsBody::SetLinearVelocity( const Vector3& velocity )
-{
- DEBUG_PRINTF("%s(%.2f %.2f %.2f)\n", __func__, velocity.x, velocity.y, velocity.z);
-
- if( Dali::DynamicsBodyConfig::RIGID == mSettings->type )
- {
- static_cast<btRigidBody*>(mBody)->setLinearVelocity(btVector3(velocity.x, velocity.y, velocity.z) );
- }
- else if( Dali::DynamicsBodyConfig::SOFT == mSettings->type )
- {
- // TODO set velocities of all vertices/nodes in the soft body
- }
-}
-
-Vector3 BulletDynamicsBody::GetLinearVelocity() const
-{
- const btVector3& linearVelocity( static_cast<btRigidBody*>(mBody)->getLinearVelocity() );
-
- return Vector3( linearVelocity.x(), linearVelocity.y(), linearVelocity.z() );
-}
-
-void BulletDynamicsBody::SetAngularVelocity( const Vector3& velocity )
-{
- DEBUG_PRINTF("%s(%.2f %.2f %.2f)\n", __func__, velocity.x, velocity.y, velocity.z);
-
- if( Dali::DynamicsBodyConfig::RIGID == mSettings->type )
- {
- static_cast<btRigidBody*>(mBody)->setAngularVelocity(btVector3(velocity.x, velocity.y, velocity.z) );
- }
- else if( Dali::DynamicsBodyConfig::SOFT == mSettings->type )
- {
- // TODO set velocities of all vertices/nodes in the soft body
- }
-}
-
-Vector3 BulletDynamicsBody::GetAngularVelocity() const
-{
- const btVector3& angularVelocity( static_cast<btRigidBody*>(mBody)->getAngularVelocity() );
-
- return Vector3( angularVelocity.x(), angularVelocity.y(), angularVelocity.z() );
-}
-
-void BulletDynamicsBody::SetKinematic( bool flag )
-{
- DEBUG_PRINTF("%s( new:%d current:%d)\n", __func__, flag, mKinematic);
-
- if( flag != mKinematic )
- {
- mKinematic = flag;
-
- btRigidBody* rigidBody( static_cast< btRigidBody* >( mBody ) );
-
- if( flag )
- {
- rigidBody->setCollisionFlags( rigidBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
- mBody->setActivationState(DISABLE_DEACTIVATION);
- }
- else
- {
- rigidBody->setCollisionFlags( rigidBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT);
- }
- }
-}
-
-/// @copydoc Dali::DynamicsBody::IsKinematic
-bool BulletDynamicsBody::IsKinematic() const
-{
- return mKinematic;
-}
-
-void BulletDynamicsBody::SetSleepEnabled( bool flag )
-{
- DEBUG_PRINTF("%s( %d )\n", __func__, flag);
-
- if( !flag )
- {
- mBody->setActivationState(DISABLE_DEACTIVATION);
- }
- else
- {
- if( mBody->getActivationState() == DISABLE_DEACTIVATION )
- {
- mBody->forceActivationState(ACTIVE_TAG);
- }
- }
-}
-
-void BulletDynamicsBody::WakeUp()
-{
- DEBUG_PRINTF("%s()\n", __func__ );
-
- if( !mKinematic )
- {
- mBody->activate();
- mActivationState = true;
- }
-}
-
-void BulletDynamicsBody::AddAnchor( unsigned int index, const Integration::DynamicsBody* anchorBody, bool collisions )
-{
- DEBUG_PRINTF("%s\n", __func__);
- const BulletDynamicsBody* anchorDynamicsBody( static_cast< const BulletDynamicsBody* >( anchorBody ) );
-
- btSoftBody* softBody( static_cast< btSoftBody* >( mBody ) );
- btRigidBody* rigidBody( static_cast< btRigidBody* >( anchorDynamicsBody->GetBody() ) );
- softBody->appendAnchor( index, rigidBody, !collisions );
-}
-
-void BulletDynamicsBody::ConserveVolume( bool flag )
-{
- if( mConserveVolume != flag )
- {
- mConserveVolume = flag;
-
- btSoftBody* softBody( static_cast< btSoftBody* >( mBody ) );
- softBody->setPose( mConserveVolume, mConserveShape );
- }
-}
-
-void BulletDynamicsBody::ConserveShape( bool flag )
-{
- if( mConserveShape != flag )
- {
- mConserveShape = flag;
-
- btSoftBody* softBody( static_cast<btSoftBody*>(mBody) );
- softBody->setPose( mConserveVolume, mConserveShape );
- }
-}
-
-short int BulletDynamicsBody::GetCollisionGroup() const
-{
- return mCollisionGroup;
-}
-
-void BulletDynamicsBody::SetCollisionGroup( short int collisionGroup )
-{
- DEBUG_PRINTF("%s(%d)\n", __func__, collisionGroup);
-
- mCollisionGroup = collisionGroup;
-}
-
-
-short int BulletDynamicsBody::GetCollisionMask() const
-{
- return mCollisionMask;
-}
-
-void BulletDynamicsBody::SetCollisionMask( short int collisionMask )
-{
- DEBUG_PRINTF("%s(%d)\n", __func__, collisionMask);
-
- mCollisionMask = collisionMask;
-}
-
-int BulletDynamicsBody::GetType() const
-{
- return mSettings->type;
-}
-
-bool BulletDynamicsBody::IsActive() const
-{
- return mBody->getActivationState() == ACTIVE_TAG;
-}
-
-void BulletDynamicsBody::SetTransform( const Vector3& position, const Quaternion& rotation )
-{
- Vector3 axis;
- float angle( 0.0f );
- rotation.ToAxisAngle( axis, angle );
-
- if( Dali::DynamicsBodyConfig::RIGID == mSettings->type )
- {
- btTransform& transform( mBody->getWorldTransform() );
- // modify parameters
- transform.setIdentity();
- transform.setOrigin( btVector3(position.x, position.y, position.z) );
- if( axis != Vector3::ZERO )
- {
- transform.setRotation( btQuaternion(btVector3(axis.x, axis.y, axis.z), btScalar(angle)) );
- }
- }
- else if( Dali::DynamicsBodyConfig::SOFT == mSettings->type )
- {
- btSoftBody* softBody( static_cast< btSoftBody* >( mBody ) );
- btTransform transform;
- transform.setIdentity();
- transform.setOrigin( btVector3(position.x, position.y, position.z) );
- if( axis != Vector3::ZERO )
- {
- transform.setRotation( btQuaternion(btVector3(axis.x, axis.y, axis.z), btScalar(angle)) );
- }
- softBody->transform( transform );
- }
-}
-
-void BulletDynamicsBody::GetTransform( Vector3& position, Quaternion& rotation )
-{
- // get updated parameters
- const btTransform& transform( GetBody()->getWorldTransform() );
- const btVector3& origin( transform.getOrigin() );
- const btQuaternion currentRotation( transform.getRotation() );
- const btVector3& axis( currentRotation.getAxis() );
- const btScalar& angle( currentRotation.getAngle() );
-
- position = Vector3( origin.x(), origin.y(), origin.z() );
- rotation = Quaternion( float(angle), Vector3( axis.x(), axis.y(), axis.z() ) );
-}
-
-void BulletDynamicsBody::GetSoftVertices( MeshData::VertexContainer& vertices ) const
-{
- const float worldScale( 1.0f / mWorld->GetWorldScale() );
-
- // copy positions and normals
- const size_t vertexCount = vertices.size();
- MeshData::Vertex* vertex( &vertices[0] );
-
- btSoftBody* softBody( static_cast<btSoftBody*>( mBody ) );
- btSoftBody::Node* node( &softBody->m_nodes[0] );
- for( size_t i = 0; i < vertexCount; ++i )
- {
- vertex->x = node->m_x.x() * worldScale;
- vertex->y = node->m_x.y() * worldScale;
- vertex->z = node->m_x.z() * worldScale;
-
- vertex->nX = node->m_n.x();
- vertex->nY = node->m_n.y();
- vertex->nZ = node->m_n.z();
-
- ++vertex;
- ++node;
- }
-}
-
-btCollisionObject* BulletDynamicsBody::GetBody() const
-{
- return mBody;
-}
-
-void BulletDynamicsBody::CreateRigidBody( const Integration::DynamicsBodySettings& bodySettings, Dali::Integration::DynamicsShape* shape,
- const Vector3& startPosition, const Quaternion& startRotation )
-{
- DEBUG_PRINTF("%s\n", __func__ );
-
- Vector3 axis;
- float angle( 0.0f );
- startRotation.ToAxisAngle( axis, angle );
-
- btVector3 inertia( 0.0f ,0.0f ,0.0f );
- btCollisionShape* collisionShape( ((BulletDynamicsShape*)shape)->GetShape() );
- if( ! EqualsZero( bodySettings.mass ) )
- {
- collisionShape->calculateLocalInertia(bodySettings.mass, inertia);
- }
-
- btRigidBody::btRigidBodyConstructionInfo constructionInfo(bodySettings.mass, NULL, collisionShape, inertia);
- constructionInfo.m_restitution = bodySettings.elasticity;
- constructionInfo.m_linearDamping = bodySettings.linearDamping;
- constructionInfo.m_angularDamping = bodySettings.angularDamping;
- constructionInfo.m_friction = bodySettings.friction;
- constructionInfo.m_linearSleepingThreshold = bodySettings.linearSleepVelocity;
- constructionInfo.m_angularSleepingThreshold = bodySettings.angularSleepVelocity;
- constructionInfo.m_startWorldTransform.setOrigin(btVector3(startPosition.x, startPosition.y, startPosition.z));
- if( axis != Vector3::ZERO )
- {
- constructionInfo.m_startWorldTransform.setRotation( btQuaternion(btVector3(axis.x, axis.y, axis.z), btScalar(angle)) );
- }
-
- mBody = new btRigidBody( constructionInfo );
- mBody->setUserPointer(this);
-}
-
-void BulletDynamicsBody::CreateSoftBody( const Integration::DynamicsBodySettings& bodySettings, Dali::Integration::DynamicsShape* shape,
- const Vector3& startPosition, const Quaternion& startRotation )
-{
- DEBUG_PRINTF("BulletDynamicsBody::CreateSoftBody()\n" );
-
- BulletDynamicsShape* dynamicsShape( static_cast< BulletDynamicsShape* >( shape ) );
-
- // copy positions
- MeshData::VertexContainer* vertices( dynamicsShape->mVertices );
- const size_t vertexCount = vertices->size();
- MeshData::Vertex* vertex( &(*vertices)[0] );
-
- MeshData::FaceIndices* faces( dynamicsShape->mFaces );
- const size_t faceCount = faces->size() / 3;
- unsigned short* faceIndex = ( &(*faces)[0] );
-
- const float worldScale( mWorld->GetWorldScale() );
-
- DEBUG_PRINTF("%s verts:%d faces:%d worldScale:%.2f\n", __func__, (int)vertexCount, (int)faceCount, worldScale );
-
- // copy vertex positions
- std::vector<btVector3> positions( vertexCount );
- btVector3* position = &positions[0];
- for( size_t i = 0; i < vertexCount; ++i )
- {
- *position++ = btVector3( vertex->x, vertex->y, vertex->z ) * worldScale;
- vertex++;
- }
-
- btSoftBody* softBody( new btSoftBody(mWorld->GetSoftBodyWorldInfo(), vertexCount, positions.data(), NULL) );
-
- // Add faces
- for( size_t i = 0; i < faceCount; ++i)
- {
- softBody->appendFace(faceIndex[0], faceIndex[1], faceIndex[2]);
- softBody->appendLink(faceIndex[0], faceIndex[1], NULL, true);
- softBody->appendLink(faceIndex[0], faceIndex[2], NULL, true);
- softBody->appendLink(faceIndex[1], faceIndex[2], NULL, true);
- faceIndex += 3;
- }
-
- softBody->m_cfg.kAHR = std::max(0.0f, std::min(1.0f, bodySettings.anchorHardness));
- softBody->m_cfg.kVC = std::max(0.0f, bodySettings.volumeConservation);
- softBody->m_cfg.kMT = std::max(0.0f, std::min(1.0f, bodySettings.shapeConservation));
- softBody->m_cfg.kDP = Clamp( bodySettings.linearDamping, 0.0f, 1.0f );
-
- btSoftBody::Material* material( softBody->m_materials[0] );
- material->m_kLST = bodySettings.linearStiffness;
-
-// material->m_flags &= ~btSoftBody::fMaterial::DebugDraw; // By default, inhibit debug draw for softbodies
- softBody->m_cfg.collisions = btSoftBody::fCollision::SDF_RS |
- btSoftBody::fCollision::CL_SS |
- 0;
-
- softBody->getCollisionShape()->setMargin(0.5f);
-
- mBody = softBody;
- mBody->setUserPointer(this);
-
- SetTransform( startPosition, startRotation );
-}
-
-} // namespace Plugin
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_PLUGIN_BULLET_DYNAMICS_BODY_H__
-#define __DALI_PLUGIN_BULLET_DYNAMICS_BODY_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-// INTERNAL INCLUDES
-#include <dali/integration-api/dynamics/dynamics-body-intf.h>
-
-class btCollisionObject;
-
-namespace Dali
-{
-
-namespace Integration
-{
-
-struct DynamicsBodySettings;
-class DynamicsShape;
-
-} // namespace Integration
-
-namespace Plugin
-{
-
-class BulletDynamicsWorld;
-
-/*
- *
- */
-class BulletDynamicsBody : public Integration::DynamicsBody
-{
-public:
- BulletDynamicsBody();
- virtual ~BulletDynamicsBody();
-
-public: // From Dali::Integration::DynamicsBody
-
- ///@ copydoc Dali::DynamicsBody::Initialize
- void Initialize( const Integration::DynamicsBodySettings& bodySettings, Integration::DynamicsShape* shape,
- Integration::DynamicsWorld& dynamicsWorld,
- const Vector3& startPosition, const Quaternion& startRotation );
-
- ///@ copydoc Dali::DynamicsBody::SetMass
- void SetMass( float mass );
-
- ///@ copydoc Dali::DynamicsBody::SetElasticity
- void SetElasticity( float elasticity );
-
- /// @copydoc Dali::DynamicsBody::SetLinearVelocity
- void SetLinearVelocity( const Vector3& velocity );
-
- /// @copydoc Dali::DynamicsBody::GetLinearVelocity
- Vector3 GetLinearVelocity() const;
-
- /// @copydoc Dali::DynamicsBody::SetAngularVelocity
- void SetAngularVelocity( const Vector3& velocity );
-
- /// @copydoc Dali::DynamicsBody::GetAngularVelocity
- Vector3 GetAngularVelocity() const;
-
- /// @copydoc Dali::DynamicsBody::SetKinematic
- void SetKinematic( bool flag );
-
- /// @copydoc Dali::DynamicsBody::IsKinematic
- bool IsKinematic() const;
-
- /// @copydoc Dali::DynamicsBody::SetSleepEnabled
- void SetSleepEnabled( bool flag );
-
- /// @copydoc Dali::DynamicsBody::WakeUp
- void WakeUp();
-
- /// @copydoc Dali::DynamicsBody::AddAnchor
- void AddAnchor( unsigned int index, const Integration::DynamicsBody* anchorBody, bool collisions );
-
- /// @copydoc Dali::DynamicsBody::ConserveVolume
- void ConserveVolume( bool flag );
-
- /// @copydoc Dali::DynamicsBody::ConserveShape
- void ConserveShape( bool flag );
-
- /// @copydoc Dali::DynamicsBody::GetCollisionGroup
- short int GetCollisionGroup() const;
-
- /// @copydoc Dali::DynamicsBody::SetCollisionGroup
- void SetCollisionGroup( short int collisionGroup );
-
- /// @copydoc Dali::DynamicsBody::GetCollisionMask
- short int GetCollisionMask() const;
-
- /// @copydoc Dali::DynamicsBody::SetCollisionMask
- void SetCollisionMask( short int collisionMask );
-
- int GetType() const;
-
- /// @copydoc Dali::DynamicsBody::IsActive
- bool IsActive() const;
-
- /// @copydoc Dali::Integration::DynamicsBody::SetTransform
- void SetTransform( const Vector3& position, const Quaternion& rotation );
-
- /// @copydoc Dali::Integration::GetTransform
- void GetTransform( Vector3& position, Quaternion& rotation );
-
- /// @copydoc Dali::Integration::GetSoftVertices
- void GetSoftVertices( MeshData::VertexContainer& vertices ) const;
-
-public:
-
- btCollisionObject* GetBody() const;
-
-private:
- /**
- * Create a rigid body
- */
- void CreateRigidBody( const Integration::DynamicsBodySettings& bodySettings, Dali::Integration::DynamicsShape* shape,
- const Vector3& startPosition, const Quaternion& startRotation );
-
- /**
- * Create a soft body
- */
- void CreateSoftBody( const Integration::DynamicsBodySettings& bodySettings, Dali::Integration::DynamicsShape* shape,
- const Vector3& startPosition, const Quaternion& startRotation );
-
-private:
- Dali::Integration::DynamicsBodySettings* mSettings;
- btCollisionObject* mBody;
- bool mConserveVolume:1;
- bool mConserveShape:1;
- bool mKinematic:1;
- bool mActivationState:1;
-
- short int mCollisionGroup;
- short int mCollisionMask;
-
- BulletDynamicsWorld* mWorld;
-
-}; // class BulletDynamicsBody
-
-} // namespace Plugin
-
-} // namespace Dali
-
-#endif // __DALI_PLUGIN_BULLET_DYNAMICS_BODY_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#define LOG_TAG "DALI_DYNAMICS"
-
-// EXTERNAL INCLUDES
-#include <dlog.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-#include <btBulletDynamicsCommon.h>
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-// INTERNAL INCLUDES
-#include "bullet-dynamics-debug.h"
-
-#define DEBUG_PRINTF(fmt, arg...) LOGD(fmt, ##arg)
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-BulletDebugDraw::BulletDebugDraw()
-: mDebugMode(0)
-{
- DEBUG_PRINTF( "%s\n", __PRETTY_FUNCTION__ );
-}
-
-BulletDebugDraw::~BulletDebugDraw()
-{
- DEBUG_PRINTF( "%s\n", __PRETTY_FUNCTION__ );
-}
-
-void BulletDebugDraw::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
-{
-// DEBUG_PRINTF( "%s\n", __PRETTY_FUNCTION__ );
-
- Integration::DynamicsDebugVertex vertex;
- vertex.position = Vector3( from.getX(), from.getY(), from.getZ() );
- vertex.color = Vector4( color.getX(), color.getY(), color.getZ(), 1.0f );
- mVertices.push_back( vertex );
- vertex.position = Vector3( to.getX(), to.getY(), to.getZ());
- mVertices.push_back( vertex );
-}
-
-void BulletDebugDraw::drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)
-{
- btVector3 to = PointOnB + (normalOnB * distance);// * 10.0f;
-
- drawLine(PointOnB, to, color);
-}
-
-void BulletDebugDraw::reportErrorWarning(const char* warningString)
-{
- DEBUG_PRINTF( "Dynamics error: %s\n", warningString );
-}
-
-void BulletDebugDraw::draw3dText(const btVector3& location,const char* textString)
-{
-}
-
-void BulletDebugDraw::setDebugMode(int debugMode)
-{
- mDebugMode = debugMode;
-}
-
-int BulletDebugDraw::getDebugMode() const
-{
- return mDebugMode;
-}
-
-void BulletDebugDraw::ClearVertices()
-{
- mVertices.clear();
-}
-
-const Integration::DynamicsDebugVertexContainer& BulletDebugDraw::GetVertices() const
-{
- return mVertices;
-}
-
-} // namespace Plugin
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_PLUGIN_BULLET_DYNAMICS_DEBUG_H__
-#define __DALI_PLUGIN_BULLET_DYNAMICS_DEBUG_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL HEADERS
-#include <dali/integration-api/dynamics/dynamics-debug-vertex.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-#include <btBulletDynamicsCommon.h>
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-/**
- * Debug draw class, BulletPhysics engine will invoke methods on this object to render debug information.
- * Debug lines are collated into a container and then rendered as a single array during Core::Render
- */
-class BulletDebugDraw : public btIDebugDraw
-{
-public:
- /**
- * Constructor
- */
- BulletDebugDraw();
-
- /**
- * Destructor
- */
- virtual ~BulletDebugDraw();
-
- virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
- virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color);
- virtual void reportErrorWarning(const char* warningString);
- virtual void draw3dText(const btVector3& location,const char* textString);
- virtual void setDebugMode(int debugMode);
- virtual int getDebugMode() const;
-
- void ClearVertices();
- const Integration::DynamicsDebugVertexContainer& GetVertices() const;
-
-private:
-
- int mDebugMode;
- Integration::DynamicsDebugVertexContainer mVertices;
-
-}; // class BulletDebugDraw
-
-} // namespace Plugin
-
-} // namespace Dali
-
-#endif /* __DALI_PLUGIN_BULLET_DYNAMICS_DEBUG_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#define LOG_TAG "DALI_DYNAMICS"
-
-// EXTERNAL INCLUDES
-#include <dlog.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-#include <btBulletDynamicsCommon.h>
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-#include <dali/public-api/math/quaternion.h>
-#include <dali/public-api/math/vector3.h>
-
-// INTERNAL INCLUDES
-#include "bullet-dynamics-joint.h"
-#include "bullet-dynamics-body.h"
-
-#define DEBUG_PRINTF(fmt, arg...) LOGD(fmt, ##arg)
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-namespace
-{
-
-const int RotationAxis( 3 );
-
-} // unnamed namespace
-
-BulletDynamicsJoint::BulletDynamicsJoint()
-{
- DEBUG_PRINTF( "%s()\n ", __PRETTY_FUNCTION__ );
-}
-
-BulletDynamicsJoint::~BulletDynamicsJoint()
-{
- DEBUG_PRINTF( "%s()\n ", __PRETTY_FUNCTION__ );
-}
-
-void BulletDynamicsJoint::Initialize( Integration::DynamicsBody* bodyA, const Vector3& positionA, const Quaternion& rotationA, const Vector3& offsetA,
- Integration::DynamicsBody* bodyB, const Vector3& positionB, const Quaternion& rotationB, const Vector3& offsetB )
-{
- DEBUG_PRINTF( "%s\n ", __PRETTY_FUNCTION__ );
-
- Vector3 axis;
- float angle( 0.0f );
- btTransform transformA;
- btTransform transformB;
-
- // Convert points and orientations to btTransforms
- transformA.setIdentity();
- transformA.setOrigin( btVector3( offsetA.x, offsetA.y, offsetA.z ) );
- rotationA.ToAxisAngle( axis, angle );
- if( axis != Vector3::ZERO )
- {
- transformA.setRotation( btQuaternion( btVector3( axis.x, axis.y, axis.z ), btScalar(angle) ) );
- }
-
- // Convert points and orientations to btTransforms
- transformB.setIdentity();
- transformB.setOrigin( btVector3( offsetB.x, offsetB.y, offsetB.z ) );
- rotationB.ToAxisAngle( axis, angle );
- if( axis != Vector3::ZERO )
- {
- transformB.setRotation( btQuaternion( btVector3( axis.x, axis.y, axis.z ), btScalar(angle) ) );
- }
-
- BulletDynamicsBody* dynamicsBodyA( static_cast< BulletDynamicsBody* >( bodyA ) );
- BulletDynamicsBody* dynamicsBodyB( static_cast< BulletDynamicsBody* >( bodyB ) );
-
- btRigidBody& rigidBodyA( static_cast< btRigidBody& >( *(dynamicsBodyA->GetBody()) ) );
- btRigidBody& rigidBodyB( static_cast< btRigidBody& >( *(dynamicsBodyB->GetBody()) ) );
-
- // create constraint
- mConstraint = new btGeneric6DofSpringConstraint(rigidBodyA, rigidBodyB, transformA, transformB, true);
-
- // default to no translation and no rotation
- mConstraint->setLinearLowerLimit(btVector3(0.0f, 0.0f, 0.0f));
- mConstraint->setLinearUpperLimit(btVector3(0.0f, 0.0f, 0.0f));
- mConstraint->setAngularLowerLimit(btVector3(0.0f, 0.0f, 0.0f));
- mConstraint->setAngularUpperLimit(btVector3(0.0f, 0.0f, 0.0f));
-}
-
-void BulletDynamicsJoint::SetLimit( int axisIndex, float lowerLimit, float upperLimit )
-{
- DEBUG_PRINTF( "%s( %d %.2f %.2f)\n ", __PRETTY_FUNCTION__, axisIndex, lowerLimit, upperLimit );
-
- mConstraint->setLimit( axisIndex, lowerLimit, upperLimit );
-}
-
-void BulletDynamicsJoint::EnableSpring( int axisIndex, bool flag )
-{
- DEBUG_PRINTF( "%s( %d %d)\n ", __PRETTY_FUNCTION__, axisIndex, flag );
-
- mConstraint->enableSpring( axisIndex, flag );
-}
-
-void BulletDynamicsJoint::SetSpringStiffness( int axisIndex, float stiffness )
-{
- DEBUG_PRINTF( "%s( %d %.2f)\n ", __PRETTY_FUNCTION__, axisIndex, stiffness );
-
- mConstraint->setStiffness( axisIndex, stiffness );
-}
-
-void BulletDynamicsJoint::SetSpringDamping( int axisIndex, float damping )
-{
- DEBUG_PRINTF( "%s\n ", __PRETTY_FUNCTION__ );
-
- mConstraint->setDamping( axisIndex, 1.0f - damping );
-}
-
-void BulletDynamicsJoint::SetSpringCenterPoint( int axisIndex, float ratio )
-{
- DEBUG_PRINTF( "%s( %d %.2f)\n ", __PRETTY_FUNCTION__, axisIndex, ratio );
-
- float equilibriumPoint( 0.0f );
-
- if( axisIndex < RotationAxis )
- {
- btVector3 translationLowerLimit;
- btVector3 translationUpperLimit;
- mConstraint->getLinearLowerLimit( translationLowerLimit );
- mConstraint->getLinearUpperLimit( translationUpperLimit );
- equilibriumPoint = translationLowerLimit[axisIndex] + ((translationUpperLimit[axisIndex] - translationLowerLimit[axisIndex]) * ratio);
- }
- else
- {
- const int axis( axisIndex - RotationAxis );
- btVector3 rotationLowerLimit;
- btVector3 rotationUpperLimit;
- mConstraint->getAngularLowerLimit( rotationLowerLimit );
- mConstraint->getAngularUpperLimit( rotationUpperLimit );
- equilibriumPoint = rotationLowerLimit[axis] + ((rotationUpperLimit[axis] - rotationLowerLimit[axis]) * ratio);
- }
-
- mConstraint->setEquilibriumPoint( axisIndex, equilibriumPoint );
-}
-
-void BulletDynamicsJoint::EnableMotor( int axisIndex, bool flag )
-{
- DEBUG_PRINTF( "%s( %d %d)\n ", __PRETTY_FUNCTION__, axisIndex, flag );
-
- if( axisIndex < RotationAxis )
- {
- mConstraint->getTranslationalLimitMotor()->m_enableMotor[axisIndex] = flag;
- }
- else
- {
- mConstraint->getRotationalLimitMotor(axisIndex - RotationAxis)->m_enableMotor = flag;
- }
-}
-
-void BulletDynamicsJoint::SetMotorVelocity( int axisIndex, float velocity )
-{
- DEBUG_PRINTF( "%s - %d %.2f\n ", __PRETTY_FUNCTION__, axisIndex, velocity );
-
- if( axisIndex < RotationAxis )
- {
- mConstraint->getTranslationalLimitMotor()->m_targetVelocity[axisIndex] = velocity;
- }
- else
- {
- mConstraint->getRotationalLimitMotor(axisIndex - RotationAxis)->m_targetVelocity = velocity;
- }
-}
-
-void BulletDynamicsJoint::SetMotorForce( int axisIndex, float force )
-{
- DEBUG_PRINTF( "%s - %d %.2f\n ", __PRETTY_FUNCTION__, axisIndex, force );
-
- if( axisIndex < RotationAxis )
- {
- mConstraint->getTranslationalLimitMotor()->m_maxMotorForce[axisIndex] = force;
- }
- else
- {
- mConstraint->getRotationalLimitMotor(axisIndex - RotationAxis)->m_maxMotorForce = force;
- }
-}
-
-btTypedConstraint* BulletDynamicsJoint::GetConstraint() const
-{
- return mConstraint;
-}
-
-} // namespace Plugin
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_PLUGIN_BULLET_DYNAMICS_JOINT_H__
-#define __DALI_PLUGIN_BULLET_DYNAMICS_JOINT_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-// INTERNAL INCLUDES
-#include <dali/integration-api/dynamics/dynamics-joint-intf.h>
-
-class btGeneric6DofSpringConstraint;
-class btTypedConstraint;
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-/*
- *
- */
-class BulletDynamicsJoint : public Integration::DynamicsJoint
-{
-public:
- BulletDynamicsJoint();
- virtual ~BulletDynamicsJoint();
-
-public: // From Dali::Integration::DynamicsJoint
-
- /// @copydoc Dali::Integration::DynamicsJoint::Initialize
- void Initialize( Integration::DynamicsBody* bodyA, const Vector3& positionA, const Quaternion& rotationA, const Vector3& offsetA,
- Integration::DynamicsBody* bodyB, const Vector3& positionB, const Quaternion& rotationB, const Vector3& offsetB );
-
- /// @copydoc Dali::Integration::DynamicsJoint::SetLinearLimit
- void SetLimit( const int axisIndex, const float lowerLimit, const float upperLimit );
-
- /// @copydoc Dali::Integration::DynamicsJoint::EnableSpring
- void EnableSpring( int axisIndex, bool flag );
-
- /// @copydoc Dali::Integration::DynamicsJoint::SetSpringStiffness
- void SetSpringStiffness( int axisIndex, float stiffness );
-
- /// @copydoc Dali::Integration::DynamicsJoint::SetSpringDamping
- void SetSpringDamping( int axisIndex, float damping );
-
- /// @copydoc Dali::Integration::DynamicsJoint::SetSpringCenterPoint
- void SetSpringCenterPoint( int axisIndex, float ratio );
-
- /// @copydoc Dali::Integration::DynamicsJoint::EnableMotor
- void EnableMotor( int axisIndex, bool flag );
-
- /// @copydoc Dali::Integration::DynamicsJoint::SetMotorVelocity
- void SetMotorVelocity( int axisIndex, float velocity );
-
- /// @copydoc Dali::Integration::DynamicsJoint::SetMotorForce
- void SetMotorForce( int axisIndex, float force );
-
-public:
-
- btTypedConstraint* GetConstraint() const;
-
-private:
-
- btGeneric6DofSpringConstraint* mConstraint;
-
-}; // class BulletDynamicsJoint
-
-} // namespace Plugin
-
-} // namespace Dali
-
-#endif // __DALI_PLUGIN_BULLET_DYNAMICS_JOINT_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#define LOG_TAG "DALI_DYNAMICS"
-
-// EXTERNAL INCLUDES
-#include <dlog.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-# include <btBulletDynamicsCommon.h>
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-#include <dali/devel-api/dynamics/dynamics-shape.h>
-#include <dali/devel-api/geometry/mesh-data.h>
-
-// INTERNAL INCLUDES
-#include "bullet-dynamics-shape.h"
-
-#define DEBUG_PRINTF(fmt, arg...) LOGD(fmt, ##arg)
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-BulletDynamicsShape::BulletDynamicsShape()
-: mShape( NULL ),
- mVertices( NULL ),
- mFaces( NULL )
-{
- DEBUG_PRINTF( "%s\n", __PRETTY_FUNCTION__ );
-}
-
-BulletDynamicsShape::~BulletDynamicsShape()
-{
- DEBUG_PRINTF( "%s\n", __PRETTY_FUNCTION__ );
-
- delete mFaces;
- delete mVertices;
- delete mShape;
-}
-
-void BulletDynamicsShape::Initialize( int type, const Vector3& dimensions )
-{
- DEBUG_PRINTF( "BulletDynamicsShape::Initialize( type:%d dimensions(%.2f %.2f %.2f)\n", type, dimensions.width, dimensions.height, dimensions.depth );
-
- switch( type )
- {
- case Dali::DynamicsShape::CAPSULE:
- {
- mShape = new btCapsuleShape( dimensions.width, dimensions.height );
- break;
- }
- case Dali::DynamicsShape::CONE:
- {
- mShape = new btConeShape( dimensions.width, dimensions.height );
- break;
- }
- case Dali::DynamicsShape::CUBE:
- {
- mShape = new btBoxShape( btVector3(dimensions.width, dimensions.height, dimensions.depth) );
- break;
- }
- case Dali::DynamicsShape::CYLINDER:
- {
- mShape = new btCylinderShape( btVector3(dimensions.width, dimensions.height * 0.5f, dimensions.depth) );
- break;
- }
- case Dali::DynamicsShape::MESH:
- {
- break;
- }
- case Dali::DynamicsShape::SPHERE:
- {
- mShape = new btSphereShape( dimensions.width );
- break;
- }
- }
-}
-
-void BulletDynamicsShape::Initialize( int type,
- const MeshData::VertexContainer& vertices,
- const MeshData::FaceIndices& faces )
-{
- DEBUG_PRINTF( "BulletDynamicsShape::Initialize( type:%d )\n", type );
-
- // copy vertices
- const size_t vertexCount( vertices.size() );
-
- mVertices = new MeshData::VertexContainer(vertexCount);
- if( 0 != vertexCount )
- {
- mVertices->assign( vertices.begin(), vertices.end() );
- }
-
- // copy faces
- const size_t faceCount( faces.size() );
-
- mFaces = new MeshData::FaceIndices(faceCount);
- if( 0 != faceCount )
- {
- mFaces->assign( faces.begin(), faces.end() );
- }
-}
-
-btCollisionShape* BulletDynamicsShape::GetShape()
-{
- return mShape;
-}
-
-} // namespace Plugin
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_PLUGIN_BULLET_DYNAMICS_SHAPE_H__
-#define __DALI_PLUGIN_BULLET_DYNAMICS_SHAPE_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/dynamics/dynamics-shape-intf.h>
-
-#include <dali/devel-api/geometry/mesh-data.h>
-
-class btCollisionShape;
-
-namespace Dali
-{
-
-struct Vector3;
-
-namespace Plugin
-{
-
-/*
- *
- */
-class BulletDynamicsShape : public Integration::DynamicsShape
-{
-public:
- BulletDynamicsShape();
- virtual ~BulletDynamicsShape();
-
-public:
- // @copydoc Dali::Integration::DynamicsShape::Initialize(int,const Vector3&)
- void Initialize( int type, const Vector3& dimensions );
-
- // @copydoc Dali::Integration::DynamicsShape::Initialize(int, const MeshData&)
- void Initialize( int type, const MeshData::VertexContainer& vertices, const MeshData::FaceIndices& faceIndices );
-
-public:
- btCollisionShape* GetShape();
-
-private:
-
- btCollisionShape* mShape;
-
-public:
-
- MeshData::VertexContainer* mVertices;
- MeshData::FaceIndices* mFaces;
-
-}; // class BulletDynamicsShape
-
-} // namespace Plugin
-
-} // namespace Dali
-
-#endif // __DALI_PLUGIN_BULLET_DYNAMICS_SHAPE_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#define LOG_TAG "DALI_DYNAMICS"
-
-// EXTERNAL INCLUDES
-#include <dlog.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-#include <btBulletDynamicsCommon.h>
-#include <BulletSoftBody/btSoftRigidDynamicsWorld.h>
-#include <BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h>
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-#include <dali/integration-api/dynamics/dynamics-collision-data.h>
-#include <dali/integration-api/dynamics/dynamics-world-settings.h>
-#include <dali/devel-api/dynamics/dynamics-body-config.h>
-#include <dali/devel-api/dynamics/dynamics-world-config.h>
-#include <dali/devel-api/dynamics/dynamics-world.h>
-
-// INTERNAL INCLUDES
-#include "bullet-dynamics-body.h"
-#include "bullet-dynamics-debug.h"
-#include "bullet-dynamics-joint.h"
-#include "bullet-dynamics-world.h"
-
-#define DEBUG_PRINTF(fmt, arg...) LOGD(fmt, ##arg)
-
-namespace Dali
-{
-
-namespace Plugin
-{
-
-BulletDynamicsWorld::BulletDynamicsWorld()
-: Integration::DynamicsWorld(),
- mSettings( NULL ),
- mDynamicsWorld( NULL ),
- mSolver( NULL ),
- mBroadphase( NULL ),
- mDispatcher( NULL ),
- mCollisionConfiguration( NULL ),
- mSoftBodyWorldInfo( NULL )
-{
- printf( "%s\n", __PRETTY_FUNCTION__ );
-}
-
-BulletDynamicsWorld::~BulletDynamicsWorld()
-{
- printf( "%s\n", __PRETTY_FUNCTION__ );
- delete mSettings;
-
- // Destroy simulation
- delete mDynamicsWorld;
- delete mSolver;
- delete mBroadphase;
- delete mDispatcher;
- delete mCollisionConfiguration;
- delete mDebugDraw;
-}
-
-void BulletDynamicsWorld::Initialize( const Dali::Integration::DynamicsWorldSettings& worldSettings )
-{
- mSettings = new Dali::Integration::DynamicsWorldSettings( worldSettings );
-
- const bool softWorld( Dali::DynamicsWorldConfig::SOFT == mSettings->type );
-
- if( softWorld )
- {
- mCollisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
- }
- else // Dali::DynamicsWorldConfig::RIGID
- {
- mCollisionConfiguration = new btDefaultCollisionConfiguration();
- }
-
- mSolver = new btSequentialImpulseConstraintSolver();
-
- mDispatcher = new btCollisionDispatcher( mCollisionConfiguration );
- mBroadphase = new btDbvtBroadphase();
-
- const Vector3& gravity = mSettings->gravity;
-
- if( softWorld )
- {
- mDynamicsWorld = new btSoftRigidDynamicsWorld( mDispatcher, mBroadphase, mSolver, mCollisionConfiguration, NULL );
- mSoftBodyWorldInfo = &static_cast<btSoftRigidDynamicsWorld*>(mDynamicsWorld)->getWorldInfo();
- mSoftBodyWorldInfo->m_dispatcher = mDispatcher;
- mSoftBodyWorldInfo->m_broadphase = mBroadphase;
- mSoftBodyWorldInfo->air_density = mSettings->airDensity;
- mSoftBodyWorldInfo->water_density = mSettings->waterDensity;
- mSoftBodyWorldInfo->water_offset = mSettings->waterOffset;
- mSoftBodyWorldInfo->water_normal.setValue( mSettings->waterNormal.x, mSettings->waterNormal.y, mSettings->waterNormal.z );
- mSoftBodyWorldInfo->m_gravity.setValue( gravity.x, gravity.y, gravity.z );
- mSoftBodyWorldInfo->m_sparsesdf.Initialize();
- DEBUG_PRINTF("Created soft/rigid dynamics world\n");
- }
- else
- {
- mDynamicsWorld = new btDiscreteDynamicsWorld( mDispatcher, mBroadphase, mSolver, mCollisionConfiguration );
- DEBUG_PRINTF("Created rigid dynamics world\n");
- }
-
- btDynamicsWorld* world( static_cast<btDynamicsWorld*>(mDynamicsWorld) );
-
- world->setGravity( btVector3(gravity.x, gravity.y, gravity.z) );
- world->getSolverInfo().m_splitImpulse = true;
-
- mDebugDraw = new BulletDebugDraw();
- mDynamicsWorld->setDebugDrawer(mDebugDraw);
-}
-
-void BulletDynamicsWorld::AddBody( Dali::Integration::DynamicsBody* body )
-{
- DEBUG_PRINTF( "Adding a body\n" );
-
- BulletDynamicsBody* dynamicsBody( static_cast< BulletDynamicsBody* >( body ) );
-
- if( Dali::DynamicsBodyConfig::RIGID == dynamicsBody->GetType() )
- {
- static_cast<btDynamicsWorld*>(mDynamicsWorld)->addRigidBody( static_cast<btRigidBody*>(dynamicsBody->GetBody()),
- dynamicsBody->GetCollisionGroup(), dynamicsBody->GetCollisionMask() );
- }
- else if( Dali::DynamicsBodyConfig::SOFT == dynamicsBody->GetType() )
- {
- if( Dali::DynamicsWorldConfig::SOFT == mSettings->type )
- {
- static_cast<btSoftRigidDynamicsWorld*>(mDynamicsWorld)->addSoftBody( static_cast<btSoftBody*>(dynamicsBody->GetBody()),
- dynamicsBody->GetCollisionGroup(), dynamicsBody->GetCollisionMask() );
- }
- }
-}
-
-void BulletDynamicsWorld::RemoveBody( Dali::Integration::DynamicsBody* body )
-{
- DEBUG_PRINTF( "Removing a body\n" );
-
- BulletDynamicsBody* dynamicsBody( static_cast< BulletDynamicsBody* >( body ) );
-
- // remove from simulation
- if( Dali::DynamicsBodyConfig::RIGID == body->GetType() )
- {
- static_cast<btDynamicsWorld*>(mDynamicsWorld)->removeRigidBody( static_cast<btRigidBody*>( dynamicsBody->GetBody() ) );
- }
- else
- {
- if( Dali::DynamicsWorldConfig::SOFT == mSettings->type )
- {
- static_cast<btSoftRigidDynamicsWorld*>(mDynamicsWorld)->removeSoftBody( static_cast<btSoftBody*>( dynamicsBody->GetBody() ) );
- }
- }
-}
-
-void BulletDynamicsWorld::AddJoint( Dali::Integration::DynamicsJoint* joint )
-{
- DEBUG_PRINTF( "Adding a joint\n" );
-
- const BulletDynamicsJoint* dynamicsJoint( static_cast< BulletDynamicsJoint* >( joint ) );
-
- // Add to simulation
- static_cast<btDynamicsWorld*>(mDynamicsWorld)->addConstraint( dynamicsJoint->GetConstraint(), true );
-}
-
-void BulletDynamicsWorld::RemoveJoint( Dali::Integration::DynamicsJoint* joint )
-{
- DEBUG_PRINTF("Removing a joint\n" );
-
- const BulletDynamicsJoint* dynamicsJoint( static_cast< BulletDynamicsJoint* >( joint ) );
- // remove from simulation
- static_cast<btDynamicsWorld*>(mDynamicsWorld)->removeConstraint( dynamicsJoint->GetConstraint() );
-}
-
-void BulletDynamicsWorld::SetGravity( const Vector3& gravity )
-{
- DEBUG_PRINTF("%s( %.2f %.2f %.2f )\n", __func__, gravity.x, gravity.y, gravity.z );
- static_cast<btDynamicsWorld*>(mDynamicsWorld)->setGravity( btVector3(gravity.x, gravity.y, gravity.z) );
-}
-
-void BulletDynamicsWorld::SetDebugDrawMode(int mode)
-{
- const int internalMode = ( (mode & Dali::DynamicsWorld::DEBUG_MODE_WIREFRAME) ? btIDebugDraw::DBG_DrawWireframe : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODE_FAST_WIREFRAME) ? btIDebugDraw::DBG_FastWireframe : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODE_AABB) ? btIDebugDraw::DBG_DrawAabb : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODE_CONTACT_POINTS) ? btIDebugDraw::DBG_DrawContactPoints : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODE_NO_DEACTIVATION) ? btIDebugDraw::DBG_NoDeactivation : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODE_CONSTRAINTS) ? btIDebugDraw::DBG_DrawConstraints : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODE_CONSTRAINTS_LIMITS) ? btIDebugDraw::DBG_DrawConstraintLimits : 0 ) |
- ( (mode & Dali::DynamicsWorld::DEBUG_MODES_NORMALS) ? btIDebugDraw::DBG_DrawNormals : 0 );
-
- mDebugDraw->setDebugMode( internalMode );
-}
-
-const Integration::DynamicsDebugVertexContainer& BulletDynamicsWorld::DebugDraw()
-{
-// DEBUG_PRINTF("%s()\n", __func__ );
- mDebugDraw->ClearVertices();
-
- mDynamicsWorld->debugDrawWorld();
-
- return mDebugDraw->GetVertices();
-}
-
-
-void BulletDynamicsWorld::Update( float elapsedSeconds )
-{
-// DEBUG_PRINTF("Stepping simulation by %.3fms\n", elapsedSeconds * 1e3f );
-
- const float timeStep( mSettings->subSteps );
- const float fixedTimeStep( (1.0f/60.0f) / (mSettings->subSteps ? mSettings->subSteps : 1) );
-
- static_cast<btDynamicsWorld*>(mDynamicsWorld)->stepSimulation( elapsedSeconds, timeStep, fixedTimeStep );
-}
-
-void BulletDynamicsWorld::CheckForCollisions( Integration::CollisionDataContainer& contacts )
-{
- /* Browse all collision pairs */
- int numManifolds = mDynamicsWorld->getDispatcher()->getNumManifolds();
- for( int manifold = 0; manifold < numManifolds; ++manifold )
- {
- btPersistentManifold* contactManifold = mDynamicsWorld->getDispatcher()->getManifoldByIndexInternal( manifold );
- btCollisionObject* objectA = (btCollisionObject*)(contactManifold->getBody0());
- btCollisionObject* objectB = (btCollisionObject*)(contactManifold->getBody1());
-
- /* Check all contacts points */
- int numContacts = contactManifold->getNumContacts();
- for( int contact = 0; contact < numContacts; ++contact )
- {
- btManifoldPoint& point = contactManifold->getContactPoint( contact );
- if( point.getDistance() < 0.0f )
- {
- const btVector3& pointOnA = point.m_localPointA;
- const btVector3& pointOnB = point.m_localPointB;
- const btVector3& normalOnB = point.m_normalWorldOnB;
- const float impulse = point.m_appliedImpulse;
-
- if( contacts.find( objectB ) == contacts.end() )
- {
- DALI_ASSERT_DEBUG(NULL != objectA);
- DALI_ASSERT_DEBUG(NULL != objectB);
- DALI_ASSERT_DEBUG(NULL != objectA->getUserPointer());
- DALI_ASSERT_DEBUG(NULL != objectB->getUserPointer());
-
- contacts[ objectB ] = Integration::DynamicsCollisionData(static_cast< Integration::DynamicsBody* >( objectA->getUserPointer() ),
- static_cast< Integration::DynamicsBody* >( objectB->getUserPointer() ),
- Vector3(pointOnA), Vector3(pointOnB), Vector3(normalOnB), impulse);
- }
- }
- }
- }
-}
-
-float BulletDynamicsWorld::GetWorldScale() const
-{
- return mSettings->worldScale;
-}
-
-btSoftBodyWorldInfo* BulletDynamicsWorld::GetSoftBodyWorldInfo()
-{
- return mSoftBodyWorldInfo;
-}
-
-} // namespace Plugin
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_PLUGIN_BULLET_DYNAMICS_WORLD_H__
-#define __DALI_PLUGIN_BULLET_DYNAMICS_WORLD_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-// INTERNAL INCLUDES
-#include <dali/integration-api/dynamics/dynamics-world-intf.h>
-
-// forward declarations
-class btCollisionWorld;
-class btConstraintSolver;
-class btBroadphaseInterface;
-class btCollisionDispatcher;
-class btCollisionConfiguration;
-class btSoftBodyWorldInfo;
-
-namespace Dali
-{
-
-namespace Integration
-{
-
-struct DynamicsWorldSettings;
-class DynamicsBody;
-class DynamicsJoint;
-
-} // namespace Integration
-
-namespace Plugin
-{
-
-class BulletDebugDraw;
-
-/*
- *
- */
-class BulletDynamicsWorld : public Dali::Integration::DynamicsWorld
-{
-public:
- BulletDynamicsWorld();
- virtual ~BulletDynamicsWorld();
-
- /// @copydoc Dali::Integration::DynamicsWorld::InitializeWorld
- void Initialize( const Dali::Integration::DynamicsWorldSettings& worldSettings );
-
- /// @copydoc Dali::Integration::DynamicsWorld::AddBody
- void AddBody( Dali::Integration::DynamicsBody* body );
-
- /// @copydoc Dali::Integration::DynamicsWorld::RemoveBody
- void RemoveBody( Dali::Integration::DynamicsBody* body );
-
- /// @copydoc Dali::Integration::DynamicsWorld::AddJoint
- void AddJoint( Dali::Integration::DynamicsJoint* joint );
-
- /// @copydoc Dali::Integration::DynamicsWorld::RemoveJoint
- void RemoveJoint( Dali::Integration::DynamicsJoint* joint );
-
- /// @copydoc Dali::Integration::DynamicsWorld::SetGravity
- void SetGravity( const Vector3& gravity );
-
- /// @copydoc Dali::DynamicsWorld::SetDebugDrawMode
- void SetDebugDrawMode(int mode);
-
- /// @copydoc Dali::Integration::DynamicsWorld::DebugDraw
- const Integration::DynamicsDebugVertexContainer& DebugDraw();
-
- /// @copydoc Dali::Integration::DynamicsWorld::Update
- void Update( float elapsedSeconds );
-
- /// @copydoc Dali::Integration::DynamicsWorld::CheckForCollisions
- void CheckForCollisions( Integration::CollisionDataContainer& contacts );
-
-public:
-
- float GetWorldScale() const;
-
- btSoftBodyWorldInfo* GetSoftBodyWorldInfo();
-
-private:
- Dali::Integration::DynamicsWorldSettings* mSettings;
- btCollisionWorld* mDynamicsWorld;
- btConstraintSolver* mSolver;
- btBroadphaseInterface* mBroadphase;
- btCollisionDispatcher* mDispatcher;
- btCollisionConfiguration* mCollisionConfiguration;
- btSoftBodyWorldInfo* mSoftBodyWorldInfo;
-
- BulletDebugDraw* mDebugDraw;
-}; // class BulletDynamicsWorld
-
-} // namespace Plugin
-
-} // namespace Dali
-
-#endif // __DALI_PLUGIN_BULLET_DYNAMICS_WORLD_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#define LOG_TAG "DALI_DYNAMICS"
-
-// EXTERNAL INCLUDES
-#include <dlog.h>
-// TODO: Change this to use #pragma GCC diagnostic push / pop when the compiler is updated to 4.6.0+
-#pragma GCC diagnostic ignored "-Wfloat-equal"
-# include <btBulletDynamicsCommon.h>
-# include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
-# include "BulletSoftBody/btSoftBodyHelpers.h"
-#pragma GCC diagnostic error "-Wfloat-equal"
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include "bullet-dynamics-body.h"
-#include "bullet-dynamics-joint.h"
-#include "bullet-dynamics-shape.h"
-#include "bullet-dynamics-world.h"
-
-#include <dali/integration-api/dynamics/dynamics-shape-intf.h>
-
-#define DEBUG_PRINTF(fmt, arg...) LOGD(fmt, ##arg)
-
-extern "C" DALI_EXPORT_API Dali::Integration::DynamicsWorld* CreateDynamicsWorld()
-{
- DEBUG_PRINTF( "%s\n", __func__ );
-
- return new Dali::Plugin::BulletDynamicsWorld();
-}
-
-extern "C" DALI_EXPORT_API Dali::Integration::DynamicsBody* CreateDynamicsBody()
-{
- DEBUG_PRINTF( "%s\n", __func__ );
-
- return new Dali::Plugin::BulletDynamicsBody();
-}
-
-extern "C" DALI_EXPORT_API Dali::Integration::DynamicsJoint* CreateDynamicsJoint()
-{
- DEBUG_PRINTF( "%s\n", __func__ );
-
- return new Dali::Plugin::BulletDynamicsJoint();
-}
-
-extern "C" DALI_EXPORT_API Dali::Integration::DynamicsShape* CreateDynamicsShape()
-{
- DEBUG_PRINTF( "%s\n", __func__ );
-
- return new Dali::Plugin::BulletDynamicsShape();
-}
-
plugin_src_files = \
$(plugin_src_dir)/dali-feedback.cpp
-
-bullet_plugin_src_files = \
- $(plugin_src_dir)/dynamics/bullet/bullet-dynamics-body.cpp \
- $(plugin_src_dir)/dynamics/bullet/bullet-dynamics-debug.cpp \
- $(plugin_src_dir)/dynamics/bullet/bullet-dynamics-joint.cpp \
- $(plugin_src_dir)/dynamics/bullet/bullet-dynamics-shape.cpp \
- $(plugin_src_dir)/dynamics/bullet/bullet-dynamics-world.cpp \
- $(plugin_src_dir)/dynamics/bullet/bullet-plugin.cpp