示例#1
0
			int calchull( btVector3[] verts, int verts_count, out TUIntArray tris_out, out int tris_count, int vlimit )
			{
				int rc = calchullgen( verts, verts_count, vlimit );
				if( rc == 0 )
				{
					tris_out = null;
					tris_count = 0;
					return 0;
				}
				btList<int> ts = new btList<int>();
				int i;

				for( i = 0; i < m_tris.Count; i++ )
				{
					if( m_tris[i] != null )
					{
						for( int j = 0; j < 3; j++ )
							ts.Add( ( m_tris[i].v)[j] );
						deAllocateTriangle( m_tris[i] );
					}
				}
				tris_count = ts.Count / 3;
				tris_out = new TUIntArray( ts.Count );

				for( i = 0; i < ts.Count; i++ )
				{
					tris_out[i] = (uint)( ts[i] );
				}
				m_tris.Count = ( 0 );

				return 1;
			}
示例#2
0
			void BringOutYourDead( btList<btVector3> verts, int vcount, btList<btVector3> overts, out int ocount, TUIntArray indices, int indexcount )
			{
				btList<int> tmpIndices = new btList<int>( m_vertexIndexMapping.Count );
				int i;

				for( i = 0; i < m_vertexIndexMapping.Count; i++ )
				{
					tmpIndices[i] = m_vertexIndexMapping[i];
				}

				TUIntArray usedIndices = new TUIntArray( (int)vcount );
				//usedIndices.Capacity( (int)vcount ) );
				//memset( usedIndices, 0, sizeof( uint ) * vcount );

				ocount = 0;

				for( i = 0; i < (int)indexcount; i++ )
				{
					int v = (int)indices[i]; // original array index

					Debug.Assert( v >= 0 && v < vcount );

					if( usedIndices[(int) v] != 0 ) // if already remapped
					{
						indices[i] = usedIndices[v] - 1; // index to new array
					}
					else
					{

						indices[i] = (uint)ocount;      // new index mapping

						overts[ocount] = verts[v]; // copy old vert to new vert array

						for( int k = 0; k < m_vertexIndexMapping.Count; k++ )
						{
							if( tmpIndices[k] ==  v )
								m_vertexIndexMapping[k] = ocount;
						}

						ocount++; // increment output vert count

						Debug.Assert( ocount >= 0 && ocount <= vcount );

						usedIndices[v] = (uint)ocount; // assign new index remapping


					}
				}
			}