issue #2790: Deprecates CCArray.

This commit is contained in:
James Chen 2013-12-07 10:48:02 +08:00
parent 23ad9f4e1a
commit 165cdf7fe6
13 changed files with 167 additions and 186 deletions

View File

@ -540,7 +540,6 @@ CC_DEPRECATED_ATTRIBUTE typedef Bool CCBool;
CC_DEPRECATED_ATTRIBUTE typedef Float CCFloat; CC_DEPRECATED_ATTRIBUTE typedef Float CCFloat;
CC_DEPRECATED_ATTRIBUTE typedef Double CCDouble; CC_DEPRECATED_ATTRIBUTE typedef Double CCDouble;
CC_DEPRECATED_ATTRIBUTE typedef Data CCData; CC_DEPRECATED_ATTRIBUTE typedef Data CCData;
CC_DEPRECATED_ATTRIBUTE typedef Array CCArray;
CC_DEPRECATED_ATTRIBUTE typedef Dictionary CCDictionary; CC_DEPRECATED_ATTRIBUTE typedef Dictionary CCDictionary;
CC_DEPRECATED_ATTRIBUTE typedef DataVisitor CCDataVisitor; CC_DEPRECATED_ATTRIBUTE typedef DataVisitor CCDataVisitor;
CC_DEPRECATED_ATTRIBUTE typedef PrettyPrinter CCPrettyPrinter; CC_DEPRECATED_ATTRIBUTE typedef PrettyPrinter CCPrettyPrinter;
@ -1030,6 +1029,7 @@ CC_DEPRECATED_ATTRIBUTE typedef __SetIterator CCSetIterator;
CC_DEPRECATED_ATTRIBUTE typedef __Set Set; CC_DEPRECATED_ATTRIBUTE typedef __Set Set;
CC_DEPRECATED_ATTRIBUTE typedef __SetIterator SetIterator; CC_DEPRECATED_ATTRIBUTE typedef __SetIterator SetIterator;
NS_CC_END NS_CC_END

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#include "CCObject.h" #include "CCObject.h"
#include "ccTypes.h" #include "ccTypes.h"
#include "CCGeometry.h" #include "CCGeometry.h"
#include "CCArray.h" #include "CCVector.h"
#include "CCGL.h" #include "CCGL.h"
#include "kazmath/mat4.h" #include "kazmath/mat4.h"
#include "CCLabelAtlas.h" #include "CCLabelAtlas.h"
@ -446,7 +446,7 @@ protected:
bool _sendCleanupToScene; bool _sendCleanupToScene;
/* scheduled scenes */ /* scheduled scenes */
Array* _scenesStack; Vector<Scene*> _scenesStack;
/* last time the main loop was updated */ /* last time the main loop was updated */
struct timeval *_lastUpdate; struct timeval *_lastUpdate;

View File

@ -108,8 +108,6 @@ struct _listEntry;
struct _hashSelectorEntry; struct _hashSelectorEntry;
struct _hashUpdateEntry; struct _hashUpdateEntry;
class Array;
/** @brief Scheduler is responsible for triggering the scheduled callbacks. /** @brief Scheduler is responsible for triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class. You should not use NSTimer. Instead use this class.

View File

@ -36,15 +36,15 @@ NS_CC_BEGIN
// std::vector implementation // std::vector implementation
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
Array::Array() __Array::Array()
: data(NULL) : data(NULL)
{ {
init(); init();
} }
Array* Array::create() __Array* __Array::create()
{ {
Array* array = new Array(); __Array* array = new __Array();
if (array && array->initWithCapacity(7)) if (array && array->initWithCapacity(7))
{ {
@ -58,9 +58,9 @@ Array* Array::create()
return array; return array;
} }
Array* Array::createWithObject(Object* object) __Array* __Array::createWithObject(Object* object)
{ {
Array* array = new Array(); __Array* array = new __Array();
if (array && array->initWithObject(object)) if (array && array->initWithObject(object))
{ {
@ -74,12 +74,12 @@ Array* Array::createWithObject(Object* object)
return array; return array;
} }
Array* Array::create(Object* object, ...) __Array* __Array::create(Object* object, ...)
{ {
va_list args; va_list args;
va_start(args,object); va_start(args,object);
Array* array = create(); __Array* array = create();
if (array && object) if (array && object)
{ {
array->addObject(object); array->addObject(object);
@ -100,16 +100,16 @@ Array* Array::create(Object* object, ...)
return array; return array;
} }
Array* Array::createWithArray(Array* otherArray) __Array* __Array::createWithArray(__Array* otherArray)
{ {
return otherArray->clone(); return otherArray->clone();
} }
Array* Array::createWithCapacity(int capacity) __Array* __Array::createWithCapacity(int capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
Array* array = new Array(); __Array* array = new __Array();
if (array && array->initWithCapacity(capacity)) if (array && array->initWithCapacity(capacity))
{ {
@ -123,9 +123,9 @@ Array* Array::createWithCapacity(int capacity)
return array; return array;
} }
Array* Array::createWithContentsOfFile(const char* fileName) __Array* __Array::createWithContentsOfFile(const char* fileName)
{ {
Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); __Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
if (ret != nullptr) if (ret != nullptr)
{ {
ret->autorelease(); ret->autorelease();
@ -133,17 +133,17 @@ Array* Array::createWithContentsOfFile(const char* fileName)
return ret; return ret;
} }
Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) __Array* __Array::createWithContentsOfFileThreadSafe(const char* fileName)
{ {
return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName); return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName);
} }
bool Array::init() bool __Array::init()
{ {
return initWithCapacity(7); return initWithCapacity(7);
} }
bool Array::initWithObject(Object* object) bool __Array::initWithObject(Object* object)
{ {
bool ret = initWithCapacity(7); bool ret = initWithCapacity(7);
if (ret) if (ret)
@ -154,7 +154,7 @@ bool Array::initWithObject(Object* object)
} }
/** Initializes an array with some objects */ /** Initializes an array with some objects */
bool Array::initWithObjects(Object* object, ...) bool __Array::initWithObjects(Object* object, ...)
{ {
bool ret = false; bool ret = false;
do do
@ -182,7 +182,7 @@ bool Array::initWithObjects(Object* object, ...)
return ret; return ret;
} }
bool Array::initWithCapacity(int capacity) bool __Array::initWithCapacity(int capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
@ -190,13 +190,13 @@ bool Array::initWithCapacity(int capacity)
return true; return true;
} }
bool Array::initWithArray(Array* otherArray) bool __Array::initWithArray(__Array* otherArray)
{ {
data = otherArray->data; data = otherArray->data;
return true; return true;
} }
int Array::getIndexOfObject(Object* object) const int __Array::getIndexOfObject(Object* object) const
{ {
auto it = data.begin(); auto it = data.begin();
@ -211,7 +211,7 @@ int Array::getIndexOfObject(Object* object) const
return -1; return -1;
} }
Object* Array::getRandomObject() Object* __Array::getRandomObject()
{ {
if (data.size()==0) if (data.size()==0)
{ {
@ -230,13 +230,13 @@ Object* Array::getRandomObject()
return data[r].get(); return data[r].get();
} }
bool Array::containsObject(Object* object) const bool __Array::containsObject(Object* object) const
{ {
auto i = this->getIndexOfObject(object); auto i = this->getIndexOfObject(object);
return (i >= 0); return (i >= 0);
} }
bool Array::isEqualToArray(Array* otherArray) bool __Array::isEqualToArray(__Array* otherArray)
{ {
for (int i = 0; i < this->count(); ++i) for (int i = 0; i < this->count(); ++i)
{ {
@ -248,64 +248,64 @@ bool Array::isEqualToArray(Array* otherArray)
return true; return true;
} }
void Array::addObject(Object* object) void __Array::addObject(Object* object)
{ {
data.push_back(RCPtr<Object>(object)); data.push_back(RCPtr<Object>(object));
} }
void Array::addObjectsFromArray(Array* otherArray) void __Array::addObjectsFromArray(__Array* otherArray)
{ {
data.insert(data.end(), otherArray->data.begin(), otherArray->data.end()); data.insert(data.end(), otherArray->data.begin(), otherArray->data.end());
} }
void Array::insertObject(Object* object, int index) void __Array::insertObject(Object* object, int index)
{ {
data.insert(std::begin(data) + index, RCPtr<Object>(object)); data.insert(std::begin(data) + index, RCPtr<Object>(object));
} }
void Array::setObject(Object* object, int index) void __Array::setObject(Object* object, int index)
{ {
data[index] = RCPtr<Object>(object); data[index] = RCPtr<Object>(object);
} }
void Array::removeLastObject(bool releaseObj) void __Array::removeLastObject(bool releaseObj)
{ {
CCASSERT(data.size(), "no objects added"); CCASSERT(data.size(), "no objects added");
data.pop_back(); data.pop_back();
} }
void Array::removeObject(Object* object, bool releaseObj /* ignored */) void __Array::removeObject(Object* object, bool releaseObj /* ignored */)
{ {
data.erase(std::remove(data.begin(), data.end(), object)); data.erase(std::remove(data.begin(), data.end(), object));
} }
void Array::removeObjectAtIndex(int index, bool releaseObj /* ignored */) void __Array::removeObjectAtIndex(int index, bool releaseObj /* ignored */)
{ {
auto obj = data[index]; auto obj = data[index];
data.erase(data.begin() + index); data.erase(data.begin() + index);
} }
void Array::removeObjectsInArray(Array* otherArray) void __Array::removeObjectsInArray(__Array* otherArray)
{ {
CCASSERT(false, "not implemented"); CCASSERT(false, "not implemented");
} }
void Array::removeAllObjects() void __Array::removeAllObjects()
{ {
data.erase(std::begin(data), std::end(data)); data.erase(std::begin(data), std::end(data));
} }
void Array::fastRemoveObjectAtIndex(int index) void __Array::fastRemoveObjectAtIndex(int index)
{ {
removeObjectAtIndex(index); removeObjectAtIndex(index);
} }
void Array::fastRemoveObject(Object* object) void __Array::fastRemoveObject(Object* object)
{ {
removeObject(object); removeObject(object);
} }
void Array::exchangeObject(Object* object1, Object* object2) void __Array::exchangeObject(Object* object1, Object* object2)
{ {
auto idx1 = getIndexOfObject(object1); auto idx1 = getIndexOfObject(object1);
auto idx2 = getIndexOfObject(object2); auto idx2 = getIndexOfObject(object2);
@ -315,34 +315,34 @@ void Array::exchangeObject(Object* object1, Object* object2)
std::swap(data[idx1], data[idx2]); std::swap(data[idx1], data[idx2]);
} }
void Array::exchangeObjectAtIndex(int index1, int index2) void __Array::exchangeObjectAtIndex(int index1, int index2)
{ {
std::swap(data[index1], data[index2]); std::swap(data[index1], data[index2]);
} }
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */) void __Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */)
{ {
data[index] = object; data[index] = object;
} }
void Array::reverseObjects() void __Array::reverseObjects()
{ {
std::reverse(std::begin(data), std::end(data)); std::reverse(std::begin(data), std::end(data));
} }
void Array::reduceMemoryFootprint() void __Array::reduceMemoryFootprint()
{ {
// N/A // N/A
} }
Array::~Array() __Array::~Array()
{ {
CCLOGINFO("deallocing Array: %p - len: %d", this, count() ); CCLOGINFO("deallocing Array: %p - len: %d", this, count() );
} }
Array* Array::clone() const __Array* __Array::clone() const
{ {
Array* ret = new Array(); __Array* ret = new __Array();
ret->autorelease(); ret->autorelease();
ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1); ret->initWithCapacity(this->data.size() > 0 ? this->data.size() : 1);
@ -368,7 +368,7 @@ Array* Array::clone() const
return ret; return ret;
} }
void Array::acceptVisitor(DataVisitor &visitor) void __Array::acceptVisitor(DataVisitor &visitor)
{ {
visitor.visit(this); visitor.visit(this);
} }
@ -379,15 +379,15 @@ void Array::acceptVisitor(DataVisitor &visitor)
#else #else
Array::Array() __Array::__Array()
: data(nullptr) : data(nullptr)
{ {
// init(); // init();
} }
Array* Array::create() __Array* __Array::create()
{ {
Array* array = new Array(); __Array* array = new __Array();
if (array && array->initWithCapacity(7)) if (array && array->initWithCapacity(7))
{ {
@ -401,9 +401,9 @@ Array* Array::create()
return array; return array;
} }
Array* Array::createWithObject(Object* object) __Array* __Array::createWithObject(Object* object)
{ {
Array* array = new Array(); __Array* array = new __Array();
if (array && array->initWithObject(object)) if (array && array->initWithObject(object))
{ {
@ -417,12 +417,12 @@ Array* Array::createWithObject(Object* object)
return array; return array;
} }
Array* Array::create(Object* object, ...) __Array* __Array::create(Object* object, ...)
{ {
va_list args; va_list args;
va_start(args,object); va_start(args,object);
Array* array = create(); __Array* array = create();
if (array && object) if (array && object)
{ {
array->addObject(object); array->addObject(object);
@ -443,16 +443,16 @@ Array* Array::create(Object* object, ...)
return array; return array;
} }
Array* Array::createWithArray(Array* otherArray) __Array* __Array::createWithArray(__Array* otherArray)
{ {
return otherArray->clone(); return otherArray->clone();
} }
Array* Array::createWithCapacity(int capacity) __Array* __Array::createWithCapacity(int capacity)
{ {
CCASSERT(capacity>=0, "Invalid capacity"); CCASSERT(capacity>=0, "Invalid capacity");
Array* array = new Array(); __Array* array = new __Array();
if (array && array->initWithCapacity(capacity)) if (array && array->initWithCapacity(capacity))
{ {
@ -466,9 +466,9 @@ Array* Array::createWithCapacity(int capacity)
return array; return array;
} }
Array* Array::createWithContentsOfFile(const char* fileName) __Array* __Array::createWithContentsOfFile(const char* fileName)
{ {
Array* ret = Array::createWithContentsOfFileThreadSafe(fileName); __Array* ret = __Array::createWithContentsOfFileThreadSafe(fileName);
if (ret != nullptr) if (ret != nullptr)
{ {
ret->autorelease(); ret->autorelease();
@ -476,11 +476,11 @@ Array* Array::createWithContentsOfFile(const char* fileName)
return ret; return ret;
} }
Array* Array::createWithContentsOfFileThreadSafe(const char* fileName) __Array* __Array::createWithContentsOfFileThreadSafe(const char* fileName)
{ {
ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName); ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName);
Array* ret = Array::createWithCapacity(static_cast<int>(arr.size())); __Array* ret = __Array::createWithCapacity(static_cast<int>(arr.size()));
std::for_each(arr.cbegin(), arr.cend(), [&ret](const Value& value){ std::for_each(arr.cbegin(), arr.cend(), [&ret](const Value& value){
ret->addObject(String::create(value.asString())); ret->addObject(String::create(value.asString()));
@ -489,14 +489,14 @@ Array* Array::createWithContentsOfFileThreadSafe(const char* fileName)
return ret; return ret;
} }
bool Array::init() bool __Array::init()
{ {
CCASSERT(!data, "Array cannot be re-initialized"); CCASSERT(!data, "Array cannot be re-initialized");
return initWithCapacity(7); return initWithCapacity(7);
} }
bool Array::initWithObject(Object* object) bool __Array::initWithObject(Object* object)
{ {
CCASSERT(!data, "Array cannot be re-initialized"); CCASSERT(!data, "Array cannot be re-initialized");
@ -509,7 +509,7 @@ bool Array::initWithObject(Object* object)
} }
/** Initializes an array with some objects */ /** Initializes an array with some objects */
bool Array::initWithObjects(Object* object, ...) bool __Array::initWithObjects(Object* object, ...)
{ {
CCASSERT(!data, "Array cannot be re-initialized"); CCASSERT(!data, "Array cannot be re-initialized");
@ -539,7 +539,7 @@ bool Array::initWithObjects(Object* object, ...)
return ret; return ret;
} }
bool Array::initWithCapacity(int capacity) bool __Array::initWithCapacity(int capacity)
{ {
CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized"); CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized");
@ -547,7 +547,7 @@ bool Array::initWithCapacity(int capacity)
return true; return true;
} }
bool Array::initWithArray(Array* otherArray) bool __Array::initWithArray(__Array* otherArray)
{ {
CCASSERT(!data, "Array cannot be re-initialized"); CCASSERT(!data, "Array cannot be re-initialized");
@ -563,12 +563,12 @@ bool Array::initWithArray(Array* otherArray)
return ret; return ret;
} }
int Array::getIndexOfObject(Object* object) const int __Array::getIndexOfObject(Object* object) const
{ {
return ccArrayGetIndexOfObject(data, object); return ccArrayGetIndexOfObject(data, object);
} }
Object* Array::getRandomObject() Object* __Array::getRandomObject()
{ {
if (data->num == 0) if (data->num == 0)
{ {
@ -585,12 +585,12 @@ Object* Array::getRandomObject()
return data->arr[static_cast<int>(data->num * r)]; return data->arr[static_cast<int>(data->num * r)];
} }
bool Array::containsObject(Object* object) const bool __Array::containsObject(Object* object) const
{ {
return ccArrayContainsObject(data, object); return ccArrayContainsObject(data, object);
} }
bool Array::isEqualToArray(Array* otherArray) bool __Array::isEqualToArray(__Array* otherArray)
{ {
for (int i = 0; i < this->count(); ++i) for (int i = 0; i < this->count(); ++i)
{ {
@ -602,25 +602,25 @@ bool Array::isEqualToArray(Array* otherArray)
return true; return true;
} }
void Array::addObject(Object* object) void __Array::addObject(Object* object)
{ {
CCASSERT(data, "Array not initialized"); CCASSERT(data, "Array not initialized");
ccArrayAppendObjectWithResize(data, object); ccArrayAppendObjectWithResize(data, object);
} }
void Array::addObjectsFromArray(Array* otherArray) void __Array::addObjectsFromArray(__Array* otherArray)
{ {
CCASSERT(data, "Array not initialized"); CCASSERT(data, "Array not initialized");
ccArrayAppendArrayWithResize(data, otherArray->data); ccArrayAppendArrayWithResize(data, otherArray->data);
} }
void Array::insertObject(Object* object, int index) void __Array::insertObject(Object* object, int index)
{ {
CCASSERT(data, "Array not initialized"); CCASSERT(data, "Array not initialized");
ccArrayInsertObjectAtIndex(data, object, index); ccArrayInsertObjectAtIndex(data, object, index);
} }
void Array::setObject(Object* object, int index) void __Array::setObject(Object* object, int index)
{ {
CCASSERT(index >= 0 && index < count(), "Invalid index"); CCASSERT(index >= 0 && index < count(), "Invalid index");
@ -632,43 +632,43 @@ void Array::setObject(Object* object, int index)
} }
} }
void Array::removeLastObject(bool releaseObj) void __Array::removeLastObject(bool releaseObj)
{ {
CCASSERT(data->num, "no objects added"); CCASSERT(data->num, "no objects added");
ccArrayRemoveObjectAtIndex(data, data->num - 1, releaseObj); ccArrayRemoveObjectAtIndex(data, data->num - 1, releaseObj);
} }
void Array::removeObject(Object* object, bool releaseObj/* = true*/) void __Array::removeObject(Object* object, bool releaseObj/* = true*/)
{ {
ccArrayRemoveObject(data, object, releaseObj); ccArrayRemoveObject(data, object, releaseObj);
} }
void Array::removeObjectAtIndex(int index, bool releaseObj) void __Array::removeObjectAtIndex(int index, bool releaseObj)
{ {
ccArrayRemoveObjectAtIndex(data, index, releaseObj); ccArrayRemoveObjectAtIndex(data, index, releaseObj);
} }
void Array::removeObjectsInArray(Array* otherArray) void __Array::removeObjectsInArray(__Array* otherArray)
{ {
ccArrayRemoveArray(data, otherArray->data); ccArrayRemoveArray(data, otherArray->data);
} }
void Array::removeAllObjects() void __Array::removeAllObjects()
{ {
ccArrayRemoveAllObjects(data); ccArrayRemoveAllObjects(data);
} }
void Array::fastRemoveObjectAtIndex(int index) void __Array::fastRemoveObjectAtIndex(int index)
{ {
ccArrayFastRemoveObjectAtIndex(data, index); ccArrayFastRemoveObjectAtIndex(data, index);
} }
void Array::fastRemoveObject(Object* object) void __Array::fastRemoveObject(Object* object)
{ {
ccArrayFastRemoveObject(data, object); ccArrayFastRemoveObject(data, object);
} }
void Array::exchangeObject(Object* object1, Object* object2) void __Array::exchangeObject(Object* object1, Object* object2)
{ {
auto index1 = ccArrayGetIndexOfObject(data, object1); auto index1 = ccArrayGetIndexOfObject(data, object1);
if (index1 == CC_INVALID_INDEX) if (index1 == CC_INVALID_INDEX)
@ -685,18 +685,18 @@ void Array::exchangeObject(Object* object1, Object* object2)
ccArraySwapObjectsAtIndexes(data, index1, index2); ccArraySwapObjectsAtIndexes(data, index1, index2);
} }
void Array::exchangeObjectAtIndex(int index1, int index2) void __Array::exchangeObjectAtIndex(int index1, int index2)
{ {
ccArraySwapObjectsAtIndexes(data, index1, index2); ccArraySwapObjectsAtIndexes(data, index1, index2);
} }
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject/* = true*/) void __Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject/* = true*/)
{ {
ccArrayInsertObjectAtIndex(data, object, index); ccArrayInsertObjectAtIndex(data, object, index);
ccArrayRemoveObjectAtIndex(data, index + 1); ccArrayRemoveObjectAtIndex(data, index + 1);
} }
void Array::reverseObjects() void __Array::reverseObjects()
{ {
if (data->num > 1) if (data->num > 1)
{ {
@ -712,21 +712,21 @@ void Array::reverseObjects()
} }
} }
void Array::reduceMemoryFootprint() void __Array::reduceMemoryFootprint()
{ {
ccArrayShrink(data); ccArrayShrink(data);
} }
Array::~Array() __Array::~__Array()
{ {
CCLOGINFO("deallocing Array: %p - len: %d", this, count() ); CCLOGINFO("deallocing Array: %p - len: %d", this, count() );
ccArrayFree(data); ccArrayFree(data);
} }
Array* Array::clone() const __Array* __Array::clone() const
{ {
Array* ret = new Array(); __Array* ret = new __Array();
ret->autorelease(); ret->autorelease();
ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1); ret->initWithCapacity(this->data->num > 0 ? this->data->num : 1);
@ -752,7 +752,7 @@ Array* Array::clone() const
return ret; return ret;
} }
void Array::acceptVisitor(DataVisitor &visitor) void __Array::acceptVisitor(DataVisitor &visitor)
{ {
visitor.visit(this); visitor.visit(this);
} }

View File

@ -230,7 +230,7 @@ while(false)
NS_CC_BEGIN NS_CC_BEGIN
class CC_DLL Array : public Object, public Clonable class CC_DLL __Array : public Object, public Clonable
{ {
public: public:
@ -238,30 +238,30 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
static Array* create(); static __Array* create();
/** Create an array with objects /** Create an array with objects
* @js NA * @js NA
*/ */
static Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION; static __Array* create(Object* object, ...) CC_REQUIRES_NULL_TERMINATION;
/** Create an array with one object /** Create an array with one object
* @js NA * @js NA
*/ */
static Array* createWithObject(Object* object); static __Array* createWithObject(Object* object);
/** Create an array with a default capacity /** Create an array with a default capacity
* @js NA * @js NA
*/ */
static Array* createWithCapacity(int capacity); static __Array* createWithCapacity(int capacity);
/** Create an array with from an existing array /** Create an array with from an existing array
* @js NA * @js NA
*/ */
static Array* createWithArray(Array* otherArray); static __Array* createWithArray(__Array* otherArray);
/** /**
@brief Generate a Array pointer by file @brief Generate a Array pointer by file
@param pFileName The file name of *.plist file @param pFileName The file name of *.plist file
@return The Array pointer generated from the file @return The Array pointer generated from the file
* @js NA * @js NA
*/ */
static Array* createWithContentsOfFile(const char* pFileName); static __Array* createWithContentsOfFile(const char* pFileName);
/* /*
@brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the
@ -269,12 +269,12 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
static Array* createWithContentsOfFileThreadSafe(const char* pFileName); static __Array* createWithContentsOfFileThreadSafe(const char* pFileName);
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
~Array(); ~__Array();
/** Initializes an array /** Initializes an array
* @js NA * @js NA
@ -300,7 +300,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
bool initWithArray(Array* otherArray); bool initWithArray(__Array* otherArray);
// Querying an Array // Querying an Array
@ -384,7 +384,7 @@ public:
/** @since 1.1 /** @since 1.1
* @js NA * @js NA
*/ */
bool isEqualToArray(Array* otherArray); bool isEqualToArray(__Array* otherArray);
// Adding Objects // Adding Objects
/** Add a certain object /** Add a certain object
@ -397,7 +397,7 @@ public:
/** Add all elements of an existing array /** Add all elements of an existing array
* @js NA * @js NA
*/ */
void addObjectsFromArray(Array* otherArray); void addObjectsFromArray(__Array* otherArray);
/** Insert a certain object at a certain index /** Insert a certain object at a certain index
* @js NA * @js NA
*/ */
@ -451,7 +451,7 @@ public:
/** Remove all elements /** Remove all elements
* @js NA * @js NA
*/ */
void removeObjectsInArray(Array* otherArray); void removeObjectsInArray(__Array* otherArray);
/** Remove all objects /** Remove all objects
* @js NA * @js NA
*/ */
@ -498,7 +498,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
virtual Array* clone() const; virtual __Array* clone() const;
// ------------------------------------------ // ------------------------------------------
// Iterators // Iterators
@ -546,12 +546,15 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Array(); __Array();
}; };
// end of data_structure group // end of data_structure group
/// @} /// @}
CC_DEPRECATED_ATTRIBUTE typedef __Array CCArray;
CC_DEPRECATED_ATTRIBUTE typedef __Array Array;
NS_CC_END NS_CC_END
#endif // __CCARRAY_H__ #endif // __CCARRAY_H__

View File

@ -60,7 +60,7 @@ void DataVisitor::visit(const String *value)
visitObject(value); visitObject(value);
} }
void DataVisitor::visit(const Array *value) void DataVisitor::visit(const __Array *value)
{ {
visitObject(value); visitObject(value);
} }
@ -136,7 +136,7 @@ void PrettyPrinter::visit(const String *p)
_result += p->getCString(); _result += p->getCString();
} }
void PrettyPrinter::visit(const Array *p) void PrettyPrinter::visit(const __Array *p)
{ {
_result += "\n"; _result += "\n";
_result += _indentStr; _result += _indentStr;

View File

@ -36,7 +36,7 @@ class Integer;
class Float; class Float;
class Double; class Double;
class String; class String;
class Array; class __Array;
class Dictionary; class Dictionary;
class __Set; class __Set;
class Data; class Data;
@ -77,7 +77,7 @@ public:
virtual void visit(const Float *p); virtual void visit(const Float *p);
virtual void visit(const Double *p); virtual void visit(const Double *p);
virtual void visit(const String *p); virtual void visit(const String *p);
virtual void visit(const Array *p); virtual void visit(const __Array *p);
virtual void visit(const Dictionary *p); virtual void visit(const Dictionary *p);
virtual void visit(const __Set *p); virtual void visit(const __Set *p);
virtual void visit(const Data *p); virtual void visit(const Data *p);
@ -98,7 +98,7 @@ public:
virtual void visit(const Float *p); virtual void visit(const Float *p);
virtual void visit(const Double *p); virtual void visit(const Double *p);
virtual void visit(const String *p); virtual void visit(const String *p);
virtual void visit(const Array *p); virtual void visit(const __Array *p);
virtual void visit(const Dictionary *p); virtual void visit(const Dictionary *p);
virtual void visit(const __Set *p); virtual void visit(const __Set *p);
virtual void visit(const Data *p); virtual void visit(const Data *p);

View File

@ -207,7 +207,7 @@ public:
* @return The array contains all keys of elements. It's an autorelease object yet. * @return The array contains all keys of elements. It's an autorelease object yet.
* @js NA * @js NA
*/ */
Array* allKeys(); __Array* allKeys();
/** /**
* Get all keys according to the specified object. * Get all keys according to the specified object.
@ -215,7 +215,7 @@ public:
* @return The array contains all keys for the specified object. It's an autorelease object yet. * @return The array contains all keys for the specified object. It's an autorelease object yet.
* @js NA * @js NA
*/ */
Array* allKeysForObject(Object* object); __Array* allKeysForObject(Object* object);
/** /**
* Get the object according to the specified string key. * Get the object according to the specified string key.
@ -302,7 +302,7 @@ public:
* Remove an object by the specified string key. * Remove an object by the specified string key.
* *
* @param key The string key for searching. * @param key The string key for searching.
* @see removeObjectForKey(intptr_t), removeObjectsForKeys(Array*), * @see removeObjectForKey(intptr_t), removeObjectsForKeys(__Array*),
* removeObjectForElememt(DictElement*), removeAllObjects(). * removeObjectForElememt(DictElement*), removeAllObjects().
* @js NA * @js NA
*/ */
@ -312,7 +312,7 @@ public:
* Remove an object by the specified integer key. * Remove an object by the specified integer key.
* *
* @param key The integer key for searching. * @param key The integer key for searching.
* @see removeObjectForKey(const std::string&), removeObjectsForKeys(Array*), * @see removeObjectForKey(const std::string&), removeObjectsForKeys(__Array*),
* removeObjectForElememt(DictElement*), removeAllObjects(). * removeObjectForElememt(DictElement*), removeAllObjects().
* @js NA * @js NA
*/ */
@ -321,19 +321,19 @@ public:
/** /**
* Remove objects by an array of keys. * Remove objects by an array of keys.
* *
* @param pKeyArray The array contains keys to be removed. * @param pKey__Array The array contains keys to be removed.
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
* removeObjectForElememt(DictElement*), removeAllObjects(). * removeObjectForElememt(DictElement*), removeAllObjects().
* @js NA * @js NA
*/ */
void removeObjectsForKeys(Array* pKeyArray); void removeObjectsForKeys(__Array* pKey__Array);
/** /**
* Remove an object by an element. * Remove an object by an element.
* *
* @param pElement The element need to be removed. * @param pElement The element need to be removed.
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
* removeObjectsForKeys(Array*), removeAllObjects(). * removeObjectsForKeys(__Array*), removeAllObjects().
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
@ -343,7 +343,7 @@ public:
* Remove all objects in the dictionary. * Remove all objects in the dictionary.
* *
* @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t), * @see removeObjectForKey(const std::string&), removeObjectForKey(intptr_t),
* removeObjectsForKeys(Array*), removeObjectForElememt(DictElement*). * removeObjectsForKeys(__Array*), removeObjectForElememt(DictElement*).
* @js NA * @js NA
*/ */
void removeAllObjects(); void removeAllObjects();

View File

@ -137,7 +137,7 @@ public:
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
Array* componentsSeparatedByString(const char *delimiter); __Array* componentsSeparatedByString(const char *delimiter);
/* override functions /* override functions
* @js NA * @js NA

View File

@ -51,7 +51,6 @@ namespace
PhysicsBody::PhysicsBody() PhysicsBody::PhysicsBody()
: _node(nullptr) : _node(nullptr)
, _shapes(nullptr)
, _world(nullptr) , _world(nullptr)
, _info(nullptr) , _info(nullptr)
, _dynamic(true) , _dynamic(true)
@ -251,9 +250,6 @@ bool PhysicsBody::init()
{ {
_info = new PhysicsBodyInfo(); _info = new PhysicsBodyInfo();
CC_BREAK_IF(_info == nullptr); CC_BREAK_IF(_info == nullptr);
_shapes = Array::create();
CC_BREAK_IF(_shapes == nullptr);
_shapes->retain();
_info->setBody(cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment))); _info->setBody(cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment)));
@ -368,7 +364,7 @@ PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/*
if (shape == nullptr) return nullptr; if (shape == nullptr) return nullptr;
// add shape to body // add shape to body
if (_shapes->getIndexOfObject(shape) == CC_INVALID_INDEX) if (_shapes.getIndex(shape) == -1)
{ {
shape->setBody(this); shape->setBody(this);
@ -386,7 +382,7 @@ PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/*
_world->addShape(shape); _world->addShape(shape);
} }
_shapes->addObject(shape); _shapes.pushBack(shape);
if (_group != CP_NO_GROUP && shape->getGroup() == CP_NO_GROUP) if (_group != CP_NO_GROUP && shape->getGroup() == CP_NO_GROUP)
{ {
@ -631,9 +627,8 @@ void PhysicsBody::setMoment(float moment)
PhysicsShape* PhysicsBody::getShape(int tag) const PhysicsShape* PhysicsBody::getShape(int tag) const
{ {
for (auto child : *_shapes) for (auto& shape : _shapes)
{ {
PhysicsShape* shape = dynamic_cast<PhysicsShape*>(child);
if (shape->getTag() == tag) if (shape->getTag() == tag)
{ {
return shape; return shape;
@ -645,9 +640,8 @@ PhysicsShape* PhysicsBody::getShape(int tag) const
void PhysicsBody::removeShape(int tag, bool reduceMassAndMoment/* = true*/) void PhysicsBody::removeShape(int tag, bool reduceMassAndMoment/* = true*/)
{ {
for (auto child : *_shapes) for (auto& shape : _shapes)
{ {
PhysicsShape* shape = dynamic_cast<PhysicsShape*>(child);
if (shape->getTag() == tag) if (shape->getTag() == tag)
{ {
removeShape(shape, reduceMassAndMoment); removeShape(shape, reduceMassAndMoment);
@ -658,7 +652,7 @@ void PhysicsBody::removeShape(int tag, bool reduceMassAndMoment/* = true*/)
void PhysicsBody::removeShape(PhysicsShape* shape, bool reduceMassAndMoment/* = true*/) void PhysicsBody::removeShape(PhysicsShape* shape, bool reduceMassAndMoment/* = true*/)
{ {
if (_shapes->getIndexOfObject(shape) != CC_INVALID_INDEX) if (_shapes->getIndexOfObject(shape) != -1)
{ {
// deduce the area, mass and moment // deduce the area, mass and moment
// area must update before mass, because the density changes depend on it. // area must update before mass, because the density changes depend on it.
@ -678,13 +672,13 @@ void PhysicsBody::removeShape(PhysicsShape* shape, bool reduceMassAndMoment/* =
// set shape->_body = nullptr make the shape->setBody will not trigger the _body->removeShape function call. // set shape->_body = nullptr make the shape->setBody will not trigger the _body->removeShape function call.
shape->_body = nullptr; shape->_body = nullptr;
shape->setBody(nullptr); shape->setBody(nullptr);
_shapes->removeObject(shape); _shapes.removeObject(shape);
} }
} }
void PhysicsBody::removeAllShapes(bool reduceMassAndMoment/* = true*/) void PhysicsBody::removeAllShapes(bool reduceMassAndMoment/* = true*/)
{ {
for (auto child : *_shapes) for (auto& child : _shapes)
{ {
PhysicsShape* shape = dynamic_cast<PhysicsShape*>(child); PhysicsShape* shape = dynamic_cast<PhysicsShape*>(child);
@ -707,7 +701,7 @@ void PhysicsBody::removeAllShapes(bool reduceMassAndMoment/* = true*/)
shape->setBody(nullptr); shape->setBody(nullptr);
} }
_shapes->removeAllObjects(); _shapes.clear();
} }
void PhysicsBody::removeFromWorld() void PhysicsBody::removeFromWorld()

View File

@ -30,11 +30,8 @@
#include "CCObject.h" #include "CCObject.h"
#include "CCGeometry.h" #include "CCGeometry.h"
#include "CCArray.h"
#include "CCPhysicsShape.h" #include "CCPhysicsShape.h"
#include "CCVector.h"
#include <vector>
NS_CC_BEGIN NS_CC_BEGIN
class Sprite; class Sprite;
@ -103,9 +100,9 @@ public:
/* remove all shapes */ /* remove all shapes */
void removeAllShapes(bool reduceMassAndMoment = true); void removeAllShapes(bool reduceMassAndMoment = true);
/* get the body shapes. */ /* get the body shapes. */
inline Array* getShapes() const { return _shapes; } inline const Vector<PhysicsShape*> getShapes() const { return _shapes; }
/* get the first shape of the body shapes. */ /* get the first shape of the body shapes. */
inline PhysicsShape* getFirstShape() const { return _shapes->count() >= 1 ? dynamic_cast<PhysicsShape*>(_shapes->getObjectAtIndex(0)) : nullptr; } inline PhysicsShape* getFirstShape() const { return _shapes.size() >= 1 ? _shapes.at(0) : nullptr; }
/* get the shape of the body. */ /* get the shape of the body. */
PhysicsShape* getShape(int tag) const; PhysicsShape* getShape(int tag) const;
@ -305,7 +302,7 @@ protected:
protected: protected:
Node* _node; Node* _node;
std::vector<PhysicsJoint*> _joints; std::vector<PhysicsJoint*> _joints;
Array* _shapes; Vector<PhysicsShape*> _shapes;
PhysicsWorld* _world; PhysicsWorld* _world;
PhysicsBodyInfo* _info; PhysicsBodyInfo* _info;
bool _dynamic; bool _dynamic;

View File

@ -97,7 +97,7 @@ public:
static void rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info); static void rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect n, RayCastCallbackInfo *info);
static void queryRectCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info); static void queryRectCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info);
static void queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info); static void queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info);
static void getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Array *arr); static void getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Vector<PhysicsShape*>* arr);
public: public:
static bool continues; static bool continues;
@ -176,13 +176,13 @@ void PhysicsWorldCallback::queryRectCallbackFunc(cpShape *shape, RectQueryCallba
PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data); PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data);
} }
void PhysicsWorldCallback::getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Array *arr) void PhysicsWorldCallback::getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Vector<PhysicsShape*>* arr)
{ {
auto it = PhysicsShapeInfo::getMap().find(shape); auto it = PhysicsShapeInfo::getMap().find(shape);
CC_ASSERT(it != PhysicsShapeInfo::getMap().end()); CC_ASSERT(it != PhysicsShapeInfo::getMap().end());
arr->addObject(it->second->getShape()); arr->pushBack(it->second->getShape());
} }
void PhysicsWorldCallback::queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info) void PhysicsWorldCallback::queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info)
@ -201,17 +201,17 @@ void PhysicsWorld::debugDraw()
_debugDraw = new PhysicsDebugDraw(*this); _debugDraw = new PhysicsDebugDraw(*this);
} }
if (_debugDraw && _bodies != nullptr) if (_debugDraw && !_bodies.empty())
{ {
if (_debugDraw->begin()) if (_debugDraw->begin())
{ {
if (_debugDrawMask & DEBUGDRAW_SHAPE) if (_debugDrawMask & DEBUGDRAW_SHAPE)
{ {
for (Object* obj : *_bodies) for (Object* obj : _bodies)
{ {
PhysicsBody* body = dynamic_cast<PhysicsBody*>(obj); PhysicsBody* body = dynamic_cast<PhysicsBody*>(obj);
for (auto shape : *body->getShapes()) for (auto& shape : body->getShapes())
{ {
_debugDraw->drawShape(*dynamic_cast<PhysicsShape*>(shape)); _debugDraw->drawShape(*dynamic_cast<PhysicsShape*>(shape));
} }
@ -392,16 +392,16 @@ void PhysicsWorld::queryPoint(PhysicsPointQueryCallbackFunc func, const Point& p
} }
} }
Array* PhysicsWorld::getShapes(const Point& point) const Vector<PhysicsShape*> PhysicsWorld::getShapes(const Point& point) const
{ {
Array* arr = Array::create(); Vector<PhysicsShape*> arr;
cpSpaceNearestPointQuery(this->_info->getSpace(), cpSpaceNearestPointQuery(this->_info->getSpace(),
PhysicsHelper::point2cpv(point), PhysicsHelper::point2cpv(point),
0, 0,
CP_ALL_LAYERS, CP_ALL_LAYERS,
CP_NO_GROUP, CP_NO_GROUP,
(cpSpaceNearestPointQueryFunc)PhysicsWorldCallback::getShapesAtPointFunc, (cpSpaceNearestPointQueryFunc)PhysicsWorldCallback::getShapesAtPointFunc,
arr); &arr);
return arr; return arr;
} }
@ -562,17 +562,8 @@ bool PhysicsWorld::init(Scene& scene)
{ {
do do
{ {
_delayAddBodies = Array::create();
_delayRemoveBodies = Array::create();
CC_BREAK_IF(_delayAddBodies == nullptr || _delayRemoveBodies == nullptr);
_delayAddBodies->retain();
_delayRemoveBodies->retain();
_info = new PhysicsWorldInfo(); _info = new PhysicsWorldInfo();
CC_BREAK_IF(_info == nullptr); CC_BREAK_IF(_info == nullptr);
_bodies = Array::create();
CC_BREAK_IF(_bodies == nullptr);
_bodies->retain();
_scene = &scene; _scene = &scene;
@ -606,7 +597,7 @@ void PhysicsWorld::addBody(PhysicsBody* body)
} }
addBodyOrDelay(body); addBodyOrDelay(body);
_bodies->addObject(body); _bodies.pushBack(body);
body->_world = this; body->_world = this;
} }
@ -627,7 +618,7 @@ void PhysicsWorld::doAddBody(PhysicsBody* body)
} }
// add shapes to space // add shapes to space
for (auto shape : *body->getShapes()) for (auto& shape : body->getShapes())
{ {
addShape(dynamic_cast<PhysicsShape*>(shape)); addShape(dynamic_cast<PhysicsShape*>(shape));
} }
@ -637,17 +628,17 @@ void PhysicsWorld::doAddBody(PhysicsBody* body)
void PhysicsWorld::addBodyOrDelay(PhysicsBody* body) void PhysicsWorld::addBodyOrDelay(PhysicsBody* body)
{ {
if (_delayRemoveBodies->getIndexOfObject(body) != CC_INVALID_INDEX) if (_delayRemoveBodies.getIndex(body) != CC_INVALID_INDEX)
{ {
_delayRemoveBodies->removeObject(body); _delayRemoveBodies.removeObject(body);
return; return;
} }
if (_info->isLocked()) if (_info->isLocked())
{ {
if (_delayAddBodies->getIndexOfObject(body) == CC_INVALID_INDEX) if (_delayAddBodies.getIndex(body) == CC_INVALID_INDEX)
{ {
_delayAddBodies->addObject(body); _delayAddBodies.pushBack(body);
_delayDirty = true; _delayDirty = true;
} }
}else }else
@ -663,25 +654,24 @@ void PhysicsWorld::updateBodies()
return; return;
} }
for (auto body : *_delayAddBodies) for (auto& body : _delayAddBodies)
{ {
doAddBody(dynamic_cast<PhysicsBody*>(body)); doAddBody(body);
} }
for (auto body : *_delayRemoveBodies) for (auto& body : _delayRemoveBodies)
{ {
doRemoveBody(dynamic_cast<PhysicsBody*>(body)); doRemoveBody(body);
} }
_delayAddBodies->removeAllObjects(); _delayAddBodies.clear();
_delayRemoveBodies->removeAllObjects(); _delayRemoveBodies.clear();
} }
void PhysicsWorld::removeBody(int tag) void PhysicsWorld::removeBody(int tag)
{ {
for (Object* obj : *_bodies) for (auto& body : _bodies)
{ {
PhysicsBody* body = dynamic_cast<PhysicsBody*>(obj);
if (body->getTag() == tag) if (body->getTag() == tag)
{ {
removeBody(body); removeBody(body);
@ -722,24 +712,24 @@ void PhysicsWorld::removeBody(PhysicsBody* body)
body->_joints.clear(); body->_joints.clear();
removeBodyOrDelay(body); removeBodyOrDelay(body);
_bodies->removeObject(body); _bodies.removeObject(body);
body->_world = nullptr; body->_world = nullptr;
} }
void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body) void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body)
{ {
if (_delayAddBodies->getIndexOfObject(body) != CC_INVALID_INDEX) if (_delayAddBodies.getIndex(body) != CC_INVALID_INDEX)
{ {
_delayAddBodies->removeObject(body); _delayAddBodies.removeObject(body);
return; return;
} }
if (_info->isLocked()) if (_info->isLocked())
{ {
if (_delayRemoveBodies->getIndexOfObject(body) == CC_INVALID_INDEX) if (_delayRemoveBodies.getIndex(body) == CC_INVALID_INDEX)
{ {
_delayRemoveBodies->addObject(body); _delayRemoveBodies.pushBack(body);
_delayDirty = true; _delayDirty = true;
} }
}else }else

View File

@ -28,12 +28,12 @@
#include "ccConfig.h" #include "ccConfig.h"
#ifdef CC_USE_PHYSICS #ifdef CC_USE_PHYSICS
#include <list> #include "CCVector.h"
#include <vector>
#include "CCObject.h" #include "CCObject.h"
#include "CCGeometry.h" #include "CCGeometry.h"
#include <list>
NS_CC_BEGIN NS_CC_BEGIN
class PhysicsBody; class PhysicsBody;
@ -41,7 +41,6 @@ class PhysicsJoint;
class PhysicsWorldInfo; class PhysicsWorldInfo;
class PhysicsShape; class PhysicsShape;
class PhysicsContact; class PhysicsContact;
class Array;
typedef Point Vect; typedef Point Vect;
@ -104,9 +103,9 @@ public:
void rayCast(PhysicsRayCastCallbackFunc func, const Point& point1, const Point& point2, void* data); void rayCast(PhysicsRayCastCallbackFunc func, const Point& point1, const Point& point2, void* data);
void queryRect(PhysicsRectQueryCallbackFunc func, const Rect& rect, void* data); void queryRect(PhysicsRectQueryCallbackFunc func, const Rect& rect, void* data);
void queryPoint(PhysicsPointQueryCallbackFunc func, const Point& point, void* data); void queryPoint(PhysicsPointQueryCallbackFunc func, const Point& point, void* data);
Array* getShapes(const Point& point) const; Vector<PhysicsShape*> getShapes(const Point& point) const;
PhysicsShape* getShape(const Point& point) const; PhysicsShape* getShape(const Point& point) const;
Array* getAllBodies() const; const Vector<PhysicsBody*>& getAllBodies() const;
PhysicsBody* getBody(int tag) const; PhysicsBody* getBody(int tag) const;
/** Register a listener to receive contact callbacks*/ /** Register a listener to receive contact callbacks*/
@ -156,7 +155,7 @@ protected:
float _speed; float _speed;
PhysicsWorldInfo* _info; PhysicsWorldInfo* _info;
Array* _bodies; Vector<PhysicsBody*> _bodies;
std::list<PhysicsJoint*> _joints; std::list<PhysicsJoint*> _joints;
Scene* _scene; Scene* _scene;
@ -165,8 +164,8 @@ protected:
int _debugDrawMask; int _debugDrawMask;
Array* _delayAddBodies; Vector<PhysicsBody*> _delayAddBodies;
Array* _delayRemoveBodies; Vector<PhysicsBody*> _delayRemoveBodies;
std::vector<PhysicsJoint*> _delayAddJoints; std::vector<PhysicsJoint*> _delayAddJoints;
std::vector<PhysicsJoint*> _delayRemoveJoints; std::vector<PhysicsJoint*> _delayRemoveJoints;