Revision: 73029
          http://sourceforge.net/p/brlcad/code/73029
Author:   brlcad
Date:     2019-05-09 05:13:23 +0000 (Thu, 09 May 2019)
Log Message:
-----------
write uvs out to disk if we have them.  still have plenty of bits left in the 
flags bitmask to extend the bot structure forward- and backwards-compatibly.  
will want to use the last bit as an extension to a bitflag+nextmemorychunk.

Modified Paths:
--------------
    brlcad/trunk/src/librt/primitives/bot/bot.c

Modified: brlcad/trunk/src/librt/primitives/bot/bot.c
===================================================================
--- brlcad/trunk/src/librt/primitives/bot/bot.c 2019-05-09 02:26:47 UTC (rev 
73028)
+++ brlcad/trunk/src/librt/primitives/bot/bot.c 2019-05-09 05:13:23 UTC (rev 
73029)
@@ -1489,6 +1489,11 @@
            + SIZEOF_NETWORK_LONG * (bip->num_face_normals * 3 + 2); /* indices 
into normals array, num_normals, num_face_normals */
     }
 
+    if (bip->bot_flags & RT_BOT_HAS_TEXTURE_UVS) {
+       ep->ext_nbytes += SIZEOF_NETWORK_DOUBLE * bip->num_uvs * 3 /* vertex 
uvs */
+           + SIZEOF_NETWORK_LONG * (bip->num_face_uvs * 3 + 2); /* indices 
into uvs array, num_uvs, num_face_uvs */
+    }
+
     ep->ext_buf = (uint8_t *)bu_malloc(ep->ext_nbytes, "BOT external");
 
     cp = ep->ext_buf;
@@ -1593,6 +1598,49 @@
        }
     }
 
+    if (bip->bot_flags & RT_BOT_HAS_TEXTURE_UVS) {
+       *(uint32_t *)&cp[0] = htonl(bip->num_uvs);
+       cp += SIZEOF_NETWORK_LONG;
+       rem -= SIZEOF_NETWORK_LONG;
+
+       *(uint32_t *)&cp[0] = htonl(bip->num_face_uvs);
+       cp += SIZEOF_NETWORK_LONG;
+       rem -= SIZEOF_NETWORK_LONG;
+
+       if (bip->num_uvs > 0) {
+           /* must be double for import and export */
+           double *uvs;
+           uvs = (double 
*)bu_malloc(bip->num_uvs*ELEMENTS_PER_VECT*sizeof(double), "uvs");
+
+           /* convert fastf_t to double */
+           for (i = 0; i < bip->num_uvs * ELEMENTS_PER_VECT; i++) {
+               uvs[i] = bip->uvs[i];
+           }
+
+           bu_cv_htond(cp, (unsigned char*)uvs, 
bip->num_uvs*ELEMENTS_PER_VECT);
+
+           bu_free(uvs, "uvs");
+
+           cp += SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT * bip->num_uvs;
+           rem -= SIZEOF_NETWORK_DOUBLE * ELEMENTS_PER_VECT * bip->num_uvs;
+       }
+       if (bip->num_face_uvs > 0) {
+           for (i = 0; i < bip->num_face_uvs; i++) {
+               *(uint32_t *)&cp[0] = htonl(bip->face_uvs[i*ELEMENTS_PER_VECT + 
0]);
+               cp += SIZEOF_NETWORK_LONG;
+               rem -= SIZEOF_NETWORK_LONG;
+
+               *(uint32_t *)&cp[0] = htonl(bip->face_uvs[i*ELEMENTS_PER_VECT + 
1]);
+               cp += SIZEOF_NETWORK_LONG;
+               rem -= SIZEOF_NETWORK_LONG;
+
+               *(uint32_t *)&cp[0] = htonl(bip->face_uvs[i*ELEMENTS_PER_VECT + 
2]);
+               cp += SIZEOF_NETWORK_LONG;
+               rem -= SIZEOF_NETWORK_LONG;
+           }
+       }
+    }
+
     return 0;
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to