Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2011, 5:07:42 AM (13 years ago)
Author:
rgrieder
Message:

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/bullet/LinearMath/btSerializer.h

    r8351 r8393  
    112112#endif
    113113
     114#define BT_SOFTBODY_CODE                MAKE_ID('S','B','D','Y')
    114115#define BT_COLLISIONOBJECT_CODE MAKE_ID('C','O','B','J')
    115116#define BT_RIGIDBODY_CODE               MAKE_ID('R','B','D','Y')
     
    120121#define BT_SHAPE_CODE                   MAKE_ID('S','H','A','P')
    121122#define BT_ARRAY_CODE                   MAKE_ID('A','R','A','Y')
     123#define BT_SBMATERIAL_CODE              MAKE_ID('S','B','M','T')
     124#define BT_SBNODE_CODE                  MAKE_ID('S','B','N','D')
    122125#define BT_DNA_CODE                             MAKE_ID('D','N','A','1')
    123 
    124126
    125127
     
    133135};
    134136
    135 
     137///The btDefaultSerializer is the main Bullet serialization class.
     138///The constructor takes an optional argument for backwards compatibility, it is recommended to leave this empty/zero.
    136139class btDefaultSerializer       :       public btSerializer
    137140{
     
    372375       
    373376
    374                 btDefaultSerializer(int totalSize)
     377                btDefaultSerializer(int totalSize=0)
    375378                        :m_totalSize(totalSize),
    376379                        m_currentSize(0),
     
    379382                        m_serializationFlags(0)
    380383                {
    381                         m_buffer = (unsigned char*)btAlignedAlloc(totalSize, 16);
     384                        m_buffer = m_totalSize?(unsigned char*)btAlignedAlloc(totalSize,16):0;
    382385                       
    383386                        const bool VOID_IS_8 = ((sizeof(void*)==8));
     
    420423                }
    421424
    422                 virtual void    startSerialization()
    423                 {
    424                         m_uniqueIdGenerator= 1;
    425 
    426                         m_currentSize = BT_HEADER_LENGTH;
     425                void    writeHeader(unsigned char* buffer) const
     426                {
     427                       
    427428
    428429#ifdef  BT_USE_DOUBLE_PRECISION
    429                         memcpy(m_buffer, "BULLETd", 7);
     430                        memcpy(buffer, "BULLETd", 7);
    430431#else
    431                         memcpy(m_buffer, "BULLETf", 7);
     432                        memcpy(buffer, "BULLETf", 7);
    432433#endif //BT_USE_DOUBLE_PRECISION
    433434       
     
    437438                        if (sizeof(void*)==8)
    438439                        {
    439                                 m_buffer[7] = '-';
     440                                buffer[7] = '-';
    440441                        } else
    441442                        {
    442                                 m_buffer[7] = '_';
     443                                buffer[7] = '_';
    443444                        }
    444445
    445446                        if (littleEndian)
    446447                        {
    447                                 m_buffer[8]='v';                               
     448                                buffer[8]='v';                         
    448449                        } else
    449450                        {
    450                                 m_buffer[8]='V';
    451                         }
    452 
    453 
    454                         m_buffer[9] = '2';
    455                         m_buffer[10] = '7';
    456                         m_buffer[11] = '7';
    457 
     451                                buffer[8]='V';
     452                        }
     453
     454
     455                        buffer[9] = '2';
     456                        buffer[10] = '7';
     457                        buffer[11] = '8';
     458
     459                }
     460
     461                virtual void    startSerialization()
     462                {
     463                        m_uniqueIdGenerator= 1;
     464                        if (m_totalSize)
     465                        {
     466                                unsigned char* buffer = internalAlloc(BT_HEADER_LENGTH);
     467                                writeHeader(buffer);
     468                        }
    458469                       
    459470                }
     
    463474                        writeDNA();
    464475
     476                        //if we didn't pre-allocate a buffer, we need to create a contiguous buffer now
     477                        int mysize = 0;
     478                        if (!m_totalSize)
     479                        {
     480                                if (m_buffer)
     481                                        btAlignedFree(m_buffer);
     482
     483                                m_currentSize += BT_HEADER_LENGTH;
     484                                m_buffer = (unsigned char*)btAlignedAlloc(m_currentSize,16);
     485
     486                                unsigned char* currentPtr = m_buffer;
     487                                writeHeader(m_buffer);
     488                                currentPtr += BT_HEADER_LENGTH;
     489                                mysize+=BT_HEADER_LENGTH;
     490                                for (int i=0;i< m_chunkPtrs.size();i++)
     491                                {
     492                                        int curLength = sizeof(btChunk)+m_chunkPtrs[i]->m_length;
     493                                        memcpy(currentPtr,m_chunkPtrs[i], curLength);
     494                                        btAlignedFree(m_chunkPtrs[i]);
     495                                        currentPtr+=curLength;
     496                                        mysize+=curLength;
     497                                }
     498                        }
    465499
    466500                        mTypes.clear();
     
    472506                        m_nameMap.clear();
    473507                        m_uniquePointers.clear();
     508                        m_chunkPtrs.clear();
    474509                }
    475510
     
    523558
    524559               
     560                virtual unsigned char* internalAlloc(size_t size)
     561                {
     562                        unsigned char* ptr = 0;
     563
     564                        if (m_totalSize)
     565                        {
     566                                ptr = m_buffer+m_currentSize;
     567                                m_currentSize += int(size);
     568                                btAssert(m_currentSize<m_totalSize);
     569                        } else
     570                        {
     571                                ptr = (unsigned char*)btAlignedAlloc(size,16);
     572                                m_currentSize += int(size);
     573                        }
     574                        return ptr;
     575                }
    525576
    526577               
     
    529580                {
    530581
    531                         unsigned char* ptr = m_buffer+m_currentSize;
    532                         m_currentSize += int(size)*numElements+sizeof(btChunk);
    533                         btAssert(m_currentSize<m_totalSize);
     582                        unsigned char* ptr = internalAlloc(int(size)*numElements+sizeof(btChunk));
    534583
    535584                        unsigned char* data = ptr + sizeof(btChunk);
Note: See TracChangeset for help on using the changeset viewer.