Merge pull request #5241 from dumganhar/develop

Some fixes:
Updates JS Test to the latest version
Remove unused files cocos/2d/cocos2dx.mk
Don't define CC_ENABLE_CHIPMUNK_INTEGATION in extension project for android.
Don't check whether CC_ENABLE_CHIPMUNK_INTEGATION is defined in CCPhysicSprite.h and CCPhysicDebugNode.h, check it in source file.
This commit is contained in:
James Chen 2014-01-26 04:08:05 -08:00
commit 77538c53e9
16 changed files with 107 additions and 276 deletions

View File

@ -1,8 +0,0 @@
@echo off
SETLOCAL
:start
mkdir win32-msvc-vs2010-x86
cd win32-msvc-vs2010-x86
cmake -G "Visual Studio 10" ../..
pause

View File

@ -1,149 +0,0 @@
################################################################################
#
# LINUX MAKEFILE
#
# Available options are:
# - CLANG=1 : Compiles with clang instead of gcc. Clang must be in your PATH.
# - V=1 : Enables the verbose mode.
# - DEBUG=1 : Enables the debug mode, disable compiler optimizations.
# - OPENAL=1 : Uses OpenAL instead of FMOD as sound engine.
#
################################################################################
all:
# Remove -Wall, because it enables -Wunused-function, and this warning exists in webp.h
# when enable c++11. I don't know why.
# GCC 4.6 is primary platform for cocos2d v.3, because it's default compiler for Android,
# Blackberry, some Linux distributions.It supports all important features of c++11, but have
# no flag "-std=c++11" (which was turned on in version 4.7).
CCFLAGS += -MMD -Wno-deprecated-declarations -fPIC
CXXFLAGS += -MMD -Wno-deprecated-declarations -fPIC -std=gnu++0x
ifeq ($(CLANG), 1)
CC := clang
CXX := clang++
DEFINES += -D__STRICT_ANSI__ # Allows clang 3.3 to use __float128
else
CC = gcc
CXX = g++
CCFLAGS += -Werror
CXXFLAGS += -Werror
endif
ARFLAGS = cr
DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
ifdef USE_BOX2D
DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1
else
DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
endif
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
ifndef COCOS_ROOT
COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..)
endif
COCOS_SRC = $(COCOS_ROOT)/cocos/2d
OBJ_DIR ?= obj
LIB_DIR = $(COCOS_ROOT)/lib/linux
BIN_DIR = bin
INCLUDES += \
-I$(COCOS_SRC)/ \
-I$(COCOS_SRC)/../math/kazmath/include \
-I$(COCOS_SRC)/platform/linux \
-I$(COCOS_SRC)/../../external/jpeg/include/linux \
-I$(COCOS_SRC)/../../external/tiff/include/linux \
-I$(COCOS_SRC)/../../external/webp/include/linux \
-I$(COCOS_SRC)/../../external/tinyxml2 \
-I$(COCOS_SRC)/../../external/unzip \
-I$(COCOS_SRC)/../../external/glfw3/include/linux \
-I$(COCOS_SRC)/../physics \
-I$(COCOS_SRC)/../base \
-I$(COCOS_SRC)/../../external/chipmunk/include/chipmunk \
-I$(COCOS_SRC)/../../external/freetype2/include/linux \
-I$(COCOS_SRC)/../.. \
-I$(COCOS_SRC)/../audio/include
LBITS := $(shell getconf LONG_BIT)
ifeq ($(DEBUG), 1)
CCFLAGS += -g3 -O0
CXXFLAGS += -g3 -O0
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1
OBJ_DIR := $(OBJ_DIR)/debug
LIB_DIR := $(LIB_DIR)/debug
BIN_DIR := $(BIN_DIR)/debug
else
CCFLAGS += -O3
CXXFLAGS += -O3
DEFINES += -DNDEBUG
OBJ_DIR := $(OBJ_DIR)/release
LIB_DIR := $(LIB_DIR)/release
BIN_DIR := $(BIN_DIR)/release
endif
ifndef V
LOG_CC = @echo " CC $@";
LOG_CXX = @echo " CXX $@";
LOG_AR = @echo " AR $@";
LOG_LINK = @echo " LINK $@";
endif
OBJECTS := $(SOURCES:.cpp=.o)
OBJECTS := $(OBJECTS:.c=.o)
OBJECTS := $(subst ../,,$(OBJECTS))
OBJECTS := $(subst $(COCOS_ROOT)/,,$(OBJECTS))
OBJECTS := $(addprefix $(OBJ_DIR)/, $(OBJECTS))
DEPS = $(OBJECTS:.o=.d)
CORE_MAKEFILE_LIST := $(MAKEFILE_LIST)
-include $(DEPS)
STATICLIBS_DIR = $(COCOS_ROOT)/external
ifeq ($(LBITS),64)
POSTFIX = 64-bit
else
POSTFIX = 32-bit
endif
STATICLIBS = $(STATICLIBS_DIR)/freetype2/prebuilt/linux/$(POSTFIX)/libfreetype.a \
$(STATICLIBS_DIR)/jpeg/prebuilt/linux/$(POSTFIX)/libjpeg.a \
$(STATICLIBS_DIR)/tiff/prebuilt/linux/$(POSTFIX)/libtiff.a \
$(STATICLIBS_DIR)/webp/prebuilt/linux/$(POSTFIX)/libwebp.a
ifneq ($(OPENAL),1)
ifeq ($(LBITS),64)
FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/lib64/api/lib
SHAREDLIBS += -lfmodex64
else
FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/api/lib
SHAREDLIBS += -lfmodex
endif
endif
SHAREDLIBS += -lGLEW -lfontconfig -lpthread -lGL -lpng `pkg-config --libs glfw3`
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))
LIBS = -lrt -lz -lX11
clean:
rm -rf $(OBJ_DIR)
rm -f $(TARGET) core
.PHONY: all clean
# If the parent Makefile defines $(EXECUTABLE) then define this as the target
# and create a 'make run' rule to run the app.
ifdef EXECUTABLE
TARGET := $(BIN_DIR)/$(EXECUTABLE)
all: $(TARGET)
run: $(TARGET)
cd $(dir $^) && ./$(notdir $^)
.PHONY: run
endif

View File

@ -64,7 +64,7 @@ Object* Object::autorelease()
}
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
void Object::release()
{
CCASSERT(_referenceCount > 0, "reference count should greater than 0");
@ -72,6 +72,7 @@ void Object::release()
if (_referenceCount == 0)
{
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
auto poolManager = PoolManager::getInstance();
if (!poolManager->getCurrentPool()->isClearing() && poolManager->isObjectInPools(this))
{
@ -104,10 +105,10 @@ void Object::release()
// obj->release(); // This `release` is the pair of `retain` of previous line.
CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool.");
}
#endif
delete this;
}
}
#endif
bool Object::isSingleReference() const
{

View File

@ -103,16 +103,8 @@ public:
* @see retain, autorelease
* @js NA
*/
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
void release();
#else
inline void release()
{
--_referenceCount;
if (_referenceCount == 0)
delete this;
}
#endif
/**
* Retains the ownership.
*

View File

@ -38,9 +38,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES += libwebsockets_static
LOCAL_CXXFLAGS += -fexceptions
LOCAL_CFLAGS += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
LOCAL_EXPORT_CFLAGS += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \

View File

@ -10,10 +10,8 @@
#include "GUI/CCEditBox/CCEditBox.h"
// Physics integration
#if CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION
#include "physics-nodes/CCPhysicsDebugNode.h"
#include "physics-nodes/CCPhysicsSprite.h"
#endif
#include "assets-manager/AssetsManager.h"

View File

@ -22,10 +22,13 @@
#include "CCPhysicsDebugNode.h"
#if CC_ENABLE_CHIPMUNK_INTEGRATION
#include "chipmunk.h"
#endif
#include "ccTypes.h"
#include "CCGeometry.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
@ -34,6 +37,7 @@
NS_CC_EXT_BEGIN
#if CC_ENABLE_CHIPMUNK_INTEGRATION
/*
IMPORTANT - READ ME!
@ -174,6 +178,7 @@ static void DrawConstraint(cpConstraint *constraint, DrawNode *renderer)
// printf("Cannot draw constraint\n");
}
}
#endif // #if CC_ENABLE_CHIPMUNK_INTEGRATION
// implementation of PhysicsDebugNode
@ -183,16 +188,17 @@ void PhysicsDebugNode::draw()
{
return;
}
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpSpaceEachShape(_spacePtr, (cpSpaceShapeIteratorFunc)DrawShape, this);
cpSpaceEachConstraint(_spacePtr, (cpSpaceConstraintIteratorFunc)DrawConstraint, this);
DrawNode::draw();
DrawNode::clear();
#endif
}
PhysicsDebugNode::PhysicsDebugNode()
: _spacePtr(NULL)
: _spacePtr(nullptr)
{}
PhysicsDebugNode* PhysicsDebugNode::create(cpSpace *space)
@ -201,9 +207,11 @@ PhysicsDebugNode* PhysicsDebugNode::create(cpSpace *space)
if (node)
{
node->init();
#if CC_ENABLE_CHIPMUNK_INTEGRATION
node->_spacePtr = space;
#else
CCASSERT(false, "CC_ENABLE_CHIPMUNK_INTEGRATION was not enabled!");
#endif
node->autorelease();
}
else
@ -220,14 +228,21 @@ PhysicsDebugNode::~PhysicsDebugNode()
cpSpace* PhysicsDebugNode::getSpace() const
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
return _spacePtr;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
return nullptr;
#endif
}
void PhysicsDebugNode::setSpace(cpSpace *space)
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
_spacePtr = space;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
#endif
}
NS_CC_EXT_END
#endif // CC_ENABLE_CHIPMUNK_INTEGRATION

View File

@ -24,12 +24,9 @@
#define __PHYSICSNODES_DEBUGNODE_H__
#include "extensions/ExtensionMacros.h"
#if CC_ENABLE_CHIPMUNK_INTEGRATION
#include "CCDrawNode.h"
#include "chipmunk.h"
struct cpSpace;
NS_CC_EXT_BEGIN
@ -73,6 +70,4 @@ protected:
NS_CC_EXT_END
#endif // CC_ENABLE_CHIPMUNK_INTEGRATION
#endif // __PHYSICSNODES_DEBUGNODE_H__

View File

@ -19,7 +19,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)
#include "CCPhysicsSprite.h"
@ -37,8 +36,8 @@ NS_CC_EXT_BEGIN
PhysicsSprite::PhysicsSprite()
: _ignoreBodyRotation(false)
, _CPBody(NULL)
, _pB2Body(NULL)
, _CPBody(nullptr)
, _pB2Body(nullptr)
, _PTMRatio(0.0f)
{}
@ -195,77 +194,64 @@ float PhysicsSprite::getPositionY() const
// Chipmunk only
//
cpBody* PhysicsSprite::getCPBody() const
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpBody* PhysicsSprite::getCPBody() const
{
return _CPBody;
}
void PhysicsSprite::setCPBody(cpBody *pBody)
{
_CPBody = pBody;
}
b2Body* PhysicsSprite::getB2Body() const
{
CCASSERT(false, "Can't call box2d methods when Chipmunk is enabled");
return NULL;
}
void PhysicsSprite::setB2Body(b2Body *pBody)
{
CCASSERT(false, "Can't call box2d methods when Chipmunk is enabled");
}
float PhysicsSprite::getPTMRatio() const
{
CCASSERT(false, "Can't call box2d methods when Chipmunk is enabled");
return 0;
}
void PhysicsSprite::setPTMRatio(float fRatio)
{
CCASSERT(false, "Can't call box2d methods when Chipmunk is enabled");
}
//
// Box2d only
//
#elif CC_ENABLE_BOX2D_INTEGRATION
b2Body* PhysicsSprite::getB2Body() const
{
return _pB2Body;
}
void PhysicsSprite::setB2Body(b2Body *pBody)
{
_pB2Body = pBody;
}
float PhysicsSprite::getPTMRatio() const
{
return _PTMRatio;
}
void PhysicsSprite::setPTMRatio(float fRatio)
{
_PTMRatio = fRatio;
}
cpBody* PhysicsSprite::getCPBody() const
{
CCASSERT(false, "Can't call Chipmunk methods when Box2d is enabled");
return NULL;
}
void PhysicsSprite::setCPBody(cpBody *pBody)
{
CCASSERT(false, "Can't call Chipmunk methods when Box2d is enabled");
}
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
return nullptr;
#endif
}
void PhysicsSprite::setCPBody(cpBody *pBody)
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
_CPBody = pBody;
#else
CCASSERT(false, "Can't call chipmunk methods when Chipmunk is disabled");
#endif
}
b2Body* PhysicsSprite::getB2Body() const
{
#if CC_ENABLE_BOX2D_INTEGRATION
return _pB2Body;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
return nullptr;
#endif
}
void PhysicsSprite::setB2Body(b2Body *pBody)
{
#if CC_ENABLE_BOX2D_INTEGRATION
_pB2Body = pBody;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
#endif
}
float PhysicsSprite::getPTMRatio() const
{
#if CC_ENABLE_BOX2D_INTEGRATION
return _PTMRatio;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
return 0;
#endif
}
void PhysicsSprite::setPTMRatio(float fRatio)
{
#if CC_ENABLE_BOX2D_INTEGRATION
_PTMRatio = fRatio;
#else
CCASSERT(false, "Can't call box2d methods when Box2d is disabled");
#endif
}
//
// Common to Box2d and Chipmunk
@ -398,13 +384,17 @@ const kmMat4& PhysicsSprite::getNodeToParentTransform() const
}
// Rot, Translate Matrix
_transform = AffineTransformMake( c * _scaleX, s * _scaleX,
-s * _scaleY, c * _scaleY,
x, y );
kmScalar mat[] = { (kmScalar)c * _scaleX, (kmScalar)s * _scaleX, 0, 0,
(kmScalar)-s * _scaleY, (kmScalar)c * _scaleY, 0, 0,
0, 0, 1, 0,
x, y, 0, 1};
kmMat4Fill(&_transform, mat);
return _transform;
#endif
}
NS_CC_EXT_END
#endif //(CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)

View File

@ -19,7 +19,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)
#ifndef __PHYSICSNODES_CCPHYSICSSPRITE_H__
#define __PHYSICSNODES_CCPHYSICSSPRITE_H__
@ -127,11 +126,8 @@ protected:
// box2d specific
b2Body *_pB2Body;
float _PTMRatio;
};
NS_CC_EXT_END
#endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__
#endif //(CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)

View File

@ -17,9 +17,12 @@ Box2DTestLayer::Box2DTestLayer()
, world(NULL)
{
#if CC_ENABLE_BOX2D_INTEGRATION
setTouchEnabled( true );
setAccelerometerEnabled( true );
auto dispatcher = Director::getInstance()->getEventDispatcher();
auto touchListener = EventListenerTouchAllAtOnce::create();
touchListener->onTouchesEnded = CC_CALLBACK_2(Box2DTestLayer::onTouchesEnded, this);
dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
// init physics
this->initPhysics();
// create reset button

View File

@ -23,7 +23,6 @@ public:
void update(float dt);
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
//CREATE_NODE(Box2DTestLayer);
#if CC_ENABLE_BOX2D_INTEGRATION
protected:
kmMat4 _modelViewMV;

View File

@ -85,15 +85,16 @@ void ChipmunkTestLayer::toggleDebugCallback(Object* sender)
ChipmunkTestLayer::~ChipmunkTestLayer()
{
#if CC_ENABLE_CHIPMUNK_INTEGRATION
// manually Free rogue shapes
for( int i=0;i<4;i++) {
cpShapeFree( _walls[i] );
}
cpSpaceFree( _space );
Device::setAccelerometerEnabled(false);
Device::setAccelerometerEnabled(false);
#endif
}
void ChipmunkTestLayer::initPhysics()

View File

@ -1,8 +1,9 @@
// enable log
#define COCOS2D_DEBUG 1
#include "TextureCacheTest.h"
// enable log
#define COCOS2D_DEBUG 1
USING_NS_CC;
TextureCacheTest::TextureCacheTest()

View File

@ -1,10 +1,10 @@
// enable log
#define COCOS2D_DEBUG 1
#include "UserDefaultTest.h"
#include "stdio.h"
#include "stdlib.h"
// enable log
#define COCOS2D_DEBUG 1
UserDefaultTest::UserDefaultTest()
{
auto s = Director::getInstance()->getWinSize();

@ -1 +1 @@
Subproject commit 85f476b018cebcb6632b9de1b3a339fb885e8c0f
Subproject commit 68e023e91b697c461fe986099189bc594ecab6c2