Flix01 / fbtBlend-Header-Only

a header-only C++ .blend file parser
zlib License
67 stars 5 forks source link

Parsing issue with Blender 2.80 .blend files #2

Closed Flix01 closed 5 years ago

Flix01 commented 5 years ago

This is a small issue that doesn't seem to prevent parsing (most of) the .blend file. Anyway: When parsing 2.80 files the following parsing error appears:

Build ==> invalid offset Camera_Runtime:32:-2055477032:216
Build ==> invalid offset (0)(-2055477032:216)
Build ==> invalid offset Camera:33:-2055476696:552

(numbers can be different, for example):

Build ==> invalid offset Camera_Runtime:32:39896:216
Build ==> invalid offset (0)(39896:216)
Build ==> invalid offset Camera:33:40232:552

The error is generated by code in "fbtBlend.h"

"Blender.h" in version 2.80 defines the two related structs in this way:

struct Camera_Runtime   {
    float   drw_corners[2][4][2];
    float   drw_tria[2][2];
    float   drw_depth[2];
    float   drw_focusmat[4][4];
    float   drw_normalmat[4][4];
};

struct Camera   {
    ID  id;
    AnimData    *adt;
    char    type;
    char    dtx;
    short   flag;
    float   passepartalpha;
    float   clipsta;
    float   clipend;
    float   lens;
    float   ortho_scale;
    float   drawsize;
    float   sensor_x;
    float   sensor_y;
    float   shiftx;
    float   shifty;
    float   YF_dofdist;
    Ipo *ipo;
    Object  *dof_ob;
    GPUDOFSettings  gpu_dof;
    CameraDOFSettings   dof;
    ListBase    bg_images;
    char    sensor_fit;
    char    _pad[7];
    CameraStereoSettings    stereo;
    Camera_Runtime  runtime;    // <==
};

Initially, I thought that, since Camera_Runtime::drw_corners was the only spot in Blender.h with a 3D array, maybe fbtBlend.h couldn't parse it correctly. But we can change it to [2][8] (instead of [2][4][2]) and still there are parsing errors.

So I don't know what to do to fix it, and I don't even know how much this issue is big.

If somebody can help, this is the place...

Flix01 commented 5 years ago

Solved it!

The maximum array size was hard-coded, in "fbtBlend.h", in FBT_ARRAY_SLOTS:

#ifndef FBT_ARRAY_SLOTS
#define FBT_ARRAY_SLOTS         2   // Maximum dimensional array, eg: (int m_member[..][..] -> [FBT_ARRAY_SLOTS])
#endif

For Blender 2.80 it must be set to 3.