From: Kimmo Hoikka Date: Thu, 9 Jul 2015 17:40:21 +0000 (+0100) Subject: Remove de-funct Bullet dynamics plugin X-Git-Tag: dali_1.0.49~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F43510%2F2;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Remove de-funct Bullet dynamics plugin Change-Id: Iee50462d991b726262246fc15b2e5388d2ec5591 --- diff --git a/adaptors/base/environment-variables.h b/adaptors/base/environment-variables.h index 3b8f663..ea7dc1e 100644 --- a/adaptors/base/environment-variables.h +++ b/adaptors/base/environment-variables.h @@ -53,7 +53,6 @@ namespace Adaptor // 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" diff --git a/adaptors/base/update-thread.cpp b/adaptors/base/update-thread.cpp index 18c9d6c..7a157fd 100644 --- a/adaptors/base/update-thread.cpp +++ b/adaptors/base/update-thread.cpp @@ -221,11 +221,6 @@ void UpdateThread::UpdateStatusLogging( unsigned int keepUpdatingStatus, bool re oss += " "; } - if ( keepUpdatingStatus & Integration::KeepUpdating::DYNAMICS_CHANGED ) - { - oss += " "; - } - if ( keepUpdatingStatus & Integration::KeepUpdating::LOADING_RESOURCES ) { oss += " "; diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp index bd8988d9..58f07ca 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp @@ -232,12 +232,6 @@ void TestPlatformAbstraction::JoinLoaderThreads() mTrace.PushCall("JoinLoaderThreads", ""); } -Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory() -{ - mTrace.PushCall("GetDynamicsFactory", ""); - return NULL; -} - /** Call this every test */ void TestPlatformAbstraction::Initialize() { @@ -273,7 +267,6 @@ bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) 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; } diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h index 9ff1142..a323f65 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h @@ -178,8 +178,6 @@ public: virtual void JoinLoaderThreads(); - virtual Integration::DynamicsFactory* GetDynamicsFactory(); - public: // TEST FUNCTIONS // Enumeration of Platform Abstraction methods @@ -198,7 +196,6 @@ public: // TEST FUNCTIONS IsLoadingFunc, SetDpiFunc, JoinLoaderThreadsFunc, - GetDynamicsFactoryFunc } TestFuncEnum; /** Call this every test */ diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index 0270fe1..e63b894 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -1,5 +1,5 @@ # -# 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. @@ -66,34 +66,12 @@ fi 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" @@ -270,9 +248,9 @@ AC_CONFIG_FILES([ 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 ]) diff --git a/build/tizen/plugins/Makefile.am b/build/tizen/plugins/Makefile.am index 18937a4..531bee0 100644 --- a/build/tizen/plugins/Makefile.am +++ b/build/tizen/plugins/Makefile.am @@ -1,5 +1,5 @@ # -# 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. @@ -29,10 +29,6 @@ if USE_FEEDBACK 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} @@ -91,27 +87,3 @@ libdali_feedback_plugin_la_LIBADD += \ $(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 diff --git a/platform-abstractions/tizen/dynamics/dynamics-factory.cpp b/platform-abstractions/tizen/dynamics/dynamics-factory.cpp deleted file mode 100644 index 0058c22..0000000 --- a/platform-abstractions/tizen/dynamics/dynamics-factory.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 - -#include -#include -#include -#include -#include -#include -#include - -// 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(dlsym( mHandle, "CreateDynamicsWorld")); - if( !mCreateDynamicsWorld ) - { - DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsWorld(): dlsym error: %s\n", dlerror() ); - result = false; - } - else - { - mCreateDynamicsBody = reinterpret_cast(dlsym( mHandle, "CreateDynamicsBody")); - if( !mCreateDynamicsBody ) - { - DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsBody(): dlsym error: %s\n", dlerror() ); - result = false; - } - else - { - mCreateDynamicsJoint = reinterpret_cast(dlsym( mHandle, "CreateDynamicsJoint")); - if( !mCreateDynamicsJoint ) - { - DALI_LOG_ERROR( "Cannot load symbol CreateDynamicsJoint(): dlsym error: %s\n", dlerror() ); - result = false; - } - else - { - mCreateDynamicsShape = reinterpret_cast(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 diff --git a/platform-abstractions/tizen/dynamics/dynamics-factory.h b/platform-abstractions/tizen/dynamics/dynamics-factory.h deleted file mode 100644 index 5c28bc8..0000000 --- a/platform-abstractions/tizen/dynamics/dynamics-factory.h +++ /dev/null @@ -1,97 +0,0 @@ -#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 - -// 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__ diff --git a/platform-abstractions/tizen/file.list b/platform-abstractions/tizen/file.list index d2d6b3f..2f1eda0 100755 --- a/platform-abstractions/tizen/file.list +++ b/platform-abstractions/tizen/file.list @@ -4,7 +4,6 @@ tizen_platform_abstraction_src_files = \ $(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 \ diff --git a/platform-abstractions/tizen/tizen-platform-abstraction.cpp b/platform-abstractions/tizen/tizen-platform-abstraction.cpp index f99c7c5..0b93dcc 100644 --- a/platform-abstractions/tizen/tizen-platform-abstraction.cpp +++ b/platform-abstractions/tizen/tizen-platform-abstraction.cpp @@ -27,7 +27,6 @@ #include #include "resource-loader/resource-loader.h" -#include "dynamics/dynamics-factory.h" #include "tizen-font-configuration-parser.h" #include "image-loaders/image-loader.h" @@ -52,7 +51,6 @@ const unsigned int NANOSECS_TO_MICROSECS( 1000 ); ///< TizenPlatformAbstraction::TizenPlatformAbstraction() : mResourceLoader(new ResourceLoader), - mDynamicsFactory(NULL), mDataStoragePath( "" ) { } @@ -60,7 +58,6 @@ TizenPlatformAbstraction::TizenPlatformAbstraction() TizenPlatformAbstraction::~TizenPlatformAbstraction() { delete mResourceLoader; - delete mDynamicsFactory; } void TizenPlatformAbstraction::GetTimeMicroseconds(unsigned int &seconds, unsigned int µSeconds) @@ -231,16 +228,6 @@ void TizenPlatformAbstraction::JoinLoaderThreads() 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; diff --git a/platform-abstractions/tizen/tizen-platform-abstraction.h b/platform-abstractions/tizen/tizen-platform-abstraction.h index 621b320..b9bcf83 100644 --- a/platform-abstractions/tizen/tizen-platform-abstraction.h +++ b/platform-abstractions/tizen/tizen-platform-abstraction.h @@ -35,7 +35,6 @@ Integration::PlatformAbstraction* CreatePlatformAbstraction(); namespace TizenPlatform { -class DynamicsFactory; class ResourceLoader; /** @@ -157,11 +156,6 @@ public: // PlatformAbstraction overrides 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; @@ -174,7 +168,6 @@ public: // PlatformAbstraction overrides private: ResourceLoader* mResourceLoader; - DynamicsFactory* mDynamicsFactory; std::string mDataStoragePath; }; diff --git a/plugins/dynamics/bullet/bullet-dynamics-body.cpp b/plugins/dynamics/bullet/bullet-dynamics-body.cpp deleted file mode 100644 index 65e34a2..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-body.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/* - * 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 -// 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 -# include "BulletSoftBody/btSoftRigidDynamicsWorld.h" -# include "BulletSoftBody/btSoftBodyHelpers.h" -#pragma GCC diagnostic error "-Wfloat-equal" - -#include -#include -#include - -// 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(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(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(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(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(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(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( 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 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 diff --git a/plugins/dynamics/bullet/bullet-dynamics-body.h b/plugins/dynamics/bullet/bullet-dynamics-body.h deleted file mode 100644 index 748aa06..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-body.h +++ /dev/null @@ -1,160 +0,0 @@ -#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 - -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__ diff --git a/plugins/dynamics/bullet/bullet-dynamics-debug.cpp b/plugins/dynamics/bullet/bullet-dynamics-debug.cpp deleted file mode 100644 index bcaa0c4..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-debug.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 -// 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 -#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 diff --git a/plugins/dynamics/bullet/bullet-dynamics-debug.h b/plugins/dynamics/bullet/bullet-dynamics-debug.h deleted file mode 100644 index 763d110..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-debug.h +++ /dev/null @@ -1,72 +0,0 @@ -#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 -// 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 -#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__ */ diff --git a/plugins/dynamics/bullet/bullet-dynamics-joint.cpp b/plugins/dynamics/bullet/bullet-dynamics-joint.cpp deleted file mode 100644 index 3470ba0..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-joint.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 -// 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 -#pragma GCC diagnostic error "-Wfloat-equal" - -#include -#include - -// 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 diff --git a/plugins/dynamics/bullet/bullet-dynamics-joint.h b/plugins/dynamics/bullet/bullet-dynamics-joint.h deleted file mode 100644 index fba09f9..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-joint.h +++ /dev/null @@ -1,87 +0,0 @@ -#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 - -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__ diff --git a/plugins/dynamics/bullet/bullet-dynamics-shape.cpp b/plugins/dynamics/bullet/bullet-dynamics-shape.cpp deleted file mode 100644 index e1850bf..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-shape.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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 -// 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 -#pragma GCC diagnostic error "-Wfloat-equal" - -#include -#include - -// 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 diff --git a/plugins/dynamics/bullet/bullet-dynamics-shape.h b/plugins/dynamics/bullet/bullet-dynamics-shape.h deleted file mode 100644 index 26d284e..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-shape.h +++ /dev/null @@ -1,70 +0,0 @@ -#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 - -#include - -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__ diff --git a/plugins/dynamics/bullet/bullet-dynamics-world.cpp b/plugins/dynamics/bullet/bullet-dynamics-world.cpp deleted file mode 100644 index 029da1e..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-world.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* - * 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 -// 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 -#include -#include -#pragma GCC diagnostic error "-Wfloat-equal" - -#include -#include -#include -#include -#include - -// 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(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(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(mDynamicsWorld)->addRigidBody( static_cast(dynamicsBody->GetBody()), - dynamicsBody->GetCollisionGroup(), dynamicsBody->GetCollisionMask() ); - } - else if( Dali::DynamicsBodyConfig::SOFT == dynamicsBody->GetType() ) - { - if( Dali::DynamicsWorldConfig::SOFT == mSettings->type ) - { - static_cast(mDynamicsWorld)->addSoftBody( static_cast(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(mDynamicsWorld)->removeRigidBody( static_cast( dynamicsBody->GetBody() ) ); - } - else - { - if( Dali::DynamicsWorldConfig::SOFT == mSettings->type ) - { - static_cast(mDynamicsWorld)->removeSoftBody( static_cast( 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(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(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(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(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 diff --git a/plugins/dynamics/bullet/bullet-dynamics-world.h b/plugins/dynamics/bullet/bullet-dynamics-world.h deleted file mode 100644 index 4f4fb18..0000000 --- a/plugins/dynamics/bullet/bullet-dynamics-world.h +++ /dev/null @@ -1,111 +0,0 @@ -#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 - -// 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__ diff --git a/plugins/dynamics/bullet/bullet-plugin.cpp b/plugins/dynamics/bullet/bullet-plugin.cpp deleted file mode 100644 index 4b7f5b3..0000000 --- a/plugins/dynamics/bullet/bullet-plugin.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 -// 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 -# include "BulletSoftBody/btSoftRigidDynamicsWorld.h" -# include "BulletSoftBody/btSoftBodyHelpers.h" -#pragma GCC diagnostic error "-Wfloat-equal" - -// INTERNAL INCLUDES -#include -#include "bullet-dynamics-body.h" -#include "bullet-dynamics-joint.h" -#include "bullet-dynamics-shape.h" -#include "bullet-dynamics-world.h" - -#include - -#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(); -} - diff --git a/plugins/file.list b/plugins/file.list index f8443e1..e467ead 100644 --- a/plugins/file.list +++ b/plugins/file.list @@ -2,12 +2,4 @@ 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