]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/picomodel/pm_lwo.c
Merge commit 'ff48e71434a414958e6e56628ccf04284d030784' into master-merge
[xonotic/netradiant.git] / libs / picomodel / pm_lwo.c
index f1d82dd92712ff05a3d1e29e0c0ebadce0d0b3b3..6431dc2b2e236f5396c585a4f0605e518d599e09 100644 (file)
@@ -32,9 +32,6 @@
 
    ----------------------------------------------------------------------------- */
 
-/* marker */
-#define PM_LWO_C
-
 /* dependencies */
 #include "picointernal.h"
 #include "lwo/lwo2.h"
@@ -76,7 +73,7 @@ static int _lwo_canload( PM_PARAMS_CANLOAD ){
        int ret;
 
        /* create a new pico memorystream */
-       s = _pico_new_memstream( (picoByte_t *)buffer, bufSize );
+       s = _pico_new_memstream( (const picoByte_t *)buffer, bufSize );
        if ( s == NULL ) {
                return PICO_PMV_ERROR_MEMORY;
        }
@@ -103,7 +100,8 @@ static picoModel_t *_lwo_load( PM_PARAMS_LOAD ){
        lwPolygon       *pol;
        lwPolVert       *v;
        lwVMapPt        *vm;
-       char name[ 64 ];
+       char name[256];
+       name[255] = '\0';
        int i, j, k, numverts;
 
        picoModel_t     *picoModel;
@@ -133,7 +131,7 @@ static picoModel_t *_lwo_load( PM_PARAMS_LOAD ){
        }
 
        /* create a new pico memorystream */
-       s = _pico_new_memstream( (picoByte_t *)buffer, bufSize );
+       s = _pico_new_memstream( (const picoByte_t *)buffer, bufSize );
        if ( s == NULL ) {
                return NULL;
        }
@@ -234,8 +232,9 @@ static picoModel_t *_lwo_load( PM_PARAMS_LOAD ){
                }
 
                /* detox and set shader name */
-               strncpy( name, surface->name, sizeof( name ) );
-               _pico_setfext( name, "" );
+               strncpy( name, surface->name, sizeof( name ) - 1 );
+               _pico_first_token( name );
+               _pico_setfext( name, NULL );
                _pico_unixify( name );
                PicoSetShaderName( picoShader, name );
 
@@ -282,9 +281,22 @@ static picoModel_t *_lwo_load( PM_PARAMS_LOAD ){
                                xyz[ 1 ] = pt->pos[ 2 ];
                                xyz[ 2 ] = pt->pos[ 1 ];
 
-                               normal[ 0 ] = v->norm[ 0 ];
-                               normal[ 1 ] = v->norm[ 2 ];
-                               normal[ 2 ] = v->norm[ 1 ];
+/* doom3 lwo data doesn't seem to have smoothing-angle information */
+#if 0
+                               if ( surface->smooth <= 0 ) {
+                                       /* use face normals */
+                                       normal[ 0 ] = v->norm[ 0 ];
+                                       normal[ 1 ] = v->norm[ 2 ];
+                                       normal[ 2 ] = v->norm[ 1 ];
+                               }
+                               else
+#endif
+                               {
+                                       /* smooth normals later */
+                                       normal[ 0 ] = 0;
+                                       normal[ 1 ] = 0;
+                                       normal[ 2 ] = 0;
+                               }
 
                                st[ 0 ] = xyz[ defaultSTAxis[ 0 ] ] * defaultXYZtoSTScale[ 0 ];
                                st[ 1 ] = xyz[ defaultSTAxis[ 1 ] ] * defaultXYZtoSTScale[ 1 ];