[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#376226: marked as done (lib3ds-dev: lib3ds doesn't handle "object-flag" chunks (patch included))



Your message dated Tue, 24 May 2011 22:05:58 +0200
with message-id <20110524200558.GA2560@free.fr>
and subject line Re: lib3ds doesn't handle "object-flag" chunks
has caused the Debian Bug report #376226,
regarding lib3ds-dev: lib3ds doesn't handle "object-flag" chunks (patch included)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
376226: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=376226
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: lib3ds-dev
Version: 1.2.0-4
Severity: normal



lib3ds ignores various "object flag" chunks like LIB3DS_OBJ_HIDDEN
(basically all chunks with prefix "LIB3DS_OBJ_").

This is particularly annoying in the case of LIB3DS_OBJ_HIDDEN, because
many 3ds models contain hidden elements which are not intended to be
rendered (e.g., multiple copies of part of the model might be provided,
each in a different state, with only one not marked as hidden); when the
hidden parts _are_ rendered, it can screw up the result.

I've attached a patch which handles this chunks.  It basically adds a
new field "obj_flags" to the Lib3dsMesh, Lib3dsCamera, and Lib3dsCamera
structures, and a new enum Lib3dsObjFlags.  Each bit of the obj_flags
field corresponds to one value in Lib3dsObjFlags.

BTW, compiling lib3ds with gcc-4.1 resulted in a non-working library
(lots of strange problems, basically it didn't parse 3ds files
correctly).  Compiling with gcc-3.3 worked fine.

Thanks,

-Miles


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.13.2
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)

Versions of packages lib3ds-dev depends on:
ii  libc6                         2.3.6-15   GNU C Library: Shared libraries

lib3ds-dev recommends no packages.

-- no debconf information
diff -ruN -X../diff.xcl lib3ds-1.2.0/lib3ds/camera.h lib3ds-1.2.0-miles-20060404/lib3ds/camera.h
--- lib3ds-1.2.0/lib3ds/camera.h	2001-07-08 04:05:30.000000000 +0900
+++ lib3ds-1.2.0-miles-20060404/lib3ds/camera.h	2006-04-04 17:04:30.000000000 +0900
@@ -45,6 +45,7 @@
     Lib3dsBool see_cone;
     Lib3dsFloat near_range;
     Lib3dsFloat far_range;
+    Lib3dsDword obj_flags;
 }; 
 
 extern LIB3DSAPI Lib3dsCamera* lib3ds_camera_new(const char *name);
diff -ruN -X../diff.xcl lib3ds-1.2.0/lib3ds/file.c lib3ds-1.2.0-miles-20060404/lib3ds/file.c
--- lib3ds-1.2.0/lib3ds/file.c	2001-08-07 19:25:43.000000000 +0900
+++ lib3ds-1.2.0-miles-20060404/lib3ds/file.c	2006-04-04 18:20:44.000000000 +0900
@@ -308,6 +308,10 @@
   Lib3dsChunk c;
   char name[64];
   Lib3dsWord chunk;
+  Lib3dsWord obj_flags = 0;
+  Lib3dsMesh *mesh = 0;
+  Lib3dsCamera *camera = 0;
+  Lib3dsLight *light = 0;
 
   if (!lib3ds_chunk_read_start(&c, LIB3DS_NAMED_OBJECT, io)) {
     return(LIB3DS_FALSE);
@@ -322,8 +326,6 @@
     switch (chunk) {
       case LIB3DS_N_TRI_OBJECT:
         {
-          Lib3dsMesh *mesh;
-
           mesh=lib3ds_mesh_new(name);
           if (!mesh) {
             return(LIB3DS_FALSE);
@@ -337,8 +339,6 @@
         break;
       case LIB3DS_N_CAMERA:
         {
-          Lib3dsCamera *camera;
-
           camera=lib3ds_camera_new(name);
           if (!camera) {
             return(LIB3DS_FALSE);
@@ -352,8 +352,6 @@
         break;
       case LIB3DS_N_DIRECT_LIGHT:
         {
-          Lib3dsLight *light;
-
           light=lib3ds_light_new(name);
           if (!light) {
             return(LIB3DS_FALSE);
@@ -365,11 +363,49 @@
           lib3ds_file_insert_light(file, light);
         }
         break;
+
+	/* Object flag chunks */
+      case LIB3DS_OBJ_HIDDEN:
+	obj_flags |= LIB3DS_OBJF_HIDDEN;
+	break;
+      case LIB3DS_OBJ_VIS_LOFTER:
+	obj_flags |= LIB3DS_OBJF_VIS_LOFTER;
+	break;
+      case LIB3DS_OBJ_DOESNT_CAST:
+	obj_flags |= LIB3DS_OBJF_DOESNT_CAST;
+	break;
+      case LIB3DS_OBJ_DONT_RECVSHADOW:
+	obj_flags |= LIB3DS_OBJF_DONT_RECVSHADOW;
+	break;
+      case LIB3DS_OBJ_MATTE:
+	obj_flags |= LIB3DS_OBJF_MATTE;
+	break;
+      case LIB3DS_OBJ_FAST:
+	obj_flags |= LIB3DS_OBJF_FAST;
+	break;
+      case LIB3DS_OBJ_PROCEDURAL:
+	obj_flags |= LIB3DS_OBJF_PROCEDURAL;
+	break;
+      case LIB3DS_OBJ_FROZEN:
+	obj_flags |= LIB3DS_OBJF_FROZEN;
+	break;
+
       default:
         lib3ds_chunk_unknown(chunk);
     }
   }
   
+  /* Set the object flags; we do this after the loop so that we don't
+     depend on the chunk order.  */
+  if (obj_flags) {
+    if (mesh)
+      mesh->obj_flags = obj_flags;
+    if (light)
+      light->obj_flags = obj_flags;
+    if (camera)
+      camera->obj_flags = obj_flags;
+  }
+
   lib3ds_chunk_read_end(&c, io);
   return(LIB3DS_TRUE);
 }
@@ -762,6 +798,36 @@
   return(LIB3DS_TRUE);
 }
 
+static void
+obj_flags_write(Lib3dsDword obj_flags, Lib3dsIo *io)
+{
+  Lib3dsChunk c;
+  c.size = 6;
+  c.chunk = LIB3DS_OBJ_HIDDEN;
+  if (obj_flags & LIB3DS_OBJF_HIDDEN)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_VIS_LOFTER;
+  if (obj_flags & LIB3DS_OBJF_VIS_LOFTER)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_DOESNT_CAST;
+  if (obj_flags & LIB3DS_OBJF_DOESNT_CAST)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_DONT_RECVSHADOW;
+  if (obj_flags & LIB3DS_OBJF_DONT_RECVSHADOW)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_MATTE;
+  if (obj_flags & LIB3DS_OBJF_MATTE)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_FAST;
+  if (obj_flags & LIB3DS_OBJF_FAST)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_PROCEDURAL;
+  if (obj_flags & LIB3DS_OBJF_PROCEDURAL)
+    lib3ds_chunk_write (&c, io);
+  c.chunk = LIB3DS_OBJ_FROZEN;
+  if (obj_flags & LIB3DS_OBJF_FROZEN)
+    lib3ds_chunk_write (&c, io);
+}
 
 static Lib3dsBool
 mdata_write(Lib3dsFile *file, Lib3dsIo *io)
@@ -841,6 +907,8 @@
       }
       lib3ds_io_write_string(io, p->name);
       lib3ds_camera_write(p,io);
+      if (p->obj_flags)
+	obj_flags_write (p->obj_flags, io);
       if (!lib3ds_chunk_write_end(&c,io)) {
         return(LIB3DS_FALSE);
       }
@@ -857,6 +925,8 @@
       }
       lib3ds_io_write_string(io,p->name);
       lib3ds_light_write(p,io);
+      if (p->obj_flags)
+	obj_flags_write (p->obj_flags, io);
       if (!lib3ds_chunk_write_end(&c,io)) {
         return(LIB3DS_FALSE);
       }
@@ -873,6 +943,8 @@
       }
       lib3ds_io_write_string(io, p->name);
       lib3ds_mesh_write(p,io);
+      if (p->obj_flags)
+	obj_flags_write (p->obj_flags, io);
       if (!lib3ds_chunk_write_end(&c,io)) {
         return(LIB3DS_FALSE);
       }
diff -ruN -X../diff.xcl lib3ds-1.2.0/lib3ds/light.h lib3ds-1.2.0-miles-20060404/lib3ds/light.h
--- lib3ds-1.2.0/lib3ds/light.h	2001-07-08 04:05:30.000000000 +0900
+++ lib3ds-1.2.0-miles-20060404/lib3ds/light.h	2006-04-04 17:22:23.000000000 +0900
@@ -63,6 +63,7 @@
     Lib3dsFloat ray_bias;
     Lib3dsFloat hot_spot;
     Lib3dsFloat fall_off;
+    Lib3dsDword obj_flags;
 }; 
 
 extern LIB3DSAPI Lib3dsLight* lib3ds_light_new(const char *name);
diff -ruN -X../diff.xcl lib3ds-1.2.0/lib3ds/mesh.h lib3ds-1.2.0-miles-20060404/lib3ds/mesh.h
--- lib3ds-1.2.0/lib3ds/mesh.h	2001-07-08 04:05:30.000000000 +0900
+++ lib3ds-1.2.0-miles-20060404/lib3ds/mesh.h	2006-04-04 17:04:11.000000000 +0900
@@ -110,6 +110,7 @@
     Lib3dsFace *faceL;
     Lib3dsBoxMap box_map;
     Lib3dsMapData map_data;
+    Lib3dsDword obj_flags;
 }; 
 
 extern LIB3DSAPI Lib3dsMesh* lib3ds_mesh_new(const char *name);
diff -ruN -X../diff.xcl lib3ds-1.2.0/lib3ds/types.h lib3ds-1.2.0-miles-20060404/lib3ds/types.h
--- lib3ds-1.2.0/lib3ds/types.h	2001-07-08 04:05:30.000000000 +0900
+++ lib3ds-1.2.0-miles-20060404/lib3ds/types.h	2006-04-04 18:20:10.000000000 +0900
@@ -118,6 +118,19 @@
 
 typedef struct _Lib3dsNode Lib3dsNode;
 
+typedef enum _Lib3dsObjFlags {
+    /* We use the prefix "LIB3DS_OBJF_" for these flags as LIB3DS_OBJ_ is
+       already used by the corresponding chunks.  */
+    LIB3DS_OBJF_HIDDEN		= 0x0001,
+    LIB3DS_OBJF_VIS_LOFTER	= 0x0002,
+    LIB3DS_OBJF_DOESNT_CAST	= 0x0004,
+    LIB3DS_OBJF_MATTE		= 0x0008,
+    LIB3DS_OBJF_FAST		= 0x0010,
+    LIB3DS_OBJF_PROCEDURAL	= 0x0020,
+    LIB3DS_OBJF_FROZEN		= 0x0040,
+    LIB3DS_OBJF_DONT_RECVSHADOW = 0x0080
+} Lib3dsObjFlags;
+
 typedef union _Lib3dsUserData {
     void *p;
     Lib3dsIntd i;
Files ../orig/lib3ds-1.2.0/tools/3ds2m and ./tools/3ds2m differ
Files ../orig/lib3ds-1.2.0/tools/3dsdump and ./tools/3dsdump differ

--- End Message ---
--- Begin Message ---
Version: 1.3.0-1

I am closing this bug report now as there is no reply to the mail
of Barry, and the upstream changelog indicates that this bug has 
been dealed with by upstream in version 1.3.0:

2007-06-14  Jan Eric Kyprianidis <www.kyprianidis.com>

        * Added support for object flags in meshes, cameras and lights

-Ralf.


--- End Message ---

Reply to: