mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-13 00:24:29 +00:00
Ported picomodel.c from 1.5
Improvements over 1.4/1.5 are in.
This commit is contained in:
parent
3fb0a994e2
commit
41f9d3a1e1
4 changed files with 593 additions and 222 deletions
|
@ -105,6 +105,7 @@ struct picoSurface_s
|
||||||
int numVertexes, maxVertexes;
|
int numVertexes, maxVertexes;
|
||||||
picoVec3_t *xyz;
|
picoVec3_t *xyz;
|
||||||
picoVec3_t *normal;
|
picoVec3_t *normal;
|
||||||
|
picoIndex_t *smoothingGroup;
|
||||||
|
|
||||||
int numSTArrays, maxSTArrays;
|
int numSTArrays, maxSTArrays;
|
||||||
picoVec2_t **st;
|
picoVec2_t **st;
|
||||||
|
@ -216,6 +217,9 @@ const picoModule_t **PicoModuleList( int *numModules );
|
||||||
|
|
||||||
picoModel_t *PicoLoadModel( char *name, int frameNum );
|
picoModel_t *PicoLoadModel( char *name, int frameNum );
|
||||||
|
|
||||||
|
typedef size_t(*PicoInputStreamReadFunc)(void* inputStream, unsigned char* buffer, size_t length);
|
||||||
|
picoModel_t* PicoModuleLoadModelStream(const picoModule_t* module, void* inputStream, PicoInputStreamReadFunc inputStreamRead, size_t streamLength, int frameNum);
|
||||||
|
|
||||||
|
|
||||||
/* model functions */
|
/* model functions */
|
||||||
picoModel_t *PicoNewModel( void );
|
picoModel_t *PicoNewModel( void );
|
||||||
|
|
|
@ -161,35 +161,22 @@ void *_pico_realloc( void **ptr, size_t oldSize, size_t newSize ){
|
||||||
* as custom clone size (the string is cropped to fit into mem
|
* as custom clone size (the string is cropped to fit into mem
|
||||||
* if needed). -sea
|
* if needed). -sea
|
||||||
*/
|
*/
|
||||||
char *_pico_clone_alloc( char *str, int size ){
|
char *_pico_clone_alloc(const char *str)
|
||||||
char *cloned;
|
{
|
||||||
size_t cloneSize;
|
char* cloned;
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if ( str == NULL ) {
|
if (str == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* set real size of cloned string */
|
|
||||||
cloneSize = ( size < 0 ) ? strlen( str ) : size;
|
|
||||||
|
|
||||||
/* allocate memory */
|
/* allocate memory */
|
||||||
cloned = _pico_alloc( cloneSize + 1 ); /* bugfix! */
|
cloned = _pico_alloc(strlen(str) + 1);
|
||||||
if ( cloned == NULL ) {
|
if (cloned == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* zero out memory allocated by cloned string */
|
|
||||||
memset( cloned,0,cloneSize );
|
|
||||||
|
|
||||||
/* copy input string to cloned string */
|
/* copy input string to cloned string */
|
||||||
if ( cloneSize < strlen( str ) ) {
|
strcpy(cloned, str);
|
||||||
memcpy( cloned,str,cloneSize );
|
|
||||||
cloned[ cloneSize ] = '\0';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
strcpy( cloned,str );
|
|
||||||
}
|
|
||||||
/* return ptr to cloned string */
|
/* return ptr to cloned string */
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ extern void ( *_pico_ptr_print )( int, const char* );
|
||||||
void *_pico_alloc( size_t size );
|
void *_pico_alloc( size_t size );
|
||||||
void *_pico_calloc( size_t num, size_t size );
|
void *_pico_calloc( size_t num, size_t size );
|
||||||
void *_pico_realloc( void **ptr, size_t oldSize, size_t newSize );
|
void *_pico_realloc( void **ptr, size_t oldSize, size_t newSize );
|
||||||
char *_pico_clone_alloc( char *str, int size );
|
char *_pico_clone_alloc( char *str/*, int size*/ );
|
||||||
void _pico_free( void *ptr );
|
void _pico_free( void *ptr );
|
||||||
|
|
||||||
/* files */
|
/* files */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue