// // RParticleMacros.h // cocos2d_libs // // Created by 徐俊杰 on 2020/4/27. // #ifndef RParticleMacros_h #define RParticleMacros_h //#include "cocos2d.h" #include "math/CCAffineTransform.h" #include "math/CCGeometry.h" #include "math/CCVertex.h" #include "math/Mat4.h" #include "math/MathUtil.h" #include "math/Quaternion.h" #include "math/Vec2.h" #include "math/Vec3.h" #include "math/Vec4.h" #include "3d/CCAABB.h" #include "platform/CCPlatformConfig.h" /// @name namespace RRP /// @{ #ifdef __cplusplus #define NS_RRP_BEGIN namespace RRP { #define NS_RRP_END } #define USING_NS_RRP using namespace RRP #define NS_RRP ::RRP #else #define NS_RRP_BEGIN #define NS_RRP_END #define USING_NS_RRP #define NS_RRP #endif // end of namespace group /// @} /******************************************************************************************/ /** LittleEndian Sense Macro, from google protobuf see: **/ /** https://github.com/google/protobuf/blob/master/src/google/protobuf/io/coded_stream.h **/ /******************************************************************************************/ #ifdef _MSC_VER #if defined(_M_IX86) #define RRP_LITTLE_ENDIAN 1 #else #define RRP_LITTLE_ENDIAN 0 #endif #if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER) #pragma runtime_checks("c", off) #endif #else #include #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include #endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) #define RRP_LITTLE_ENDIAN 1 #else #define RRP_LITTLE_ENDIAN 0 #endif #endif // MemoryMacros.h #if defined(__GNUC__) #define ALIGN_OF(T) __alignof__(T) #define ALIGN_TYPE(val) __attribute__((aligned(val))) #define FORCE_INLINE inline __attribute__ ((always_inline)) #elif defined(_MSC_VER) #define ALIGN_OF(T) __alignof(T) #define ALIGN_TYPE(val) __declspec(align(val)) #define FORCE_INLINE __forceinline #else #define ALIGN_TYPE(size) #define FORCE_INLINE inline #endif #define UNITY_MALLOC_ALIGNED(l,s,a) ::malloc(s) #define UNITY_REALLOC_ALIGNED(l,p,s,a) ::realloc(p, s) #define FREE_TEMP_MANUAL(ptr) ::free(ptr) // LogAssert.h #define AssertIf(x) do { (void)sizeof(x); } while(0) #define AssertIfObject(x,o) do { (void)sizeof(x); (void)sizeof(o); } while(0) #define Assert(x) do { (void)sizeof(x); } while(0) #define AssertMsg(x,...) do { (void)sizeof(x); } while(0) #define AssertMsgObject(x,o,...) do { (void)sizeof(x); } while(0) #define DebugAssertIf(x) AssertIf(x) #define DebugAssert(x) Assert(x) #define DebugAssertMsg(x, ...) AssertMsg(x, __VA_ARGS__) #define DEBUG_BREAK #define AssertBreak(x) \ do { \ if(!(x)) \ { \ DEBUG_BREAK; \ Assert(x); \ } \ } while(0) // ExportModules.h #define EXPORT_COREMODULE CC_DLL #define EXPORT_MODULE CC_DLL // ObjectDefines.h #define INSTANTIATE_TEMPLATE_TRANSFER_WITH_DECL(x, decl) \ template decl void x::Transfer(JsonRead& transfer); \ template decl void x::Transfer(JsonWrite& transfer); \ template decl void x::Transfer(StreamedBinaryRead& transfer); \ template decl void x::Transfer(StreamedBinaryWrite& transfer); #define INSTANTIATE_TEMPLATE_TRANSFER(x) INSTANTIATE_TEMPLATE_TRANSFER_WITH_DECL(x, ) #define FOR_QY_TEST 1 #define ENABLE_PHYSICS 1 enum { // @TBD: tweak to ideal values per platform / device / rendering API kDynamicBatchingVerticesThreshold = 300, // verts (needed at build time since required channels isn't known) kDynamicBatchingVertsByChannelThreshold = 300 * 3, // verts * channels kDynamicBatchingIndicesThreshold = 32000 // >32k causes a slowdown on MBPs with AMD cards (Case 394520) }; // AllocatorLabels.h struct MemLabelId { // GetRootHeader }; enum ObjectCreationMode { // Create the object from the main thread in a perfectly normal way kCreateObjectDefault = 0, // Create the object from another thread. Might assign an instance ID but will not register with IDToPointer map. // Objects created like this, need to call, AwakeFromLoadThraded, and Object::RegisterInstanceID and AwakeFromLoad (kDidLoadThreaded); from the main thread kCreateObjectFromNonMainThread = 1, // Create the object and register the instance id but do not lock the object // creation mutex because the code calling it already called LockObjectCreation mutex. kCreateObjectDefaultNoLock = 2 }; // Types typedef cocos2d::Vec2 Vector2f; typedef cocos2d::Vec3 Vector3f; typedef cocos2d::Vec4 Vector4f; typedef cocos2d::Color4B ColorRGBA32; typedef cocos2d::Color4F ColorRGBAf; typedef cocos2d::Mat4 Matrix4x4f; typedef cocos2d::AABB MinMaxAABB; typedef cocos2d::Quaternion Quaternionf; #ifndef kPI #define kPI 3.14159265358979323846264338327950288419716939937510F #endif #define GET_SET_DIRTY(TYPE,PROP_NAME,VAR_NAME) void Set##PROP_NAME (TYPE val) { VAR_NAME = val; SetDirty(); } const TYPE Get##PROP_NAME () const {return (const TYPE)VAR_NAME; } // Vector3.h const float Vector3f_Epsilon = 0.00001F; //inline float Dot(const Vector3f &lhs, const Vector3f &rhs) //{ // return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z; //} //inline float SqrtImpl (float f) //{ // return sqrt (f); //} //inline float SqrMagnitude (const Vector3f& inV){ return Dot (inV, inV); } //inline bool CompareApproximately (float f0, float f1, float epsilon = 0.000001F) //{ // float dist = (f0 - f1); // dist = abs (dist); // return dist < epsilon; //} //inline Vector3f Lerp (const Vector3f& from, const Vector3f& to, float t) { return to * t + from * (1.0F - t); } //inline Vector3f Cross (const Vector3f& lhs, const Vector3f& rhs) //{ // return Vector3f ( // lhs.y * rhs.z - lhs.z * rhs.y, // lhs.z * rhs.x - lhs.x * rhs.z, // lhs.x * rhs.y - lhs.y * rhs.x); //} //inline float Magnitude (const Vector3f& inV){return SqrtImpl(Dot (inV, inV));} // FloatConversion.h //inline float Lerp (float from, float to, float t) //{ // return to * t + from * (1.0F - t); //} //#define k1OverSqrt2 float(0.7071067811865475244008443621048490) // Calculates a vector that is orthonormal to n. // Assumes that n is normalized //Vector3f OrthoNormalVectorFast (const Vector3f& n); //Vector3f OrthoNormalVectorFast (const Vector3f& n) //{ // Vector3f res; // if (abs (n.z) > k1OverSqrt2) // { // // choose p in y-z plane // float a = n.y*n.y + n.z*n.z; // float k = 1.0F / sqrt (a); // res.x = 0; // res.y = -n.z*k; // res.z = n.y*k; // } // else // { // // choose p in x-y plane // float a = n.x*n.x + n.y*n.y; // float k = 1.0F / sqrt (a); // res.x = -n.y*k; // res.y = n.x*k; // res.z = 0; // } // return res; //} // Orthonormalizes the three vectors, returns false if no orthonormal basis could be formed. //EXPORT_COREMODULE void OrthoNormalize (Vector3f* inU, Vector3f* inV, Vector3f* inW); //void OrthoNormalize (Vector3f* inU, Vector3f* inV, Vector3f* inW) //{ // // compute u0 // float mag = Magnitude (*inU); // if (mag > Vector3f_Epsilon) // *inU = *inU /mag; // else // *inU = Vector3f (1.0F, 0.0F, 0.0F); // // // compute u1 // float dot0 = Dot (*inU, *inV); // *inV -= dot0 * *inU; // mag = Magnitude (*inV); // if (mag > Vector3f_Epsilon) // *inV = *inV / mag; // else // *inV = OrthoNormalVectorFast (*inU); // // // compute u2 // float dot1 = Dot (*inV, *inW); // dot0 = Dot (*inU, *inW); // *inW -= dot0 * *inU + dot1 * *inV; // mag = Magnitude (*inW); // if (mag > Vector3f_Epsilon) // *inW = *inW / mag; // else // *inW = Cross (*inU, *inV); //} // AABB /// This version is much slower but works correctly with non-uniform scale //void TransformAABBSlow (const AABB& aabb, const Matrix4x4f& transform, AABB& result); //void TransformAABBSlow (const AABB& aabb, const Matrix4x4f& transform, AABB& result) //{ // MinMaxAABB transformed; // transformed.reset (); // // Vector3f v[8]; // aabb.GetVertices (v); //// for (int i=0;i<8;i++) //// transformed.Encapsulate (transform.MultiplyPoint3 (v[i])); // // result = transformed; //} // OSTypes.h typedef unsigned char UInt8; typedef unsigned short UInt16; # if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) typedef unsigned int UInt32; #else # if __LP64__ typedef unsigned int UInt32; # else typedef unsigned long UInt32; # endif #endif typedef unsigned long long UInt64; typedef signed char SInt8; typedef signed short SInt16; # if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) typedef signed int SInt32; # else # if __LP64__ typedef signed int SInt32; # else typedef signed long SInt32; # endif #endif typedef signed long long SInt64; #endif /* RParticleMacros_h */