2007/11/12, Ralf Gerlich <[EMAIL PROTECTED]>:
>
> Hi Christian!
>
> Christian Buchner wrote:
> > This code loads the largest (non-airport) BTG file from the World
> > scenery disk 1 (mounted on drive S: on Windows) and tries to save it
> back.
>
> I don't have that disk, but I downloaded the respective chunk from the
> FlightGear scenery download site to try and reproduce the problem.
>
> I'll try it with the respective tile from that download and if I can't
> reproduce it, we'll compare hashes or somebody will have to send me that
> tile.


I think I already know what the problem is. There is no normal vector index
attached to the SG_TRIANGLE_FANS object.

Each vertex stored in the BTG file appears to get implicitly mapped to a
normal vector index. Of course that only works if the number of normal
vectors stored in the file matches exactly number of vertices. This
appears to be true for all existing scenery files.

The write_bin subroutine tries to write out the index nevertheless, although

the fans_n index vector' has 0 length. Then you get the crash.

I've fixed this bug by adding additional checks before deciding whether
to write the index or not. The check for tris_n[0].size() is new.

if ( tris_n.size()  && tris_n[0].size()  ) { idx_mask |= SG_IDX_NORMALS;
++idx_size; }

and later when writing out the indices I check the corresponding bit flag in
the idx_mask

            if ( idx_mask & SG_IDX_NORMALS ) {
                sgWriteUShort( fp, (unsigned short)tris_n[i][j] );
            }

I added checks like this to all primitives ( fans, stripes, faces and
points)
and also to the COLORS, TEXCOORDS, VERTICES indices.

I am now working to achieve on a higher compressing storage format using
some variable
length coding, quantization and some differential/predictive encoding of
indices and
coordinates.

Christian
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to