/****************************************************************************** libx42 - skinned vertex animation library Copyright (C) 2007 HermitWorks Entertainment Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA. ******************************************************************************/ #include "local.h" X42_EXPORT bool X42_CALL x42_CopyIndices_u16( u16 *oIdx, uint baseIdx, const x42data_t *x42, uint groupNum, x42opts_t *opts ) { uint i; const x42group_t *g; const x42index_t * RESTRICT idxs; u16 * RESTRICT out = oIdx; REF_PARAM( opts ); #ifndef LIBX42_NO_PARAM_VALIDATION demand_rf( oIdx != NULL, X42_ERR_BADPTR, "oIdx is NULL" ); demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" ); demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" ); demand_rf( groupNum < x42->header.numGroups, X42_ERR_OUTOFRANGE, "group number out of range" ); #endif g = x42->groups + groupNum; if( g->firstIndex == X42_NO_INDICES ) { //implicit vertices for( i = 0; i < g->numElems; i++ ) out[i] = (u16)(baseIdx + i); return true; } idxs = x42->indices + g->firstIndex; if( baseIdx == 0 ) { memcpy( out, idxs, sizeof( short ) * g->numElems ); return true; } for( i = 0; i < g->numElems; i++ ) out[i] = (u16)(baseIdx + idxs[i]); return true; } X42_EXPORT bool X42_CALL x42_CopyIndices_u32( u32 *oIdx, uint baseIdx, const x42data_t *x42, uint groupNum, x42opts_t *opts ) { uint i; const x42group_t *g; const x42index_t * RESTRICT idxs; u32 * RESTRICT out = oIdx; REF_PARAM( opts ); #ifndef LIBX42_NO_PARAM_VALIDATION demand_rf( oIdx != NULL, X42_ERR_BADPTR, "oIdx is NULL" ); demand_rf( x42 != NULL, X42_ERR_BADPTR, "x42 is NULL" ); demand_rf( x42_ValidateHeader( &x42->header ), X42_ERR_BADDATA, "invalid x42 header data" ); demand_rf( groupNum < x42->header.numGroups, X42_ERR_OUTOFRANGE, "group number out of range" ); #endif g = x42->groups + groupNum; if( g->firstIndex == X42_NO_INDICES ) { //implicit vertices for( i = 0; i < g->numElems; i++ ) out[i] = baseIdx + i; return true; } idxs = x42->indices + g->firstIndex; for( i = 0; i < g->numElems; i++ ) out[i] = baseIdx + idxs[i]; return true; }