Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r352 - branches/itanium2/Model/Groups
- Date: Thu, 26 May 2005 16:28:00 -0600 (MDT)
Author: abe
Date: Thu May 26 16:28:00 2005
New Revision: 352
Modified:
branches/itanium2/Model/Groups/kdtree.cc
branches/itanium2/Model/Groups/kdtree.h
Log:
endian swap
Modified: branches/itanium2/Model/Groups/kdtree.cc
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.cc (original)
+++ branches/itanium2/Model/Groups/kdtree.cc Thu May 26 16:28:00 2005
@@ -183,19 +183,22 @@
// Specify the root node loaded from the file.
rootNode = (KDTreeNode*)buffer;
- rootNode->endian_swap();
-
// Get the bounding box from the file.
AABox3f bboxf = *(AABox3f*)((char*)buffer + fileSize -
sizeof(AABox3f));
-
- bboxf.min[0] = endian_swap( bboxf.min[0] );
- bboxf.min[1] = endian_swap( bboxf.min[1] );
- bboxf.min[2] = endian_swap( bboxf.min[2] );
-
- bboxf.max[0] = endian_swap( bboxf.max[0] );
- bboxf.max[1] = endian_swap( bboxf.max[1] );
- bboxf.max[2] = endian_swap( bboxf.max[2] );
-
+
+ if (is_big_endian()) {
+
+ rootNode->endian_swap();
+
+ bboxf.min[0] = endian_swap( bboxf.min[0] );
+ bboxf.min[1] = endian_swap( bboxf.min[1] );
+ bboxf.min[2] = endian_swap( bboxf.min[2] );
+
+ bboxf.max[0] = endian_swap( bboxf.max[0] );
+ bboxf.max[1] = endian_swap( bboxf.max[1] );
+ bboxf.max[2] = endian_swap( bboxf.max[2] );
+
+ }
bbox = BBox( bboxf.min, bboxf.max );
/////////////////////////////////////////////////////////////////////////////
@@ -225,8 +228,10 @@
triIndices = indices;
// Swap the indicies.
- for (int i=0;i<nInt;++i) {
- (*indices)[i] = endian_swap( (*indices)[i] );
+ if (is_big_endian()) {
+ for (int i=0;i<nInt;++i) {
+ (*indices)[i] = endian_swap( (*indices)[i] );
+ }
}
// create material
Modified: branches/itanium2/Model/Groups/kdtree.h
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.h (original)
+++ branches/itanium2/Model/Groups/kdtree.h Thu May 26 16:28:00 2005
@@ -88,6 +88,17 @@
return out;
}
+
+ // Check the endianness of this machine.
+ inline bool is_big_endian() {
+ unsigned int x = 0x00112233;
+
+ char *p = (char *)&x;
+
+ printf(">>%X\n",p[0]);
+
+ return (p[0] == 0x00);
+ }
///////////////////////////////////////////////////////////////////////////
// KDTREE INTERNAL NODE
- [MANTA] r352 - branches/itanium2/Model/Groups, abe, 05/26/2005
Archive powered by MHonArc 2.6.16.