/* Generated by Pyrex 0.9.3 on Sat Mar  4 23:19:23 2006 */

#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#include "GL/glew.h"
#include "SDL/SDL_endian.h"
#include "SDL/SDL.h"
#include "chunk.h"
#include "matrix.h"
#include "cal3d_wrapper.h"
#include "freetype_include.h"
#include "stdlib.h"
#include "string.h"
#include "math.h"


typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
static PyObject *__Pyx_UnpackItem(PyObject *, int); /*proto*/
static int __Pyx_EndUnpack(PyObject *, int); /*proto*/
static int __Pyx_PrintItem(PyObject *); /*proto*/
static int __Pyx_PrintNewline(void); /*proto*/
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static void __Pyx_ReRaise(void); /*proto*/
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
static PyObject *__Pyx_GetExcValue(void); /*proto*/
static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/
static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], int nargs, PyObject **args2, PyObject **kwds2); /*proto*/
static void __Pyx_WriteUnraisable(char *name); /*proto*/
static void __Pyx_AddTraceback(char *funcname); /*proto*/
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size);  /*proto*/
static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
staticforward char **__pyx_f;

/* Declarations from _soya */

typedef struct {
  void (*content);
  int nb;
  int max;
} __pyx_t_5_soya_Chunk;

enum  {
  __pyx_e_5_soya_QUALITY_LOW = 0,
  __pyx_e_5_soya_QUALITY_MEDIUM = 1,
  __pyx_e_5_soya_QUALITY_HIGH = 2,
};

enum  {
  __pyx_e_5_soya_INITED = (1 << 0),
  __pyx_e_5_soya_USE_MIPMAP = (1 << 1),
  __pyx_e_5_soya_FULLSCREEN = (1 << 2),
  __pyx_e_5_soya_WIREFRAME = (1 << 3),
  __pyx_e_5_soya_FX_INITED = (1 << 4),
  __pyx_e_5_soya_SHADOWS = (1 << 5),
  __pyx_e_5_soya_HAS_STENCIL = (1 << 6),
};

enum  {
  __pyx_e_5_soya_MATERIAL_SEPARATE_SPECULAR = (1 << 1),
  __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING = (1 << 2),
  __pyx_e_5_soya_MATERIAL_ALPHA = (1 << 3),
  __pyx_e_5_soya_MATERIAL_MASK = (1 << 4),
  __pyx_e_5_soya_MATERIAL_CLAMP = (1 << 5),
  __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING = (1 << 6),
  __pyx_e_5_soya_MATERIAL_MIPMAP = (1 << 7),
  __pyx_e_5_soya_MATERIAL_BORDER = (1 << 8),
  __pyx_e_5_soya_MATERIAL_EMULATE_BORDER = (1 << 9),
};

enum  {
  __pyx_e_5_soya_VERTEX_ALPHA = (1 << 1),
  __pyx_e_5_soya_VERTEX_MADE = (1 << 3),
  __pyx_e_5_soya_VERTEX_INVISIBLE = (1 << 4),
  __pyx_e_5_soya_VERTEX_FX_TRANSITION = (1 << 5),
};

enum  {
  __pyx_e_5_soya_FACE_TRIANGLE = (1 << 0),
  __pyx_e_5_soya_FACE_QUAD = (1 << 1),
  __pyx_e_5_soya_FACE_NON_SOLID = (1 << 2),
  __pyx_e_5_soya_FACE_HIDDEN = (1 << 3),
  __pyx_e_5_soya_FACE_ALPHA = (1 << 4),
  __pyx_e_5_soya_FACE_DOUBLE_SIDED = (1 << 5),
  __pyx_e_5_soya_FACE_SMOOTH_LIT = (1 << 6),
  __pyx_e_5_soya_FACE_FRONT = (1 << 7),
  __pyx_e_5_soya_FACE_BACK = (1 << 8),
  __pyx_e_5_soya_FACE_NO_VERTEX_NORMAL_INFLUENCE = (1 << 9),
  __pyx_e_5_soya_FACE_NON_LIT = (1 << 10),
  __pyx_e_5_soya_FACE_STATIC_LIT = (1 << 11),
  __pyx_e_5_soya_FACE_LIGHT_FRONT = (1 << 12),
  __pyx_e_5_soya_FACE_LIGHT_BACK = (1 << 13),
};

enum  {
  __pyx_e_5_soya_PACK_SECONDPASS = (1 << 2),
  __pyx_e_5_soya_PACK_SPECIAL = (1 << 3),
};

enum  {
  __pyx_e_5_soya_HIDDEN = (1 << 0),
  __pyx_e_5_soya_LEFTHANDED = (1 << 3),
  __pyx_e_5_soya_NON_SOLID = (1 << 4),
  __pyx_e_5_soya_WORLD_BATCHED = (1 << 6),
  __pyx_e_5_soya_BONUS_BATCHED = (1 << 6),
  __pyx_e_5_soya_WORLD_PORTAL_LINKED = (1 << 7),
  __pyx_e_5_soya_LIGHT_TOP_LEVEL = (1 << 7),
  __pyx_e_5_soya_LIGHT_DIRECTIONAL = (1 << 8),
  __pyx_e_5_soya_LIGHT_NO_SHADOW = (1 << 9),
  __pyx_e_5_soya_LIGHT_SHADOW_COLOR = (1 << 10),
  __pyx_e_5_soya_LIGHT_STATIC = (1 << 11),
  __pyx_e_5_soya_CAMERA_PARTIAL = (1 << 5),
  __pyx_e_5_soya_CAMERA_ORTHO = (1 << 6),
  __pyx_e_5_soya_FACE2_LIT = (1 << 12),
  __pyx_e_5_soya_FACE2_SMOOTH_LIT = (1 << 13),
  __pyx_e_5_soya_FACE2_STATIC_LIT = (1 << 14),
  __pyx_e_5_soya_FACE2_DOUBLE_SIDED = (1 << 15),
  __pyx_e_5_soya_COORDSYST_STATE_VALID = (1 << 16),
};

enum  {
  __pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES = (1 << 5),
  __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES = (1 << 6),
  __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE = (1 << 8),
  __pyx_e_5_soya_PORTAL_TELEPORTER = (1 << 9),
};

enum  {
  __pyx_e_5_soya_RAYPICK_CULL_FACE = (1 << 0),
  __pyx_e_5_soya_RAYPICK_HALF_LINE = (1 << 1),
};

enum  {
  __pyx_e_5_soya_RAYPICK_DIRECT = 1,
  __pyx_e_5_soya_RAYPICK_INDIRECT = 2,
};

enum  {
  __pyx_e_5_soya_COORDSYS_INVALID = 0,
  __pyx_e_5_soya_COORDSYS_ROOT_VALID = (1 << 0),
  __pyx_e_5_soya_COORDSYS_INVERTED_ROOT_VALID = (1 << 1),
};

enum  {
  __pyx_e_5_soya_RENDERER_STATE_OPAQUE = 0,
  __pyx_e_5_soya_RENDERER_STATE_SECONDPASS = 1,
  __pyx_e_5_soya_RENDERER_STATE_ALPHA = 2,
  __pyx_e_5_soya_RENDERER_STATE_SPECIAL = 3,
};

enum  {
  __pyx_e_5_soya_PACK_OPTIONS = ((((__pyx_e_5_soya_FACE_TRIANGLE | __pyx_e_5_soya_FACE_QUAD) | __pyx_e_5_soya_FACE_ALPHA) | __pyx_e_5_soya_FACE_DOUBLE_SIDED) | __pyx_e_5_soya_FACE_NON_LIT),
  __pyx_e_5_soya_DISPLAY_LIST_OPTIONS = ((((__pyx_e_5_soya_FACE_TRIANGLE | __pyx_e_5_soya_FACE_QUAD) | __pyx_e_5_soya_FACE_ALPHA) | __pyx_e_5_soya_FACE_DOUBLE_SIDED) | __pyx_e_5_soya_FACE_NON_LIT),
};

enum  {
  __pyx_e_5_soya_SHAPE_DIFFUSES = (1 << 5),
  __pyx_e_5_soya_SHAPE_EMISSIVES = (1 << 6),
  __pyx_e_5_soya_SHAPE_TEXCOORDS = (1 << 8),
  __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS = (1 << 10),
  __pyx_e_5_soya_SHAPE_CELLSHADING = (1 << 11),
  __pyx_e_5_soya_SHAPE_NEVER_LIT = (1 << 12),
  __pyx_e_5_soya_SHAPE_PLANE_EQUATION = (1 << 14),
  __pyx_e_5_soya_SHAPE_NEIGHBORS = (1 << 15),
  __pyx_e_5_soya_SHAPE_INITED = (1 << 16),
  __pyx_e_5_soya_SHAPE_TREE = (1 << 17),
  __pyx_e_5_soya_SHAPE_DISPLAY_LISTS = (1 << 18),
  __pyx_e_5_soya_SHAPE_FACE_LIST = (1 << 19),
  __pyx_e_5_soya_SHAPE_HAS_SPHERE = (1 << 20),
  __pyx_e_5_soya_SHAPE_SHADOW = (1 << 21),
  __pyx_e_5_soya_SHAPE_STATIC_SHADOW = (1 << 22),
  __pyx_e_5_soya_SHAPE_STATIC_LIT = (1 << 23),
  __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS = (1 << 24),
};

enum  {
  __pyx_e_5_soya_TEXT_ALIGN_LEFT = 0,
  __pyx_e_5_soya_TEXT_ALIGN_CENTER = 1,
};

enum  {
  __pyx_e_5_soya_FONT_RASTER = 1,
  __pyx_e_5_soya_FONT_TEXTURE = 2,
};

enum  {
  __pyx_e_5_soya_ATMOSPHERE_FOG = (1 << 3),
  __pyx_e_5_soya_ATMOSPHERE_SKY_BOX_ALPHA = (1 << 7),
  __pyx_e_5_soya_ATMOSPHERE_HAS_CHILD = (1 << 8),
};

enum  {
  __pyx_e_5_soya_SPRITE_ALPHA = (1 << 7),
  __pyx_e_5_soya_SPRITE_COLORED = (1 << 9),
  __pyx_e_5_soya_SPRITE_NEVER_LIT = (1 << 11),
  __pyx_e_5_soya_SPRITE_RECEIVE_SHADOW = (1 << 12),
};

enum  {
  __pyx_e_5_soya_PARTICLES_MULTI_COLOR = (1 << 14),
  __pyx_e_5_soya_PARTICLES_MULTI_SIZE = (1 << 15),
  __pyx_e_5_soya_PARTICLES_CYLINDER = (1 << 16),
  __pyx_e_5_soya_PARTICLES_AUTO_GENERATE = (1 << 17),
  __pyx_e_5_soya_PARTICLES_REMOVABLE = (1 << 18),
};

enum  {
  __pyx_e_5_soya_LAND_INITED = (1 << 2),
  __pyx_e_5_soya_LAND_REAL_LOD_RAYPICK = (1 << 3),
  __pyx_e_5_soya_LAND_VERTEX_OPTIONS = (1 << 7),
  __pyx_e_5_soya_LAND_COLORED = (1 << 8),
};

enum  {
  __pyx_e_5_soya_LAND_VERTEX_HIDDEN = (1 << 0),
  __pyx_e_5_soya_LAND_VERTEX_ALPHA = __pyx_e_5_soya_VERTEX_ALPHA,
  __pyx_e_5_soya_LAND_VERTEX_NON_SOLID = (1 << 2),
  __pyx_e_5_soya_LAND_VERTEX_FORCE_PRESENCE = (1 << 3),
};

enum  {
  __pyx_e_5_soya_CAL3D_ALPHA = (1 << 5),
  __pyx_e_5_soya_CAL3D_CELL_SHADING = (1 << 6),
  __pyx_e_5_soya_CAL3D_SHADOW = (1 << 7),
  __pyx_e_5_soya_CAL3D_NEIGHBORS = (1 << 8),
  __pyx_e_5_soya_CAL3D_INITED = (1 << 9),
  __pyx_e_5_soya_CAL3D_DOUBLE_SIDED = (1 << 10),
};

typedef struct {
  float (position[3]);
  float (points[24]);
  float (planes[24]);
} __pyx_t_5_soya_Frustum;

struct __pyx_t_5_soya__Pack {
  int option;
  int material_id;
  struct __pyx_t_5_soya__Pack (*alpha);
  struct __pyx_t_5_soya__Pack (*secondpass);
  __pyx_t_5_soya_Chunk (*batched_faces);
};

typedef struct {
  int option;
  int id;
  int material_id;
  int (*faces_id);
  __pyx_t_5_soya_Chunk (*chunk);
} __pyx_t_5_soya_DisplayList;

typedef struct {
  int nb_opaque_list;
  int nb_alpha_list;
  __pyx_t_5_soya_DisplayList (*display_lists);
} __pyx_t_5_soya_DisplayLists;

typedef struct {
  int option;
  struct __pyx_t_5_soya__Pack (*pack);
  int normal;
  int (v[4]);
} __pyx_t_5_soya_ShapeFace;

struct __pyx_t_5_soya__Node {
  int nb_faces;
  int nb_children;
  int (*faces);
  struct __pyx_t_5_soya__Node (*(*children));
  float (sphere[4]);
};

typedef struct {
  float (texcoord[2]);
  float (normal[3]);
  float (coord[3]);
  struct __pyx_t_5_soya__Pack (*pack);
} __pyx_t_5_soya_LandVertex;

struct __pyx_t_5_soya__LandTri {
  char level;
  float (normal[3]);
  float (sphere[4]);
  __pyx_t_5_soya_LandVertex (*v1);
  __pyx_t_5_soya_LandVertex (*v2);
  __pyx_t_5_soya_LandVertex (*v3);
  struct __pyx_t_5_soya__LandTri (*parent);
  struct __pyx_t_5_soya__LandTri (*left_child);
  struct __pyx_t_5_soya__LandTri (*right_child);
  struct __pyx_t_5_soya__LandTri (*left_neighbor);
  struct __pyx_t_5_soya__LandTri (*right_neighbor);
  struct __pyx_t_5_soya__LandTri (*base_neighbor);
  struct __pyx_t_5_soya__Pack (*pack);
  struct __pyx_t_5_soya__LandPatch (*patch);
  int texcoord_type;
};

struct __pyx_t_5_soya__LandPatch {
  float (sphere[4]);
  char level;
  struct __pyx_t_5_soya__LandTri (*tri_top);
  struct __pyx_t_5_soya__LandTri (*tri_left);
  struct __pyx_t_5_soya__LandTri (*tri_right);
  struct __pyx_t_5_soya__LandTri (*tri_bottom);
  int visible;
};

staticforward PyTypeObject __pyx_type_5_soya__CObj;

struct __pyx_obj_5_soya__CObj {
  PyObject_HEAD
  struct __pyx_vtabstruct_5_soya__CObj *__pyx_vtab;
};

struct __pyx_vtabstruct_5_soya__CObj {
  PyObject *((*__getcstate__)(struct __pyx_obj_5_soya__CObj *));
  void ((*__setcstate__)(struct __pyx_obj_5_soya__CObj *,PyObject *));
};
static struct __pyx_vtabstruct_5_soya__CObj *__pyx_vtabptr_5_soya__CObj;

staticforward PyTypeObject __pyx_type_5_soya__Image;

struct __pyx_obj_5_soya__Image {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  int nb_color;
  int width;
  int height;
  GLubyte (*_pixels);
  PyObject *_filename;
};

struct __pyx_vtabstruct_5_soya__Image {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  int ((*check_for_gl)(struct __pyx_obj_5_soya__Image *));
  GLuint ((*typ)(struct __pyx_obj_5_soya__Image *));
  GLuint ((*internal_format)(struct __pyx_obj_5_soya__Image *));
};
static struct __pyx_vtabstruct_5_soya__Image *__pyx_vtabptr_5_soya__Image;

staticforward PyTypeObject __pyx_type_5_soya__Material;

struct __pyx_obj_5_soya__Material {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  int _option;
  int _nb_packs;
  struct __pyx_obj_5_soya__Image *_texture;
  GLuint _id;
  float shininess;
  GLfloat (_diffuse[4]);
  GLfloat (_specular[4]);
  GLfloat (_emissive[4]);
  PyObject *_filename;
  struct __pyx_t_5_soya__Pack (*(*_packs));
};

struct __pyx_vtabstruct_5_soya__Material {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  struct __pyx_t_5_soya__Pack (*((*_pack)(struct __pyx_obj_5_soya__Material *,int )));
  void ((*_init_texture)(struct __pyx_obj_5_soya__Material *));
  void ((*_build_2D_mipmaps)(struct __pyx_obj_5_soya__Material *,int ));
  void ((*_compute_alpha)(struct __pyx_obj_5_soya__Material *));
  void ((*_activate)(struct __pyx_obj_5_soya__Material *));
  void ((*_inactivate)(struct __pyx_obj_5_soya__Material *));
};
static struct __pyx_vtabstruct_5_soya__Material *__pyx_vtabptr_5_soya__Material;

staticforward PyTypeObject __pyx_type_5_soya__Shape;

struct __pyx_obj_5_soya__Shape {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  PyObject *_filename;
};

struct __pyx_vtabstruct_5_soya__Shape {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  void ((*_batch)(struct __pyx_obj_5_soya__Shape *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_render)(struct __pyx_obj_5_soya__Shape *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_shadow)(struct __pyx_obj_5_soya__Shape *,struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya__Light *));
  void ((*_get_box)(struct __pyx_obj_5_soya__Shape *,float (*),float (*)));
  void ((*_raypick)(struct __pyx_obj_5_soya__Shape *,struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_raypick_b)(struct __pyx_obj_5_soya__Shape *,struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_collect_raypickables)(struct __pyx_obj_5_soya__Shape *,__pyx_t_5_soya_Chunk (*),float (*),float (*),struct __pyx_obj_5_soya_CoordSyst *));
};
static struct __pyx_vtabstruct_5_soya__Shape *__pyx_vtabptr_5_soya__Shape;

staticforward PyTypeObject __pyx_type_5_soya__SimpleShape;

struct __pyx_obj_5_soya__SimpleShape {
  struct __pyx_obj_5_soya__Shape __pyx_base;
  int _option;
  PyObject *_materials;
  int _nb_faces;
  int _nb_vertices;
  int _nb_coords;
  int _nb_vnormals;
  int _nb_colors;
  int _nb_values;
  float (*_coords);
  float (*_vnormals);
  float (*_colors);
  float (*_values);
  int (*_vertex_coords);
  int (*_vertex_texcoords);
  int (*_vertex_diffuses);
  int (*_vertex_emissives);
  char (*_vertex_options);
  __pyx_t_5_soya_ShapeFace (*_faces);
  int (*_neighbors);
  int (*_simple_neighbors);
  char (*_neighbors_side);
  char (*_simple_neighbors_side);
  __pyx_t_5_soya_DisplayLists (*_display_lists);
  float (*_sphere);
};

struct __pyx_vtabstruct_5_soya__SimpleShape {
  struct __pyx_vtabstruct_5_soya__Shape __pyx_base;
  void ((*__setcstate_data__)(struct __pyx_obj_5_soya__SimpleShape *,PyObject *));
  void ((*_register_material)(struct __pyx_obj_5_soya__SimpleShape *,struct __pyx_obj_5_soya__Material *));
  void ((*_add_coord)(struct __pyx_obj_5_soya__SimpleShape *,struct __pyx_obj_5_soya__Vertex *));
  int ((*_register_value)(struct __pyx_obj_5_soya__SimpleShape *,float (*),int ));
  int ((*_register_color)(struct __pyx_obj_5_soya__SimpleShape *,float (*)));
  void ((*_add_face)(struct __pyx_obj_5_soya__SimpleShape *,struct __pyx_obj_5_soya__Face *,PyObject *,PyObject *,PyObject *,int ));
  int ((*_add_vertex)(struct __pyx_obj_5_soya__SimpleShape *,struct __pyx_obj_5_soya__Vertex *,PyObject *,PyObject *,PyObject *,int ));
  PyObject *((*_identify_vertices)(struct __pyx_obj_5_soya__SimpleShape *,PyObject *,float ));
  void ((*_compute_face_normals)(struct __pyx_obj_5_soya__SimpleShape *,PyObject *));
  void ((*_compute_vertex_normals)(struct __pyx_obj_5_soya__SimpleShape *,PyObject *,PyObject *,PyObject *));
  void ((*_compute_face_neighbors)(struct __pyx_obj_5_soya__SimpleShape *,PyObject *,PyObject *,PyObject *,int (*),char (*)));
  void ((*_build_sphere)(struct __pyx_obj_5_soya__SimpleShape *));
  void ((*_build_display_list)(struct __pyx_obj_5_soya__SimpleShape *));
  void ((*_init_display_list)(struct __pyx_obj_5_soya__SimpleShape *));
  void ((*_batch_face)(struct __pyx_obj_5_soya__SimpleShape *,__pyx_t_5_soya_ShapeFace (*)));
  void ((*_face_raypick)(struct __pyx_obj_5_soya__SimpleShape *,__pyx_t_5_soya_ShapeFace (*),float (*),struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_face_raypick_b)(struct __pyx_obj_5_soya__SimpleShape *,__pyx_t_5_soya_ShapeFace (*),float (*),struct __pyx_obj_5_soya_RaypickData *));
  void ((*_render_triangle)(struct __pyx_obj_5_soya__SimpleShape *,__pyx_t_5_soya_ShapeFace (*)));
  void ((*_render_quad)(struct __pyx_obj_5_soya__SimpleShape *,__pyx_t_5_soya_ShapeFace (*)));
  void ((*_render_vertex)(struct __pyx_obj_5_soya__SimpleShape *,int ,int ));
};
static struct __pyx_vtabstruct_5_soya__SimpleShape *__pyx_vtabptr_5_soya__SimpleShape;

staticforward PyTypeObject __pyx_type_5_soya__CellShadingShape;

struct __pyx_obj_5_soya__CellShadingShape {
  struct __pyx_obj_5_soya__SimpleShape __pyx_base;
  struct __pyx_obj_5_soya__Material *_shader;
  float (_outline_color[4]);
  float _outline_width;
  float _outline_attenuation;
};

struct __pyx_vtabstruct_5_soya__CellShadingShape {
  struct __pyx_vtabstruct_5_soya__SimpleShape __pyx_base;
  void ((*_build_cellshading)(struct __pyx_obj_5_soya__CellShadingShape *,struct __pyx_obj_5_soya__Material *,PyObject *,float ,float ));
  void ((*_render_outline)(struct __pyx_obj_5_soya__CellShadingShape *,__pyx_t_5_soya_Frustum (*)));
  void ((*_prepare_cellshading_shades)(struct __pyx_obj_5_soya__CellShadingShape *,float (*),PyObject *));
  void ((*_prepare_cellshading)(struct __pyx_obj_5_soya__CellShadingShape *,struct __pyx_obj_5_soya_CoordSyst *,float (*)));
  float ((*_vertex_compute_cellshading)(struct __pyx_obj_5_soya__CellShadingShape *,float (*),float (*),PyObject *,float ));
  void ((*_render_triangle_cellshading)(struct __pyx_obj_5_soya__CellShadingShape *,__pyx_t_5_soya_ShapeFace (*),float (*)));
  void ((*_render_quad_cellshading)(struct __pyx_obj_5_soya__CellShadingShape *,__pyx_t_5_soya_ShapeFace (*),float (*)));
  void ((*_render_vertex_cellshading_smoothlit)(struct __pyx_obj_5_soya__CellShadingShape *,int ,int ,float (*)));
  void ((*_render_vertex_cellshading)(struct __pyx_obj_5_soya__CellShadingShape *,int ,int ,float (*)));
};
static struct __pyx_vtabstruct_5_soya__CellShadingShape *__pyx_vtabptr_5_soya__CellShadingShape;

staticforward PyTypeObject __pyx_type_5_soya__TreeShape;

struct __pyx_obj_5_soya__TreeShape {
  struct __pyx_obj_5_soya__SimpleShape __pyx_base;
  struct __pyx_t_5_soya__Node (*_tree);
};

struct __pyx_vtabstruct_5_soya__TreeShape {
  struct __pyx_vtabstruct_5_soya__SimpleShape __pyx_base;
  PyObject *((*_node2chunk)(struct __pyx_obj_5_soya__TreeShape *,struct __pyx_t_5_soya__Node (*),__pyx_t_5_soya_Chunk (*)));
  struct __pyx_t_5_soya__Node (*((*_chunk2node)(struct __pyx_obj_5_soya__TreeShape *,__pyx_t_5_soya_Chunk (*))));
  void ((*_build_tree)(struct __pyx_obj_5_soya__TreeShape *));
  void ((*_optimize_tree)(struct __pyx_obj_5_soya__TreeShape *,float ,int ,float ));
  void ((*compute_sphere)(struct __pyx_obj_5_soya__TreeShape *,__pyx_t_5_soya_ShapeFace (*),float (*)));
  void ((*_batch_node)(struct __pyx_obj_5_soya__TreeShape *,struct __pyx_t_5_soya__Node (*),__pyx_t_5_soya_Frustum (*)));
  void ((*_node_raypick)(struct __pyx_obj_5_soya__TreeShape *,struct __pyx_t_5_soya__Node (*),float (*),struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_node_raypick_b)(struct __pyx_obj_5_soya__TreeShape *,struct __pyx_t_5_soya__Node (*),float (*),struct __pyx_obj_5_soya_RaypickData *));
  void ((*_raypick_from_context)(struct __pyx_obj_5_soya__TreeShape *,struct __pyx_obj_5_soya_RaypickData *,__pyx_t_5_soya_Chunk (*)));
  int ((*_raypick_from_context_b)(struct __pyx_obj_5_soya__TreeShape *,struct __pyx_obj_5_soya_RaypickData *,__pyx_t_5_soya_Chunk (*)));
};
static struct __pyx_vtabstruct_5_soya__TreeShape *__pyx_vtabptr_5_soya__TreeShape;

staticforward PyTypeObject __pyx_type_5_soya_Position;

struct __pyx_obj_5_soya_Position {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  struct __pyx_obj_5_soya_CoordSyst *_parent;
};

struct __pyx_vtabstruct_5_soya_Position {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  void ((*_into)(struct __pyx_obj_5_soya_Position *,struct __pyx_obj_5_soya_CoordSyst *,float (*)));
  void ((*_out)(struct __pyx_obj_5_soya_Position *,float (*)));
};
static struct __pyx_vtabstruct_5_soya_Position *__pyx_vtabptr_5_soya_Position;

staticforward PyTypeObject __pyx_type_5_soya__Point;

struct __pyx_obj_5_soya__Point {
  struct __pyx_obj_5_soya_Position __pyx_base;
  float (_matrix[3]);
};

struct __pyx_vtabstruct_5_soya__Point {
  struct __pyx_vtabstruct_5_soya_Position __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__Point *__pyx_vtabptr_5_soya__Point;

staticforward PyTypeObject __pyx_type_5_soya__Vector;

struct __pyx_obj_5_soya__Vector {
  struct __pyx_obj_5_soya__Point __pyx_base;
};

struct __pyx_vtabstruct_5_soya__Vector {
  struct __pyx_vtabstruct_5_soya__Point __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__Vector *__pyx_vtabptr_5_soya__Vector;

staticforward PyTypeObject __pyx_type_5_soya__Vertex;

struct __pyx_obj_5_soya__Vertex {
  struct __pyx_obj_5_soya__Point __pyx_base;
  float _tex_x;
  float _tex_y;
  PyObject *_diffuse;
  PyObject *_emissive;
  struct __pyx_obj_5_soya__Face *_face;
  struct __pyx_obj_5_soya__Vector *_normal;
};

struct __pyx_vtabstruct_5_soya__Vertex {
  struct __pyx_vtabstruct_5_soya__Point __pyx_base;
  void ((*_render)(struct __pyx_obj_5_soya__Vertex *,struct __pyx_obj_5_soya_CoordSyst *));
  float ((*_angle_at)(struct __pyx_obj_5_soya__Vertex *));
};
static struct __pyx_vtabstruct_5_soya__Vertex *__pyx_vtabptr_5_soya__Vertex;

staticforward PyTypeObject __pyx_type_5_soya_CoordSyst;

struct __pyx_obj_5_soya_CoordSyst {
  struct __pyx_obj_5_soya_Position __pyx_base;
  float (_matrix[19]);
  float (__root_matrix[19]);
  float (__inverted_root_matrix[19]);
  float (_render_matrix[19]);
  int _frustum_id;
  int _validity;
  int __raypick_data;
  int _option;
};

struct __pyx_vtabstruct_5_soya_CoordSyst {
  struct __pyx_vtabstruct_5_soya_Position __pyx_base;
  void ((*_batch)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_render)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_shadow)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya__Light *));
  void ((*_raypick)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_raypick_b)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_collect_raypickables)(struct __pyx_obj_5_soya_CoordSyst *,__pyx_t_5_soya_Chunk (*),float (*),float (*)));
  int ((*_contains)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya__CObj *));
  float (*((*_raypick_data)(struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya_RaypickData *)));
  float ((*_distance_out)(struct __pyx_obj_5_soya_CoordSyst *,float ));
  void ((*_invalidate)(struct __pyx_obj_5_soya_CoordSyst *));
  void ((*check_lefthanded)(struct __pyx_obj_5_soya_CoordSyst *));
  float (*((*_root_matrix)(struct __pyx_obj_5_soya_CoordSyst *)));
  float (*((*_inverted_root_matrix)(struct __pyx_obj_5_soya_CoordSyst *)));
  struct __pyx_obj_5_soya__World *((*_get_root)(struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_get_box)(struct __pyx_obj_5_soya_CoordSyst *,float (*),float (*)));
  void ((*_get_sphere)(struct __pyx_obj_5_soya_CoordSyst *,float (*)));
};
static struct __pyx_vtabstruct_5_soya_CoordSyst *__pyx_vtabptr_5_soya_CoordSyst;

staticforward PyTypeObject __pyx_type_5_soya__Camera;

struct __pyx_obj_5_soya__Camera {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__World *_to_render;
  float _front;
  float _back;
  float _fov;
  __pyx_t_5_soya_Frustum (*_frustum);
  int (_viewport[4]);
  PyObject *_master;
};

struct __pyx_vtabstruct_5_soya__Camera {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_init_frustum)(struct __pyx_obj_5_soya__Camera *));
  void ((*_subrender_scene)(struct __pyx_obj_5_soya__Camera *));
  void ((*_render_scene)(struct __pyx_obj_5_soya__Camera *));
};
static struct __pyx_vtabstruct_5_soya__Camera *__pyx_vtabptr_5_soya__Camera;

staticforward PyTypeObject __pyx_type_5_soya__Light;

struct __pyx_obj_5_soya__Light {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  float radius;
  float angle;
  float exponent;
  float _w;
  float _constant;
  float _linear;
  float _quadratic;
  float (_colors[16]);
  float (_data[3]);
  int _id;
  int _gl_id_enabled;
};

struct __pyx_vtabstruct_5_soya__Light {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  int ((*_shadow_at)(struct __pyx_obj_5_soya__Light *,float (*)));
  float ((*_spotlight_at)(struct __pyx_obj_5_soya__Light *,float (*)));
  float ((*_attenuation_at)(struct __pyx_obj_5_soya__Light *,float (*)));
  void ((*_static_light_at)(struct __pyx_obj_5_soya__Light *,float (*),float (*),int ,float (*)));
  void ((*_cast_into)(struct __pyx_obj_5_soya__Light *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_activate)(struct __pyx_obj_5_soya__Light *));
  void ((*_compute_radius)(struct __pyx_obj_5_soya__Light *));
};
static struct __pyx_vtabstruct_5_soya__Light *__pyx_vtabptr_5_soya__Light;

staticforward PyTypeObject __pyx_type_5_soya__Volume;

struct __pyx_obj_5_soya__Volume {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__Shape *_shape;
};

struct __pyx_vtabstruct_5_soya__Volume {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__Volume *__pyx_vtabptr_5_soya__Volume;

staticforward PyTypeObject __pyx_type_5_soya__World;

struct __pyx_obj_5_soya__World {
  struct __pyx_obj_5_soya__Volume __pyx_base;
  PyObject *children;
  struct __pyx_obj_5_soya__Atmosphere *_atmosphere;
  PyObject *_filename;
  struct __pyx_obj_5_soya_Shapifier *_shapifier;
};

struct __pyx_vtabstruct_5_soya__World {
  struct __pyx_vtabstruct_5_soya__Volume __pyx_base;
  void ((*_search_all)(struct __pyx_obj_5_soya__World *,PyObject *,PyObject *));
};
static struct __pyx_vtabstruct_5_soya__World *__pyx_vtabptr_5_soya__World;

staticforward PyTypeObject __pyx_type_5_soya__Face;

struct __pyx_obj_5_soya__Face {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  PyObject *_vertices;
  struct __pyx_obj_5_soya__Material *_material;
  struct __pyx_obj_5_soya__Vector *_normal;
};

struct __pyx_vtabstruct_5_soya__Face {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_compute_normal)(struct __pyx_obj_5_soya__Face *));
};
static struct __pyx_vtabstruct_5_soya__Face *__pyx_vtabptr_5_soya__Face;

staticforward PyTypeObject __pyx_type_5_soya__Cal3dVolume;

struct __pyx_obj_5_soya__Cal3dVolume {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__Cal3dShape *_shape;
  PyObject *_attached_meshes;
  PyObject *_attached_coordsysts;
  struct CalModel (*_model);
  float _delta_time;
  float (*_face_planes);
  float (*_vertex_coords);
  float (*_vertex_normals);
  int _face_plane_ok;
  int _vertex_ok;
};

struct __pyx_vtabstruct_5_soya__Cal3dVolume {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_build_submeshes)(struct __pyx_obj_5_soya__Cal3dVolume *));
  void ((*_build_face_planes)(struct __pyx_obj_5_soya__Cal3dVolume *));
  void ((*_attach_all)(struct __pyx_obj_5_soya__Cal3dVolume *));
};
static struct __pyx_vtabstruct_5_soya__Cal3dVolume *__pyx_vtabptr_5_soya__Cal3dVolume;

staticforward PyTypeObject __pyx_type_5_soya__Cal3dShape;

struct __pyx_obj_5_soya__Cal3dShape {
  struct __pyx_obj_5_soya__Shape __pyx_base;
  int _option;
  int _nb_faces;
  int _nb_vertices;
  float (_sphere[4]);
  PyObject *_meshes;
  PyObject *_animations;
  PyObject *_materials;
  PyObject *_submeshes;
  PyObject *_full_filename;
  struct CalCoreModel (*_core_model);
  struct __pyx_obj_5_soya__Material *_shader;
  float (_outline_color[4]);
  float _outline_width;
  float _outline_attenuation;
};

struct __pyx_vtabstruct_5_soya__Cal3dShape {
  struct __pyx_vtabstruct_5_soya__Shape __pyx_base;
  void ((*_build_submeshes)(struct __pyx_obj_5_soya__Cal3dShape *));
  void ((*_set_face_neighborhood)(struct __pyx_obj_5_soya__Cal3dShape *,int ,int ,GLfloat (*)));
  void ((*_set_cell_shading)(struct __pyx_obj_5_soya__Cal3dShape *,struct __pyx_obj_5_soya__Material *,GLfloat (*),GLfloat ));
  void ((*_prepare_cellshading)(struct __pyx_obj_5_soya__Cal3dShape *,struct __pyx_obj_5_soya_CoordSyst *,float (*),int ,float (*),float (*)));
  void ((*_prepare_cellshading_shades)(struct __pyx_obj_5_soya__Cal3dShape *,float (*),PyObject *,int ,float (*),float (*)));
  void ((*_render_outline)(struct __pyx_obj_5_soya__Cal3dShape *,struct __pyx_obj_5_soya__Cal3dSubMesh *,__pyx_t_5_soya_Frustum (*),float (*),float (*),float (*)));
  struct __pyx_obj_5_soya__Material *((*_get_material_4_cal3d)(struct __pyx_obj_5_soya__Cal3dShape *,PyObject *,float ,float ,float ,float ,float ,float ,float ,float ,float ));
  struct __pyx_obj_5_soya__Material *((*_create_material_4_cal3d)(struct __pyx_obj_5_soya__Cal3dShape *,PyObject *,float ,float ,float ,float ,float ,float ,float ,float ,float ));
  void ((*_set_texture_from_model)(struct __pyx_obj_5_soya__Cal3dShape *,struct __pyx_obj_5_soya__Material *,PyObject *));
  int ((*_shadow2)(struct __pyx_obj_5_soya__Cal3dShape *,struct __pyx_obj_5_soya__Cal3dSubMesh *,struct __pyx_obj_5_soya__Cal3dVolume *,struct __pyx_obj_5_soya__Light *,float (*),float (*),float (*)));
  void ((*_build_vertices)(struct __pyx_obj_5_soya__Cal3dShape *,struct __pyx_obj_5_soya__Cal3dVolume *));
};
static struct __pyx_vtabstruct_5_soya__Cal3dShape *__pyx_vtabptr_5_soya__Cal3dShape;

staticforward PyTypeObject __pyx_type_5_soya__Sprite;

struct __pyx_obj_5_soya__Sprite {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  float _width;
  float _height;
  float (_color[4]);
  struct __pyx_obj_5_soya__Material *_material;
};

struct __pyx_vtabstruct_5_soya__Sprite {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_compute_alpha)(struct __pyx_obj_5_soya__Sprite *));
};
static struct __pyx_vtabstruct_5_soya__Sprite *__pyx_vtabptr_5_soya__Sprite;

staticforward PyTypeObject __pyx_type_5_soya__Portal;

struct __pyx_obj_5_soya__Portal {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__World *_beyond;
  PyObject *_beyond_name;
  double (*_equation);
  struct __pyx_obj_5_soya_Context *_context;
  int _nb_vertices;
  float (*_coords);
};

struct __pyx_vtabstruct_5_soya__Portal {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_compute_clipping_planes)(struct __pyx_obj_5_soya__Portal *));
  void ((*_compute_points)(struct __pyx_obj_5_soya__Portal *));
  void ((*_atmosphere_clear_part)(struct __pyx_obj_5_soya__Portal *));
  void ((*_draw_fog)(struct __pyx_obj_5_soya__Portal *,struct __pyx_obj_5_soya__Atmosphere *));
};
static struct __pyx_vtabstruct_5_soya__Portal *__pyx_vtabptr_5_soya__Portal;

staticforward PyTypeObject __pyx_type_5_soya__Land;

struct __pyx_obj_5_soya__Land {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  PyObject *_materials;
  __pyx_t_5_soya_LandVertex (*_vertices);
  char (*_vertex_options);
  int (*_vertex_colors);
  float (*_vertex_geos);
  float (*_normals);
  int _nb_colors;
  float (*_colors);
  int _nb_vertex_width;
  int _nb_vertex_depth;
  int _patch_size;
  int _max_level;
  float _texture_factor;
  float _scale_factor;
  float _split_factor;
  int _nb_patchs;
  int _nb_patch_width;
  int _nb_patch_depth;
  struct __pyx_t_5_soya__LandPatch (*_patchs);
};

struct __pyx_vtabstruct_5_soya__Land {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  __pyx_t_5_soya_LandVertex (*((*_get_vertex)(struct __pyx_obj_5_soya__Land *,int ,int )));
  void ((*_check_size)(struct __pyx_obj_5_soya__Land *));
  void ((*_free_patchs)(struct __pyx_obj_5_soya__Land *));
  void ((*__del__)(struct __pyx_obj_5_soya__Land *));
  void ((*_add_material)(struct __pyx_obj_5_soya__Land *,struct __pyx_obj_5_soya__Material *));
  float ((*_get_height)(struct __pyx_obj_5_soya__Land *,int ,int ));
  void ((*_set_height)(struct __pyx_obj_5_soya__Land *,int ,int ,float ));
  void ((*_init)(struct __pyx_obj_5_soya__Land *));
  void ((*_compute_normal)(struct __pyx_obj_5_soya__Land *,int ,int ));
  void ((*_compute_normals)(struct __pyx_obj_5_soya__Land *));
  void ((*_compute_coords)(struct __pyx_obj_5_soya__Land *));
  void ((*_create_patch)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandPatch (*),int ,int ,int ));
  void ((*_create_patchs)(struct __pyx_obj_5_soya__Land *));
  int ((*_register_color)(struct __pyx_obj_5_soya__Land *,float (*)));
  void ((*_tri_split)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*)));
  int ((*_tri_merge_child)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*)));
  void ((*_tri_set_level)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*),char ));
  void ((*_patch_set_level)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandPatch (*),char ));
  int ((*_patch_update)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandPatch (*),__pyx_t_5_soya_Frustum (*),float (*)));
  void ((*_tri_force_presence)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*),__pyx_t_5_soya_LandVertex (*)));
  void ((*_force_presence)(struct __pyx_obj_5_soya__Land *));
  void ((*_tri_batch)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*),__pyx_t_5_soya_Frustum (*)));
  void ((*_patch_batch)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandPatch (*),__pyx_t_5_soya_Frustum (*)));
  void ((*_tri_render_middle)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*)));
  void ((*_tri_render_secondpass)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*)));
  void ((*_tri_raypick)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*),float (*),struct __pyx_obj_5_soya_RaypickData *));
  int ((*_tri_raypick_b)(struct __pyx_obj_5_soya__Land *,struct __pyx_t_5_soya__LandTri (*),float (*),int ));
  void ((*_full_raypick)(struct __pyx_obj_5_soya__Land *,__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),float (*),float (*),struct __pyx_obj_5_soya_RaypickData *));
  void ((*_full_raypick_rect)(struct __pyx_obj_5_soya__Land *,int ,int ,int ,int ,float (*),struct __pyx_obj_5_soya_RaypickData *));
  int ((*_full_raypick_b)(struct __pyx_obj_5_soya__Land *,__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),float (*),float (*),int ));
  int ((*_full_raypick_rect_b)(struct __pyx_obj_5_soya__Land *,int ,int ,int ,int ,float (*),int ));
  void ((*_check_vertex_options)(struct __pyx_obj_5_soya__Land *));
  int ((*_check_color)(struct __pyx_obj_5_soya__Land *,float (*)));
  void ((*_vertex_render_special)(struct __pyx_obj_5_soya__Land *,__pyx_t_5_soya_LandVertex (*)));
};
static struct __pyx_vtabstruct_5_soya__Land *__pyx_vtabptr_5_soya__Land;

staticforward PyTypeObject __pyx_type_5_soya__WaterCube;

struct __pyx_obj_5_soya__WaterCube {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
};

struct __pyx_vtabstruct_5_soya__WaterCube {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_render_watercube)(struct __pyx_obj_5_soya__WaterCube *));
};
static struct __pyx_vtabstruct_5_soya__WaterCube *__pyx_vtabptr_5_soya__WaterCube;

staticforward PyTypeObject __pyx_type_5_soya__Atmosphere;

struct __pyx_obj_5_soya__Atmosphere {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  int _option;
  int _fog_type;
  float _fog_start;
  float _fog_end;
  float _fog_density;
  float (_ambient[4]);
  float (_bg_color[4]);
  float (_fog_color[4]);
};

struct __pyx_vtabstruct_5_soya__Atmosphere {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  void ((*_clear)(struct __pyx_obj_5_soya__Atmosphere *));
  void ((*_draw_bg)(struct __pyx_obj_5_soya__Atmosphere *));
  void ((*_render)(struct __pyx_obj_5_soya__Atmosphere *));
  float ((*_fog_factor_at)(struct __pyx_obj_5_soya__Atmosphere *,float (*)));
};
static struct __pyx_vtabstruct_5_soya__Atmosphere *__pyx_vtabptr_5_soya__Atmosphere;

staticforward PyTypeObject __pyx_type_5_soya_Renderer;

struct __pyx_obj_5_soya_Renderer {
  PyObject_HEAD
  struct __pyx_vtabstruct_5_soya_Renderer *__pyx_vtab;
  int engine_option;
  int state;
  struct __pyx_obj_5_soya__World *root_object;
  struct __pyx_obj_5_soya__Camera *current_camera;
  struct __pyx_obj_5_soya__Material *current_material;
  __pyx_t_5_soya_Frustum (*root_frustum);
  __pyx_t_5_soya_Chunk (*frustums);
  struct __pyx_obj_5_soya_CoordSyst *current_coordsyst;
  struct __pyx_obj_5_soya_Context *current_context;
  PyObject *contexts;
  int nb_contexts;
  int max_contexts;
  struct __pyx_obj_5_soya__Atmosphere *root_atmosphere;
  __pyx_t_5_soya_Chunk (*opaque);
  __pyx_t_5_soya_Chunk (*secondpass);
  __pyx_t_5_soya_Chunk (*alpha);
  __pyx_t_5_soya_Chunk (*specials);
  PyObject *top_lights;
  PyObject *worlds_made;
  PyObject *portals;
  PyObject *watercubes;
  __pyx_t_5_soya_Chunk (*data);
  __pyx_t_5_soya_Chunk (*used_opaque_packs);
  __pyx_t_5_soya_Chunk (*used_secondpass_packs);
  __pyx_t_5_soya_Chunk (*used_alpha_packs);
  float (*(*colors));
  SDL_Surface (*screen);
  int screen_width;
  int screen_height;
  float delta_time;
};

struct __pyx_vtabstruct_5_soya_Renderer {
  __pyx_t_5_soya_Frustum (*((*_frustum)(struct __pyx_obj_5_soya_Renderer *,struct __pyx_obj_5_soya_CoordSyst *)));
  struct __pyx_obj_5_soya_Context *((*_context)(struct __pyx_obj_5_soya_Renderer *));
  void ((*_activate_context_over)(struct __pyx_obj_5_soya_Renderer *,struct __pyx_obj_5_soya_Context *,struct __pyx_obj_5_soya_Context *));
  void ((*_reset)(struct __pyx_obj_5_soya_Renderer *));
  void ((*_batch)(struct __pyx_obj_5_soya_Renderer *,__pyx_t_5_soya_Chunk (*),PyObject *,struct __pyx_obj_5_soya_CoordSyst *,int ));
  void ((*_render)(struct __pyx_obj_5_soya_Renderer *));
  void ((*_render_list)(struct __pyx_obj_5_soya_Renderer *,__pyx_t_5_soya_Chunk (*)));
  void ((*_clear_screen)(struct __pyx_obj_5_soya_Renderer *,float (*)));
  void ((*_render_shadows)(struct __pyx_obj_5_soya_Renderer *));
};
static struct __pyx_vtabstruct_5_soya_Renderer *__pyx_vtabptr_5_soya_Renderer;

staticforward PyTypeObject __pyx_type_5_soya_Context;

struct __pyx_obj_5_soya_Context {
  PyObject_HEAD
  PyObject *lights;
  struct __pyx_obj_5_soya__Atmosphere *atmosphere;
  struct __pyx_obj_5_soya__Portal *portal;
};

staticforward PyTypeObject __pyx_type_5_soya_RaypickData;

struct __pyx_obj_5_soya_RaypickData {
  PyObject_HEAD
  int option;
  __pyx_t_5_soya_Chunk (*raypicked);
  __pyx_t_5_soya_Chunk (*raypick_data);
  float (root_data[7]);
  float (normal[3]);
  float result;
  float root_result;
  struct __pyx_obj_5_soya_CoordSyst *result_coordsyst;
};

staticforward PyTypeObject __pyx_type_5_soya_RaypickContext;

struct __pyx_obj_5_soya_RaypickContext {
  PyObject_HEAD
  __pyx_t_5_soya_Chunk (*_items);
  struct __pyx_obj_5_soya__World *_root;
};

staticforward PyTypeObject __pyx_type_5_soya_Idler;

struct __pyx_obj_5_soya_Idler {
  PyObject_HEAD
  PyObject *_next_round_tasks;
  PyObject *_return_value;
  PyObject *_scenes;
  double round_duration;
  double min_frame_duration;
  double fps;
  int running;
  int will_render;
  double _time;
  double _time_since_last_round;
};

staticforward PyTypeObject __pyx_type_5_soya_Glyph;

struct __pyx_obj_5_soya_Glyph {
  PyObject_HEAD
  float _pixels_x1;
  float _pixels_y1;
  float _pixels_x2;
  float _pixels_y2;
  float width;
  float height;
  float y;
  float x;
  PyObject *unichar;
};

staticforward PyTypeObject __pyx_type_5_soya_Font;

struct __pyx_obj_5_soya_Font {
  PyObject_HEAD
  struct __pyx_vtabstruct_5_soya_Font *__pyx_vtab;
  FT_Face _face;
  PyObject *filename;
  int _width;
  int _height;
  PyObject *_glyphs;
  GLubyte (*_pixels);
  int _current_x;
  int _current_y;
  int _current_height;
  int _pixels_height;
  int _rendering;
  GLuint _tex_id;
};

struct __pyx_vtabstruct_5_soya_Font {
  struct __pyx_obj_5_soya_Glyph *((*_get_glyph)(struct __pyx_obj_5_soya_Font *,PyObject *));
  PyObject *((*_gen_glyph)(struct __pyx_obj_5_soya_Font *,PyObject *,int ));
  void ((*_sizeup_pixel)(struct __pyx_obj_5_soya_Font *,int ));
  void ((*_init)(struct __pyx_obj_5_soya_Font *));
};
static struct __pyx_vtabstruct_5_soya_Font *__pyx_vtabptr_5_soya_Font;

staticforward PyTypeObject __pyx_type_5_soya_Shapifier;

struct __pyx_obj_5_soya_Shapifier {
  struct __pyx_obj_5_soya__CObj __pyx_base;
};

struct __pyx_vtabstruct_5_soya_Shapifier {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  struct __pyx_obj_5_soya__Shape *((*_shapify)(struct __pyx_obj_5_soya_Shapifier *,struct __pyx_obj_5_soya__World *));
};
static struct __pyx_vtabstruct_5_soya_Shapifier *__pyx_vtabptr_5_soya_Shapifier;

staticforward PyTypeObject __pyx_type_5_soya_Traveling;

struct __pyx_obj_5_soya_Traveling {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  struct __pyx_obj_5_soya_CoordSyst *_incline_as;
  int _smooth_move;
  int _smooth_rotation;
};

struct __pyx_vtabstruct_5_soya_Traveling {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_Traveling *__pyx_vtabptr_5_soya_Traveling;

staticforward PyTypeObject __pyx_type_5_soya__TravelingCamera;

struct __pyx_obj_5_soya__TravelingCamera {
  struct __pyx_obj_5_soya__Camera __pyx_base;
  PyObject *_travelings;
  struct __pyx_obj_5_soya_Traveling *_traveling;
  float _speed_value;
  float _proportion;
  struct __pyx_obj_5_soya__Vector *_speed;
};

struct __pyx_vtabstruct_5_soya__TravelingCamera {
  struct __pyx_vtabstruct_5_soya__Camera __pyx_base;
  void ((*_traveling_changed)(struct __pyx_obj_5_soya__TravelingCamera *));
};
static struct __pyx_vtabstruct_5_soya__TravelingCamera *__pyx_vtabptr_5_soya__TravelingCamera;

staticforward PyTypeObject __pyx_type_5_soya__NoBackgroundAtmosphere;

struct __pyx_obj_5_soya__NoBackgroundAtmosphere {
  struct __pyx_obj_5_soya__Atmosphere __pyx_base;
};

struct __pyx_vtabstruct_5_soya__NoBackgroundAtmosphere {
  struct __pyx_vtabstruct_5_soya__Atmosphere __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__NoBackgroundAtmosphere *__pyx_vtabptr_5_soya__NoBackgroundAtmosphere;

staticforward PyTypeObject __pyx_type_5_soya__SkyAtmosphere;

struct __pyx_obj_5_soya__SkyAtmosphere {
  struct __pyx_obj_5_soya__Atmosphere __pyx_base;
  float (_sky_color[4]);
  float _cloud_scale;
  struct __pyx_obj_5_soya__Material *_cloud;
  PyObject *_sky_box;
};

struct __pyx_vtabstruct_5_soya__SkyAtmosphere {
  struct __pyx_vtabstruct_5_soya__Atmosphere __pyx_base;
  void ((*_draw_sky_plane)(struct __pyx_obj_5_soya__SkyAtmosphere *));
  void ((*_draw_sky_box)(struct __pyx_obj_5_soya__SkyAtmosphere *));
};
static struct __pyx_vtabstruct_5_soya__SkyAtmosphere *__pyx_vtabptr_5_soya__SkyAtmosphere;

staticforward PyTypeObject __pyx_type_5_soya_PythonCoordSyst;

struct __pyx_obj_5_soya_PythonCoordSyst {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
};

struct __pyx_vtabstruct_5_soya_PythonCoordSyst {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_PythonCoordSyst *__pyx_vtabptr_5_soya_PythonCoordSyst;

staticforward PyTypeObject __pyx_type_5_soya_CoordSystState;

struct __pyx_obj_5_soya_CoordSystState {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  float (_quaternion[4]);
};

struct __pyx_vtabstruct_5_soya_CoordSystState {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_check_state_validity)(struct __pyx_obj_5_soya_CoordSystState *));
};
static struct __pyx_vtabstruct_5_soya_CoordSystState *__pyx_vtabptr_5_soya_CoordSystState;

staticforward PyTypeObject __pyx_type_5_soya__FixTraveling;

struct __pyx_obj_5_soya__FixTraveling {
  struct __pyx_obj_5_soya_Traveling __pyx_base;
  struct __pyx_obj_5_soya_Position *_target;
  struct __pyx_obj_5_soya_Position *_direction;
};

struct __pyx_vtabstruct_5_soya__FixTraveling {
  struct __pyx_vtabstruct_5_soya_Traveling __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__FixTraveling *__pyx_vtabptr_5_soya__FixTraveling;

staticforward PyTypeObject __pyx_type_5_soya__ThirdPersonTraveling;

struct __pyx_obj_5_soya__ThirdPersonTraveling {
  struct __pyx_obj_5_soya_Traveling __pyx_base;
  struct __pyx_obj_5_soya_Position *_target;
  struct __pyx_obj_5_soya__Point *__target;
  struct __pyx_obj_5_soya__Point *_best;
  struct __pyx_obj_5_soya__Point *_result;
  struct __pyx_obj_5_soya__Point *__direction;
  struct __pyx_obj_5_soya__Vector *_direction;
  struct __pyx_obj_5_soya__Vector *__normal;
  float _distance;
  float _offset_y;
  float _offset_y2;
  float _lateral_angle;
  float _top_view;
  float _speed;
  struct __pyx_obj_5_soya_RaypickContext *_context;
};

struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling {
  struct __pyx_vtabstruct_5_soya_Traveling __pyx_base;
  float ((*_check)(struct __pyx_obj_5_soya__ThirdPersonTraveling *,struct __pyx_obj_5_soya_RaypickContext *,struct __pyx_obj_5_soya_Position *,struct __pyx_obj_5_soya__Vector *,struct __pyx_obj_5_soya__Point *));
};
static struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *__pyx_vtabptr_5_soya__ThirdPersonTraveling;

staticforward PyTypeObject __pyx_type_5_soya__PythonMaterial;

struct __pyx_obj_5_soya__PythonMaterial {
  struct __pyx_obj_5_soya__Material __pyx_base;
};

struct __pyx_vtabstruct_5_soya__PythonMaterial {
  struct __pyx_vtabstruct_5_soya__Material __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__PythonMaterial *__pyx_vtabptr_5_soya__PythonMaterial;

staticforward PyTypeObject __pyx_type_5_soya__CylinderSprite;

struct __pyx_obj_5_soya__CylinderSprite {
  struct __pyx_obj_5_soya__Sprite __pyx_base;
};

struct __pyx_vtabstruct_5_soya__CylinderSprite {
  struct __pyx_vtabstruct_5_soya__Sprite __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__CylinderSprite *__pyx_vtabptr_5_soya__CylinderSprite;

staticforward PyTypeObject __pyx_type_5_soya__Bonus;

struct __pyx_obj_5_soya__Bonus {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  float _angle;
  float (_color[4]);
  struct __pyx_obj_5_soya__Material *_material;
  struct __pyx_obj_5_soya__Material *_halo;
};

struct __pyx_vtabstruct_5_soya__Bonus {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__Bonus *__pyx_vtabptr_5_soya__Bonus;

staticforward PyTypeObject __pyx_type_5_soya__Particles;

struct __pyx_obj_5_soya__Particles {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__Material *_material;
  struct __pyx_obj_5_soya_CoordSyst *_particle_coordsyst;
  int _nb_particles;
  int _nb_max_particles;
  int _particle_size;
  float (*_particles);
  float _delta_time;
  int _nb_colors;
  int _nb_sizes;
  float (*_fading_colors);
  float (*_sizes);
  int _nb_creatable_particles;
  int _max_particles_per_round;
};

struct __pyx_vtabstruct_5_soya__Particles {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
  void ((*_reinit)(struct __pyx_obj_5_soya__Particles *));
  void ((*_advance)(struct __pyx_obj_5_soya__Particles *,float ));
  void ((*_compute_alpha)(struct __pyx_obj_5_soya__Particles *));
  void ((*_get_fading_color)(struct __pyx_obj_5_soya__Particles *,float ,float ,float (*)));
  void ((*_get_size)(struct __pyx_obj_5_soya__Particles *,float ,float ,float (*)));
  float (*((*_generate)(struct __pyx_obj_5_soya__Particles *,int ,float )));
};
static struct __pyx_vtabstruct_5_soya__Particles *__pyx_vtabptr_5_soya__Particles;

staticforward PyTypeObject __pyx_type_5_soya_FlagFirework;

struct __pyx_obj_5_soya_FlagFirework {
  struct __pyx_obj_5_soya__Particles __pyx_base;
  struct __pyx_obj_5_soya__Particles *_subgenerator;
  int _nb_sub_particles;
};

struct __pyx_vtabstruct_5_soya_FlagFirework {
  struct __pyx_vtabstruct_5_soya__Particles __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_FlagFirework *__pyx_vtabptr_5_soya_FlagFirework;

staticforward PyTypeObject __pyx_type_5_soya_SimpleShapifier;

struct __pyx_obj_5_soya_SimpleShapifier {
  struct __pyx_obj_5_soya_Shapifier __pyx_base;
  int _shadow;
  float _max_face_angle;
};

struct __pyx_vtabstruct_5_soya_SimpleShapifier {
  struct __pyx_vtabstruct_5_soya_Shapifier __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_SimpleShapifier *__pyx_vtabptr_5_soya_SimpleShapifier;

staticforward PyTypeObject __pyx_type_5_soya_TreeShapifier;

struct __pyx_obj_5_soya_TreeShapifier {
  struct __pyx_obj_5_soya_SimpleShapifier __pyx_base;
  float _collapsing_distance;
  int _quality;
  float _max_child_radius;
};

struct __pyx_vtabstruct_5_soya_TreeShapifier {
  struct __pyx_vtabstruct_5_soya_SimpleShapifier __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_TreeShapifier *__pyx_vtabptr_5_soya_TreeShapifier;

staticforward PyTypeObject __pyx_type_5_soya_CellShadingShapifier;

struct __pyx_obj_5_soya_CellShadingShapifier {
  struct __pyx_obj_5_soya_SimpleShapifier __pyx_base;
  struct __pyx_obj_5_soya__Material *_shader;
  PyObject *_outline_color;
  float _outline_width;
  float _outline_attenuation;
};

struct __pyx_vtabstruct_5_soya_CellShadingShapifier {
  struct __pyx_vtabstruct_5_soya_SimpleShapifier __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_CellShadingShapifier *__pyx_vtabptr_5_soya_CellShadingShapifier;

staticforward PyTypeObject __pyx_type_5_soya__Cal3dSubMesh;

struct __pyx_obj_5_soya__Cal3dSubMesh {
  PyObject_HEAD
  struct __pyx_vtabstruct_5_soya__Cal3dSubMesh *__pyx_vtab;
  int _option;
  int _mesh;
  int _submesh;
  struct __pyx_obj_5_soya__Material *_material;
  int _nb_faces;
  int _nb_vertices;
  int (*_faces);
  int (*_face_neighbors);
};

struct __pyx_vtabstruct_5_soya__Cal3dSubMesh {
  PyObject *((*_build)(struct __pyx_obj_5_soya__Cal3dSubMesh *,struct __pyx_obj_5_soya__Cal3dShape *,struct CalRenderer (*),struct CalCoreModel (*),struct CalCoreMesh (*),int ,int ));
  void ((*_build_neighbors)(struct __pyx_obj_5_soya__Cal3dSubMesh *,PyObject *,float (*)));
};
static struct __pyx_vtabstruct_5_soya__Cal3dSubMesh *__pyx_vtabptr_5_soya__Cal3dSubMesh;

staticforward PyTypeObject __pyx_type_5_soya__SolidShape;

struct __pyx_obj_5_soya__SolidShape {
  struct __pyx_obj_5_soya__SimpleShape __pyx_base;
};

struct __pyx_vtabstruct_5_soya__SolidShape {
  struct __pyx_vtabstruct_5_soya__SimpleShape __pyx_base;
  void ((*_render_triangle_solid)(struct __pyx_obj_5_soya__SolidShape *,__pyx_t_5_soya_ShapeFace (*),struct __pyx_obj_5_soya_CoordSyst *,int (*)));
};
static struct __pyx_vtabstruct_5_soya__SolidShape *__pyx_vtabptr_5_soya__SolidShape;

staticforward PyTypeObject __pyx_type_5_soya__IdleingMaterial;

struct __pyx_obj_5_soya__IdleingMaterial {
  struct __pyx_obj_5_soya__Material __pyx_base;
};

struct __pyx_vtabstruct_5_soya__IdleingMaterial {
  struct __pyx_vtabstruct_5_soya__Material __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__IdleingMaterial *__pyx_vtabptr_5_soya__IdleingMaterial;

staticforward PyTypeObject __pyx_type_5_soya__PythonIdleingMaterial;

struct __pyx_obj_5_soya__PythonIdleingMaterial {
  struct __pyx_obj_5_soya__IdleingMaterial __pyx_base;
};

struct __pyx_vtabstruct_5_soya__PythonIdleingMaterial {
  struct __pyx_vtabstruct_5_soya__IdleingMaterial __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__PythonIdleingMaterial *__pyx_vtabptr_5_soya__PythonIdleingMaterial;

staticforward PyTypeObject __pyx_type_5_soya_Fountain;

struct __pyx_obj_5_soya_Fountain {
  struct __pyx_obj_5_soya__Particles __pyx_base;
};

struct __pyx_vtabstruct_5_soya_Fountain {
  struct __pyx_vtabstruct_5_soya__Particles __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_Fountain *__pyx_vtabptr_5_soya_Fountain;

staticforward PyTypeObject __pyx_type_5_soya_Smoke;

struct __pyx_obj_5_soya_Smoke {
  struct __pyx_obj_5_soya__Particles __pyx_base;
};

struct __pyx_vtabstruct_5_soya_Smoke {
  struct __pyx_vtabstruct_5_soya__Particles __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_Smoke *__pyx_vtabptr_5_soya_Smoke;

staticforward PyTypeObject __pyx_type_5_soya_FlagSubFire;

struct __pyx_obj_5_soya_FlagSubFire {
  struct __pyx_obj_5_soya__Particles __pyx_base;
};

struct __pyx_vtabstruct_5_soya_FlagSubFire {
  struct __pyx_vtabstruct_5_soya__Particles __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_FlagSubFire *__pyx_vtabptr_5_soya_FlagSubFire;

staticforward PyTypeObject __pyx_type_5_soya_SolidShapifier;

struct __pyx_obj_5_soya_SolidShapifier {
  struct __pyx_obj_5_soya_SimpleShapifier __pyx_base;
};

struct __pyx_vtabstruct_5_soya_SolidShapifier {
  struct __pyx_vtabstruct_5_soya_SimpleShapifier __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_SolidShapifier *__pyx_vtabptr_5_soya_SolidShapifier;

static PyTypeObject *__pyx_ptype_5_soya__CObj = 0;
static PyTypeObject *__pyx_ptype_5_soya__Image = 0;
static PyTypeObject *__pyx_ptype_5_soya__Material = 0;
static PyTypeObject *__pyx_ptype_5_soya__Shape = 0;
static PyTypeObject *__pyx_ptype_5_soya__SimpleShape = 0;
static PyTypeObject *__pyx_ptype_5_soya__CellShadingShape = 0;
static PyTypeObject *__pyx_ptype_5_soya__TreeShape = 0;
static PyTypeObject *__pyx_ptype_5_soya_Position = 0;
static PyTypeObject *__pyx_ptype_5_soya__Point = 0;
static PyTypeObject *__pyx_ptype_5_soya__Vector = 0;
static PyTypeObject *__pyx_ptype_5_soya__Vertex = 0;
static PyTypeObject *__pyx_ptype_5_soya_CoordSyst = 0;
static PyTypeObject *__pyx_ptype_5_soya__Camera = 0;
static PyTypeObject *__pyx_ptype_5_soya__Light = 0;
static PyTypeObject *__pyx_ptype_5_soya__Volume = 0;
static PyTypeObject *__pyx_ptype_5_soya__World = 0;
static PyTypeObject *__pyx_ptype_5_soya__Face = 0;
static PyTypeObject *__pyx_ptype_5_soya__Cal3dVolume = 0;
static PyTypeObject *__pyx_ptype_5_soya__Cal3dShape = 0;
static PyTypeObject *__pyx_ptype_5_soya__Sprite = 0;
static PyTypeObject *__pyx_ptype_5_soya__Portal = 0;
static PyTypeObject *__pyx_ptype_5_soya__Land = 0;
static PyTypeObject *__pyx_ptype_5_soya__WaterCube = 0;
static PyTypeObject *__pyx_ptype_5_soya__Atmosphere = 0;
static PyTypeObject *__pyx_ptype_5_soya_Renderer = 0;
static PyTypeObject *__pyx_ptype_5_soya_Context = 0;
static PyTypeObject *__pyx_ptype_5_soya_RaypickData = 0;
static PyTypeObject *__pyx_ptype_5_soya_RaypickContext = 0;
static PyTypeObject *__pyx_ptype_5_soya_Idler = 0;
static PyTypeObject *__pyx_ptype_5_soya_Glyph = 0;
static PyTypeObject *__pyx_ptype_5_soya_Font = 0;
static PyTypeObject *__pyx_ptype_5_soya_Shapifier = 0;
static PyTypeObject *__pyx_ptype_5_soya_Traveling = 0;
static PyTypeObject *__pyx_ptype_5_soya__TravelingCamera = 0;
static PyTypeObject *__pyx_ptype_5_soya__NoBackgroundAtmosphere = 0;
static PyTypeObject *__pyx_ptype_5_soya__SkyAtmosphere = 0;
static PyTypeObject *__pyx_ptype_5_soya_PythonCoordSyst = 0;
static PyTypeObject *__pyx_ptype_5_soya_CoordSystState = 0;
static PyTypeObject *__pyx_ptype_5_soya__FixTraveling = 0;
static PyTypeObject *__pyx_ptype_5_soya__ThirdPersonTraveling = 0;
static PyTypeObject *__pyx_ptype_5_soya__PythonMaterial = 0;
static PyTypeObject *__pyx_ptype_5_soya__CylinderSprite = 0;
static PyTypeObject *__pyx_ptype_5_soya__Bonus = 0;
static PyTypeObject *__pyx_ptype_5_soya__Particles = 0;
static PyTypeObject *__pyx_ptype_5_soya_FlagFirework = 0;
static PyTypeObject *__pyx_ptype_5_soya_SimpleShapifier = 0;
static PyTypeObject *__pyx_ptype_5_soya_TreeShapifier = 0;
static PyTypeObject *__pyx_ptype_5_soya_CellShadingShapifier = 0;
static PyTypeObject *__pyx_ptype_5_soya__Cal3dSubMesh = 0;
static PyTypeObject *__pyx_ptype_5_soya__SolidShape = 0;
static PyTypeObject *__pyx_ptype_5_soya__IdleingMaterial = 0;
static PyTypeObject *__pyx_ptype_5_soya__PythonIdleingMaterial = 0;
static PyTypeObject *__pyx_ptype_5_soya_Fountain = 0;
static PyTypeObject *__pyx_ptype_5_soya_Smoke = 0;
static PyTypeObject *__pyx_ptype_5_soya_FlagSubFire = 0;
static PyTypeObject *__pyx_ptype_5_soya_SolidShapifier = 0;
static float __pyx_v_5_soya_LIGHT_NULL_ATTENUATION;
static int __pyx_v_5_soya_quality;
static int __pyx_v_5_soya_CAN_USE_TEX_BORDER;
static struct __pyx_obj_5_soya_Renderer *__pyx_v_5_soya_renderer;
static int __pyx_v_5_soya_MAX_LIGHTS;
static int __pyx_v_5_soya_MAX_CLIP_PLANES;
static int __pyx_v_5_soya_MAX_TEXTURES;
static int __pyx_v_5_soya_MAX_TEXTURE_SIZE;
static int __pyx_v_5_soya_SHADOW_DISPLAY_LIST;
static GLUtesselator (*__pyx_v_5_soya_SHADOW_TESS);
static __pyx_t_5_soya_Chunk (*__pyx_v_5_soya_SHADOW_TESS_CHUNK);
static float (__pyx_v_5_soya_white[4]);
static struct __pyx_obj_5_soya__Material *__pyx_v_5_soya__DEFAULT_MATERIAL;
static struct __pyx_obj_5_soya__Material *__pyx_v_5_soya__SHADER_DEFAULT_MATERIAL;
static int __pyx_v_5_soya_NB_JOYSTICK;
static SDL_Joystick (*(*__pyx_v_5_soya_JOYSTICKS));
static PyObject *__pyx_v_5_soya_DRIVER_3D;
static int __pyx_v_5_soya_SDL_UNICODE;
static struct __pyx_obj_5_soya_RaypickData *__pyx_v_5_soya_raypick_data;
static PyObject *__pyx_v_5_soya_LIGHTS;
static PyObject *__pyx_v_5_soya_LAST_LIGHTS;
static float (__pyx_v_5_soya__SPRITE_MATRIX[16]);
static float (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[16]);
static struct __pyx_obj_5_soya__Material *__pyx_v_5_soya__PARTICLE_DEFAULT_MATERIAL;
static void ((*__pyx_v_5_soya_land_drawColor)(float (*)));
static void ((*__pyx_v_5_soya_land_disableColor)(void));
static void ((*__pyx_v_5_soya_land_enableColor)(void));
static struct __pyx_obj_5_soya_Shapifier *__pyx_v_5_soya__DEFAULT_SHAPIFIER;
static int __pyx_v_5_soya_cal3d_nb_faces;
static int __pyx_v_5_soya_cal3d_nb_vertices;
static float (*__pyx_v_5_soya_cal3d_texcoords_array);
static float (*__pyx_v_5_soya_cal3d_shades_array);
static int (*__pyx_v_5_soya_cal3d_facesides_array);
static FT_Library __pyx_v_5_soya_library;
static int __pyx_v_5_soya_library_inited;
static PyObject *__pyx_k3;
static int __pyx_k4;
static int __pyx_k5;
static int __pyx_k6;
static int __pyx_k7;
static int __pyx_k8;
static PyObject *__pyx_k9;
static struct __pyx_obj_5_soya_CoordSyst *__pyx_k10;
static float __pyx_k11;
static float __pyx_k12;
static float __pyx_k13;
static struct __pyx_obj_5_soya__Vector *__pyx_k14;
static int __pyx_k16;
static PyObject *__pyx_k18;
static struct __pyx_obj_5_soya__Material *__pyx_k19;
static float __pyx_k20;
static int __pyx_k21;
static int __pyx_k22;
static struct __pyx_obj_5_soya__Point *__pyx_k23;
static struct __pyx_obj_5_soya__Vector *__pyx_k24;
static float __pyx_k25;
static int __pyx_k26;
static int __pyx_k27;
static struct __pyx_obj_5_soya__Point *__pyx_k28;
static struct __pyx_obj_5_soya__Vector *__pyx_k29;
static struct __pyx_obj_5_soya__World *__pyx_k30;
static struct __pyx_obj_5_soya__World *__pyx_k31;
static struct __pyx_obj_5_soya__Shape *__pyx_k32;
static struct __pyx_obj_5_soya__World *__pyx_k33;
static struct __pyx_obj_5_soya__Shape *__pyx_k34;
static float __pyx_k35;
static int __pyx_k36;
static int __pyx_k37;
static struct __pyx_obj_5_soya__Point *__pyx_k38;
static struct __pyx_obj_5_soya__Vector *__pyx_k39;
static float __pyx_k40;
static int __pyx_k41;
static int __pyx_k42;
static struct __pyx_obj_5_soya_RaypickContext *__pyx_k43;
static PyObject *__pyx_k44;
static struct __pyx_obj_5_soya__World *__pyx_k45;
static struct __pyx_obj_5_soya__World *__pyx_k46;
static float __pyx_k47;
static struct __pyx_obj_5_soya__Point *__pyx_k48;
static struct __pyx_obj_5_soya__World *__pyx_k49;
static PyObject *__pyx_k50;
static int __pyx_k51;
static int __pyx_k52;
static struct __pyx_obj_5_soya_Position *__pyx_k53;
static struct __pyx_obj_5_soya__Vector *__pyx_k54;
static int __pyx_k55;
static int __pyx_k56;
static PyObject *__pyx_k57;
static int __pyx_k58;
static int __pyx_k59;
static int __pyx_k60;
static int __pyx_k61;
static PyObject *__pyx_k62;
static int __pyx_k63;
static int __pyx_k64;
static int __pyx_k65;
static struct __pyx_obj_5_soya__Image *__pyx_k66;
static struct __pyx_obj_5_soya__Image *__pyx_k67;
static struct __pyx_obj_5_soya_CoordSyst *__pyx_k68;
static float __pyx_k69;
static float __pyx_k70;
static float __pyx_k71;
static float __pyx_k72;
static float __pyx_k73;
static PyObject *__pyx_k74;
static PyObject *__pyx_k75;
static struct __pyx_obj_5_soya__World *__pyx_k76;
static PyObject *__pyx_k77;
static struct __pyx_obj_5_soya__Material *__pyx_k78;
static float __pyx_k79;
static struct __pyx_obj_5_soya__World *__pyx_k80;
static struct __pyx_obj_5_soya__Material *__pyx_k81;
static struct __pyx_obj_5_soya__World *__pyx_k82;
static struct __pyx_obj_5_soya__Material *__pyx_k83;
static struct __pyx_obj_5_soya__Material *__pyx_k84;
static struct __pyx_obj_5_soya__World *__pyx_k85;
static struct __pyx_obj_5_soya__Material *__pyx_k86;
static int __pyx_k87;
static int __pyx_k88;
static int __pyx_k89;
static float __pyx_k90;
static float __pyx_k91;
static float __pyx_k92;
static float __pyx_k93;
static float __pyx_k94;
static float __pyx_k95;
static struct __pyx_obj_5_soya__World *__pyx_k97;
static struct __pyx_obj_5_soya__Material *__pyx_k98;
static int __pyx_k99;
static int __pyx_k100;
static struct __pyx_obj_5_soya__World *__pyx_k101;
static struct __pyx_obj_5_soya__Material *__pyx_k102;
static int __pyx_k103;
static int __pyx_k104;
static struct __pyx_obj_5_soya__World *__pyx_k105;
static struct __pyx_obj_5_soya__Material *__pyx_k106;
static int __pyx_k107;
static int __pyx_k108;
static float __pyx_k109;
static float __pyx_k110;
static float __pyx_k111;
static struct __pyx_obj_5_soya__World *__pyx_k112;
static struct __pyx_obj_5_soya__Material *__pyx_k113;
static int __pyx_k114;
static int __pyx_k115;
static PyObject *__pyx_k116;
static int __pyx_k117;
static int __pyx_k118;
static struct __pyx_obj_5_soya__World *__pyx_k119;
static int __pyx_k120;
static int __pyx_k121;
static float __pyx_k122;
static int __pyx_k123;
static int __pyx_k124;
static int __pyx_k125;
static int __pyx_k126;
static float __pyx_k127;
static int __pyx_k128;
static float __pyx_k129;
static float __pyx_k130;
static int __pyx_k131;
static float __pyx_k132;
static int __pyx_k133;
static float __pyx_k134;
static struct __pyx_obj_5_soya__Material *__pyx_k135;
static PyObject *__pyx_k136;
static float __pyx_k137;
static float __pyx_k138;
static struct __pyx_obj_5_soya__Material *__pyx_k140;
static PyObject *__pyx_k141;
static float __pyx_k142;
static float __pyx_k143;
static struct __pyx_obj_5_soya__World *__pyx_k144;
static struct __pyx_obj_5_soya__Cal3dShape *__pyx_k145;
static PyObject *__pyx_k146;
static PyObject *__pyx_k147;
static float __pyx_k148;
static float __pyx_k149;
static float __pyx_k150;
static float __pyx_k151;
static float __pyx_k152;
static int __pyx_k153;
static int __pyx_k154;
static float __pyx_k155;
static int __pyx_k156;
static char (*(__pyx_f_5_soya_dup(char (*),int ))); /*proto*/
static PyObject *(__pyx_f_5_soya_chunk_to_string(__pyx_t_5_soya_Chunk (*))); /*proto*/
static PyObject *(__pyx_f_5_soya_drop_chunk_to_string(__pyx_t_5_soya_Chunk (*))); /*proto*/
static __pyx_t_5_soya_Chunk (*(__pyx_f_5_soya_string_to_chunk(PyObject *))); /*proto*/
static void (__pyx_f_5_soya_dump_info(void)); /*proto*/
static void (__pyx_f_5_soya_init_gl(void)); /*proto*/
static void (__pyx_f_5_soya_base_init(void)); /*proto*/
static void (__pyx_f_5_soya_base_quit(void)); /*proto*/
static void (__pyx_f_5_soya_init_joysticks(void)); /*proto*/
static void (__pyx_f_5_soya_init_video(char (*),int ,int ,int ,int )); /*proto*/
static int (__pyx_f_5_soya_check_gl_error(void)); /*proto*/
static PyObject *(__pyx_f_5_soya_make_raypick_result(float (*),float ,float (*),struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya__Point *,struct __pyx_obj_5_soya__Vector *)); /*proto*/
static struct __pyx_obj_5_soya_RaypickData *(__pyx_f_5_soya_get_raypick_data(void)); /*proto*/
static __pyx_t_5_soya_Frustum (*(__pyx_f_5_soya_frustum_coordsyst_into(__pyx_t_5_soya_Frustum (*),__pyx_t_5_soya_Frustum (*),float (*),float (*)))); /*proto*/
static void (__pyx_f_5_soya_disable_all_lights(void)); /*proto*/
static void (__pyx_f_5_soya_disable_static_lights(void)); /*proto*/
static void (__pyx_f_5_soya_enable_static_lights(void)); /*proto*/
static void (__pyx_f_5_soya_disable_deep_lights(void)); /*proto*/
static int (__pyx_f_5_soya_power_of_2(int )); /*proto*/
static GLubyte (*(__pyx_f_5_soya_pixels_scale_down_2(int ,GLuint (*),GLuint (*),int ,GLubyte (*)))); /*proto*/
static struct __pyx_t_5_soya__Pack (*(__pyx_f_5_soya_pack_get_alpha(struct __pyx_t_5_soya__Pack (*)))); /*proto*/
static struct __pyx_t_5_soya__Pack (*(__pyx_f_5_soya_pack_get_secondpass(struct __pyx_t_5_soya__Pack (*)))); /*proto*/
static void (__pyx_f_5_soya_pack_batch_face(struct __pyx_t_5_soya__Pack (*),void (*))); /*proto*/
static void (__pyx_f_5_soya_pack_batch_end(PyObject *,struct __pyx_obj_5_soya_CoordSyst *)); /*proto*/
static int (__pyx_f_5_soya_face_vertices_number(__pyx_t_5_soya_ShapeFace (*))); /*proto*/
static void (__pyx_f_5_soya_shape_option_activate(int )); /*proto*/
static void (__pyx_f_5_soya_shape_option_inactivate(int )); /*proto*/
static void (__pyx_f_5_soya_face_option_activate(int )); /*proto*/
static void (__pyx_f_5_soya_face_option_inactivate(int )); /*proto*/
static void (__pyx_f_5_soya_shape_shadow_tess_combine(double (*),void (*(*)),float (*),void (*(*)))); /*proto*/
static void (__pyx_f_5_soya_segment_projection_intersect_plane(float (*),float (*),float (*),float (*),float ,float (*),float (*),float (*),float (*),int (*))); /*proto*/
static struct __pyx_t_5_soya__Node (*(__pyx_f_5_soya_node_new(int ,GLfloat (*)))); /*proto*/
static struct __pyx_t_5_soya__Node (*(__pyx_f_5_soya_node_register_face(struct __pyx_t_5_soya__Node (*),struct __pyx_t_5_soya__Node (*),int ,float (*)))); /*proto*/
static void (__pyx_f_5_soya_node_register_inside_face(struct __pyx_t_5_soya__Node (*),int ,GLfloat (*))); /*proto*/
static void (__pyx_f_5_soya_node_register_node(struct __pyx_t_5_soya__Node (*),struct __pyx_t_5_soya__Node (*))); /*proto*/
static void (__pyx_f_5_soya_node_add_face(struct __pyx_t_5_soya__Node (*),int ,float (*))); /*proto*/
static int (__pyx_f_5_soya_node_gather(struct __pyx_t_5_soya__Node (*),int ,float )); /*proto*/
static void (__pyx_f_5_soya_node_added(struct __pyx_t_5_soya__Node (*),struct __pyx_t_5_soya__Node (*))); /*proto*/
static void (__pyx_f_5_soya_node_add_node(struct __pyx_t_5_soya__Node (*),struct __pyx_t_5_soya__Node (*))); /*proto*/
static void (__pyx_f_5_soya_node_collapse_with_child(struct __pyx_t_5_soya__Node (*),float )); /*proto*/
static void (__pyx_f_5_soya_node_join(struct __pyx_t_5_soya__Node (*),struct __pyx_t_5_soya__Node (*))); /*proto*/
static void (__pyx_f_5_soya_node_optimize(struct __pyx_t_5_soya__Node (*),float ,int ,float )); /*proto*/
static int (__pyx_f_5_soya_node_get_nb_level(struct __pyx_t_5_soya__Node (*))); /*proto*/
static int (__pyx_f_5_soya_node_get_memory_size(struct __pyx_t_5_soya__Node (*))); /*proto*/
static PyObject *(__pyx_f_5_soya_node_collect_raypickables(struct __pyx_t_5_soya__Node (*),__pyx_t_5_soya_Chunk (*),float (*))); /*proto*/
static void (__pyx_f_5_soya_land_tri_dealloc(struct __pyx_t_5_soya__LandTri (*))); /*proto*/
static int (__pyx_f_5_soya_land_tri_has_child(struct __pyx_t_5_soya__LandTri (*))); /*proto*/
static int (__pyx_f_5_soya_land_tri_diamond(struct __pyx_t_5_soya__LandTri (*))); /*proto*/
static void (__pyx_f_5_soya_land_tri_sphere(float (*),float (*),float (*),float (*))); /*proto*/
static struct __pyx_t_5_soya__LandTri (*(__pyx_f_5_soya_land_get_tri(void))); /*proto*/
static void (__pyx_f_5_soya_land_tri_drop(struct __pyx_t_5_soya__LandTri (*))); /*proto*/
static struct __pyx_t_5_soya__LandTri (*(__pyx_f_5_soya_land_create_tri(__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),struct __pyx_t_5_soya__LandPatch (*)))); /*proto*/
static struct __pyx_t_5_soya__LandTri (*(__pyx_f_5_soya_land_create_child_tri(__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),struct __pyx_t_5_soya__LandTri (*)))); /*proto*/
static void (__pyx_f_5_soya_land_tri_update_neighbor_after_split(struct __pyx_t_5_soya__LandTri (*))); /*proto*/
static void (__pyx_f_5_soya_land_tri_force_split(struct __pyx_t_5_soya__LandTri (*),__pyx_t_5_soya_LandVertex (*))); /*proto*/
static void (__pyx_f_5_soya_land_tri_update_neighbor_after_merge(struct __pyx_t_5_soya__LandTri (*))); /*proto*/
static void (__pyx_f_5_soya_land_get_height_at_factors(__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),__pyx_t_5_soya_LandVertex (*),float ,float ,float (*),float (*))); /*proto*/
static void (__pyx_f_5_soya_land_drawColor_radeon(float (*))); /*proto*/
static void (__pyx_f_5_soya_noop(void)); /*proto*/
static void (__pyx_f_5_soya_land_disableColor_radeon(void)); /*proto*/
static void (__pyx_f_5_soya_land_enableColor_radeon(void)); /*proto*/
static void (__pyx_f_5_soya_SET_COLOR_OPAQUE(struct __pyx_obj_5_soya__Land *,int )); /*proto*/
static void (__pyx_f_5_soya_SET_COLOR_ALPHA(struct __pyx_obj_5_soya__Land *,int )); /*proto*/
static void (__pyx_f_5_soya_quit_cal3d(void)); /*proto*/

/* Implementation of _soya */

static char (__pyx_k1[]) = "0.10.2";
static char (__pyx_k2[]) = "Soya 3D";
static char (__pyx_k139[]) = "os.path";

static PyObject *__pyx_n_SDL_ALLEVENTS;
static PyObject *__pyx_n_Image;
static PyObject *__pyx_n_Material;
static PyObject *__pyx_n_Shape;
static PyObject *__pyx_n_SimpleShape;
static PyObject *__pyx_n_SolidShape;
static PyObject *__pyx_n_TreeShape;
static PyObject *__pyx_n_CellShadingShape;
static PyObject *__pyx_n_Point;
static PyObject *__pyx_n_Vector;
static PyObject *__pyx_n_Camera;
static PyObject *__pyx_n_Light;
static PyObject *__pyx_n_Volume;
static PyObject *__pyx_n_World;
static PyObject *__pyx_n_Cal3dVolume;
static PyObject *__pyx_n_Cal3dShape;
static PyObject *__pyx_n_Portal;
static PyObject *__pyx_n_WaterCube;
static PyObject *__pyx_n_Face;
static PyObject *__pyx_n_Atmosphere;
static PyObject *__pyx_n_Particles;
static PyObject *__pyx_n_VERSION;
static PyObject *__pyx_n_BLACK;
static PyObject *__pyx_n_WHITE;
static PyObject *__pyx_n_TRANSPARENT;
static PyObject *__pyx_n_get_max_texture_size;
static PyObject *__pyx_n__set_default_material;
static PyObject *__pyx_n__set_shader_default_material;
static PyObject *__pyx_n__reconstructor;
static PyObject *__pyx_n_set_quality;
static PyObject *__pyx_n_toggle_wireframe;
static PyObject *__pyx_n_set_gamma;
static PyObject *__pyx_n_set_video;
static PyObject *__pyx_n_init;
static PyObject *__pyx_n_quit;
static PyObject *__pyx_n_set_use_unicode;
static PyObject *__pyx_n_process_event;
static PyObject *__pyx_n_get_mod;
static PyObject *__pyx_n_cursor_set_visible;
static PyObject *__pyx_n_ALL_EVENTS;
static PyObject *__pyx_n_set_mouse_pos;
static PyObject *__pyx_n_get_grab_input;
static PyObject *__pyx_n_set_grab_input;
static PyObject *__pyx_n_clear_events;
static PyObject *__pyx_n_get_mouse_rel_pos;
static PyObject *__pyx_n_get_renderer;
static PyObject *__pyx_n_root_widget;
static PyObject *__pyx_n_GLError;
static PyObject *__pyx_n_check_error;
static PyObject *__pyx_n_set_root_widget;
static PyObject *__pyx_n_render;
static PyObject *__pyx_n_get_screen_width;
static PyObject *__pyx_n_get_screen_height;
static PyObject *__pyx_n_weakref;
static PyObject *__pyx_n_IDLER;
static PyObject *__pyx_n_BEFORE_RENDER;
static PyObject *__pyx_n_IDLEING_ITEMS;
static PyObject *__pyx_n_open_image;
static PyObject *__pyx_n_image_from_pil;
static PyObject *__pyx_n_screenshot;
static PyObject *__pyx_n__set_particle_default_material;
static PyObject *__pyx_n_random;
static PyObject *__pyx_n__is_static_light;
static PyObject *__pyx_n__set_default_shapifier;
static PyObject *__pyx_n_os;
static PyObject *__pyx_n_load_raw_image;
static PyObject *__pyx_n_parse_cal3d_cfg_file;
static PyObject *__pyx_n_StandardError;
static PyObject *__pyx_n_WeakKeyDictionary;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k2p;
static PyObject *__pyx_k139p;

static PyObject *__pyx_f_5_soya_get_max_texture_size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_get_max_texture_size(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/base.pyx":292 */
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.get_max_texture_size");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya__set_default_material(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__set_default_material(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"material",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_material)) return 0;
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":304 */
  Py_INCREF(((PyObject *)__pyx_v_material));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL));
  __pyx_v_5_soya__DEFAULT_MATERIAL = ((PyObject *)__pyx_v_material);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._set_default_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya__set_shader_default_material(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__set_shader_default_material(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"material",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_material)) return 0;
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":310 */
  Py_INCREF(((PyObject *)__pyx_v_material));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__SHADER_DEFAULT_MATERIAL));
  __pyx_v_5_soya__SHADER_DEFAULT_MATERIAL = ((PyObject *)__pyx_v_material);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._set_shader_default_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static char (*__pyx_f_5_soya_dup(char (*__pyx_v_data),int __pyx_v_size)) {
  char (*__pyx_v_buffer);
  char (*__pyx_r);

  /* "/home/jiba/src/soya/base.pyx":316 */
  __pyx_v_buffer = ((char (*))malloc(__pyx_v_size));

  /* "/home/jiba/src/soya/base.pyx":317 */
  memcpy(__pyx_v_buffer,__pyx_v_data,__pyx_v_size);

  /* "/home/jiba/src/soya/base.pyx":318 */
  __pyx_r = __pyx_v_buffer;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.dup");
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_n___new__;

static PyObject *__pyx_f_5_soya__reconstructor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__reconstructor(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_clazz = 0;
  struct __pyx_obj_5_soya__CObj *__pyx_v_obj;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"clazz",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_clazz)) return 0;
  Py_INCREF(__pyx_v_clazz);
  __pyx_v_obj = Py_None; Py_INCREF((PyObject *) __pyx_v_obj);

  /* "/home/jiba/src/soya/base.pyx":324 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_clazz, __pyx_n___new__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
  Py_INCREF(__pyx_v_clazz);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_clazz);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__CObj)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_obj));
  __pyx_v_obj = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/base.pyx":325 */
  Py_INCREF(((PyObject *)__pyx_v_obj));
  __pyx_r = ((PyObject *)__pyx_v_obj);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._reconstructor");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_clazz);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_CObj___getcstate__(struct __pyx_obj_5_soya__CObj *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/base.pyx":329 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._CObj.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_CObj___setcstate__(struct __pyx_obj_5_soya__CObj *__pyx_v_self,PyObject *__pyx_v_cstate) {
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/base.pyx":332 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CObj.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_n_getattr;
static PyObject *__pyx_n___dict__;


static PyObject *__pyx_f_5_soya_5_CObj___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_CObj___getstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/base.pyx":335 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_getattr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  Py_INCREF(__pyx_n___dict__);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n___dict__);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__CObj *)((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)->__pyx_vtab)->__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n___dict__); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
    __pyx_1 = 0;
    __pyx_3 = 0;
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__CObj *)((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)->__pyx_vtab)->__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._CObj.__getstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_CObj___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_CObj___setstate__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  static char *__pyx_argnames[] = {"state",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_state)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_state);

  /* "/home/jiba/src/soya/base.pyx":339 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  ((struct __pyx_vtabstruct_5_soya__CObj *)((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)->__pyx_vtab)->__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/base.pyx":340 */
  __pyx_3 = PyObject_Length(__pyx_v_state); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
  __pyx_4 = (__pyx_3 > 1);
  if (__pyx_4) {
    __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (PyObject_SetAttr(__pyx_v_self, __pyx_n___dict__, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._CObj.__setstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_state);
  return __pyx_r;
}

static PyObject *__pyx_n___class__;
static PyObject *__pyx_n___getstate__;

static PyObject *__pyx_f_5_soya_5_CObj___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_CObj___reduce__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/base.pyx":343 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__reconstructor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n___getstate__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_5);
  __pyx_1 = 0;
  __pyx_3 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._CObj.__reduce__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_copy;
static PyObject *__pyx_n_id;
static PyObject *__pyx_n_deepcopy;
static PyObject *__pyx_n___setstate__;


static PyObject *__pyx_f_5_soya_5_CObj___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_CObj___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_memo = 0;
  struct __pyx_obj_5_soya__CObj *__pyx_v_clone;
  PyObject *__pyx_v_copy;
  PyObject *__pyx_v_state;
  PyObject *__pyx_v_state_clone;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"memo",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_memo)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_memo);
  __pyx_v_clone = Py_None; Py_INCREF((PyObject *) __pyx_v_clone);
  __pyx_v_copy = Py_None; Py_INCREF(__pyx_v_copy);
  __pyx_v_state = Py_None; Py_INCREF(__pyx_v_state);
  __pyx_v_state_clone = Py_None; Py_INCREF(__pyx_v_state_clone);

  /* "/home/jiba/src/soya/base.pyx":348 */
  __pyx_1 = __Pyx_Import(__pyx_n_copy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; goto __pyx_L1;}
  Py_DECREF(__pyx_v_copy);
  __pyx_v_copy = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/base.pyx":349 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___new__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__CObj)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  Py_INCREF(__pyx_1);
  Py_DECREF(((PyObject *)__pyx_v_clone));
  __pyx_v_clone = __pyx_1;
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (PyObject_SetItem(__pyx_v_memo, __pyx_4, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/base.pyx":351 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n___getstate__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_state);
  __pyx_v_state = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/base.pyx":352 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_copy, __pyx_n_deepcopy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  Py_INCREF(__pyx_v_state);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_state);
  Py_INCREF(__pyx_v_memo);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_memo);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_state_clone);
  __pyx_v_state_clone = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/base.pyx":353 */
  __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_clone), __pyx_n___setstate__); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
  Py_INCREF(__pyx_v_state_clone);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_state_clone);
  __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/base.pyx":355 */
  Py_INCREF(((PyObject *)__pyx_v_clone));
  __pyx_r = ((PyObject *)__pyx_v_clone);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._CObj.__deepcopy__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_clone);
  Py_DECREF(__pyx_v_copy);
  Py_DECREF(__pyx_v_state);
  Py_DECREF(__pyx_v_state_clone);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_memo);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_chunk_to_string(__pyx_t_5_soya_Chunk (*__pyx_v_chunk)) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;

  /* "/home/jiba/src/soya/base.pyx":359 */
  __pyx_1 = PyString_FromStringAndSize(((char (*))__pyx_v_chunk->content),__pyx_v_chunk->nb); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.chunk_to_string");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_drop_chunk_to_string(__pyx_t_5_soya_Chunk (*__pyx_v_chunk)) {
  PyObject *__pyx_v_string;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  __pyx_v_string = Py_None; Py_INCREF(__pyx_v_string);

  /* "/home/jiba/src/soya/base.pyx":363 */
  __pyx_1 = PyString_FromStringAndSize(((char (*))__pyx_v_chunk->content),__pyx_v_chunk->nb); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; goto __pyx_L1;}
  Py_DECREF(__pyx_v_string);
  __pyx_v_string = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/base.pyx":364 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/base.pyx":365 */
  Py_INCREF(__pyx_v_string);
  __pyx_r = __pyx_v_string;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.drop_chunk_to_string");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_string);
  return __pyx_r;
}

static __pyx_t_5_soya_Chunk (*__pyx_f_5_soya_string_to_chunk(PyObject *__pyx_v_string)) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int __pyx_v_length;
  __pyx_t_5_soya_Chunk (*__pyx_r);
  int __pyx_1;
  Py_INCREF(__pyx_v_string);

  /* "/home/jiba/src/soya/base.pyx":370 */
  __pyx_1 = PyObject_Length(__pyx_v_string); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; goto __pyx_L1;}
  __pyx_v_length = __pyx_1;

  /* "/home/jiba/src/soya/base.pyx":371 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/base.pyx":372 */
  chunk_register(__pyx_v_chunk,__pyx_v_length);

  /* "/home/jiba/src/soya/base.pyx":373 */
  memcpy(__pyx_v_chunk->content,PyString_AS_STRING(__pyx_v_string),__pyx_v_length);

  /* "/home/jiba/src/soya/base.pyx":374 */
  __pyx_v_chunk->nb = 0;

  /* "/home/jiba/src/soya/base.pyx":375 */
  __pyx_r = __pyx_v_chunk;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.string_to_chunk");
  __pyx_L0:;
  Py_DECREF(__pyx_v_string);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_set_quality(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_set_quality(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_q;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"q",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_q)) return 0;

  /* "/home/jiba/src/soya/init.pyx":25 */
  __pyx_v_5_soya_quality = __pyx_v_q;

  /* "/home/jiba/src/soya/init.pyx":26 */
  __pyx_1 = (__pyx_v_q == __pyx_e_5_soya_QUALITY_LOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":27 */
    glHint(GL_FOG_HINT,GL_FASTEST);

    /* "/home/jiba/src/soya/init.pyx":28 */
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_FASTEST);

    /* "/home/jiba/src/soya/init.pyx":29 */
    glHint(GL_POINT_SMOOTH_HINT,GL_FASTEST);

    /* "/home/jiba/src/soya/init.pyx":30 */
    glHint(GL_LINE_SMOOTH_HINT,GL_FASTEST);

    /* "/home/jiba/src/soya/init.pyx":31 */
    glHint(GL_POLYGON_SMOOTH_HINT,GL_FASTEST);

    /* "/home/jiba/src/soya/init.pyx":32 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option & (~__pyx_e_5_soya_SHADOWS));
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_q == __pyx_e_5_soya_QUALITY_MEDIUM);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":35 */
    glHint(GL_FOG_HINT,GL_DONT_CARE);

    /* "/home/jiba/src/soya/init.pyx":36 */
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_DONT_CARE);

    /* "/home/jiba/src/soya/init.pyx":37 */
    glHint(GL_POINT_SMOOTH_HINT,GL_DONT_CARE);

    /* "/home/jiba/src/soya/init.pyx":38 */
    glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE);

    /* "/home/jiba/src/soya/init.pyx":39 */
    glHint(GL_POLYGON_SMOOTH_HINT,GL_DONT_CARE);

    /* "/home/jiba/src/soya/init.pyx":40 */
    __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_HAS_STENCIL);
    if (__pyx_1) {
      __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option | __pyx_e_5_soya_SHADOWS);
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_q == __pyx_e_5_soya_QUALITY_HIGH);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":43 */
    glHint(GL_FOG_HINT,GL_NICEST);

    /* "/home/jiba/src/soya/init.pyx":44 */
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);

    /* "/home/jiba/src/soya/init.pyx":45 */
    glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);

    /* "/home/jiba/src/soya/init.pyx":46 */
    glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);

    /* "/home/jiba/src/soya/init.pyx":47 */
    glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);

    /* "/home/jiba/src/soya/init.pyx":48 */
    __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_HAS_STENCIL);
    if (__pyx_1) {
      __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option | __pyx_e_5_soya_SHADOWS);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.set_quality");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_toggle_wireframe(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_toggle_wireframe(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/init.pyx":51 */
  __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_WIREFRAME);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":52 */
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

    /* "/home/jiba/src/soya/init.pyx":53 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option & (~__pyx_e_5_soya_WIREFRAME));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":55 */
    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);

    /* "/home/jiba/src/soya/init.pyx":56 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option | __pyx_e_5_soya_WIREFRAME);
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.toggle_wireframe");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_k159p;

static char (__pyx_k159[]) = "\n* Soya * version %s\n* Using OpenGL %s\n*   - renderer : %s\n*   - vendor   : %s\n*   - maximum number of lights        : %s\n*   - maximum number of clip planes   : %s\n*   - maximum number of texture units : %s\n*   - maximum texture size            : %s pixels\n";

static void __pyx_f_5_soya_dump_info(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;

  /* "/home/jiba/src/soya/init.pyx":59 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_VERSION); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; goto __pyx_L1;}
  __pyx_2 = PyString_FromString(((char (*))glGetString(GL_VERSION))); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; goto __pyx_L1;}
  __pyx_3 = PyString_FromString(((char (*))glGetString(GL_RENDERER))); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 71; goto __pyx_L1;}
  __pyx_4 = PyString_FromString(((char (*))glGetString(GL_VENDOR))); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_5_soya_MAX_LIGHTS); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; goto __pyx_L1;}
  __pyx_6 = PyInt_FromLong(__pyx_v_5_soya_MAX_CLIP_PLANES); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_7 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURES); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; goto __pyx_L1;}
  __pyx_8 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(8); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_9, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_9, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_9, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_9, 3, __pyx_4);
  PyTuple_SET_ITEM(__pyx_9, 4, __pyx_5);
  PyTuple_SET_ITEM(__pyx_9, 5, __pyx_6);
  PyTuple_SET_ITEM(__pyx_9, 6, __pyx_7);
  PyTuple_SET_ITEM(__pyx_9, 7, __pyx_8);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k159p, __pyx_9); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 68; goto __pyx_L1;}
  Py_DECREF(__pyx_9); __pyx_9 = 0;
  if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_WriteUnraisable("_soya.dump_info");
  __pyx_L0:;
}

static PyObject *__pyx_n_append;

static PyObject *__pyx_k160p;
static PyObject *__pyx_k161p;
static PyObject *__pyx_k162p;

static char (__pyx_k160[]) = "";
static char (__pyx_k161[]) = "* Soya 3D * Warning : glGetString returns NULL!";
static char (__pyx_k162[]) = "DRI Radeon";

static void __pyx_f_5_soya_init_gl(void) {
  int __pyx_v_i;
  GLfloat (__pyx_v_black[4]);
  char (*__pyx_v_gl_renderer);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;

  /* "/home/jiba/src/soya/init.pyx":82 */
  glGetIntegerv(GL_MAX_LIGHTS,(&__pyx_v_5_soya_MAX_LIGHTS));

  /* "/home/jiba/src/soya/init.pyx":83 */
  glGetIntegerv(GL_MAX_CLIP_PLANES,(&__pyx_v_5_soya_MAX_CLIP_PLANES));

  /* "/home/jiba/src/soya/init.pyx":84 */
  glGetIntegerv(GL_MAX_TEXTURE_UNITS,(&__pyx_v_5_soya_MAX_TEXTURES));

  /* "/home/jiba/src/soya/init.pyx":85 */
  glGetIntegerv(GL_MAX_TEXTURE_SIZE,(&__pyx_v_5_soya_MAX_TEXTURE_SIZE));

  /* "/home/jiba/src/soya/init.pyx":88 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_5_soya_MAX_LIGHTS; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/init.pyx":89 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_5_soya_LIGHTS, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; goto __pyx_L1;}
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_2, 0, Py_None);
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/init.pyx":90 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_5_soya_LAST_LIGHTS, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;}
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_2, 0, Py_None);
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":92 */
  glClearDepth(1.0);

  /* "/home/jiba/src/soya/init.pyx":93 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/init.pyx":94 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/init.pyx":96 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/init.pyx":98 */
  glDisable(GL_COLOR_MATERIAL);

  /* "/home/jiba/src/soya/init.pyx":99 */
  glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);

  /* "/home/jiba/src/soya/init.pyx":100 */
  glEnable(GL_COLOR_MATERIAL);

  /* "/home/jiba/src/soya/init.pyx":103 */
  (__pyx_v_black[3]) = 1.0;

  /* "/home/jiba/src/soya/init.pyx":104 */
  glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,__pyx_v_black);

  /* "/home/jiba/src/soya/init.pyx":105 */
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);

  /* "/home/jiba/src/soya/init.pyx":106 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/init.pyx":108 */
  glDisable(GL_NORMALIZE);

  /* "/home/jiba/src/soya/init.pyx":110 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/init.pyx":111 */
  glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

  /* "/home/jiba/src/soya/init.pyx":112 */
  glDisable(GL_ALPHA_TEST);

  /* "/home/jiba/src/soya/init.pyx":113 */
  glAlphaFunc(GL_NOTEQUAL,0.0);

  /* "/home/jiba/src/soya/init.pyx":115 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/init.pyx":116 */
  glCullFace(GL_BACK);

  /* "/home/jiba/src/soya/init.pyx":117 */
  glFrontFace(GL_CCW);

  /* "/home/jiba/src/soya/init.pyx":119 */
  glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

  /* "/home/jiba/src/soya/init.pyx":120 */
  glEnable(GL_POINT_SMOOTH);

  /* "/home/jiba/src/soya/init.pyx":121 */
  glDisable(GL_LINE_SMOOTH);

  /* "/home/jiba/src/soya/init.pyx":122 */
  glDisable(GL_POLYGON_SMOOTH);

  /* "/home/jiba/src/soya/init.pyx":123 */
  glShadeModel(GL_SMOOTH);

  /* "/home/jiba/src/soya/init.pyx":125 */
  glDisable(GL_DITHER);

  /* "/home/jiba/src/soya/init.pyx":127 */
  glPixelStorei(GL_PACK_ALIGNMENT,1);

  /* "/home/jiba/src/soya/init.pyx":128 */
  glPixelStorei(GL_UNPACK_ALIGNMENT,1);

  /* "/home/jiba/src/soya/init.pyx":129 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);

  /* "/home/jiba/src/soya/init.pyx":130 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);

  /* "/home/jiba/src/soya/init.pyx":133 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/init.pyx":134 */
  glColor4f(1.0,1.0,1.0,1.0);

  /* "/home/jiba/src/soya/init.pyx":137 */
  __pyx_v_5_soya_SHADOW_DISPLAY_LIST = glGenLists(1);

  /* "/home/jiba/src/soya/init.pyx":138 */
  __pyx_v_5_soya_SHADOW_TESS_CHUNK = chunk_new();

  /* "/home/jiba/src/soya/init.pyx":139 */
  __pyx_v_5_soya_SHADOW_TESS = gluNewTess();

  /* "/home/jiba/src/soya/init.pyx":141 */
  gluTessCallback(__pyx_v_5_soya_SHADOW_TESS,GLU_TESS_BEGIN,((void ((*)(void)))glBegin));

  /* "/home/jiba/src/soya/init.pyx":142 */
  gluTessCallback(__pyx_v_5_soya_SHADOW_TESS,GLU_TESS_VERTEX,((void ((*)(void)))glVertex3dv));

  /* "/home/jiba/src/soya/init.pyx":143 */
  gluTessCallback(__pyx_v_5_soya_SHADOW_TESS,GLU_TESS_END,((void ((*)(void)))glEnd));

  /* "/home/jiba/src/soya/init.pyx":144 */
  gluTessCallback(__pyx_v_5_soya_SHADOW_TESS,GLU_TESS_COMBINE,((void ((*)(void)))__pyx_f_5_soya_shape_shadow_tess_combine));

  /* "/home/jiba/src/soya/init.pyx":147 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_set_quality); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_5_soya_quality); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/init.pyx":151 */
  __pyx_v_gl_renderer = ((char (*))glGetString(GL_RENDERER));

  /* "/home/jiba/src/soya/init.pyx":152 */
  __pyx_4 = (__pyx_v_gl_renderer == 0);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/init.pyx":153 */
    Py_INCREF(__pyx_k160p);
    Py_DECREF(__pyx_v_5_soya_DRIVER_3D);
    __pyx_v_5_soya_DRIVER_3D = __pyx_k160p;

    /* "/home/jiba/src/soya/init.pyx":154 */
    if (__Pyx_PrintItem(__pyx_k161p) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 154; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":155 */
    __pyx_4 = __pyx_f_5_soya_check_gl_error(); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; goto __pyx_L1;}
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":157 */
    __pyx_1 = PyString_FromString(((char (*))glGetString(GL_RENDERER))); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 157; goto __pyx_L1;}
    Py_DECREF(__pyx_v_5_soya_DRIVER_3D);
    __pyx_v_5_soya_DRIVER_3D = __pyx_1;
    __pyx_1 = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/init.pyx":158 */
  __pyx_4 = PySequence_Contains(__pyx_v_5_soya_DRIVER_3D, __pyx_k162p); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; goto __pyx_L1;}
  if (__pyx_4) {

    /* "/home/jiba/src/soya/init.pyx":168 */
    __pyx_v_5_soya_CAN_USE_TEX_BORDER = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya.init_gl");
  __pyx_L0:;
}

static void __pyx_f_5_soya_base_init(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;

  /* "/home/jiba/src/soya/init.pyx":173 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_Renderer), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_Renderer)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_5_soya_renderer));
  __pyx_v_5_soya_renderer = __pyx_2;
  __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya.base_init");
  __pyx_L0:;
}

static PyObject *__pyx_n_fx_quit;

static PyObject *__pyx_k163p;

static char (__pyx_k163[]) = "* Soya3D * Quit...";

static void __pyx_f_5_soya_base_quit(void) {
  int __pyx_v_i;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/jiba/src/soya/init.pyx":181 */
  if (__Pyx_PrintItem(__pyx_k163p) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; goto __pyx_L1;}
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; goto __pyx_L1;}

  /* "/home/jiba/src/soya/init.pyx":187 */
  __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_FX_INITED);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_fx_quit); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 187; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 187; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 187; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/init.pyx":194 */
  __pyx_1 = (__pyx_v_5_soya_SHADOW_DISPLAY_LIST != (-1));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":195 */
    glDeleteLists(__pyx_v_5_soya_SHADOW_DISPLAY_LIST,1);

    /* "/home/jiba/src/soya/init.pyx":196 */
    chunk_dealloc(__pyx_v_5_soya_SHADOW_TESS_CHUNK);

    /* "/home/jiba/src/soya/init.pyx":197 */
    gluDeleteTess(__pyx_v_5_soya_SHADOW_TESS);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":200 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_5_soya_NB_JOYSTICK; ++__pyx_v_i) {
    SDL_JoystickClose((__pyx_v_5_soya_JOYSTICKS[__pyx_v_i]));
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/init.pyx":201 */
  SDL_Quit();

  /* "/home/jiba/src/soya/init.pyx":203 */
  free(__pyx_v_5_soya_JOYSTICKS);

  /* "/home/jiba/src/soya/init.pyx":204 */
  __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option & (~__pyx_e_5_soya_INITED));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya.base_quit");
  __pyx_L0:;
}

static void __pyx_f_5_soya_init_joysticks(void) {
  int __pyx_v_i;
  int __pyx_1;

  /* "/home/jiba/src/soya/init.pyx":210 */
  __pyx_v_5_soya_NB_JOYSTICK = SDL_NumJoysticks();

  /* "/home/jiba/src/soya/init.pyx":212 */
  __pyx_1 = (__pyx_v_5_soya_NB_JOYSTICK > 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":213 */
    SDL_JoystickEventState(SDL_ENABLE);

    /* "/home/jiba/src/soya/init.pyx":214 */
    __pyx_v_5_soya_JOYSTICKS = ((SDL_Joystick (*(*)))malloc((__pyx_v_5_soya_NB_JOYSTICK * (sizeof(SDL_Joystick (*))))));

    /* "/home/jiba/src/soya/init.pyx":215 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_5_soya_NB_JOYSTICK; ++__pyx_v_i) {
      (__pyx_v_5_soya_JOYSTICKS[__pyx_v_i]) = SDL_JoystickOpen(__pyx_v_i);
      __pyx_L3:;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.init_joysticks");
  __pyx_L0:;
}

static PyObject *__pyx_n_RuntimeError;

static PyObject *__pyx_k164p;

static char (__pyx_k164[]) = "Video query failed : %s";

static PyObject *__pyx_f_5_soya_set_gamma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_set_gamma[] = "Defines gamma correction.\n    Usage : soya.set_gamma(red_gamma,green_gamma,blue_gamma)\n    if XXX_gamma=1.0 : no change\n    >1.0 : dark\n    <1.0 : bright";
static PyObject *__pyx_f_5_soya_set_gamma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_r_gamma;
  float __pyx_v_g_gamma;
  float __pyx_v_b_gamma;
  int __pyx_v_i;
  PyObject *__pyx_v_s;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"r_gamma","g_gamma","b_gamma",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_r_gamma, &__pyx_v_g_gamma, &__pyx_v_b_gamma)) return 0;
  __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);

  /* "/home/jiba/src/soya/init.pyx":224 */
  __pyx_v_i = SDL_SetGamma(__pyx_v_r_gamma,__pyx_v_g_gamma,__pyx_v_b_gamma);

  /* "/home/jiba/src/soya/init.pyx":225 */
  __pyx_1 = (__pyx_v_i < 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":226 */
    __pyx_2 = PyString_FromString(SDL_GetError()); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k164p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/init.pyx":227 */
    if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":228 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; goto __pyx_L1;}
    Py_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 228; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.set_gamma");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

static PyObject *__pyx_n_time;
static PyObject *__pyx_n_sleep;
static PyObject *__pyx_n_resize;

static PyObject *__pyx_k165p;
static PyObject *__pyx_k166p;
static PyObject *__pyx_k167p;
static PyObject *__pyx_k168p;
static PyObject *__pyx_k171p;

static char (__pyx_k165[]) = "Video query failed : %s";
static char (__pyx_k166[]) = "Video mode set failed : %s";
static char (__pyx_k167[]) = "* Soya * Failed to set stencil buffer, shadows will be disabled.";
static char (__pyx_k168[]) = "* Soya * Using %i bits stencil buffer";
static char (__pyx_k171[]) = "* Soya * ERROR : OpenGL is not ready... Soya will crash soon i guess :-(";

static PyObject *__pyx_f_5_soya_set_video(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_set_video(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_fullscreen;
  int __pyx_v_resizable;
  int __pyx_v_stencil;
  int __pyx_v_bits_per_pixel;
  unsigned int __pyx_v_flags;
  SDL_VideoInfo (*__pyx_v_info);
  PyObject *__pyx_v_s;
  int __pyx_v_i;
  PyObject *__pyx_v_sleep;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  unsigned int __pyx_5;
  int __pyx_6;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"width","height","fullscreen","resizable",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iiii", __pyx_argnames, &__pyx_v_width, &__pyx_v_height, &__pyx_v_fullscreen, &__pyx_v_resizable)) return 0;
  __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);
  __pyx_v_sleep = Py_None; Py_INCREF(__pyx_v_sleep);

  /* "/home/jiba/src/soya/init.pyx":234 */
  __pyx_v_5_soya_renderer->screen_width = __pyx_v_width;

  /* "/home/jiba/src/soya/init.pyx":235 */
  __pyx_v_5_soya_renderer->screen_height = __pyx_v_height;

  /* "/home/jiba/src/soya/init.pyx":237 */
  __pyx_v_info = SDL_GetVideoInfo();

  /* "/home/jiba/src/soya/init.pyx":238 */
  __pyx_1 = (__pyx_v_info == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":239 */
    __pyx_2 = PyString_FromString(SDL_GetError()); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 239; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k165p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 239; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/init.pyx":240 */
    if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":241 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; goto __pyx_L1;}
    Py_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 241; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/init.pyx":246 */
  __pyx_v_bits_per_pixel = __pyx_v_info->vfmt->BitsPerPixel;

  /* "/home/jiba/src/soya/init.pyx":247 */
  __pyx_v_flags = ((SDL_OPENGL | SDL_GL_DOUBLEBUFFER) | SDL_HWPALETTE);

  /* "/home/jiba/src/soya/init.pyx":248 */
  __pyx_1 = (__pyx_v_fullscreen == 0);
  if (__pyx_1) {
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option & (~__pyx_e_5_soya_FULLSCREEN));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":250 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option | __pyx_e_5_soya_FULLSCREEN);

    /* "/home/jiba/src/soya/init.pyx":251 */
    __pyx_v_flags = (__pyx_v_flags | SDL_FULLSCREEN);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":253 */
  __pyx_1 = (__pyx_v_resizable == 1);
  if (__pyx_1) {
    __pyx_v_flags = (__pyx_v_flags | SDL_RESIZABLE);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/init.pyx":254 */
  __pyx_5 = __pyx_v_info->hw_available;
  if (__pyx_5) {
    __pyx_v_flags = (__pyx_v_flags | SDL_HWSURFACE);
    goto __pyx_L5;
  }
  /*else*/ {
    __pyx_v_flags = (__pyx_v_flags | SDL_SWSURFACE);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/init.pyx":256 */
  __pyx_5 = __pyx_v_info->blit_hw;
  if (__pyx_5) {
    __pyx_v_flags = (__pyx_v_flags | SDL_HWACCEL);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/init.pyx":257 */
  __pyx_v_stencil = 16;

  /* "/home/jiba/src/soya/init.pyx":258 */
  while (1) {
    __pyx_L7:;
    __pyx_1 = (__pyx_v_stencil > 1);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/init.pyx":259 */
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,__pyx_v_stencil);

    /* "/home/jiba/src/soya/init.pyx":261 */
    __pyx_v_5_soya_renderer->screen = SDL_SetVideoMode(__pyx_v_width,__pyx_v_height,__pyx_v_bits_per_pixel,__pyx_v_flags);

    /* "/home/jiba/src/soya/init.pyx":262 */
    __pyx_1 = (__pyx_v_5_soya_renderer->screen == 0);
    if (__pyx_1) {
      __pyx_v_stencil = (__pyx_v_stencil >> 1);
      goto __pyx_L9;
    }
    /*else*/ {
      goto __pyx_L8;
    }
    __pyx_L9:;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/init.pyx":265 */
  __pyx_1 = (__pyx_v_5_soya_renderer->screen == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":266 */
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,0);

    /* "/home/jiba/src/soya/init.pyx":267 */
    __pyx_v_5_soya_renderer->screen = SDL_SetVideoMode(__pyx_v_width,__pyx_v_height,__pyx_v_bits_per_pixel,__pyx_v_flags);

    /* "/home/jiba/src/soya/init.pyx":268 */
    __pyx_1 = (__pyx_v_5_soya_renderer->screen == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/init.pyx":269 */
      __pyx_2 = PyString_FromString(SDL_GetError()); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 269; goto __pyx_L1;}
      __pyx_3 = PyNumber_Remainder(__pyx_k166p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 269; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/init.pyx":270 */
      if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 270; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 270; goto __pyx_L1;}

      /* "/home/jiba/src/soya/init.pyx":271 */
      __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; goto __pyx_L1;}
      Py_INCREF(__pyx_v_s);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_s);
      __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; goto __pyx_L1;}
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/init.pyx":272 */
    if (__Pyx_PrintItem(__pyx_k167p) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":273 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option & (~__pyx_e_5_soya_HAS_STENCIL));

    /* "/home/jiba/src/soya/init.pyx":274 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option & (~__pyx_e_5_soya_SHADOWS));
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":276 */
    __pyx_4 = PyInt_FromLong(__pyx_v_stencil); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; goto __pyx_L1;}
    __pyx_2 = PyNumber_Remainder(__pyx_k168p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":277 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option | __pyx_e_5_soya_HAS_STENCIL);
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/init.pyx":281 */
  __pyx_3 = PyList_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 281; goto __pyx_L1;}
  Py_INCREF(__pyx_n_sleep);
  PyList_SET_ITEM(__pyx_3, 0, __pyx_n_sleep);
  __pyx_4 = __Pyx_Import(__pyx_n_time, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 281; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_sleep); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 281; goto __pyx_L1;}
  Py_DECREF(__pyx_v_sleep);
  __pyx_v_sleep = __pyx_2;
  __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/init.pyx":282 */
  for (__pyx_v_i = 0; __pyx_v_i < 10; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/init.pyx":283 */
    __pyx_1 = (glGetString(GL_RENDERER) != 0);
    if (__pyx_1) {
      goto __pyx_L13;
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/home/jiba/src/soya/init.pyx":284 */
    __pyx_3 = PyFloat_FromDouble(0.1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_v_sleep, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 284; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_L12:;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":286 */
    if (__Pyx_PrintItem(__pyx_k171p) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 286; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 286; goto __pyx_L1;}
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/init.pyx":289 */
  glViewport(0,0,__pyx_v_5_soya_renderer->screen_width,__pyx_v_5_soya_renderer->screen_height);

  /* "/home/jiba/src/soya/init.pyx":290 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/init.pyx":291 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/init.pyx":292 */
  glOrtho(0.0,((GLfloat )__pyx_v_width),((GLfloat )__pyx_v_height),0.0,(-1.0),1.0);

  /* "/home/jiba/src/soya/init.pyx":293 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/init.pyx":294 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/init.pyx":297 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 297; goto __pyx_L1;}
  __pyx_1 = __pyx_3 == Py_None;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_6 = (!__pyx_1);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/init.pyx":298 */
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_resize); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    __pyx_7 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    __pyx_8 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_9, 0, __pyx_3);
    PyTuple_SET_ITEM(__pyx_9, 1, __pyx_4);
    PyTuple_SET_ITEM(__pyx_9, 2, __pyx_7);
    PyTuple_SET_ITEM(__pyx_9, 3, __pyx_8);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_7 = 0;
    __pyx_8 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_9); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_9); __pyx_9 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L15;
  }
  __pyx_L15:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.set_video");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_sleep);
  return __pyx_r;
}

static PyObject *__pyx_n_sys;
static PyObject *__pyx_n_platform;
static PyObject *__pyx_n_darwin;

static PyObject *__pyx_k174p;
static PyObject *__pyx_k175p;
static PyObject *__pyx_k176p;

static char (__pyx_k174[]) = "* Soya * Initializing for MacOSX...";
static char (__pyx_k175[]) = "soya.macosx";
static char (__pyx_k176[]) = "Could not initialize SDL : %s";

static void __pyx_f_5_soya_init_video(char (*__pyx_v_title),int __pyx_v_width,int __pyx_v_height,int __pyx_v_fullscreen,int __pyx_v_resizable) {
  PyObject *__pyx_v_sys;
  PyObject *__pyx_v_soya;
  PyObject *__pyx_v_s;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  __pyx_v_sys = Py_None; Py_INCREF(__pyx_v_sys);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);
  __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);

  /* "/home/jiba/src/soya/init.pyx":302 */
  __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 302; goto __pyx_L1;}
  Py_DECREF(__pyx_v_sys);
  __pyx_v_sys = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/init.pyx":303 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_sys, __pyx_n_platform); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_1, __pyx_n_darwin, &__pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; goto __pyx_L1;}
  __pyx_2 = __pyx_2 == 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/init.pyx":304 */
    if (__Pyx_PrintItem(__pyx_k174p) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 304; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":305 */
    __pyx_1 = __Pyx_Import(__pyx_k175p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_v_soya);
    __pyx_v_soya = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/init.pyx":308 */
  __pyx_2 = (SDL_Init(((SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) | SDL_INIT_NOPARACHUTE)) < 0);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/init.pyx":309 */
    __pyx_1 = PyString_FromString(SDL_GetError()); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 309; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k176p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 309; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_v_s);
    __pyx_v_s = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/init.pyx":310 */
    if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 310; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 310; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":311 */
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; goto __pyx_L1;}
    Py_INCREF(__pyx_v_s);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_s);
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":312 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_set_video); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_height); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_fullscreen); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_6 = PyInt_FromLong(__pyx_v_resizable); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_7, 2, __pyx_5);
  PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_7); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/init.pyx":313 */
  __pyx_2 = (__pyx_v_title != 0);
  if (__pyx_2) {
    SDL_WM_SetCaption(__pyx_v_title,0);
    goto __pyx_L4;
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_WriteUnraisable("_soya.init_video");
  __pyx_L0:;
  Py_DECREF(__pyx_v_sys);
  Py_DECREF(__pyx_v_soya);
  Py_DECREF(__pyx_v_s);
}

static PyObject *__pyx_n_atexit;
static PyObject *__pyx_n_register;
static PyObject *__pyx_n_soya;
static PyObject *__pyx_n_inited;


static PyObject *__pyx_f_5_soya_init(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_init[] = "init(title = \"Soya 3D\", width = 640, height = 480, fullscreen = 0, resizeable = 1, create_surface = 1)\n\nInits Soya 3D and display the 3D view.\n\nTITLE is the title of the window.\nWIDTH and HEIGHT the dimensions of the 3D view.\nFULLSCREEN is true for fullscreen and false for windowed mode.\nRESIZEABLE is true for a resizeable window.";
static PyObject *__pyx_f_5_soya_init(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_title = 0;
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_fullscreen;
  int __pyx_v_resizeable;
  int __pyx_v_create_surface;
  PyObject *__pyx_v_SDL_UNICODE;
  PyObject *__pyx_v_atexit;
  PyObject *__pyx_v_soya;
  PyObject *__pyx_r;
  int __pyx_1;
  char (*__pyx_2);
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"title","width","height","fullscreen","resizeable","create_surface",0};
  __pyx_v_title = __pyx_k3;
  __pyx_v_width = __pyx_k4;
  __pyx_v_height = __pyx_k5;
  __pyx_v_fullscreen = __pyx_k6;
  __pyx_v_resizeable = __pyx_k7;
  __pyx_v_create_surface = __pyx_k8;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|Oiiiii", __pyx_argnames, &__pyx_v_title, &__pyx_v_width, &__pyx_v_height, &__pyx_v_fullscreen, &__pyx_v_resizeable, &__pyx_v_create_surface)) return 0;
  Py_INCREF(__pyx_v_title);
  __pyx_v_SDL_UNICODE = Py_None; Py_INCREF(__pyx_v_SDL_UNICODE);
  __pyx_v_atexit = Py_None; Py_INCREF(__pyx_v_atexit);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);

  /* "/home/jiba/src/soya/init.pyx":325 */
  __pyx_1 = (!(__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_INITED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":326 */
    __pyx_f_5_soya_base_init();

    /* "/home/jiba/src/soya/init.pyx":327 */
    __pyx_1 = __pyx_v_create_surface;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/init.pyx":328 */
      __pyx_2 = PyString_AsString(__pyx_v_title); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 328; goto __pyx_L1;}
      __pyx_f_5_soya_init_video(__pyx_2,__pyx_v_width,__pyx_v_height,__pyx_v_fullscreen,__pyx_v_resizeable);
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/init.pyx":329 */
    __pyx_f_5_soya_init_joysticks();

    /* "/home/jiba/src/soya/init.pyx":330 */
    __pyx_f_5_soya_init_gl();

    /* "/home/jiba/src/soya/init.pyx":332 */
    glewInit();

    /* "/home/jiba/src/soya/init.pyx":334 */
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 334; goto __pyx_L1;}
    Py_DECREF(__pyx_v_SDL_UNICODE);
    __pyx_v_SDL_UNICODE = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/init.pyx":336 */
    __pyx_v_5_soya_renderer->engine_option = (__pyx_v_5_soya_renderer->engine_option | __pyx_e_5_soya_INITED);

    /* "/home/jiba/src/soya/init.pyx":338 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
    __pyx_1 = __pyx_3 == Py_None;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = (!__pyx_1);
    if (__pyx_4) {
      __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_resize); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(0); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      __pyx_7 = PyInt_FromLong(__pyx_v_width); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_height); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_9, 0, __pyx_3);
      PyTuple_SET_ITEM(__pyx_9, 1, __pyx_6);
      PyTuple_SET_ITEM(__pyx_9, 2, __pyx_7);
      PyTuple_SET_ITEM(__pyx_9, 3, __pyx_8);
      __pyx_3 = 0;
      __pyx_6 = 0;
      __pyx_7 = 0;
      __pyx_8 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_9); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 338; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_9); __pyx_9 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/init.pyx":340 */
    __pyx_6 = __Pyx_Import(__pyx_n_atexit, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 340; goto __pyx_L1;}
    Py_DECREF(__pyx_v_atexit);
    __pyx_v_atexit = __pyx_6;
    __pyx_6 = 0;

    /* "/home/jiba/src/soya/init.pyx":341 */
    __pyx_7 = PyObject_GetAttr(__pyx_v_atexit, __pyx_n_register); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 341; goto __pyx_L1;}
    __pyx_8 = __Pyx_GetName(__pyx_m, __pyx_n_quit); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 341; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 341; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_8);
    __pyx_8 = 0;
    __pyx_9 = PyObject_CallObject(__pyx_7, __pyx_5); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 341; goto __pyx_L1;}
    Py_DECREF(__pyx_7); __pyx_7 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_9); __pyx_9 = 0;

    /* "/home/jiba/src/soya/init.pyx":343 */
    __pyx_3 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 343; goto __pyx_L1;}
    Py_DECREF(__pyx_v_soya);
    __pyx_v_soya = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/init.pyx":344 */
    __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 344; goto __pyx_L1;}
    if (PyObject_SetAttr(__pyx_v_soya, __pyx_n_inited, __pyx_6) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 344; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/init.pyx":346 */
  __pyx_f_5_soya_dump_info();

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.init");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_SDL_UNICODE);
  Py_DECREF(__pyx_v_atexit);
  Py_DECREF(__pyx_v_soya);
  Py_DECREF(__pyx_v_title);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_quit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_quit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/init.pyx":349 */
  __pyx_f_5_soya_base_quit();

  /* "/home/jiba/src/soya/init.pyx":350 */
  __pyx_f_5_soya_quit_cal3d();

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.quit");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_set_use_unicode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_set_use_unicode[] = "when set process_event will return a 4 part tuple for a keydown event.\n  the fourth part contains the unicode symbol for the key.\n  usefull for getting CAPITALS and !£$% etc in text boxes for example ";
static PyObject *__pyx_f_5_soya_set_use_unicode(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"state",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_state)) return 0;
  Py_INCREF(__pyx_v_state);

  /* "/home/jiba/src/soya/init.pyx":358 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_state); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 358; goto __pyx_L1;}
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":359 */
    __pyx_v_5_soya_SDL_UNICODE = 1;

    /* "/home/jiba/src/soya/init.pyx":360 */
    SDL_EnableUNICODE(1);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":362 */
    __pyx_v_5_soya_SDL_UNICODE = 0;

    /* "/home/jiba/src/soya/init.pyx":363 */
    SDL_EnableUNICODE(0);
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.set_use_unicode");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_state);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_process_event(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_process_event(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_events;
  SDL_Event __pyx_v_event;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_v_events = Py_None; Py_INCREF(__pyx_v_events);

  /* "/home/jiba/src/soya/init.pyx":373 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 373; goto __pyx_L1;}
  Py_DECREF(__pyx_v_events);
  __pyx_v_events = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/init.pyx":375 */
  while (1) {
    __pyx_L2:;
    __pyx_2 = SDL_PollEvent((&__pyx_v_event));
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/init.pyx":376 */
    __pyx_2 = (__pyx_v_event.type == SDL_KEYDOWN);
    if (!__pyx_2) {
      __pyx_2 = (__pyx_v_event.type == SDL_KEYUP);
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":377 */
      __pyx_2 = (__pyx_v_5_soya_SDL_UNICODE == 1);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_event.type == SDL_KEYDOWN);
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/init.pyx":378 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_event.key.keysym.sym); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        __pyx_5 = PyInt_FromLong(__pyx_v_event.key.keysym.mod); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(__pyx_v_event.key.keysym.unicode); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_7, 0, __pyx_3);
        PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
        PyTuple_SET_ITEM(__pyx_7, 2, __pyx_5);
        PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
        __pyx_3 = 0;
        __pyx_4 = 0;
        __pyx_5 = 0;
        __pyx_6 = 0;
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_7);
        __pyx_7 = 0;
        __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 378; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/init.pyx":380 */
        __pyx_5 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        __pyx_7 = PyInt_FromLong(__pyx_v_event.key.keysym.sym); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        __pyx_1 = PyInt_FromLong(__pyx_v_event.key.keysym.mod); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6);
        PyTuple_SET_ITEM(__pyx_3, 1, __pyx_7);
        PyTuple_SET_ITEM(__pyx_3, 2, __pyx_1);
        __pyx_6 = 0;
        __pyx_7 = 0;
        __pyx_1 = 0;
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 380; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_event.type == SDL_MOUSEMOTION);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":382 */
      __pyx_7 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_1 = PyInt_FromLong(SDL_MOUSEMOTION); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(__pyx_v_event.motion.x); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(__pyx_v_event.motion.y); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_event.motion.xrel); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(__pyx_v_event.motion.yrel); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.motion.state); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_9 = PyTuple_New(6); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_9, 0, __pyx_1);
      PyTuple_SET_ITEM(__pyx_9, 1, __pyx_3);
      PyTuple_SET_ITEM(__pyx_9, 2, __pyx_5);
      PyTuple_SET_ITEM(__pyx_9, 3, __pyx_4);
      PyTuple_SET_ITEM(__pyx_9, 4, __pyx_6);
      PyTuple_SET_ITEM(__pyx_9, 5, __pyx_8);
      __pyx_1 = 0;
      __pyx_3 = 0;
      __pyx_5 = 0;
      __pyx_4 = 0;
      __pyx_6 = 0;
      __pyx_8 = 0;
      __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_9);
      __pyx_9 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_7, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 382; goto __pyx_L1;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_event.type == SDL_MOUSEBUTTONDOWN);
    if (!__pyx_2) {
      __pyx_2 = (__pyx_v_event.type == SDL_MOUSEBUTTONUP);
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":384 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(__pyx_v_event.button.button); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.button.x); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      __pyx_9 = PyInt_FromLong(__pyx_v_event.button.y); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_7, 0, __pyx_4);
      PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
      PyTuple_SET_ITEM(__pyx_7, 2, __pyx_8);
      PyTuple_SET_ITEM(__pyx_7, 3, __pyx_9);
      __pyx_4 = 0;
      __pyx_6 = 0;
      __pyx_8 = 0;
      __pyx_9 = 0;
      __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7);
      __pyx_7 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 384; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_event.type == SDL_JOYAXISMOTION);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":387 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(SDL_JOYAXISMOTION); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.jaxis.axis); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      __pyx_9 = PyInt_FromLong(__pyx_v_event.jaxis.value); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      __pyx_7 = PyTuple_New(3); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_7, 0, __pyx_6);
      PyTuple_SET_ITEM(__pyx_7, 1, __pyx_8);
      PyTuple_SET_ITEM(__pyx_7, 2, __pyx_9);
      __pyx_6 = 0;
      __pyx_8 = 0;
      __pyx_9 = 0;
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_7);
      __pyx_7 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 387; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_event.type == SDL_JOYBUTTONDOWN);
    if (!__pyx_2) {
      __pyx_2 = (__pyx_v_event.type == SDL_JOYBUTTONUP);
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":389 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.jbutton.button); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
      __pyx_9 = PyTuple_New(2); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_9, 0, __pyx_6);
      PyTuple_SET_ITEM(__pyx_9, 1, __pyx_8);
      __pyx_6 = 0;
      __pyx_8 = 0;
      __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_7, 0, __pyx_9);
      __pyx_9 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_7); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_event.type == SDL_QUIT);
    if (!__pyx_2) {
      __pyx_2 = (__pyx_v_event.type == SDL_VIDEOEXPOSE);
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":392 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; goto __pyx_L1;}
      __pyx_1 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_1);
      __pyx_1 = 0;
      __pyx_8 = PyTuple_New(1); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_8, 0, __pyx_6);
      __pyx_6 = 0;
      __pyx_9 = PyObject_CallObject(__pyx_5, __pyx_8); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 392; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_8); __pyx_8 = 0;
      Py_DECREF(__pyx_9); __pyx_9 = 0;
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_event.type == SDL_VIDEORESIZE);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/init.pyx":394 */
      __pyx_2 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_FULLSCREEN);
      if (__pyx_2) {
        __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_set_video); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_7 = PyInt_FromLong(__pyx_v_event.resize.w); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_event.resize.h); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_7);
        PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
        PyTuple_SET_ITEM(__pyx_5, 2, __pyx_1);
        PyTuple_SET_ITEM(__pyx_5, 3, __pyx_6);
        __pyx_7 = 0;
        __pyx_4 = 0;
        __pyx_1 = 0;
        __pyx_6 = 0;
        __pyx_8 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        goto __pyx_L6;
      }
      /*else*/ {
        __pyx_9 = __Pyx_GetName(__pyx_m, __pyx_n_set_video); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        __pyx_7 = PyInt_FromLong(__pyx_v_event.resize.w); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_event.resize.h); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(4); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_7);
        PyTuple_SET_ITEM(__pyx_3, 1, __pyx_4);
        PyTuple_SET_ITEM(__pyx_3, 2, __pyx_1);
        PyTuple_SET_ITEM(__pyx_3, 3, __pyx_6);
        __pyx_7 = 0;
        __pyx_4 = 0;
        __pyx_1 = 0;
        __pyx_6 = 0;
        __pyx_5 = PyObject_CallObject(__pyx_9, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 395; goto __pyx_L1;}
        Py_DECREF(__pyx_9); __pyx_9 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/init.pyx":397 */
      __pyx_8 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      __pyx_7 = PyInt_FromLong(SDL_VIDEORESIZE); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_event.resize.w); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      __pyx_1 = PyInt_FromLong(__pyx_v_event.resize.h); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_7);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
      PyTuple_SET_ITEM(__pyx_6, 2, __pyx_1);
      __pyx_7 = 0;
      __pyx_4 = 0;
      __pyx_1 = 0;
      __pyx_9 = PyTuple_New(1); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_9, 0, __pyx_6);
      __pyx_6 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_8, __pyx_9); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 397; goto __pyx_L1;}
      Py_DECREF(__pyx_8); __pyx_8 = 0;
      Py_DECREF(__pyx_9); __pyx_9 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":399 */
  Py_INCREF(__pyx_v_events);
  __pyx_r = __pyx_v_events;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.process_event");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_events);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_get_mod(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_get_mod(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/init.pyx":402 */
  __pyx_1 = PyInt_FromLong(SDL_GetModState()); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 402; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.get_mod");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_cursor_set_visible(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_cursor_set_visible(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_visibility;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"visibility",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_visibility)) return 0;

  /* "/home/jiba/src/soya/init.pyx":405 */
  __pyx_1 = (__pyx_v_visibility == 0);
  if (__pyx_1) {
    SDL_ShowCursor(SDL_DISABLE);
    goto __pyx_L2;
  }
  /*else*/ {
    SDL_ShowCursor(SDL_ENABLE);
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.cursor_set_visible");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_set_mouse_pos(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_set_mouse_pos[] = " move the mouse cursor to x,y";
static PyObject *__pyx_f_5_soya_set_mouse_pos(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_y;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii", __pyx_argnames, &__pyx_v_x, &__pyx_v_y)) return 0;

  /* "/home/jiba/src/soya/init.pyx":415 */
  SDL_WarpMouse(__pyx_v_x,__pyx_v_y);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.set_mouse_pos");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_get_grab_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_get_grab_input[] = " queries mouse grabbing\n  returns 1 or 0";
static PyObject *__pyx_f_5_soya_get_grab_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/init.pyx":421 */
  __pyx_1 = (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":422 */
    __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 422; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/init.pyx":424 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 424; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.get_grab_input");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_set_grab_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_set_grab_input[] = " grabs the mouse and keyboard input to our window\n  set_grab_state(0|1) to set state\n  ";
static PyObject *__pyx_f_5_soya_set_grab_input(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_mode;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"mode",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_mode)) return 0;

  /* "/home/jiba/src/soya/init.pyx":431 */
  __pyx_1 = (__pyx_v_mode == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/init.pyx":432 */
    SDL_WM_GrabInput(SDL_GRAB_ON);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/init.pyx":434 */
    SDL_WM_GrabInput(SDL_GRAB_OFF);
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.set_grab_input");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_clear_events(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_clear_events[] = " go through all the events in the key and remove them.\n  mask currently on supports ALL_EVENTS\n  ";
static PyObject *__pyx_f_5_soya_clear_events(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mask = 0;
  SDL_Event __pyx_v_event;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  static char *__pyx_argnames[] = {"mask",0};
  __pyx_v_mask = __pyx_k9;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_mask)) return 0;
  Py_INCREF(__pyx_v_mask);

  /* "/home/jiba/src/soya/init.pyx":445 */
  SDL_PumpEvents();

  /* "/home/jiba/src/soya/init.pyx":447 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyInt_AsLong(__pyx_v_mask); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 447; goto __pyx_L1;}
    __pyx_2 = (SDL_PeepEvents((&__pyx_v_event),1,SDL_GETEVENT,__pyx_1) == 1);
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/init.pyx":448 */
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.clear_events");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_mask);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_get_mouse_rel_pos(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_get_mouse_rel_pos[] = " return the relative mouse position since the last call to this function";
static PyObject *__pyx_f_5_soya_get_mouse_rel_pos(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_y;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/init.pyx":455 */
  SDL_GetRelativeMouseState((&__pyx_v_x),(&__pyx_v_y));

  /* "/home/jiba/src/soya/init.pyx":457 */
  __pyx_1 = PyInt_FromLong(__pyx_v_x); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 457; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_y); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 457; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 457; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.get_mouse_rel_pos");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_n_ValueError;

static PyObject *__pyx_k179p;

static char (__pyx_k179[]) = "Position is an abstract class. Use Point instead.";

static int __pyx_f_5_soya_8Position___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_8Position___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":34 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; goto __pyx_L1;}
  Py_INCREF(__pyx_k179p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k179p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __Pyx_Raise(__pyx_3, 0, 0);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Position.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_8Position__into(struct __pyx_obj_5_soya_Position *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,float (*__pyx_v_result)) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/math3d.pyx":37 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.Position._into");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_8Position__out(struct __pyx_obj_5_soya_Position *__pyx_v_self,float (*__pyx_v_result)) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":40 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.Position._out");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_8Position___mod__(PyObject *__pyx_v_self, PyObject *__pyx_v_coordsyst); /*proto*/
static char __pyx_doc_5_soya_8Position___mod__[] = "Position % coordsyst -> Point\n\nConverts a Position to the coordinate system COORDSYST and returns the result.\nThe returned value may be the same Point if its coordinate system is\nalready COORDSYST, so you should be careful if you modify it.";
static PyObject *__pyx_f_5_soya_8Position___mod__(PyObject *__pyx_v_self, PyObject *__pyx_v_coordsyst) {
  struct __pyx_obj_5_soya__Point *__pyx_v_p;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_p = Py_None; Py_INCREF((PyObject *) __pyx_v_p);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya_Position, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":49 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya_Position *)__pyx_v_self)->_parent) == Py_None;
  if (!__pyx_1) {
    __pyx_1 = __pyx_v_coordsyst == Py_None;
    if (!__pyx_1) {
      __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya_Position *)__pyx_v_self)->_parent) == __pyx_v_coordsyst;
    }
  }
  if (__pyx_1) {
    Py_INCREF((PyObject *)__pyx_v_self);
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/math3d.pyx":50 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_coordsyst);
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_p));
  __pyx_v_p = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":51 */
  ((struct __pyx_vtabstruct_5_soya_Position *)((struct __pyx_obj_5_soya_Position *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_into(((struct __pyx_obj_5_soya_Position *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_coordsyst),__pyx_v_p->_matrix);

  /* "/home/jiba/src/soya/math3d.pyx":52 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_p));
  __pyx_r = ((PyObject *)__pyx_v_p);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Position.__mod__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8Position_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8Position_position[] = "Position.position() -> Point\n\nReturns the position of this Position (a Point or a Vector, whatever Position is).";
static PyObject *__pyx_f_5_soya_8Position_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":58 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Position.position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_keys;
static PyObject *__pyx_n___deepcopy__;

static PyObject *__pyx_f_5_soya_6_Point___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_memo = 0;
  struct __pyx_obj_5_soya__Point *__pyx_v_clone;
  PyObject *__pyx_v_parent;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  int __pyx_6;
  static char *__pyx_argnames[] = {"memo",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_memo)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_memo);
  __pyx_v_clone = Py_None; Py_INCREF((PyObject *) __pyx_v_clone);
  __pyx_v_parent = Py_None; Py_INCREF(__pyx_v_parent);

  /* "/home/jiba/src/soya/math3d.pyx":67 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_v_memo, __pyx_n_keys); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_5 = PySequence_Contains(__pyx_4, __pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_6 = (!__pyx_5);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/math3d.pyx":68 */
    Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
    Py_DECREF(__pyx_v_parent);
    __pyx_v_parent = ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent);

    /* "/home/jiba/src/soya/math3d.pyx":69 */
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 69; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
    ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = Py_None;

    /* "/home/jiba/src/soya/math3d.pyx":70 */
    __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_Position), __pyx_n___deepcopy__); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    Py_INCREF(__pyx_v_memo);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_memo);
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_clone));
    __pyx_v_clone = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/math3d.pyx":71 */
    if (!__Pyx_TypeTest(__pyx_v_parent, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; goto __pyx_L1;}
    Py_INCREF(__pyx_v_parent);
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
    ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = __pyx_v_parent;
    if (!__Pyx_TypeTest(__pyx_v_parent, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; goto __pyx_L1;}
    Py_INCREF(__pyx_v_parent);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_clone->__pyx_base._parent));
    __pyx_v_clone->__pyx_base._parent = __pyx_v_parent;

    /* "/home/jiba/src/soya/math3d.pyx":72 */
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_clone));
    __pyx_r = ((PyObject *)__pyx_v_clone);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_4 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_Position), __pyx_n___deepcopy__); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
    Py_INCREF(__pyx_v_memo);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_memo);
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Point.__deepcopy__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_clone);
  Py_DECREF(__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_memo);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_position[] = "Position.position() -> Point\n\nReturns the position of this Position (a Point or a Vector, whatever Position is).";
static PyObject *__pyx_f_5_soya_6_Point_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":79 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Point__into(struct __pyx_obj_5_soya__Point *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,float (*__pyx_v_result)) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/math3d.pyx":82 */
  memcpy(__pyx_v_result,__pyx_v_self->_matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":83 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_2 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
    __pyx_1 = (!__pyx_2);
    if (__pyx_1) {
      __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == ((PyObject *)__pyx_v_coordsyst);
      __pyx_1 = (!__pyx_2);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/math3d.pyx":84 */
    point_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base._parent));

    /* "/home/jiba/src/soya/math3d.pyx":85 */
    point_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_coordsyst));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Point._into");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_6_Point__out(struct __pyx_obj_5_soya__Point *__pyx_v_self,float (*__pyx_v_result)) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":88 */
  memcpy(__pyx_v_result,__pyx_v_self->_matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":89 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/math3d.pyx":90 */
    point_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base._parent));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Point._out");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_6_Point_6parent___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point_6parent___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":94 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.parent.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Point_6parent___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parent); /*proto*/
static int __pyx_f_5_soya_6_Point_6parent___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_parent) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya_CoordSyst, 1, "parent")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":96 */
  Py_INCREF(__pyx_v_parent);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = __pyx_v_parent;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.parent.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point_set_parent(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"parent",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_parent)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya_CoordSyst, 1, "parent")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":99 */
  Py_INCREF(((PyObject *)__pyx_v_parent));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = ((PyObject *)__pyx_v_parent);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.set_parent");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_1x___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point_1x___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":103 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Point.x.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Point_1x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Point_1x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 104; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":105 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.x.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_1y___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point_1y___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":109 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 109; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Point.y.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Point_1y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Point_1y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":111 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.y.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_1z___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point_1z___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":115 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2])); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Point.z.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Point_1z___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Point_1z___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":117 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.z.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Point___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point___init__[] = "Point(parent = None, x = 0.0, y = 0.0, z = 0.0)\n\nCreates a new Point, with coordinates X, Y and Z, defined in the coordinates\nsystem PARENT.\n";
static int __pyx_f_5_soya_6_Point___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent = 0;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  int __pyx_r;
  static char *__pyx_argnames[] = {"parent","x","y","z",0};
  __pyx_v_parent = __pyx_k10;
  __pyx_v_x = __pyx_k11;
  __pyx_v_y = __pyx_k12;
  __pyx_v_z = __pyx_k13;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|Offf", __pyx_argnames, &__pyx_v_parent, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya_CoordSyst, 1, "parent")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":125 */
  Py_INCREF(((PyObject *)__pyx_v_parent));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = ((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/math3d.pyx":126 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = __pyx_v_x;

  /* "/home/jiba/src/soya/math3d.pyx":127 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) = __pyx_v_y;

  /* "/home/jiba/src/soya/math3d.pyx":128 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) = __pyx_v_z;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_n_get_root;

static PyObject *__pyx_f_5_soya_6_Point_get_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_get_root[] = "Position.get_root() -> World\n\nGets the root parent of a Position. The root parent is the root World of the\nhierarchy (ofen called the \"scene\" object).";
static PyObject *__pyx_f_5_soya_6_Point_get_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":135 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent), __pyx_n_get_root); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Point.get_root");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_set_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_set_xyz[] = "Position.set_xyz(x, y, z)\n\nSets the coordinates of a Position to X, Y and Z.";
static PyObject *__pyx_f_5_soya_6_Point_set_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":141 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = __pyx_v_x;

  /* "/home/jiba/src/soya/math3d.pyx":142 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) = __pyx_v_y;

  /* "/home/jiba/src/soya/math3d.pyx":143 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) = __pyx_v_z;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.set_xyz");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_move(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_move[] = "Position.move(position)\n\nMoves a Position to POSITION.\nCoordinates system conversion is performed if needed (=if the Position and\nPOSITION are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_6_Point_move(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_position = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"position",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_position)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_position);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_position), __pyx_ptype_5_soya_Position, 0, "position")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 145; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":151 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_position->__pyx_base.__pyx_vtab)->_into(__pyx_v_position,((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.move");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_position);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point___add__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static char __pyx_doc_5_soya_6_Point___add__[] = "Position + Vector -> Point\n\nTranslates a Position and returns the result (a new Point).\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_6_Point___add__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Point, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 153; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 153; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":161 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)),((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":162 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) + (__pyx_v_v[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) + (__pyx_v_v[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) + (__pyx_v_v[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Point.__add__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point___sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static char __pyx_doc_5_soya_6_Point___sub__[] = "Position - Vector -> Point\n\nTranslates a Position and returns the result (a new Point).\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_6_Point___sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Point, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":171 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)),((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":172 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) - (__pyx_v_v[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) - (__pyx_v_v[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) - (__pyx_v_v[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Point.__sub__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_add_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_add_xyz[] = "Position.add_xyz(x, y, z)\n\nTranslates the coordinates of a Position by X, Y and Z.";
static PyObject *__pyx_f_5_soya_6_Point_add_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":178 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) + __pyx_v_x);

  /* "/home/jiba/src/soya/math3d.pyx":179 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) + __pyx_v_y);

  /* "/home/jiba/src/soya/math3d.pyx":180 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) + __pyx_v_z);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.add_xyz");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_add_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_add_vector[] = "Position.add_vector(vector)\n\nTranslates a Position IN PLACE.\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).\n\nFor Vector, add_vector means vectorial addition (translating a vector does\nnothing !).";
static PyObject *__pyx_f_5_soya_6_Point_add_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"vector",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_vector)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 182; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":192 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":193 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) + (__pyx_v_v[0]));

  /* "/home/jiba/src/soya/math3d.pyx":194 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) + (__pyx_v_v[1]));

  /* "/home/jiba/src/soya/math3d.pyx":195 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) + (__pyx_v_v[2]));

  /* "/home/jiba/src/soya/math3d.pyx":196 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.add_vector");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_n_add_vector;

static PyObject *__pyx_f_5_soya_6_Point___iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point___iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 198; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":199 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_vector);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_vector);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Point.__iadd__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_add_mul_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_add_mul_vector[] = "Position.add_mul_vector(k, vector)\n\nTranslates a Position IN PLACE, by K * VECTOR.\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).\n\nFor Vector, add_mul_vector means vectorial addition (translating a vector does\nnothing !).";
static PyObject *__pyx_f_5_soya_6_Point_add_mul_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_k;
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"k","vector",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fO", __pyx_argnames, &__pyx_v_k, &__pyx_v_vector)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":211 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":212 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) + (__pyx_v_k * (__pyx_v_v[0])));

  /* "/home/jiba/src/soya/math3d.pyx":213 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) + (__pyx_v_k * (__pyx_v_v[1])));

  /* "/home/jiba/src/soya/math3d.pyx":214 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) = ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) + (__pyx_v_k * (__pyx_v_v[2])));

  /* "/home/jiba/src/soya/math3d.pyx":215 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.add_mul_vector");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_distance_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_distance_to[] = "Position.distance_to(other) -> float\n\nGets the distance between a Position and anOTHER.";
static PyObject *__pyx_f_5_soya_6_Point_distance_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_other = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"other",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_other)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":222 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_other->__pyx_base.__pyx_vtab)->_into(__pyx_v_other,((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":223 */
  __pyx_1 = PyFloat_FromDouble(sqrt((((((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) - (__pyx_v_v[0])) * ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) - (__pyx_v_v[0]))) + (((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) - (__pyx_v_v[1])) * ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) - (__pyx_v_v[1])))) + (((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) - (__pyx_v_v[2])) * ((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) - (__pyx_v_v[2])))))); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Point.distance_to");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_vector_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_vector_to[] = "Position.vector_to(other) -> Vector\n\nGets the vector that starts at a Position and ends at OTHER.";
static PyObject *__pyx_f_5_soya_6_Point_vector_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_other = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"other",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_other)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 225; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":230 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_other->__pyx_base.__pyx_vtab)->_into(__pyx_v_other,((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":231 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((__pyx_v_v[0]) - (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((__pyx_v_v[1]) - (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((__pyx_v_v[2]) - (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 231; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Point.vector_to");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static PyObject *__pyx_n_vector_to;

static PyObject *__pyx_f_5_soya_6_Point___rshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point___rshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Point, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":234 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_vector_to); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 234; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 234; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_other);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_other);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 234; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Point.__rshift__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static PyObject *__pyx_n___name__;

static PyObject *__pyx_k180p;

static char (__pyx_k180[]) = "<%s %s, %s, %s in %s>";

static PyObject *__pyx_f_5_soya_6_Point___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":237 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(5); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 4, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  __pyx_2 = 0;
  __pyx_1 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k180p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 237; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Point.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_parent;

static PyObject *__pyx_f_5_soya_6_Point___getcstate__(struct __pyx_obj_5_soya__Point *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":241 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/math3d.pyx":242 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_matrix,3);

  /* "/home/jiba/src/soya/math3d.pyx":243 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 243; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 243; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 243; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Point.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Point___setcstate__(struct __pyx_obj_5_soya__Point *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/math3d.pyx":249 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 249; goto __pyx_L1;}
  if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent, __pyx_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 249; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":250 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/math3d.pyx":251 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_matrix,3);

  /* "/home/jiba/src/soya/math3d.pyx":252 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Point.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_6_Point_convert_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_convert_to[] = "Point.convert_to(parent)\n\nConverts a Point to the coordinates system PARENT in place. The x, y and z\ncoordinates are modified, and the Point\'s parent is set to PARENT.";
static PyObject *__pyx_f_5_soya_6_Point_convert_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"parent",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_parent)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya_CoordSyst, 1, "parent")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":262 */
  ((struct __pyx_vtabstruct_5_soya__Point *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)),__pyx_v_parent,((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix);

  /* "/home/jiba/src/soya/math3d.pyx":263 */
  Py_INCREF(((PyObject *)__pyx_v_parent));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = ((PyObject *)__pyx_v_parent);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.convert_to");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_n_convert_to;

static PyObject *__pyx_f_5_soya_6_Point___imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_parent); /*proto*/
static PyObject *__pyx_f_5_soya_6_Point___imod__(PyObject *__pyx_v_self, PyObject *__pyx_v_parent) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya_CoordSyst, 1, "parent")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 265; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":266 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_convert_to); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 266; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 266; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_parent);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_parent);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 266; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":267 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Point.__imod__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_copy[] = "Point.copy() -> Point\n\nReturns a copy of a Point.";
static PyObject *__pyx_f_5_soya_6_Point_copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":273 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 273; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 273; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Point.copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Point_clone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Point_clone[] = "Point.clone(other)\n\nChanges IN PLACE this point so as it is a clone of OTHER.";
static PyObject *__pyx_f_5_soya_6_Point_clone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_other = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"other",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_other)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 275; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":279 */
  Py_INCREF(((PyObject *)__pyx_v_other->_parent));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  ((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent = ((PyObject *)__pyx_v_other->_parent);

  /* "/home/jiba/src/soya/math3d.pyx":280 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 280; goto __pyx_L1;}
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_other->__pyx_base.__pyx_vtab)->_into(__pyx_v_other,((struct __pyx_obj_5_soya_CoordSyst *)Py_None),((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Point.clone");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Vector__into(struct __pyx_obj_5_soya__Vector *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,float (*__pyx_v_result)) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/math3d.pyx":290 */
  memcpy(__pyx_v_result,__pyx_v_self->__pyx_base._matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":291 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_2 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
    __pyx_1 = (!__pyx_2);
    if (__pyx_1) {
      __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == ((PyObject *)__pyx_v_coordsyst);
      __pyx_1 = (!__pyx_2);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/math3d.pyx":292 */
    vector_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));

    /* "/home/jiba/src/soya/math3d.pyx":293 */
    vector_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_coordsyst));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Vector._into");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_7_Vector__out(struct __pyx_obj_5_soya__Vector *__pyx_v_self,float (*__pyx_v_result)) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":296 */
  memcpy(__pyx_v_result,__pyx_v_self->__pyx_base._matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":297 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/math3d.pyx":298 */
    vector_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Vector._out");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_7_Vector_copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_copy[] = "Vector.copy() -> Vector\n\nReturns a copy of a Vector.";
static PyObject *__pyx_f_5_soya_7_Vector_copy(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":304 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 304; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 304; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 304; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 304; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 304; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 304; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Vector.copy");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n___init__;

static PyObject *__pyx_f_5_soya_7_Vector_cross_product(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_cross_product[] = "Vector.cross_product(VECTOR, RESULT = None) -> Vector\n\nReturns the cross product of a Vector with VECTOR.";
static PyObject *__pyx_f_5_soya_7_Vector_cross_product(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_result = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"vector","result",0};
  __pyx_v_result = __pyx_k14;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_vector, &__pyx_v_result)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  Py_INCREF((PyObject *)__pyx_v_result);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 306; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_result), __pyx_ptype_5_soya__Vector, 1, "result")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 306; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":311 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":312 */
  __pyx_1 = ((PyObject *)__pyx_v_result) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/math3d.pyx":313 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 313; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (__pyx_v_v[2])) - ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (__pyx_v_v[1])))); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 314; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (__pyx_v_v[0])) - ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (__pyx_v_v[2])))); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (__pyx_v_v[1])) - ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (__pyx_v_v[0])))); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 316; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
    PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
    PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/math3d.pyx":319 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n___init__); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (__pyx_v_v[2])) - ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (__pyx_v_v[1])))); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 320; goto __pyx_L1;}
    __pyx_2 = PyFloat_FromDouble((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (__pyx_v_v[0])) - ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (__pyx_v_v[2])))); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 321; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (__pyx_v_v[1])) - ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (__pyx_v_v[0])))); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 322; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(4); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 319; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_5);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_2);
    PyTuple_SET_ITEM(__pyx_3, 3, __pyx_6);
    __pyx_5 = 0;
    __pyx_2 = 0;
    __pyx_6 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 319; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/jiba/src/soya/math3d.pyx":324 */
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    __pyx_r = ((PyObject *)__pyx_v_result);
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Vector.cross_product");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  Py_DECREF((PyObject *)__pyx_v_result);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector_dot_product(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_dot_product[] = "Vector.dot_product(VECTOR) -> float\n\nReturns the dot product of a Vector with VECTOR.";
static PyObject *__pyx_f_5_soya_7_Vector_dot_product(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"vector",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_vector)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 326; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":331 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":332 */
  __pyx_1 = PyFloat_FromDouble(((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (__pyx_v_v[0])) + ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (__pyx_v_v[1]))) + ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (__pyx_v_v[2])))); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 332; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Vector.dot_product");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector_length(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_length[] = "Vector.length() -> float\n\nGets the length of a Vector.";
static PyObject *__pyx_f_5_soya_7_Vector_length(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":338 */
  __pyx_1 = PyFloat_FromDouble(sqrt(((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0])) + ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]))) + ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]))))); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 338; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Vector.length");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector_set_length(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_set_length[] = "Vector.set_length(new_length)\n\nSets the length of a Vector to NEW_LENGTH. The Vector\'s coordinates are\nmultiplied as needed.";
static PyObject *__pyx_f_5_soya_7_Vector_set_length(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_new_length;
  float __pyx_v_f;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"new_length",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_new_length)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":346 */
  __pyx_v_f = (__pyx_v_new_length / sqrt(((((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0])) + ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]))) + ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2])))));

  /* "/home/jiba/src/soya/math3d.pyx":347 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * __pyx_v_f);

  /* "/home/jiba/src/soya/math3d.pyx":348 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * __pyx_v_f);

  /* "/home/jiba/src/soya/math3d.pyx":349 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * __pyx_v_f);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vector.set_length");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___mod__(PyObject *__pyx_v_self, PyObject *__pyx_v_coordsyst); /*proto*/
static char __pyx_doc_5_soya_7_Vector___mod__[] = "Vector % coordsyst -> Vector\n\nConverts a Vector to the coordinate system COORDSYST and returns the result.\nThe returned value may be the same Vector if its coordinate system is\nalready COORDSYST, so you should be carreful if you modify it.";
static PyObject *__pyx_f_5_soya_7_Vector___mod__(PyObject *__pyx_v_self, PyObject *__pyx_v_coordsyst) {
  struct __pyx_obj_5_soya__Vector *__pyx_v_p;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_p = Py_None; Py_INCREF((PyObject *) __pyx_v_p);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 351; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 351; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":358 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent) == Py_None;
  if (!__pyx_1) {
    __pyx_1 = __pyx_v_coordsyst == Py_None;
    if (!__pyx_1) {
      __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent) == __pyx_v_coordsyst;
    }
  }
  if (__pyx_1) {
    Py_INCREF((PyObject *)__pyx_v_self);
    __pyx_r = __pyx_v_self;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/math3d.pyx":359 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 359; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 359; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_coordsyst);
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 359; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 359; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_p));
  __pyx_v_p = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":360 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_coordsyst),__pyx_v_p->__pyx_base._matrix);

  /* "/home/jiba/src/soya/math3d.pyx":361 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_p));
  __pyx_r = ((PyObject *)__pyx_v_p);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Vector.__mod__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___add__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static char __pyx_doc_5_soya_7_Vector___add__[] = "Vector + Vector -> Vector\n\nPerforms vectorial addition, and returns the result (a new Vector).\nCoordinates system conversion is performed if needed (=if the Vector and\nVECTOR are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_7_Vector___add__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Point, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 363; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 363; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":370 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)),((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":371 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) + (__pyx_v_v[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[1]) + (__pyx_v_v[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[2]) + (__pyx_v_v[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Vector.__add__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___mul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___mul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  float __pyx_v_number;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_number = PyFloat_AsDouble(__pyx_arg_number); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 373; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 373; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":374 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * __pyx_v_number)); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * __pyx_v_number)); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * __pyx_v_number)); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 374; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Vector.__mul__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___div__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  float __pyx_v_number;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_number = PyFloat_AsDouble(__pyx_arg_number); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 376; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 376; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":377 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) / __pyx_v_number)); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) / __pyx_v_number)); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) / __pyx_v_number)); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 377; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Vector.__div__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n___div__;

static PyObject *__pyx_f_5_soya_7_Vector___truediv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___truediv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  float __pyx_v_number;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_number = PyFloat_AsDouble(__pyx_arg_number); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 379; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 379; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":380 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___div__); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 380; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_number); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 380; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 380; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 380; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Vector.__truediv__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___imul__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  float __pyx_v_number;
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_number = PyFloat_AsDouble(__pyx_arg_number); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 382; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":383 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) * __pyx_v_number);

  /* "/home/jiba/src/soya/math3d.pyx":384 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) * __pyx_v_number);

  /* "/home/jiba/src/soya/math3d.pyx":385 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) * __pyx_v_number);

  /* "/home/jiba/src/soya/math3d.pyx":386 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vector.__imul__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___idiv__(PyObject *__pyx_v_self, PyObject *__pyx_arg_number) {
  float __pyx_v_number;
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_number = PyFloat_AsDouble(__pyx_arg_number); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 388; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":389 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) / __pyx_v_number);

  /* "/home/jiba/src/soya/math3d.pyx":390 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) / __pyx_v_number);

  /* "/home/jiba/src/soya/math3d.pyx":391 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) / __pyx_v_number);

  /* "/home/jiba/src/soya/math3d.pyx":392 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vector.__idiv__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector___neg__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___neg__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":395 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((-(((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((-(((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((-(((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 395; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Vector.__neg__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_abs;

static PyObject *__pyx_f_5_soya_7_Vector___abs__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vector___abs__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":398 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
  __pyx_5 = 0;
  __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_5);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Vector.__abs__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_length;

static PyObject *__pyx_f_5_soya_7_Vector_normalize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_normalize[] = "Vector.normalize()\n\nNormalizes a Vector IN PLACE.";
static PyObject *__pyx_f_5_soya_7_Vector_normalize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_length;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/math3d.pyx":405 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_length); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 405; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 405; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 405; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 405; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_length = __pyx_4;

  /* "/home/jiba/src/soya/math3d.pyx":406 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) / __pyx_v_length);

  /* "/home/jiba/src/soya/math3d.pyx":407 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) / __pyx_v_length);

  /* "/home/jiba/src/soya/math3d.pyx":408 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) = ((((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) / __pyx_v_length);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Vector.normalize");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector_set_start_end(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_set_start_end[] = "Vector.set_start_end(start, end)\n\nSets this vector IN PLACE so as it correspond to the vector start->end.";
static PyObject *__pyx_f_5_soya_7_Vector_set_start_end(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_start = 0;
  struct __pyx_obj_5_soya_Position *__pyx_v_end = 0;
  float (__pyx_v_s[3]);
  float (__pyx_v_e[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"start","end",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_start, &__pyx_v_end)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_start);
  Py_INCREF((PyObject *)__pyx_v_end);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start), __pyx_ptype_5_soya_Position, 0, "start")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 410; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_end), __pyx_ptype_5_soya_Position, 0, "end")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 410; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":415 */
  Py_INCREF(((PyObject *)__pyx_v_start->_parent));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  ((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent = ((PyObject *)__pyx_v_start->_parent);

  /* "/home/jiba/src/soya/math3d.pyx":416 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_start->__pyx_base.__pyx_vtab)->_into(__pyx_v_start,((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_s);

  /* "/home/jiba/src/soya/math3d.pyx":417 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_end->__pyx_base.__pyx_vtab)->_into(__pyx_v_end,((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_e);

  /* "/home/jiba/src/soya/math3d.pyx":418 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[0]) = ((__pyx_v_e[0]) - (__pyx_v_s[0]));

  /* "/home/jiba/src/soya/math3d.pyx":419 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[1]) = ((__pyx_v_e[1]) - (__pyx_v_s[1]));

  /* "/home/jiba/src/soya/math3d.pyx":420 */
  (((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix[2]) = ((__pyx_v_e[2]) - (__pyx_v_s[2]));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vector.set_start_end");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_start);
  Py_DECREF((PyObject *)__pyx_v_end);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vector_angle_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vector_angle_to[] = "Vector.angle_to(VECTOR) -> angle in degree\n\nComputes the angle between this Vector and VECTOR.";
static PyObject *__pyx_f_5_soya_7_Vector_angle_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"vector",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_vector)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 422; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":427 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/math3d.pyx":428 */
  __pyx_1 = PyFloat_FromDouble(((vector_angle(((struct __pyx_obj_5_soya__Vector *)__pyx_v_self)->__pyx_base._matrix,__pyx_v_v) * 180.0) / pi)); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 428; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Vector.angle_to");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static int __pyx_f_5_soya_7Context___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7Context___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/renderer.pyx":26 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Context *)__pyx_v_self)->lights);
  ((struct __pyx_obj_5_soya_Context *)__pyx_v_self)->lights = __pyx_1;
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Context.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8Renderer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_8Renderer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/renderer.pyx":70 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->engine_option = (__pyx_e_5_soya_USE_MIPMAP | __pyx_e_5_soya_SHADOWS);

  /* "/home/jiba/src/soya/renderer.pyx":71 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->root_frustum = ((__pyx_t_5_soya_Frustum (*))malloc((sizeof(__pyx_t_5_soya_Frustum ))));

  /* "/home/jiba/src/soya/renderer.pyx":72 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->top_lights);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->top_lights = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":73 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->worlds_made);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->worlds_made = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":74 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->portals);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->portals = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":75 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->watercubes);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->watercubes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":76 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->contexts);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->contexts = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":78 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->opaque = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":79 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->secondpass = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":80 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->alpha = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":81 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->specials = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":83 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->data = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":84 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->frustums = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":85 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->used_opaque_packs = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":86 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->used_secondpass_packs = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":87 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->used_alpha_packs = get_chunk();

  /* "/home/jiba/src/soya/renderer.pyx":89 */
  Py_INCREF(((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->current_material));
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->current_material = ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Renderer.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_8Renderer___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_8Renderer___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/renderer.pyx":92 */
  free(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->root_frustum);

  /* "/home/jiba/src/soya/renderer.pyx":93 */
  chunk_dealloc(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->data);

  /* "/home/jiba/src/soya/renderer.pyx":94 */
  chunk_dealloc(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->frustums);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Renderer.__dealloc__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static __pyx_t_5_soya_Frustum (*__pyx_f_5_soya_8Renderer__frustum(struct __pyx_obj_5_soya_Renderer *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst)) {
  __pyx_t_5_soya_Frustum (*__pyx_r);
  int __pyx_1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/renderer.pyx":97 */
  __pyx_1 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
  if (__pyx_1) {
    __pyx_r = __pyx_v_self->root_frustum;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/renderer.pyx":98 */
  __pyx_1 = (__pyx_v_coordsyst->_frustum_id == (-1));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/renderer.pyx":99 */
    __pyx_v_coordsyst->_frustum_id = chunk_register(__pyx_v_self->frustums,(sizeof(__pyx_t_5_soya_Frustum )));

    /* "/home/jiba/src/soya/renderer.pyx":100 */
    frustum_by_matrix(((__pyx_t_5_soya_Frustum (*))(__pyx_v_self->frustums->content + __pyx_v_coordsyst->_frustum_id)),__pyx_v_self->root_frustum,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_coordsyst));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/renderer.pyx":101 */
  __pyx_r = ((__pyx_t_5_soya_Frustum (*))(__pyx_v_self->frustums->content + __pyx_v_coordsyst->_frustum_id));
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.Renderer._frustum");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  return __pyx_r;
}

static struct __pyx_obj_5_soya_Context *__pyx_f_5_soya_8Renderer__context(struct __pyx_obj_5_soya_Renderer *__pyx_v_self) {
  struct __pyx_obj_5_soya_Context *__pyx_v_context;
  struct __pyx_obj_5_soya_Context *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_context = Py_None; Py_INCREF((PyObject *) __pyx_v_context);

  /* "/home/jiba/src/soya/renderer.pyx":105 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_Context), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":106 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->contexts, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_context));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_context));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":107 */
  Py_INCREF(((PyObject *)__pyx_v_context));
  __pyx_r = (struct __pyx_obj_5_soya_Context *)((PyObject *)__pyx_v_context);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Renderer._context");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_context);
  Py_DECREF(__pyx_v_self);
  return ((struct __pyx_obj_5_soya_Context *)__pyx_r) ;
}

static void __pyx_f_5_soya_8Renderer__activate_context_over(struct __pyx_obj_5_soya_Renderer *__pyx_v_self,struct __pyx_obj_5_soya_Context *__pyx_v_old,struct __pyx_obj_5_soya_Context *__pyx_v_new) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_old);
  Py_INCREF(__pyx_v_new);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/renderer.pyx":112 */
  __pyx_1 = ((PyObject *)__pyx_v_old) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":114 */
    __pyx_3 = PyObject_GetIter(__pyx_v_old->lights); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; goto __pyx_L1;}
    for (;;) {
      __pyx_L3:;
      __pyx_4 = PyIter_Next(__pyx_3);
      if (!__pyx_4) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
      __pyx_v_light = __pyx_4;
      __pyx_4 = 0;

      /* "/home/jiba/src/soya/renderer.pyx":115 */
      __pyx_1 = (__pyx_v_light->_id != (-1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/renderer.pyx":116 */
        __pyx_v_light->_gl_id_enabled = 0;

        /* "/home/jiba/src/soya/renderer.pyx":117 */
        glDisable((GL_LIGHT0 + __pyx_v_light->_id));
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L4:;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":118 */
    __pyx_1 = ((PyObject *)__pyx_v_old->portal) == Py_None;
    __pyx_2 = (!__pyx_1);
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_old->portal->__pyx_base._option & (__pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES | __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES));
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/renderer.pyx":119 */
      glDisable(GL_CLIP_PLANE0);

      /* "/home/jiba/src/soya/renderer.pyx":120 */
      glDisable(GL_CLIP_PLANE1);

      /* "/home/jiba/src/soya/renderer.pyx":121 */
      glDisable(GL_CLIP_PLANE2);

      /* "/home/jiba/src/soya/renderer.pyx":122 */
      glDisable(GL_CLIP_PLANE3);

      /* "/home/jiba/src/soya/renderer.pyx":123 */
      __pyx_1 = (__pyx_v_old->portal->__pyx_base._option & __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES);
      if (__pyx_1) {
        glDisable(GL_CLIP_PLANE4);
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/renderer.pyx":125 */
  __pyx_2 = ((PyObject *)__pyx_v_new) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/renderer.pyx":126 */
    __pyx_1 = ((PyObject *)__pyx_v_new->atmosphere) == Py_None;
    __pyx_2 = (!__pyx_1);
    if (__pyx_2) {
      __pyx_2 = ((PyObject *)__pyx_v_old) == Py_None;
      if (!__pyx_2) {
        __pyx_1 = ((PyObject *)__pyx_v_new->atmosphere) == ((PyObject *)__pyx_v_old->atmosphere);
        __pyx_2 = (!__pyx_1);
      }
    }
    if (__pyx_2) {
      ((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_new->atmosphere->__pyx_base.__pyx_vtab)->_render(__pyx_v_new->atmosphere);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/renderer.pyx":127 */
    __pyx_4 = PyObject_GetIter(__pyx_v_new->lights); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 127; goto __pyx_L1;}
    for (;;) {
      __pyx_L10:;
      __pyx_3 = PyIter_Next(__pyx_4);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 127; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 127; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
      __pyx_v_light = __pyx_3;
      __pyx_3 = 0;
      ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_activate(__pyx_v_light);
    }
    __pyx_L11:;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/renderer.pyx":129 */
  __pyx_3 = PyObject_GetIter(__pyx_v_5_soya_renderer->top_lights); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; goto __pyx_L1;}
  for (;;) {
    __pyx_L12:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":130 */
    __pyx_1 = (__pyx_v_light->_id == (-1));
    if (__pyx_1) {
      __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_light), __pyx_n_render); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; goto __pyx_L1;}
      Py_INCREF(Py_None);
      PyTuple_SET_ITEM(__pyx_5, 0, Py_None);
      __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      goto __pyx_L14;
    }
    __pyx_L14:;
  }
  __pyx_L13:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":132 */
  __pyx_1 = ((PyObject *)__pyx_v_new) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_1 = ((PyObject *)__pyx_v_new->portal) == Py_None;
    __pyx_2 = (!__pyx_1);
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_new->portal->__pyx_base._option & (__pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES | __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES));
    }
  }
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":133 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/renderer.pyx":134 */
    glClipPlane(GL_CLIP_PLANE0,__pyx_v_new->portal->_equation);

    /* "/home/jiba/src/soya/renderer.pyx":135 */
    glClipPlane(GL_CLIP_PLANE1,(__pyx_v_new->portal->_equation + 4));

    /* "/home/jiba/src/soya/renderer.pyx":136 */
    glClipPlane(GL_CLIP_PLANE2,(__pyx_v_new->portal->_equation + 8));

    /* "/home/jiba/src/soya/renderer.pyx":137 */
    glClipPlane(GL_CLIP_PLANE3,(__pyx_v_new->portal->_equation + 12));

    /* "/home/jiba/src/soya/renderer.pyx":138 */
    glEnable(GL_CLIP_PLANE0);

    /* "/home/jiba/src/soya/renderer.pyx":139 */
    glEnable(GL_CLIP_PLANE1);

    /* "/home/jiba/src/soya/renderer.pyx":140 */
    glEnable(GL_CLIP_PLANE2);

    /* "/home/jiba/src/soya/renderer.pyx":141 */
    glEnable(GL_CLIP_PLANE3);

    /* "/home/jiba/src/soya/renderer.pyx":142 */
    __pyx_1 = (__pyx_v_new->portal->__pyx_base._option & __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":143 */
      glClipPlane(GL_CLIP_PLANE4,(__pyx_v_new->portal->_equation + 16));

      /* "/home/jiba/src/soya/renderer.pyx":144 */
      glEnable(GL_CLIP_PLANE4);
      goto __pyx_L16;
    }
    __pyx_L16:;
    goto __pyx_L15;
  }
  __pyx_L15:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya.Renderer._activate_context_over");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_old);
  Py_DECREF(__pyx_v_new);
}

static PyObject *__pyx_n___imul__;

static void __pyx_f_5_soya_8Renderer__reset(struct __pyx_obj_5_soya_Renderer *__pyx_v_self) {
  struct __pyx_obj_5_soya__World *__pyx_v_world;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_world = Py_None; Py_INCREF((PyObject *) __pyx_v_world);

  /* "/home/jiba/src/soya/renderer.pyx":148 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Atmosphere)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 148; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->root_atmosphere));
  __pyx_v_self->root_atmosphere = Py_None;

  /* "/home/jiba/src/soya/renderer.pyx":149 */
  __pyx_f_5_soya_disable_all_lights();

  /* "/home/jiba/src/soya/renderer.pyx":150 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->worlds_made); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_world));
    __pyx_v_world = __pyx_2;
    __pyx_2 = 0;
    __pyx_v_world->__pyx_base.__pyx_base._option = (__pyx_v_world->__pyx_base.__pyx_base._option - __pyx_e_5_soya_WORLD_BATCHED);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":151 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->contexts, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 151; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 151; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":152 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->top_lights, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 152; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":153 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->worlds_made, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":154 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->portals, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 154; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":155 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->watercubes, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":156 */
  __pyx_v_self->opaque->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":157 */
  __pyx_v_self->secondpass->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":158 */
  __pyx_v_self->alpha->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":159 */
  __pyx_v_self->specials->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":160 */
  __pyx_v_self->data->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":161 */
  __pyx_v_self->delta_time = 0.0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya.Renderer._reset");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_world);
  Py_DECREF(__pyx_v_self);
}

static void __pyx_f_5_soya_8Renderer__batch(struct __pyx_obj_5_soya_Renderer *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_list),PyObject *__pyx_v_obj,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,int __pyx_v_data) {
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_obj);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/renderer.pyx":164 */
  chunk_add_ptr(__pyx_v_list,((void (*))__pyx_v_obj));

  /* "/home/jiba/src/soya/renderer.pyx":165 */
  chunk_add_ptr(__pyx_v_list,((void (*))((PyObject *)__pyx_v_coordsyst)));

  /* "/home/jiba/src/soya/renderer.pyx":166 */
  chunk_add_ptr(__pyx_v_list,((void (*))((PyObject *)__pyx_v_5_soya_renderer->current_context)));

  /* "/home/jiba/src/soya/renderer.pyx":167 */
  chunk_add_int(__pyx_v_list,__pyx_v_data);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.Renderer._batch");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_n_reverse;
static PyObject *__pyx_n_fx_advance_time;

static void __pyx_f_5_soya_8Renderer__render(struct __pyx_obj_5_soya_Renderer *__pyx_v_self) {
  struct __pyx_obj_5_soya_Context *__pyx_v_ctxt;
  struct __pyx_obj_5_soya__Portal *__pyx_v_portal;
  struct __pyx_obj_5_soya__World *__pyx_v_world;
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_ctxt = Py_None; Py_INCREF((PyObject *) __pyx_v_ctxt);
  __pyx_v_portal = Py_None; Py_INCREF((PyObject *) __pyx_v_portal);
  __pyx_v_world = Py_None; Py_INCREF((PyObject *) __pyx_v_world);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/renderer.pyx":176 */
  __pyx_v_5_soya_renderer->frustums->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":179 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_context(__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 179; goto __pyx_L1;}
  Py_INCREF(__pyx_1);
  Py_DECREF(((PyObject *)__pyx_v_ctxt));
  __pyx_v_ctxt = __pyx_1;
  Py_INCREF(__pyx_1);
  Py_DECREF(((PyObject *)__pyx_v_self->current_context));
  __pyx_v_self->current_context = __pyx_1;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":180 */
  ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->root_object->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._batch(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->root_object),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->current_camera));

  /* "/home/jiba/src/soya/renderer.pyx":184 */
  __pyx_2 = ((PyObject *)__pyx_v_self->root_atmosphere) == Py_None;
  __pyx_3 = (!__pyx_2);
  if (__pyx_3) {
    ((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_self->root_atmosphere->__pyx_base.__pyx_vtab)->_clear(__pyx_v_self->root_atmosphere);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_clear_screen(__pyx_v_self,0);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/renderer.pyx":187 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->portals, __pyx_n_reverse); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":188 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->portals); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 188; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_4 = PyIter_Next(__pyx_1);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 188; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Portal)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 188; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_portal));
    __pyx_v_portal = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":189 */
    __pyx_2 = (__pyx_v_portal->__pyx_base._option & __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE);
    if (__pyx_2) {
      ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_portal->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_atmosphere_clear_part(__pyx_v_portal);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L4:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":191 */
  __pyx_5 = PyObject_GetIter(__pyx_v_self->top_lights); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; goto __pyx_L1;}
  for (;;) {
    __pyx_L6:;
    __pyx_4 = PyIter_Next(__pyx_5);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_4;
    __pyx_4 = 0;
    ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_activate(__pyx_v_light);
  }
  __pyx_L7:;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":193 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)__pyx_v_self->current_context));
  __pyx_v_self->current_context = Py_None;

  /* "/home/jiba/src/soya/renderer.pyx":197 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_OPAQUE;

  /* "/home/jiba/src/soya/renderer.pyx":198 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_render_list(__pyx_v_self,__pyx_v_self->opaque);

  /* "/home/jiba/src/soya/renderer.pyx":201 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_SECONDPASS;

  /* "/home/jiba/src/soya/renderer.pyx":202 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_render_list(__pyx_v_self,__pyx_v_self->secondpass);

  /* "/home/jiba/src/soya/renderer.pyx":204 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_ALPHA;

  /* "/home/jiba/src/soya/renderer.pyx":205 */
  glEnable(GL_BLEND);

  /* "/home/jiba/src/soya/renderer.pyx":206 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/renderer.pyx":207 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_render_list(__pyx_v_self,__pyx_v_self->alpha);

  /* "/home/jiba/src/soya/renderer.pyx":209 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya__DEFAULT_MATERIAL->__pyx_base.__pyx_vtab)->_activate(__pyx_v_5_soya__DEFAULT_MATERIAL);

  /* "/home/jiba/src/soya/renderer.pyx":210 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 210; goto __pyx_L1;}
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_activate_context_over(__pyx_v_self,__pyx_v_self->current_context,((struct __pyx_obj_5_soya_Context *)Py_None));

  /* "/home/jiba/src/soya/renderer.pyx":211 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)__pyx_v_self->current_context));
  __pyx_v_self->current_context = Py_None;

  /* "/home/jiba/src/soya/renderer.pyx":214 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->portals); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; goto __pyx_L1;}
  for (;;) {
    __pyx_L8:;
    __pyx_4 = PyIter_Next(__pyx_1);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Portal)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_portal));
    __pyx_v_portal = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":215 */
    __pyx_3 = (__pyx_v_portal->__pyx_base._option & __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/renderer.pyx":217 */
      Py_INCREF(((PyObject *)((PyObject *)__pyx_v_portal->__pyx_base.__pyx_base._parent)));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_world));
      __pyx_v_world = ((PyObject *)((PyObject *)__pyx_v_portal->__pyx_base.__pyx_base._parent));

      /* "/home/jiba/src/soya/renderer.pyx":218 */
      while (1) {
        __pyx_L11:;
        __pyx_3 = ((PyObject *)__pyx_v_world) == Py_None;
        __pyx_2 = (!__pyx_3);
        if (__pyx_2) {
          __pyx_2 = ((PyObject *)__pyx_v_world->_atmosphere) == Py_None;
        }
        if (!__pyx_2) break;
        Py_INCREF(((PyObject *)((PyObject *)__pyx_v_world->__pyx_base.__pyx_base.__pyx_base._parent)));
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_world));
        __pyx_v_world = ((PyObject *)((PyObject *)__pyx_v_world->__pyx_base.__pyx_base.__pyx_base._parent));
      }
      __pyx_L12:;

      /* "/home/jiba/src/soya/renderer.pyx":219 */
      __pyx_2 = ((PyObject *)__pyx_v_world->_atmosphere) == Py_None;
      __pyx_3 = (!__pyx_2);
      if (__pyx_3) {
        __pyx_3 = (__pyx_v_world->_atmosphere->_option & __pyx_e_5_soya_ATMOSPHERE_FOG);
      }
      if (__pyx_3) {

        /* "/home/jiba/src/soya/renderer.pyx":220 */
        ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_portal->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_draw_fog(__pyx_v_portal,__pyx_v_world->_atmosphere);
        goto __pyx_L13;
      }
      __pyx_L13:;
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
  __pyx_L9:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":223 */
  __pyx_2 = (__pyx_v_self->engine_option & __pyx_e_5_soya_SHADOWS);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_render_shadows(__pyx_v_self);
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/jiba/src/soya/renderer.pyx":225 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_SPECIAL;

  /* "/home/jiba/src/soya/renderer.pyx":226 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_render_list(__pyx_v_self,__pyx_v_self->specials);

  /* "/home/jiba/src/soya/renderer.pyx":231 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/renderer.pyx":232 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/renderer.pyx":233 */
  __pyx_3 = (__pyx_v_self->engine_option & __pyx_e_5_soya_FX_INITED);
  if (__pyx_3) {
    __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_fx_advance_time); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 233; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 233; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 233; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/renderer.pyx":235 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_reset(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya.Renderer._render");
  __pyx_L0:;
  Py_DECREF(__pyx_v_ctxt);
  Py_DECREF((PyObject *)__pyx_v_portal);
  Py_DECREF((PyObject *)__pyx_v_world);
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_n_isinstance;

static void __pyx_f_5_soya_8Renderer__render_list(struct __pyx_obj_5_soya_Renderer *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_list)) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  struct __pyx_obj_5_soya_Context *__pyx_v_context;
  int __pyx_v_i;
  int __pyx_v_nb;
  struct __pyx_obj_5_soya__CObj *__pyx_v_obj;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  __pyx_v_context = Py_None; Py_INCREF((PyObject *) __pyx_v_context);
  __pyx_v_obj = Py_None; Py_INCREF((PyObject *) __pyx_v_obj);

  /* "/home/jiba/src/soya/renderer.pyx":245 */
  __pyx_v_nb = __pyx_v_list->nb;

  /* "/home/jiba/src/soya/renderer.pyx":246 */
  __pyx_v_list->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":247 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_list->nb < __pyx_v_nb);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/renderer.pyx":248 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_list);
    Py_INCREF(__pyx_2);
    Py_DECREF(((PyObject *)__pyx_v_obj));
    __pyx_v_obj = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":249 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_list);
    Py_INCREF((PyObject *)__pyx_2);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":250 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_list);
    Py_INCREF(__pyx_2);
    Py_DECREF(((PyObject *)__pyx_v_context));
    __pyx_v_context = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":251 */
    __pyx_v_self->data->nb = chunk_get_int(__pyx_v_list);

    /* "/home/jiba/src/soya/renderer.pyx":254 */
    __pyx_1 = ((PyObject *)__pyx_v_context) == ((PyObject *)__pyx_v_self->current_context);
    __pyx_3 = (!__pyx_1);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/renderer.pyx":255 */
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_self->__pyx_vtab)->_activate_context_over(__pyx_v_self,__pyx_v_self->current_context,__pyx_v_context);

      /* "/home/jiba/src/soya/renderer.pyx":256 */
      Py_INCREF(((PyObject *)__pyx_v_context));
      Py_DECREF(((PyObject *)__pyx_v_self->current_context));
      __pyx_v_self->current_context = ((PyObject *)__pyx_v_context);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/renderer.pyx":259 */
    Py_INCREF(((PyObject *)__pyx_v_coordsyst));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->current_coordsyst));
    __pyx_v_self->current_coordsyst = ((PyObject *)__pyx_v_coordsyst);

    /* "/home/jiba/src/soya/renderer.pyx":260 */
    __pyx_1 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
    __pyx_3 = (!__pyx_1);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/renderer.pyx":261 */
      glLoadMatrixf(__pyx_v_coordsyst->_render_matrix);

      /* "/home/jiba/src/soya/renderer.pyx":262 */
      __pyx_1 = ((__pyx_v_coordsyst->_render_matrix[17]) != 1.0);
      if (__pyx_1) {
        glEnable(GL_NORMALIZE);
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/renderer.pyx":264 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_obj));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_obj));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Shape));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__Shape));
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyObject_IsTrue(__pyx_5); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 264; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_3) {
      ((struct __pyx_vtabstruct_5_soya__Shape *)((struct __pyx_obj_5_soya__Shape *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_vtab)->_render(((struct __pyx_obj_5_soya__Shape *)((PyObject *)__pyx_v_obj)),__pyx_v_coordsyst);
      goto __pyx_L7;
    }
    /*else*/ {
      ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_vtab)->_render(((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj)),__pyx_v_coordsyst);
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/renderer.pyx":267 */
    __pyx_3 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
    __pyx_1 = (!__pyx_3);
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_coordsyst->_render_matrix[17]) != 1.0);
    }
    if (__pyx_1) {
      glDisable(GL_NORMALIZE);
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya.Renderer._render_list");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_context);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF(__pyx_v_self);
}

static void __pyx_f_5_soya_8Renderer__clear_screen(struct __pyx_obj_5_soya_Renderer *__pyx_v_self,float (*__pyx_v_color)) {
  int (*__pyx_v_size);
  int __pyx_1;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/renderer.pyx":271 */
  __pyx_1 = (__pyx_v_self->current_camera->__pyx_base._option & __pyx_e_5_soya_CAMERA_PARTIAL);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/renderer.pyx":272 */
    __pyx_v_size = __pyx_v_self->current_camera->_viewport;

    /* "/home/jiba/src/soya/renderer.pyx":273 */
    glDisable(GL_LIGHTING);

    /* "/home/jiba/src/soya/renderer.pyx":274 */
    glDisable(GL_FOG);

    /* "/home/jiba/src/soya/renderer.pyx":275 */
    glDisable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/renderer.pyx":276 */
    glDisable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/renderer.pyx":277 */
    glDepthMask(GL_FALSE);

    /* "/home/jiba/src/soya/renderer.pyx":278 */
    __pyx_1 = (__pyx_v_color == 0);
    if (__pyx_1) {
      glColor3f(0.0,0.0,0.0);
      goto __pyx_L3;
    }
    /*else*/ {
      glColor4fv(__pyx_v_color);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/renderer.pyx":280 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/renderer.pyx":281 */
    glMatrixMode(GL_PROJECTION);

    /* "/home/jiba/src/soya/renderer.pyx":282 */
    glPushMatrix();

    /* "/home/jiba/src/soya/renderer.pyx":283 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/renderer.pyx":284 */
    glOrtho(0.0,((GLfloat )(__pyx_v_size[2])),((GLfloat )(__pyx_v_size[3])),0.0,(-1.0),1.0);

    /* "/home/jiba/src/soya/renderer.pyx":285 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/renderer.pyx":286 */
    glVertex2i(0,0);

    /* "/home/jiba/src/soya/renderer.pyx":287 */
    glVertex2i((__pyx_v_size[2]),0);

    /* "/home/jiba/src/soya/renderer.pyx":288 */
    glVertex2i((__pyx_v_size[2]),(__pyx_v_size[3]));

    /* "/home/jiba/src/soya/renderer.pyx":289 */
    glVertex2i(0,(__pyx_v_size[3]));

    /* "/home/jiba/src/soya/renderer.pyx":290 */
    glEnd();

    /* "/home/jiba/src/soya/renderer.pyx":291 */
    glMatrixMode(GL_PROJECTION);

    /* "/home/jiba/src/soya/renderer.pyx":292 */
    glPopMatrix();

    /* "/home/jiba/src/soya/renderer.pyx":293 */
    glMatrixMode(GL_MODELVIEW);

    /* "/home/jiba/src/soya/renderer.pyx":294 */
    glEnable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/renderer.pyx":295 */
    glEnable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/renderer.pyx":296 */
    glEnable(GL_FOG);

    /* "/home/jiba/src/soya/renderer.pyx":297 */
    glEnable(GL_LIGHTING);

    /* "/home/jiba/src/soya/renderer.pyx":298 */
    glDepthMask(GL_TRUE);

    /* "/home/jiba/src/soya/renderer.pyx":299 */
    glClear(GL_DEPTH_BUFFER_BIT);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/renderer.pyx":301 */
    __pyx_1 = (__pyx_v_color == 0);
    if (__pyx_1) {
      glClearColor(0.0,0.0,0.0,1.0);
      goto __pyx_L4;
    }
    /*else*/ {
      glClearColor((__pyx_v_color[0]),(__pyx_v_color[1]),(__pyx_v_color[2]),(__pyx_v_color[3]));
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/renderer.pyx":303 */
    glClear((GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.Renderer._clear_screen");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static void __pyx_f_5_soya_8Renderer__render_shadows(struct __pyx_obj_5_soya_Renderer *__pyx_v_self) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  float (__pyx_v_p[12]);
  float (*__pyx_v_ptrf);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF(__pyx_v_self);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/renderer.pyx":309 */
  __pyx_v_ptrf = __pyx_v_self->current_camera->_frustum->points;

  /* "/home/jiba/src/soya/renderer.pyx":315 */
  (__pyx_v_p[0]) = (((__pyx_v_ptrf[0]) + (__pyx_v_ptrf[12])) * 0.5);

  /* "/home/jiba/src/soya/renderer.pyx":316 */
  (__pyx_v_p[1]) = (((__pyx_v_ptrf[1]) + (__pyx_v_ptrf[13])) * 0.5);

  /* "/home/jiba/src/soya/renderer.pyx":317 */
  (__pyx_v_p[2]) = (((__pyx_v_ptrf[2]) + (__pyx_v_ptrf[14])) * 0.5);

  /* "/home/jiba/src/soya/renderer.pyx":318 */
  (__pyx_v_p[3]) = (-(__pyx_v_p[0]));

  /* "/home/jiba/src/soya/renderer.pyx":319 */
  (__pyx_v_p[4]) = (__pyx_v_p[1]);

  /* "/home/jiba/src/soya/renderer.pyx":320 */
  (__pyx_v_p[5]) = (__pyx_v_p[2]);

  /* "/home/jiba/src/soya/renderer.pyx":321 */
  (__pyx_v_p[6]) = (-(__pyx_v_p[0]));

  /* "/home/jiba/src/soya/renderer.pyx":322 */
  (__pyx_v_p[7]) = (-(__pyx_v_p[1]));

  /* "/home/jiba/src/soya/renderer.pyx":323 */
  (__pyx_v_p[8]) = (__pyx_v_p[2]);

  /* "/home/jiba/src/soya/renderer.pyx":324 */
  (__pyx_v_p[9]) = (__pyx_v_p[0]);

  /* "/home/jiba/src/soya/renderer.pyx":325 */
  (__pyx_v_p[10]) = (-(__pyx_v_p[1]));

  /* "/home/jiba/src/soya/renderer.pyx":326 */
  (__pyx_v_p[11]) = (__pyx_v_p[2]);

  /* "/home/jiba/src/soya/renderer.pyx":327 */
  glEnableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/renderer.pyx":328 */
  glVertexPointer(3,GL_FLOAT,0,__pyx_v_p);

  /* "/home/jiba/src/soya/renderer.pyx":329 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/renderer.pyx":330 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/renderer.pyx":331 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/renderer.pyx":332 */
  glDepthFunc(GL_LEQUAL);

  /* "/home/jiba/src/soya/renderer.pyx":333 */
  glPushMatrix();

  /* "/home/jiba/src/soya/renderer.pyx":335 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 335; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 335; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 335; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":336 */
    __pyx_3 = ((PyObject *)__pyx_v_light) == Py_None;
    if (!__pyx_3) {
      __pyx_3 = (__pyx_v_light->__pyx_base._option & __pyx_e_5_soya_LIGHT_NO_SHADOW);
    }
    if (__pyx_3) {
      goto __pyx_L2;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/renderer.pyx":338 */
    glStencilMask(4294967295);

    /* "/home/jiba/src/soya/renderer.pyx":339 */
    glClearStencil(0);

    /* "/home/jiba/src/soya/renderer.pyx":340 */
    glClear(GL_STENCIL_BUFFER_BIT);

    /* "/home/jiba/src/soya/renderer.pyx":341 */
    glEnable(GL_STENCIL_TEST);

    /* "/home/jiba/src/soya/renderer.pyx":342 */
    glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);

    /* "/home/jiba/src/soya/renderer.pyx":345 */
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 345; goto __pyx_L1;}
    __pyx_3 = ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->root_object->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._shadow(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->root_object),((struct __pyx_obj_5_soya_CoordSyst *)Py_None),__pyx_v_light);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/renderer.pyx":347 */
      glStencilMask(0);

      /* "/home/jiba/src/soya/renderer.pyx":348 */
      glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

      /* "/home/jiba/src/soya/renderer.pyx":350 */
      glColor4fv((__pyx_v_light->_colors + 12));

      /* "/home/jiba/src/soya/renderer.pyx":351 */
      glStencilFunc(GL_NOTEQUAL,0,4294967295);

      /* "/home/jiba/src/soya/renderer.pyx":352 */
      glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);

      /* "/home/jiba/src/soya/renderer.pyx":353 */
      glDisable(GL_CULL_FACE);

      /* "/home/jiba/src/soya/renderer.pyx":358 */
      glEnable(GL_DEPTH_TEST);

      /* "/home/jiba/src/soya/renderer.pyx":359 */
      glDepthFunc(GL_NOTEQUAL);

      /* "/home/jiba/src/soya/renderer.pyx":360 */
      glDepthRange(1.0,1.0);

      /* "/home/jiba/src/soya/renderer.pyx":362 */
      glLoadIdentity();

      /* "/home/jiba/src/soya/renderer.pyx":363 */
      glDrawArrays(GL_QUADS,0,4);

      /* "/home/jiba/src/soya/renderer.pyx":364 */
      glEnable(GL_DEPTH_TEST);

      /* "/home/jiba/src/soya/renderer.pyx":365 */
      glEnable(GL_CULL_FACE);

      /* "/home/jiba/src/soya/renderer.pyx":366 */
      glDepthFunc(GL_LEQUAL);

      /* "/home/jiba/src/soya/renderer.pyx":367 */
      glDepthRange(0.0,1.0);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/renderer.pyx":369 */
      glStencilMask(0);

      /* "/home/jiba/src/soya/renderer.pyx":370 */
      glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
    }
    __pyx_L5:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":372 */
  glPopMatrix();

  /* "/home/jiba/src/soya/renderer.pyx":373 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/renderer.pyx":374 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/renderer.pyx":375 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/renderer.pyx":376 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/renderer.pyx":377 */
  glDisable(GL_STENCIL_TEST);

  /* "/home/jiba/src/soya/renderer.pyx":378 */
  glDisableClientState(GL_VERTEX_ARRAY);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya.Renderer._render_shadows");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_get_renderer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_get_renderer(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;

  /* "/home/jiba/src/soya/renderer.pyx":381 */
  Py_INCREF(((PyObject *)__pyx_v_5_soya_renderer));
  __pyx_r = ((PyObject *)__pyx_v_5_soya_renderer);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.get_renderer");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_check_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_check_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_1 = __pyx_f_5_soya_check_gl_error(); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 390; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 390; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.check_error");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_n_GL_INVALID_ENUM;
static PyObject *__pyx_n_GL_INVALID_OPERATION;
static PyObject *__pyx_n_GL_STACK_OVERFLOW;
static PyObject *__pyx_n_GL_STACK_UNDERFLOW;
static PyObject *__pyx_n_GL_OUT_OF_MEMORY;

static PyObject *__pyx_k191p;
static PyObject *__pyx_k192p;

static char (__pyx_k191[]) = "Unknown GL_ERROR";
static char (__pyx_k192[]) = "Unknown GL_Error";

static int __pyx_f_5_soya_check_gl_error(void) {
  GLenum __pyx_v_error;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":394 */
  __pyx_v_error = glGetError();

  /* "/home/jiba/src/soya/renderer.pyx":395 */
  __pyx_1 = (__pyx_v_error != GL_NO_ERROR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/renderer.pyx":396 */
    __pyx_1 = (__pyx_v_error == GL_INVALID_ENUM);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":396 */
      if (__Pyx_PrintItem(__pyx_n_GL_INVALID_ENUM) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 396; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 396; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":396 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 396; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 396; goto __pyx_L1;}
      Py_INCREF(__pyx_n_GL_INVALID_ENUM);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_GL_INVALID_ENUM);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 396; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 396; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == GL_INVALID_OPERATION);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":397 */
      if (__Pyx_PrintItem(__pyx_n_GL_INVALID_OPERATION) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":397 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; goto __pyx_L1;}
      Py_INCREF(__pyx_n_GL_INVALID_OPERATION);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_GL_INVALID_OPERATION);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 397; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == GL_STACK_OVERFLOW);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":398 */
      if (__Pyx_PrintItem(__pyx_n_GL_STACK_OVERFLOW) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 398; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 398; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":398 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 398; goto __pyx_L1;}
      Py_INCREF(__pyx_n_GL_STACK_OVERFLOW);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_GL_STACK_OVERFLOW);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 398; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 398; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == GL_STACK_UNDERFLOW);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":399 */
      if (__Pyx_PrintItem(__pyx_n_GL_STACK_UNDERFLOW) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 399; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 399; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":399 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 399; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 399; goto __pyx_L1;}
      Py_INCREF(__pyx_n_GL_STACK_UNDERFLOW);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_GL_STACK_UNDERFLOW);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 399; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 399; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == GL_OUT_OF_MEMORY);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":400 */
      if (__Pyx_PrintItem(__pyx_n_GL_OUT_OF_MEMORY) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":400 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; goto __pyx_L1;}
      Py_INCREF(__pyx_n_GL_OUT_OF_MEMORY);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_GL_OUT_OF_MEMORY);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 400; goto __pyx_L1;}
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/renderer.pyx":401 */
      if (__Pyx_PrintItem(__pyx_k191p) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":401 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; goto __pyx_L1;}
      Py_INCREF(__pyx_k192p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k192p);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[3]; __pyx_lineno = 401; goto __pyx_L1;}
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.check_gl_error");
  __pyx_r = -1;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_set_root_widget(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_set_root_widget[] = "set_root_widget(widget)\n\nSets the root widget of Soya3D. The root widget is the one used for rendering.\nIt is typically a camera, or a group of widget (soya.widget.Group) which includes\na camera.";
static PyObject *__pyx_f_5_soya_set_root_widget(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_widget = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static char *__pyx_argnames[] = {"widget",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_widget)) return 0;
  Py_INCREF(__pyx_v_widget);

  /* "/home/jiba/src/soya/renderer.pyx":411 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_root_widget, __pyx_v_widget) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 411; goto __pyx_L1;}

  /* "/home/jiba/src/soya/renderer.pyx":412 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 412; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 412; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":413 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_resize); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_5 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_6 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_6) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
    PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
    PyTuple_SET_ITEM(__pyx_7, 2, __pyx_5);
    PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
    __pyx_1 = 0;
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_6 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 413; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_7); __pyx_7 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.set_root_widget");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_widget);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_render(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_render[] = "render()\n\nRenders the 3D scene. Use set_root_widget() to choose which camera is used.";
static PyObject *__pyx_f_5_soya_render(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_swap_buffer;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"swap_buffer",0};
  __pyx_v_swap_buffer = __pyx_k16;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|i", __pyx_argnames, &__pyx_v_swap_buffer)) return 0;

  /* "/home/jiba/src/soya/renderer.pyx":419 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 419; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 419; goto __pyx_L1;}
  if (__pyx_2) {
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyInt_FromLong((__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_INITED)); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 419; goto __pyx_L1;}
  }
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 419; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":420 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 420; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_render); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 420; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 420; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 420; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":421 */
    __pyx_2 = __pyx_f_5_soya_check_gl_error(); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 421; goto __pyx_L1;}

    /* "/home/jiba/src/soya/renderer.pyx":422 */
    __pyx_2 = __pyx_v_swap_buffer;
    if (__pyx_2) {
      SDL_GL_SwapBuffers();
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.render");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_get_screen_width(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_get_screen_width(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 424; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.get_screen_width");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_get_screen_height(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_get_screen_height(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 425; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.get_screen_height");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5Idler_6scenes___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5Idler_6scenes___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/idler.pyx":64 */
  Py_INCREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes);
  __pyx_r = ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Idler.scenes.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5Idler_16next_round_tasks___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5Idler_16next_round_tasks___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/idler.pyx":68 */
  Py_INCREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks);
  __pyx_r = ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Idler.next_round_tasks.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_list;


static int __pyx_f_5_soya_5Idler___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler___init__[] = "Idler(scene1, scene2,...) -> Idler\n\nCreates a new idler for scenes SCENE1, SCENE2,....";
static int __pyx_f_5_soya_5Idler___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_scenes = 0;
  PyObject *__pyx_v_soya;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_scenes, 0) < 0) return -1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_scenes);
    return -1;
  }
  Py_INCREF(__pyx_v_self);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);

  /* "/home/jiba/src/soya/idler.pyx":74 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks);
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":75 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->fps = 0.0;

  /* "/home/jiba/src/soya/idler.pyx":76 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->running = 0;

  /* "/home/jiba/src/soya/idler.pyx":77 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; goto __pyx_L1;}
  Py_INCREF(__pyx_v_scenes);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_scenes);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes);
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/idler.pyx":78 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->round_duration = 0.030;

  /* "/home/jiba/src/soya/idler.pyx":79 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->min_frame_duration = 0.020;

  /* "/home/jiba/src/soya/idler.pyx":80 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->will_render = 0;

  /* "/home/jiba/src/soya/idler.pyx":82 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 82; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":83 */
  if (PyObject_SetAttr(__pyx_v_soya, __pyx_n_IDLER, __pyx_v_self) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 83; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Idler.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_scenes);
  Py_DECREF(__pyx_v_soya);
  Py_DECREF(__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_n_thread;
static PyObject *__pyx_n_start_new_thread;
static PyObject *__pyx_n_idle;


static PyObject *__pyx_f_5_soya_5Idler_start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_start[] = "Idler.start()\n\nStarts idling with a new thread (see Idler.idle() if you don\'t want to create a new thread).";
static PyObject *__pyx_f_5_soya_5Idler_start(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_thread;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_thread = Py_None; Py_INCREF(__pyx_v_thread);

  /* "/home/jiba/src/soya/idler.pyx":89 */
  __pyx_1 = __Pyx_Import(__pyx_n_thread, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 89; goto __pyx_L1;}
  Py_DECREF(__pyx_v_thread);
  __pyx_v_thread = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":90 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_thread, __pyx_n_start_new_thread); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_idle); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Idler.start");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_thread);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5Idler_stop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_stop[] = "Idler.stop(VALUE = None)\n\nStops idling. The stopping may not occur immediately, but at the end of the next iteration.\nIdler.stop() causes Idler.idle() to returns ; VALUE is the (optionnal) value that Idler.idle() will return.";
static PyObject *__pyx_f_5_soya_5Idler_stop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_value = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"value",0};
  __pyx_v_value = __pyx_k18;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_value)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_value);

  /* "/home/jiba/src/soya/idler.pyx":97 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->running = 0;

  /* "/home/jiba/src/soya/idler.pyx":98 */
  Py_INCREF(__pyx_v_value);
  Py_DECREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_return_value);
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_return_value = __pyx_v_value;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Idler.stop");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_value);
  return __pyx_r;
}


static PyObject *__pyx_f_5_soya_5Idler_reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5Idler_reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_time;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  double __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_time = Py_None; Py_INCREF(__pyx_v_time);

  /* "/home/jiba/src/soya/idler.pyx":101 */
  __pyx_1 = __Pyx_Import(__pyx_n_time, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 101; goto __pyx_L1;}
  Py_DECREF(__pyx_v_time);
  __pyx_v_time = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":102 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time = __pyx_4;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Idler.reset");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_time);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_begin_round;
static PyObject *__pyx_n_advance_time;
static PyObject *__pyx_n_end_round;


static PyObject *__pyx_f_5_soya_5Idler_idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_idle[] = "Idler.idle()\n\nStarts idling with the current thread. This method never finishes, until you call Idler.stop().";
static PyObject *__pyx_f_5_soya_5Idler_idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_time;
  double __pyx_v_last_fps_computation_time;
  double __pyx_v_current;
  double __pyx_v_delta;
  double __pyx_v_spent_time;
  int __pyx_v_nb_frame;
  PyObject *__pyx_v_task;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  double __pyx_4;
  int __pyx_5;
  long __pyx_6;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_time = Py_None; Py_INCREF(__pyx_v_time);
  __pyx_v_task = Py_None; Py_INCREF(__pyx_v_task);

  /* "/home/jiba/src/soya/idler.pyx":108 */
  __pyx_1 = __Pyx_Import(__pyx_n_time, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 108; goto __pyx_L1;}
  Py_DECREF(__pyx_v_time);
  __pyx_v_time = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":113 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->running = 1;

  /* "/home/jiba/src/soya/idler.pyx":114 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time = __pyx_4;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_v_last_fps_computation_time = __pyx_4;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/idler.pyx":115 */
  ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time_since_last_round = 0.0;

  /* "/home/jiba/src/soya/idler.pyx":117 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 117; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 117; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 117; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/idler.pyx":119 */
  while (1) {
    __pyx_L2:;
    __pyx_5 = (((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->running == 1);
    if (!__pyx_5) break;

    /* "/home/jiba/src/soya/idler.pyx":120 */
    __pyx_v_nb_frame = 0;

    /* "/home/jiba/src/soya/idler.pyx":121 */
    while (1) {
      __pyx_L4:;
      __pyx_5 = (((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->running == 1);
      if (__pyx_5) {
        __pyx_5 = (__pyx_v_nb_frame < 80);
      }
      if (!__pyx_5) break;

      /* "/home/jiba/src/soya/idler.pyx":122 */
      __pyx_v_nb_frame = (__pyx_v_nb_frame + 1);

      /* "/home/jiba/src/soya/idler.pyx":124 */
      while (1) {
        __pyx_L6:;
        __pyx_6 = 1;
        if (!__pyx_6) break;

        /* "/home/jiba/src/soya/idler.pyx":125 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 125; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_v_current = __pyx_4;

        /* "/home/jiba/src/soya/idler.pyx":126 */
        __pyx_v_delta = (__pyx_v_current - ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time);

        /* "/home/jiba/src/soya/idler.pyx":127 */
        __pyx_5 = (__pyx_v_delta > ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->min_frame_duration);
        if (__pyx_5) {
          goto __pyx_L7;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/idler.pyx":128 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_sleep); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; goto __pyx_L1;}
        __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->min_frame_duration - __pyx_v_delta)); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
        __pyx_2 = 0;
        __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/idler.pyx":130 */
      ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time = __pyx_v_current;

      /* "/home/jiba/src/soya/idler.pyx":132 */
      while (1) {
        __pyx_L9:;
        __pyx_5 = ((((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time_since_last_round + __pyx_v_delta) > ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->round_duration);
        if (!__pyx_5) break;

        /* "/home/jiba/src/soya/idler.pyx":133 */
        __pyx_v_spent_time = (((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->round_duration - ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time_since_last_round);

        /* "/home/jiba/src/soya/idler.pyx":135 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_advance_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; goto __pyx_L1;}
        __pyx_3 = PyFloat_FromDouble((__pyx_v_spent_time / ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->round_duration)); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;

        /* "/home/jiba/src/soya/idler.pyx":136 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_end_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 136; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 136; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 136; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;

        /* "/home/jiba/src/soya/idler.pyx":137 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 137; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 137; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 137; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;

        /* "/home/jiba/src/soya/idler.pyx":139 */
        __pyx_5 = PyObject_IsTrue(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 139; goto __pyx_L1;}
        if (__pyx_5) {

          /* "/home/jiba/src/soya/idler.pyx":140 */
          __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; goto __pyx_L1;}
          for (;;) {
            __pyx_L12:;
            __pyx_2 = PyIter_Next(__pyx_1);
            if (!__pyx_2) {
              if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; goto __pyx_L1;}
              break;
            }
            Py_DECREF(__pyx_v_task);
            __pyx_v_task = __pyx_2;
            __pyx_2 = 0;
            __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; goto __pyx_L1;}
            __pyx_2 = PyObject_CallObject(__pyx_v_task, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 140; goto __pyx_L1;}
            Py_DECREF(__pyx_3); __pyx_3 = 0;
            Py_DECREF(__pyx_2); __pyx_2 = 0;
          }
          __pyx_L13:;
          Py_DECREF(__pyx_1); __pyx_1 = 0;

          /* "/home/jiba/src/soya/idler.pyx":141 */
          __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; goto __pyx_L1;}
          Py_DECREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks);
          ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_next_round_tasks = __pyx_3;
          __pyx_3 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/jiba/src/soya/idler.pyx":143 */
        __pyx_v_delta = (__pyx_v_delta - __pyx_v_spent_time);

        /* "/home/jiba/src/soya/idler.pyx":144 */
        ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time_since_last_round = 0;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/idler.pyx":146 */
      ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->will_render = 1;

      /* "/home/jiba/src/soya/idler.pyx":147 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_advance_time); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; goto __pyx_L1;}
      __pyx_1 = PyFloat_FromDouble((__pyx_v_delta / ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->round_duration)); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
      __pyx_1 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/jiba/src/soya/idler.pyx":148 */
      ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->will_render = 0;

      /* "/home/jiba/src/soya/idler.pyx":149 */
      ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time_since_last_round = (((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_time_since_last_round + __pyx_v_delta);

      /* "/home/jiba/src/soya/idler.pyx":151 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_render); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 151; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 151; goto __pyx_L1;}
      __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 151; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/idler.pyx":153 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 153; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_v_current = __pyx_4;

    /* "/home/jiba/src/soya/idler.pyx":154 */
    ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->fps = (__pyx_v_nb_frame / (__pyx_v_current - __pyx_v_last_fps_computation_time));

    /* "/home/jiba/src/soya/idler.pyx":155 */
    __pyx_v_last_fps_computation_time = __pyx_v_current;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/idler.pyx":157 */
  Py_INCREF(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_return_value);
  __pyx_r = ((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_return_value;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Idler.idle");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_time);
  Py_DECREF(__pyx_v_task);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_widget_begin_round;

static PyObject *__pyx_f_5_soya_5Idler_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_begin_round[] = "Idler.begin_round()\n\nCalled by Idler.idle when a new round begins; default implementation delegates to Idler.scene.begin_round.";
static PyObject *__pyx_f_5_soya_5Idler_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_scene;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_scene = Py_None; Py_INCREF((PyObject *) __pyx_v_scene);
  __pyx_v_item = Py_None; Py_INCREF(__pyx_v_item);

  /* "/home/jiba/src/soya/idler.pyx":164 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_IDLEING_ITEMS); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_1;
    __pyx_1 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_v_item, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 164; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/idler.pyx":165 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_3 = PyIter_Next(__pyx_1);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_scene));
    __pyx_v_scene = __pyx_3;
    __pyx_3 = 0;
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_scene), __pyx_n_begin_round); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 165; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L5:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":166 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; goto __pyx_L1;}
  __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_5) {
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_widget_begin_round); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 166; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Idler.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_scene);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_widget_end_round;

static PyObject *__pyx_f_5_soya_5Idler_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_end_round[] = "Idler.end_round()\n\nCalled by Idler.idle when a round is finished; default implementation delegates to Idler.scene.end_round.";
static PyObject *__pyx_f_5_soya_5Idler_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_scene;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_scene = Py_None; Py_INCREF((PyObject *) __pyx_v_scene);
  __pyx_v_item = Py_None; Py_INCREF(__pyx_v_item);

  /* "/home/jiba/src/soya/idler.pyx":173 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_IDLEING_ITEMS); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_1;
    __pyx_1 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_v_item, __pyx_n_end_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/idler.pyx":174 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_3 = PyIter_Next(__pyx_1);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_scene));
    __pyx_v_scene = __pyx_3;
    __pyx_3 = 0;
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_scene), __pyx_n_end_round); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L5:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":175 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; goto __pyx_L1;}
  __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_5) {
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_widget_end_round); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/idler.pyx":177 */
  PyErr_CheckSignals();

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Idler.end_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_scene);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_widget_advance_time;

static PyObject *__pyx_f_5_soya_5Idler_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_advance_time[] = "Idler.advance_time(proportion)\n\nCalled by Idler.idle when a piece of a round has occured; default implementation delegates to Idler.scene.advance_time.\nPROPORTION is the proportion of the current round\'s time that has passed (1.0 for an entire round).";
static PyObject *__pyx_f_5_soya_5Idler_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  struct __pyx_obj_5_soya__World *__pyx_v_scene;
  PyObject *__pyx_v_item;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_scene = Py_None; Py_INCREF((PyObject *) __pyx_v_scene);
  __pyx_v_item = Py_None; Py_INCREF(__pyx_v_item);

  /* "/home/jiba/src/soya/idler.pyx":185 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_IDLEING_ITEMS); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_item);
    __pyx_v_item = __pyx_1;
    __pyx_1 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_v_item, __pyx_n_advance_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 185; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/idler.pyx":186 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_Idler *)__pyx_v_self)->_scenes); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_4 = PyIter_Next(__pyx_1);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_scene));
    __pyx_v_scene = __pyx_4;
    __pyx_4 = 0;
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_scene), __pyx_n_advance_time); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
    __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 186; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L5:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":187 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_5) {
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_widget_advance_time); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_1 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 187; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Idler.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_scene);
  Py_DECREF(__pyx_v_item);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5Idler_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5Idler_render[] = "Idler.render()\n\nCalled by Idler.idle when rendering is needed; default implementation calls soya.render.";
static PyObject *__pyx_f_5_soya_5Idler_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_i = Py_None; Py_INCREF(__pyx_v_i);

  /* "/home/jiba/src/soya/idler.pyx":193 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_BEFORE_RENDER); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_1;
    __pyx_1 = 0;
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_v_i, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/idler.pyx":194 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_render); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 194; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 194; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 194; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Idler.render");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_11_Atmosphere___init__[] = "Atmosphere()\n\nCreate a new Atmosphere.";
static int __pyx_f_5_soya_11_Atmosphere___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":59 */
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[0]) = 0.5;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[1]) = 0.5;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[2]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":60 */
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[3]) = 1.0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[3]) = 1.0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[3]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":61 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type = GL_LINEAR;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":62 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_start = 10.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":63 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_end = 100.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":64 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_density = 1.0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Atmosphere.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere___getcstate__(struct __pyx_obj_5_soya__Atmosphere *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":69 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":70 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":71 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_type);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":72 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_start);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":73 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_end);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":74 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_density);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":75 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":76 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":77 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":78 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 78; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_11_Atmosphere___setcstate__(struct __pyx_obj_5_soya__Atmosphere *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":83 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":84 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":85 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_type));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":86 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_start));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":87 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_end));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":88 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_density));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":89 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":90 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":91 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":92 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Atmosphere.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_3fog___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_3fog___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":96 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_option & __pyx_e_5_soya_ATMOSPHERE_FOG)); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.fog.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_3fog___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_3fog___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":98 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_x); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 98; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_option | __pyx_e_5_soya_ATMOSPHERE_FOG);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_option & (~__pyx_e_5_soya_ATMOSPHERE_FOG));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Atmosphere.fog.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_8fog_type___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_8fog_type___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":103 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type == GL_LINEAR);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":104 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type == GL_EXP);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 104; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":105 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type == GL_EXP2);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 105; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Atmosphere.fog_type.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_8fog_type___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_8fog_type___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 107; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":108 */
  __pyx_1 = (__pyx_v_x == 0);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type = GL_LINEAR;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":109 */
  __pyx_1 = (__pyx_v_x == 1);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type = GL_EXP;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":110 */
  __pyx_1 = (__pyx_v_x == 2);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type = GL_EXP2;
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Atmosphere.fog_type.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_9fog_start___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_9fog_start___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":114 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_start); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.fog_start.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_9fog_start___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_9fog_start___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":116 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_start = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Atmosphere.fog_start.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_7fog_end___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_7fog_end___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":120 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_end); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 120; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.fog_end.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_7fog_end___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_7fog_end___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":122 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_end = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Atmosphere.fog_end.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_11fog_density___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_11fog_density___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":126 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_density); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 126; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.fog_density.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_11fog_density___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_11fog_density___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 127; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":128 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_density = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Atmosphere.fog_density.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_7ambient___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_7ambient___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":132 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Atmosphere.ambient.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_7ambient___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_7ambient___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":134 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_ambient[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.ambient.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_8bg_color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_8bg_color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":138 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Atmosphere.bg_color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_8bg_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_8bg_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":140 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_bg_color[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.bg_color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Atmosphere_9fog_color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Atmosphere_9fog_color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":144 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Atmosphere.fog_color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Atmosphere_9fog_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_11_Atmosphere_9fog_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":146 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_color[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Atmosphere.fog_color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static void __pyx_f_5_soya_11_Atmosphere__clear(struct __pyx_obj_5_soya__Atmosphere *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":149 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_clear_screen(__pyx_v_5_soya_renderer,__pyx_v_self->_bg_color);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":150 */
  ((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_self->__pyx_base.__pyx_vtab)->_draw_bg(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Atmosphere._clear");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_11_Atmosphere__draw_bg(struct __pyx_obj_5_soya__Atmosphere *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":153 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Atmosphere._draw_bg");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static char (__pyx_k197[]) = "Apply fog and ambient.";

static void __pyx_f_5_soya_11_Atmosphere__render(struct __pyx_obj_5_soya__Atmosphere *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":156 */
  __pyx_k197;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":157 */
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT,__pyx_v_self->_ambient);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":158 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_ATMOSPHERE_FOG);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":159 */
    glFogf(GL_FOG_MODE,__pyx_v_self->_fog_type);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":160 */
    glFogf(GL_FOG_START,__pyx_v_self->_fog_start);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":161 */
    glFogf(GL_FOG_END,__pyx_v_self->_fog_end);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":162 */
    glFogf(GL_FOG_DENSITY,__pyx_v_self->_fog_density);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":163 */
    glFogfv(GL_FOG_COLOR,__pyx_v_self->_fog_color);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":164 */
    glEnable(GL_FOG);
    goto __pyx_L2;
  }
  /*else*/ {
    glDisable(GL_FOG);
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Atmosphere._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static float __pyx_f_5_soya_11_Atmosphere__fog_factor_at(struct __pyx_obj_5_soya__Atmosphere *__pyx_v_self,float (*__pyx_v_p)) {
  float __pyx_v_z;
  float __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":169 */
  __pyx_v_z = sqrt(((((__pyx_v_p[0]) * (__pyx_v_p[0])) + ((__pyx_v_p[1]) * (__pyx_v_p[1]))) + ((__pyx_v_p[2]) * (__pyx_v_p[2]))));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":170 */
  __pyx_1 = (__pyx_v_self->_fog_type == GL_LINEAR);
  if (__pyx_1) {
    __pyx_r = ((float )(1.0 - ((__pyx_v_self->_fog_end - __pyx_v_z) / (__pyx_v_self->_fog_end - __pyx_v_self->_fog_start))));
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->_fog_type == GL_EXP);
  if (__pyx_1) {
    __pyx_r = ((float )(1.0 - exp((__pyx_v_self->_fog_density * __pyx_v_z))));
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->_fog_type == GL_EXP2);
  if (__pyx_1) {
    __pyx_r = ((float )(1.0 - exp((((__pyx_v_self->_fog_density * __pyx_v_self->_fog_density) * __pyx_v_z) * __pyx_v_z))));
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":173 */
  __pyx_r = 0.0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Atmosphere._fog_factor_at");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_23_NoBackgroundAtmosphere__clear(struct __pyx_obj_5_soya__NoBackgroundAtmosphere *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":177 */
  glClear(GL_DEPTH_BUFFER_BIT);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._NoBackgroundAtmosphere._clear");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_14_SkyAtmosphere___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_14_SkyAtmosphere___init__[] = "SkyAtmosphere()\n\nCreate a SkyAtmosphere";
static int __pyx_f_5_soya_14_SkyAtmosphere___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":190 */
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._ambient[0]) = 0.5;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._ambient[1]) = 0.5;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._ambient[2]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":191 */
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._ambient[3]) = 1.0;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._bg_color[3]) = 1.0;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_color[3]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":192 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_type = GL_LINEAR;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":193 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_start = 10.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":194 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_end = 100.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":195 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_density = 1.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":196 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box);
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":197 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud_scale = 1.0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_SkyAtmosphere___getcstate__(struct __pyx_obj_5_soya__SkyAtmosphere *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":202 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":203 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":204 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_type);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":205 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_start);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":206 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_end);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":207 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_density);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":208 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":209 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":210 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":211 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sky_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":212 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_cloud_scale);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":213 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 213; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 213; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_cloud));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_cloud));
  Py_INCREF(__pyx_v_self->_sky_box);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_self->_sky_box);
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_14_SkyAtmosphere___setcstate__(struct __pyx_obj_5_soya__SkyAtmosphere *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_cstate2;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":217 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_cloud));
  __pyx_v_self->_cloud = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_sky_box);
  __pyx_v_self->_sky_box = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":219 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":220 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":221 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_type));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":222 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_start));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":223 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_end));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":224 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_density));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":225 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":226 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":227 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":228 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sky_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":229 */
  __pyx_4 = PyObject_Length(__pyx_v_cstate2); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 229; goto __pyx_L1;}
  __pyx_5 = (__pyx_4 >= 88);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":230 */
    chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_cloud_scale));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":232 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SkyAtmosphere.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_set_sky_box(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_14_SkyAtmosphere_set_sky_box[] = "SkyAtmosphere.set_sky_box(FRONT, RIGHT, BACK, LEFT, BOTTOM, TOP = None)\n\nSets the sky box. The sky box is made of 6 materials that are displayed on the 6 faces of a cube.\nThe TOP material is optional.\n";
static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_set_sky_box(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_front = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_right = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_back = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_left = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_bottom = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_top = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"front","right","back","left","bottom","top",0};
  __pyx_v_top = __pyx_k19;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOO|O", __pyx_argnames, &__pyx_v_front, &__pyx_v_right, &__pyx_v_back, &__pyx_v_left, &__pyx_v_bottom, &__pyx_v_top)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_front);
  Py_INCREF((PyObject *)__pyx_v_right);
  Py_INCREF((PyObject *)__pyx_v_back);
  Py_INCREF((PyObject *)__pyx_v_left);
  Py_INCREF((PyObject *)__pyx_v_bottom);
  Py_INCREF((PyObject *)__pyx_v_top);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_front), __pyx_ptype_5_soya__Material, 1, "front")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right), __pyx_ptype_5_soya__Material, 1, "right")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_back), __pyx_ptype_5_soya__Material, 1, "back")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left), __pyx_ptype_5_soya__Material, 1, "left")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bottom), __pyx_ptype_5_soya__Material, 1, "bottom")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_top), __pyx_ptype_5_soya__Material, 1, "top")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":240 */
  __pyx_1 = ((PyObject *)__pyx_v_top) == Py_None;
  if (__pyx_1) {
    __pyx_2 = PyTuple_New(5); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 240; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_front));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_front));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_right));
    PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_right));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_back));
    PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_back));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_left));
    PyTuple_SET_ITEM(__pyx_2, 3, ((PyObject *)__pyx_v_left));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_bottom));
    PyTuple_SET_ITEM(__pyx_2, 4, ((PyObject *)__pyx_v_bottom));
    Py_DECREF(((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box);
    ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyTuple_New(6); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 241; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_front));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_front));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_right));
    PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_right));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_back));
    PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_back));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_left));
    PyTuple_SET_ITEM(__pyx_2, 3, ((PyObject *)__pyx_v_left));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_bottom));
    PyTuple_SET_ITEM(__pyx_2, 4, ((PyObject *)__pyx_v_bottom));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_top));
    PyTuple_SET_ITEM(__pyx_2, 5, ((PyObject *)__pyx_v_top));
    Py_DECREF(((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box);
    ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.set_sky_box");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_front);
  Py_DECREF((PyObject *)__pyx_v_right);
  Py_DECREF((PyObject *)__pyx_v_back);
  Py_DECREF((PyObject *)__pyx_v_left);
  Py_DECREF((PyObject *)__pyx_v_bottom);
  Py_DECREF((PyObject *)__pyx_v_top);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_7sky_box___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_7sky_box___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":245 */
  Py_INCREF(((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box);
  __pyx_r = ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SkyAtmosphere.sky_box.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_front;
static PyObject *__pyx_n_right;
static PyObject *__pyx_n_back;
static PyObject *__pyx_n_left;
static PyObject *__pyx_n_bottom;
static PyObject *__pyx_n_top;

static PyObject *__pyx_k198p;

static char (__pyx_k198[]) = "Sky box must be a tuple of 5 or 6 materials";

static int __pyx_f_5_soya_14_SkyAtmosphere_7sky_box___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_sky_box); /*proto*/
static int __pyx_f_5_soya_14_SkyAtmosphere_7sky_box___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_sky_box) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_sky_box);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":247 */
  __pyx_2 = PyObject_Length(__pyx_v_sky_box); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_1 = (__pyx_2 == 0);
  if (!__pyx_1) {
    __pyx_2 = PyObject_Length(__pyx_v_sky_box); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 247; goto __pyx_L1;}
    __pyx_1 = (__pyx_2 == 5);
    if (!__pyx_1) {
      __pyx_2 = PyObject_Length(__pyx_v_sky_box); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 247; goto __pyx_L1;}
      __pyx_1 = (__pyx_2 == 6);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":248 */
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_front); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_right); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_back); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_left); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_bottom); if (!__pyx_7) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_8 = __Pyx_GetName(__pyx_b, __pyx_n_top); if (!__pyx_8) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_9 = PyTuple_New(6); if (!__pyx_9) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 248; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_9, 0, __pyx_3);
    PyTuple_SET_ITEM(__pyx_9, 1, __pyx_4);
    PyTuple_SET_ITEM(__pyx_9, 2, __pyx_5);
    PyTuple_SET_ITEM(__pyx_9, 3, __pyx_6);
    PyTuple_SET_ITEM(__pyx_9, 4, __pyx_7);
    PyTuple_SET_ITEM(__pyx_9, 5, __pyx_8);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_6 = 0;
    __pyx_7 = 0;
    __pyx_8 = 0;
    Py_DECREF(((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box);
    ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_box = __pyx_9;
    __pyx_9 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 249; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 249; goto __pyx_L1;}
    Py_INCREF(__pyx_k198p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k198p);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 249; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[5]; __pyx_lineno = 249; goto __pyx_L1;}
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.sky_box.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_sky_box);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_9sky_color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_9sky_color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":253 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 253; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.sky_color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14_SkyAtmosphere_9sky_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_14_SkyAtmosphere_9sky_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":255 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_sky_color[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.sky_color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_5cloud___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_5cloud___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":259 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SkyAtmosphere.cloud.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14_SkyAtmosphere_5cloud___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_14_SkyAtmosphere_5cloud___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 1, "x")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 260; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":261 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud));
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SkyAtmosphere.cloud.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_11cloud_scale___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14_SkyAtmosphere_11cloud_scale___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":265 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 265; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SkyAtmosphere.cloud_scale.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14_SkyAtmosphere_11cloud_scale___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_14_SkyAtmosphere_11cloud_scale___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 266; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":267 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->_cloud_scale = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SkyAtmosphere.cloud_scale.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_14_SkyAtmosphere__draw_bg(struct __pyx_obj_5_soya__SkyAtmosphere *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":270 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":271 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":272 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":273 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":274 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":275 */
  __pyx_1 = ((__pyx_v_self->_sky_color[3]) != 0.0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__SkyAtmosphere *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_draw_sky_plane(__pyx_v_self);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":276 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_self->_sky_box); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 276; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__SkyAtmosphere *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_draw_sky_box(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":277 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":278 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":279 */
  glEnable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":280 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":281 */
  glEnable(GL_CULL_FACE);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SkyAtmosphere._draw_bg");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_activate;

static void __pyx_f_5_soya_14_SkyAtmosphere__draw_sky_plane(struct __pyx_obj_5_soya__SkyAtmosphere *__pyx_v_self) {
  int __pyx_v_nb2;
  int __pyx_v_nb3;
  int __pyx_v_i;
  float (__pyx_v_plane[4]);
  float (__pyx_v_face1[12]);
  float __pyx_v_y;
  float __pyx_v_h;
  float __pyx_v_f;
  float __pyx_v_g;
  float (*__pyx_v_ptr);
  float (*__pyx_v_face2);
  float (*__pyx_v_face3);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":288 */
  glLoadMatrixf(__pyx_v_5_soya_renderer->current_camera->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":291 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL), __pyx_n_activate); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":292 */
  __pyx_v_ptr = __pyx_v_5_soya_renderer->current_camera->_frustum->points;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":293 */
  for (__pyx_v_i = 0; __pyx_v_i < 12; ++__pyx_v_i) {
    (__pyx_v_face1[__pyx_v_i]) = ((__pyx_v_ptr[(12 + __pyx_v_i)]) * 0.5);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":295 */
  __pyx_v_ptr = ((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":296 */
  point_by_matrix(__pyx_v_face1,__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":297 */
  point_by_matrix((__pyx_v_face1 + 3),__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":298 */
  point_by_matrix((__pyx_v_face1 + 6),__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":299 */
  point_by_matrix((__pyx_v_face1 + 9),__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":301 */
  __pyx_v_y = (__pyx_v_5_soya_renderer->current_camera->_back * 0.5);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":302 */
  __pyx_v_h = (__pyx_v_5_soya_renderer->root_frustum->position[1]);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":303 */
  (__pyx_v_plane[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":304 */
  (__pyx_v_plane[1]) = (-1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":305 */
  (__pyx_v_plane[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":306 */
  (__pyx_v_plane[3]) = (__pyx_v_h + __pyx_v_y);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":307 */
  face_intersect_plane(__pyx_v_face1,4,__pyx_v_plane,(&__pyx_v_face2),(&__pyx_v_nb2));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":308 */
  __pyx_4 = (__pyx_v_nb2 > 0);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":309 */
    glColor4fv(__pyx_v_self->_sky_color);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":310 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":311 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb2; ++__pyx_v_i) {
      glVertex3fv((__pyx_v_face2 + (__pyx_v_i * 3)));
      __pyx_L5:;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":312 */
    glEnd();
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":313 */
  free(__pyx_v_face2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":315 */
  (__pyx_v_plane[1]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":316 */
  (__pyx_v_plane[3]) = (-(__pyx_v_plane[3]));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":317 */
  face_intersect_plane(__pyx_v_face1,4,__pyx_v_plane,(&__pyx_v_face3),(&__pyx_v_nb3));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":318 */
  (__pyx_v_plane[1]) = (-1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":319 */
  (__pyx_v_plane[3]) = (__pyx_v_5_soya_renderer->root_frustum->position[1]);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":320 */
  face_intersect_plane(__pyx_v_face3,__pyx_v_nb3,__pyx_v_plane,(&__pyx_v_face2),(&__pyx_v_nb2));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":321 */
  free(__pyx_v_face3);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":322 */
  __pyx_4 = (__pyx_v_nb2 > 0);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":323 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":324 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":325 */
    while (1) {
      __pyx_L8:;
      __pyx_4 = (__pyx_v_i < (__pyx_v_nb2 * 3));
      if (!__pyx_4) break;

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":326 */
      __pyx_v_f = (((__pyx_v_face2[(__pyx_v_i + 1)]) - __pyx_v_h) / __pyx_v_y);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":327 */
      __pyx_v_g = (1.0 - __pyx_v_f);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":328 */
      glColor4f((((__pyx_v_self->_sky_color[0]) * __pyx_v_f) + ((__pyx_v_self->__pyx_base._bg_color[0]) * __pyx_v_g)),(((__pyx_v_self->_sky_color[1]) * __pyx_v_f) + ((__pyx_v_self->__pyx_base._bg_color[1]) * __pyx_v_g)),(((__pyx_v_self->_sky_color[2]) * __pyx_v_f) + ((__pyx_v_self->__pyx_base._bg_color[2]) * __pyx_v_g)),(((__pyx_v_self->_sky_color[3]) * __pyx_v_f) + ((__pyx_v_self->__pyx_base._bg_color[3]) * __pyx_v_g)));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":332 */
      glVertex3fv((__pyx_v_face2 + __pyx_v_i));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":333 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":334 */
    glEnd();
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":335 */
  free(__pyx_v_face2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":338 */
  __pyx_4 = ((PyObject *)__pyx_v_self->_cloud) == Py_None;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":339 */
    (__pyx_v_plane[1]) = ((__pyx_v_5_soya_renderer->root_frustum->position[1]) + 5.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":340 */
    __pyx_v_h = (__pyx_v_5_soya_renderer->current_camera->_back * 0.7);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":341 */
    glEnable(GL_BLEND);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":342 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_cloud), __pyx_n_activate); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":344 */
    __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":345 */
    (__pyx_v_plane[0]) = (((__pyx_v_ptr[0]) * 0.01) * __pyx_v_self->_cloud_scale);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":346 */
    (__pyx_v_plane[2]) = (((__pyx_v_ptr[2]) * 0.01) * __pyx_v_self->_cloud_scale);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":347 */
    __pyx_v_y = ((__pyx_v_h * 0.1) * __pyx_v_self->_cloud_scale);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":349 */
    __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":350 */
    glTranslatef((__pyx_v_ptr[0]),0.0,(__pyx_v_ptr[2]));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":352 */
    glBegin(GL_TRIANGLE_FAN);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":354 */
    glTexCoord2f((__pyx_v_plane[0]),(__pyx_v_plane[2]));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":355 */
    glVertex3f(0.0,(__pyx_v_plane[1]),0.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":357 */
    __pyx_v_ptr = __pyx_v_self->_cloud->_diffuse;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":358 */
    glColor4f((__pyx_v_ptr[0]),(__pyx_v_ptr[1]),(__pyx_v_ptr[2]),0.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":360 */
    glTexCoord2f(((__pyx_v_plane[0]) - __pyx_v_y),((__pyx_v_plane[2]) - __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":360 */
    glVertex3f((-__pyx_v_h),(__pyx_v_plane[1]),(-__pyx_v_h));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":361 */
    glTexCoord2f(((__pyx_v_plane[0]) + __pyx_v_y),((__pyx_v_plane[2]) - __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":361 */
    glVertex3f(__pyx_v_h,(__pyx_v_plane[1]),(-__pyx_v_h));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":362 */
    glTexCoord2f(((__pyx_v_plane[0]) + __pyx_v_y),((__pyx_v_plane[2]) + __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":362 */
    glVertex3f(__pyx_v_h,(__pyx_v_plane[1]),__pyx_v_h);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":363 */
    glTexCoord2f(((__pyx_v_plane[0]) - __pyx_v_y),((__pyx_v_plane[2]) + __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":363 */
    glVertex3f((-__pyx_v_h),(__pyx_v_plane[1]),__pyx_v_h);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":364 */
    glTexCoord2f(((__pyx_v_plane[0]) - __pyx_v_y),((__pyx_v_plane[2]) - __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":364 */
    glVertex3f((-__pyx_v_h),(__pyx_v_plane[1]),(-__pyx_v_h));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":366 */
    glEnd();

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":367 */
    glDisable(GL_BLEND);
    goto __pyx_L10;
  }
  __pyx_L10:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SkyAtmosphere._draw_sky_plane");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_14_SkyAtmosphere__draw_sky_box(struct __pyx_obj_5_soya__SkyAtmosphere *__pyx_v_self) {
  int __pyx_v_nb;
  float (*__pyx_v_ptr);
  float __pyx_v_SKY_BOX_DISTANCE;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":373 */
  __pyx_v_SKY_BOX_DISTANCE = 10.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":374 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_sky_box); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_v_nb = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":375 */
  __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":376 */
  glLoadMatrixf(__pyx_v_5_soya_renderer->current_camera->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":377 */
  glTranslatef((__pyx_v_ptr[0]),(__pyx_v_ptr[1]),(__pyx_v_ptr[2]));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":378 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_ATMOSPHERE_SKY_BOX_ALPHA);
  if (__pyx_1) {
    glEnable(GL_BLEND);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":381 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 381; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 381; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_activate); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 381; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 381; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 381; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":382 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":383 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":383 */
  glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":384 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":384 */
  glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":385 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":385 */
  glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":386 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":386 */
  glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":387 */
  glEnd();

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":389 */
  __pyx_1 = (__pyx_v_nb > 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":391 */
    __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 391; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_activate); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 391; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":392 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":393 */
    glTexCoord2f(0.0,0.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":393 */
    glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":394 */
    glTexCoord2f(1.0,0.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":394 */
    glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":395 */
    glTexCoord2f(1.0,1.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":395 */
    glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":396 */
    glTexCoord2f(0.0,1.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":396 */
    glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":397 */
    glEnd();

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":399 */
    __pyx_1 = (__pyx_v_nb > 2);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":401 */
      __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 401; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 401; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_activate); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 401; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 401; goto __pyx_L1;}
      __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 401; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":402 */
      glBegin(GL_QUADS);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":403 */
      glTexCoord2f(0.0,0.0);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":403 */
      glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":404 */
      glTexCoord2f(1.0,0.0);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":404 */
      glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":405 */
      glTexCoord2f(1.0,1.0);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":405 */
      glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":406 */
      glTexCoord2f(0.0,1.0);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":406 */
      glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":407 */
      glEnd();

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":409 */
      __pyx_1 = (__pyx_v_nb > 3);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":411 */
        __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 411; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 411; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_activate); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 411; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 411; goto __pyx_L1;}
        __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 411; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":412 */
        glBegin(GL_QUADS);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":413 */
        glTexCoord2f(0.0,0.0);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":413 */
        glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE));

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":414 */
        glTexCoord2f(1.0,0.0);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":414 */
        glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":415 */
        glTexCoord2f(1.0,1.0);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":415 */
        glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":416 */
        glTexCoord2f(0.0,1.0);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":416 */
        glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":417 */
        glEnd();

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":419 */
        __pyx_1 = (__pyx_v_nb > 4);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":421 */
          __pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 421; goto __pyx_L1;}
          __pyx_3 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 421; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_activate); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 421; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 421; goto __pyx_L1;}
          __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 421; goto __pyx_L1;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_3); __pyx_3 = 0;

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":422 */
          glBegin(GL_QUADS);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":423 */
          glTexCoord2f(0.0,0.0);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":423 */
          glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":424 */
          glTexCoord2f(1.0,0.0);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":424 */
          glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":425 */
          glTexCoord2f(1.0,1.0);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":425 */
          glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":426 */
          glTexCoord2f(0.0,1.0);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":426 */
          glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":427 */
          glEnd();

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":429 */
          __pyx_1 = (__pyx_v_nb > 5);
          if (__pyx_1) {

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":431 */
            __pyx_4 = PyInt_FromLong(5); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 431; goto __pyx_L1;}
            __pyx_2 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 431; goto __pyx_L1;}
            Py_DECREF(__pyx_4); __pyx_4 = 0;
            __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_activate); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 431; goto __pyx_L1;}
            Py_DECREF(__pyx_2); __pyx_2 = 0;
            __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 431; goto __pyx_L1;}
            __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 431; goto __pyx_L1;}
            Py_DECREF(__pyx_3); __pyx_3 = 0;
            Py_DECREF(__pyx_4); __pyx_4 = 0;
            Py_DECREF(__pyx_2); __pyx_2 = 0;

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":432 */
            glBegin(GL_QUADS);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":433 */
            glTexCoord2f(0.0,0.0);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":433 */
            glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE));

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":434 */
            glTexCoord2f(1.0,0.0);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":434 */
            glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE));

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":435 */
            glTexCoord2f(1.0,1.0);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":435 */
            glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":436 */
            glTexCoord2f(0.0,1.0);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":436 */
            glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":437 */
            glEnd();
            goto __pyx_L7;
          }
          __pyx_L7:;
          goto __pyx_L6;
        }
        __pyx_L6:;
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":439 */
  glDisable(GL_BLEND);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SkyAtmosphere._draw_sky_box");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_make_raypick_result(float (*__pyx_v_f),float __pyx_v_z,float (*__pyx_v_normal),struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Point *__pyx_v_p,struct __pyx_obj_5_soya__Vector *__pyx_v_v) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_p);
  Py_INCREF((PyObject *)__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":23 */
  __pyx_1 = (__pyx_v_f == 0);
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":24 */
  __pyx_1 = ((PyObject *)__pyx_v_p) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":25 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(((__pyx_v_f[0]) + ((__pyx_v_f[3]) * __pyx_v_z))); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(((__pyx_v_f[1]) + ((__pyx_v_f[4]) * __pyx_v_z))); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(((__pyx_v_f[2]) + ((__pyx_v_f[5]) * __pyx_v_z))); if (!__pyx_5) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)__pyx_v_coordsyst));
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
    PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_p));
    __pyx_v_p = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":26 */
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_coordsyst));
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_v));
    __pyx_v_v = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":27 */
    memcpy(__pyx_v_v->__pyx_base._matrix,__pyx_v_normal,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":28 */
    __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 28; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_p));
    PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)__pyx_v_p));
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_v));
    PyTuple_SET_ITEM(__pyx_6, 1, ((PyObject *)__pyx_v_v));
    __pyx_r = __pyx_6;
    __pyx_6 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":30 */
    Py_INCREF(((PyObject *)__pyx_v_coordsyst));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_p->__pyx_base._parent));
    __pyx_v_p->__pyx_base._parent = ((PyObject *)__pyx_v_coordsyst);
    Py_INCREF(((PyObject *)__pyx_v_coordsyst));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_v->__pyx_base.__pyx_base._parent));
    __pyx_v_v->__pyx_base.__pyx_base._parent = ((PyObject *)__pyx_v_coordsyst);

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":31 */
    (__pyx_v_p->_matrix[0]) = ((__pyx_v_f[0]) + ((__pyx_v_f[3]) * __pyx_v_z));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":32 */
    (__pyx_v_p->_matrix[1]) = ((__pyx_v_f[1]) + ((__pyx_v_f[4]) * __pyx_v_z));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":33 */
    (__pyx_v_p->_matrix[2]) = ((__pyx_v_f[2]) + ((__pyx_v_f[5]) * __pyx_v_z));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":34 */
    memcpy(__pyx_v_v->__pyx_base._matrix,__pyx_v_normal,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":35 */
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 35; goto __pyx_L1;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya.make_raypick_result");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_v);
  return __pyx_r;
}

static int __pyx_f_5_soya_11RaypickData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_11RaypickData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":47 */
  ((struct __pyx_obj_5_soya_RaypickData *)__pyx_v_self)->raypicked = get_chunk();

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":48 */
  ((struct __pyx_obj_5_soya_RaypickData *)__pyx_v_self)->raypick_data = get_chunk();

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.RaypickData.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_11RaypickData___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_11RaypickData___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":51 */
  drop_chunk(((struct __pyx_obj_5_soya_RaypickData *)__pyx_v_self)->raypicked);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":52 */
  drop_chunk(((struct __pyx_obj_5_soya_RaypickData *)__pyx_v_self)->raypick_data);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.RaypickData.__dealloc__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static struct __pyx_obj_5_soya_RaypickData *__pyx_f_5_soya_get_raypick_data(void) {
  struct __pyx_obj_5_soya_RaypickData *__pyx_r;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":58 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 58; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_raypick_data->result_coordsyst));
  __pyx_v_5_soya_raypick_data->result_coordsyst = Py_None;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":59 */
  __pyx_v_5_soya_raypick_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":60 */
  __pyx_v_5_soya_raypick_data->raypick_data->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":61 */
  Py_INCREF(((PyObject *)__pyx_v_5_soya_raypick_data));
  __pyx_r = (struct __pyx_obj_5_soya_RaypickData *)((PyObject *)__pyx_v_5_soya_raypick_data);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.get_raypick_data");
  __pyx_r = 0;
  __pyx_L0:;
  return ((struct __pyx_obj_5_soya_RaypickData *)__pyx_r) ;
}

static int __pyx_f_5_soya_14RaypickContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_14RaypickContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_root = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {"root",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_root)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_root);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root), __pyx_ptype_5_soya__World, 1, "root")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 68; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":69 */
  ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items = get_chunk();

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":70 */
  Py_INCREF(((PyObject *)__pyx_v_root));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_root));
  ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_root = ((PyObject *)__pyx_v_root);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.RaypickContext.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_root);
  return __pyx_r;
}

static void __pyx_f_5_soya_14RaypickContext___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_14RaypickContext___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":73 */
  drop_chunk(((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.RaypickContext.__dealloc__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_14RaypickContext_raypick(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_14RaypickContext_raypick[] = "raypick(origin, direction, distance = -1.0, half_line = 1, cull_face = 1, p = None, v = None) -> None or (Point, Vector)\n\nSee World.raypick";
static PyObject *__pyx_f_5_soya_14RaypickContext_raypick(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_origin = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction = 0;
  float __pyx_v_distance;
  int __pyx_v_half_line;
  int __pyx_v_cull_face;
  struct __pyx_obj_5_soya__Point *__pyx_v_p = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_v = 0;
  __pyx_t_5_soya_Chunk (*__pyx_v_items);
  struct __pyx_obj_5_soya_RaypickData *__pyx_v_data;
  struct __pyx_obj_5_soya__CObj *__pyx_v_obj;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  float (*__pyx_v_d);
  int __pyx_v_max;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"origin","direction","distance","half_line","cull_face","p","v",0};
  __pyx_v_distance = __pyx_k20;
  __pyx_v_half_line = __pyx_k21;
  __pyx_v_cull_face = __pyx_k22;
  __pyx_v_p = __pyx_k23;
  __pyx_v_v = __pyx_k24;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|fiiOO", __pyx_argnames, &__pyx_v_origin, &__pyx_v_direction, &__pyx_v_distance, &__pyx_v_half_line, &__pyx_v_cull_face, &__pyx_v_p, &__pyx_v_v)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_origin);
  Py_INCREF((PyObject *)__pyx_v_direction);
  Py_INCREF((PyObject *)__pyx_v_p);
  Py_INCREF((PyObject *)__pyx_v_v);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);
  __pyx_v_obj = Py_None; Py_INCREF((PyObject *) __pyx_v_obj);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_origin), __pyx_ptype_5_soya_Position, 0, "origin")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 75; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 75; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya__Point, 1, "p")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 75; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5_soya__Vector, 1, "v")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 75; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":80 */
  __pyx_v_items = ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":81 */
  __pyx_1 = (__pyx_v_items->nb == 0);
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":88 */
  __pyx_2 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 88; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":90 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_origin->__pyx_base.__pyx_vtab)->_out(__pyx_v_origin,__pyx_v_data->root_data);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":91 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_direction->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_direction),(__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":92 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":93 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":94 */
  __pyx_v_data->option = ((__pyx_e_5_soya_RAYPICK_CULL_FACE * __pyx_v_cull_face) + (__pyx_e_5_soya_RAYPICK_HALF_LINE * __pyx_v_half_line));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":96 */
  __pyx_v_max = __pyx_v_items->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":97 */
  __pyx_v_items->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":98 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = (__pyx_v_items->nb < __pyx_v_max);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":99 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_items);
    Py_INCREF(__pyx_2);
    Py_DECREF(((PyObject *)__pyx_v_obj));
    __pyx_v_obj = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":100 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 100; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 100; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_obj));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_obj));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__TreeShape));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__TreeShape));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 100; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 100; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__TreeShape *)((struct __pyx_obj_5_soya__TreeShape *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_raypick_from_context(((struct __pyx_obj_5_soya__TreeShape *)((PyObject *)__pyx_v_obj)),__pyx_v_data,__pyx_v_items);
      goto __pyx_L5;
    }
    /*else*/ {
      ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_vtab)->_raypick(((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj)),__pyx_v_data,((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj))->__pyx_base._parent);
    }
    __pyx_L5:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":103 */
  __pyx_1 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
  if (__pyx_1) {
    __pyx_v_d = 0;
    goto __pyx_L6;
  }
  /*else*/ {
    __pyx_v_d = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_data->result_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_data->result_coordsyst,__pyx_v_data);
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":106 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":107 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":108 */
  while (1) {
    __pyx_L7:;
    __pyx_1 = (__pyx_v_data->raypicked->nb < __pyx_v_max);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":109 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_data->raypicked);
    Py_INCREF((PyObject *)__pyx_2);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":110 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":112 */
  __pyx_3 = __pyx_f_5_soya_make_raypick_result(__pyx_v_d,__pyx_v_data->result,__pyx_v_data->normal,__pyx_v_data->result_coordsyst,__pyx_v_p,__pyx_v_v); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 112; goto __pyx_L1;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.RaypickContext.raypick");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_origin);
  Py_DECREF((PyObject *)__pyx_v_direction);
  Py_DECREF((PyObject *)__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_v);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14RaypickContext_raypick_b(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_14RaypickContext_raypick_b[] = "raypick_b(origin, direction, distance = -1.0, half_line = 1, cull_face = 1, p = None, v = None) -> bool\n\nSee World.raypick_b";
static PyObject *__pyx_f_5_soya_14RaypickContext_raypick_b(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_origin = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction = 0;
  float __pyx_v_distance;
  int __pyx_v_half_line;
  int __pyx_v_cull_face;
  struct __pyx_obj_5_soya__Point *__pyx_v_p = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_v = 0;
  __pyx_t_5_soya_Chunk (*__pyx_v_items);
  struct __pyx_obj_5_soya_RaypickData *__pyx_v_data;
  struct __pyx_obj_5_soya__CObj *__pyx_v_obj;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  int __pyx_v_result;
  int __pyx_v_max;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"origin","direction","distance","half_line","cull_face","p","v",0};
  __pyx_v_distance = __pyx_k25;
  __pyx_v_half_line = __pyx_k26;
  __pyx_v_cull_face = __pyx_k27;
  __pyx_v_p = __pyx_k28;
  __pyx_v_v = __pyx_k29;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|fiiOO", __pyx_argnames, &__pyx_v_origin, &__pyx_v_direction, &__pyx_v_distance, &__pyx_v_half_line, &__pyx_v_cull_face, &__pyx_v_p, &__pyx_v_v)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_origin);
  Py_INCREF((PyObject *)__pyx_v_direction);
  Py_INCREF((PyObject *)__pyx_v_p);
  Py_INCREF((PyObject *)__pyx_v_v);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);
  __pyx_v_obj = Py_None; Py_INCREF((PyObject *) __pyx_v_obj);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_origin), __pyx_ptype_5_soya_Position, 0, "origin")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 114; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 114; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya__Point, 1, "p")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 114; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5_soya__Vector, 1, "v")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 114; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":119 */
  __pyx_v_items = ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":120 */
  __pyx_1 = (__pyx_v_items->nb == 0);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 120; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":126 */
  __pyx_2 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 126; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":127 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_origin->__pyx_base.__pyx_vtab)->_out(__pyx_v_origin,__pyx_v_data->root_data);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":128 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_direction->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_direction),(__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":129 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":130 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":131 */
  __pyx_v_data->option = ((__pyx_e_5_soya_RAYPICK_CULL_FACE * __pyx_v_cull_face) + (__pyx_e_5_soya_RAYPICK_HALF_LINE * __pyx_v_half_line));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":133 */
  __pyx_v_max = __pyx_v_items->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":134 */
  __pyx_v_items->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":135 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = (__pyx_v_items->nb < __pyx_v_max);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":136 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_items);
    Py_INCREF(__pyx_2);
    Py_DECREF(((PyObject *)__pyx_v_obj));
    __pyx_v_obj = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":137 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_obj));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_obj));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__TreeShape));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__TreeShape));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/raypick.pyx":138 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya__TreeShape *)((struct __pyx_obj_5_soya__TreeShape *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_raypick_from_context_b(((struct __pyx_obj_5_soya__TreeShape *)((PyObject *)__pyx_v_obj)),__pyx_v_data,__pyx_v_items);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/raypick.pyx":138 */
        __pyx_v_result = 1;

        /* "/home/jiba/src/soya/soya3d/raypick.pyx":138 */
        goto __pyx_L4;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/raypick.pyx":140 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_b(((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj)),__pyx_v_data,((struct __pyx_obj_5_soya_CoordSyst *)((PyObject *)__pyx_v_obj))->__pyx_base._parent);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/raypick.pyx":140 */
        __pyx_v_result = 1;

        /* "/home/jiba/src/soya/soya3d/raypick.pyx":140 */
        goto __pyx_L4;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L5:;
  }
  /*else*/ {
    __pyx_v_result = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":143 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":144 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":145 */
  while (1) {
    __pyx_L8:;
    __pyx_1 = (__pyx_v_data->raypicked->nb < __pyx_v_max);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":146 */
    __pyx_2 = (PyObject *)chunk_get_ptr(__pyx_v_data->raypicked);
    Py_INCREF((PyObject *)__pyx_2);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":147 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":149 */
  __pyx_3 = PyInt_FromLong(__pyx_v_result); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.RaypickContext.raypick_b");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  Py_DECREF(__pyx_v_obj);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_origin);
  Py_DECREF((PyObject *)__pyx_v_direction);
  Py_DECREF((PyObject *)__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_v);
  return __pyx_r;
}

static __pyx_t_5_soya_Frustum (*__pyx_f_5_soya_frustum_coordsyst_into(__pyx_t_5_soya_Frustum (*__pyx_v_r),__pyx_t_5_soya_Frustum (*__pyx_v_f),float (*__pyx_v_old),float (*__pyx_v_new))) {
  float (__pyx_v_scalefactor[3]);
  float __pyx_v_scaling;
  int __pyx_v_i;
  __pyx_t_5_soya_Frustum (*__pyx_r);
  int __pyx_1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":22 */
  (__pyx_v_scalefactor[0]) = 1.0;
  (__pyx_v_scalefactor[1]) = 1.0;
  (__pyx_v_scalefactor[2]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":23 */
  __pyx_1 = (__pyx_v_r == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":25 */
    __pyx_v_r = ((__pyx_t_5_soya_Frustum (*))malloc((sizeof(__pyx_t_5_soya_Frustum ))));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":28 */
  memcpy(__pyx_v_r,__pyx_v_f,(sizeof(__pyx_t_5_soya_Frustum )));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":29 */
  __pyx_1 = (__pyx_v_new != __pyx_v_old);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":31 */
    __pyx_1 = (__pyx_v_old != 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":32 */
      for (__pyx_v_i = 0; __pyx_v_i < 8; ++__pyx_v_i) {
        point_by_matrix((__pyx_v_r->points + (3 * __pyx_v_i)),__pyx_v_old);
        __pyx_L5:;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":33 */
      (__pyx_v_scalefactor[0]) = ((__pyx_v_scalefactor[0]) * (__pyx_v_old[16]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":34 */
      (__pyx_v_scalefactor[1]) = ((__pyx_v_scalefactor[1]) * (__pyx_v_old[17]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":35 */
      (__pyx_v_scalefactor[2]) = ((__pyx_v_scalefactor[2]) * (__pyx_v_old[18]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":36 */
      point_by_matrix(__pyx_v_r->position,__pyx_v_old);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":38 */
    __pyx_1 = (__pyx_v_new != 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":39 */
      for (__pyx_v_i = 0; __pyx_v_i < 8; ++__pyx_v_i) {
        point_by_matrix((__pyx_v_r->points + (3 * __pyx_v_i)),__pyx_v_new);
        __pyx_L8:;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":40 */
      (__pyx_v_scalefactor[0]) = ((__pyx_v_scalefactor[0]) * (__pyx_v_new[16]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":41 */
      (__pyx_v_scalefactor[1]) = ((__pyx_v_scalefactor[1]) * (__pyx_v_new[17]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":42 */
      (__pyx_v_scalefactor[2]) = ((__pyx_v_scalefactor[2]) * (__pyx_v_new[18]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":43 */
      point_by_matrix(__pyx_v_r->position,__pyx_v_new);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":46 */
    __pyx_v_scaling = (__pyx_v_scalefactor[0]);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":47 */
    __pyx_1 = ((__pyx_v_scalefactor[1]) > __pyx_v_scaling);
    if (__pyx_1) {
      __pyx_v_scaling = (__pyx_v_scalefactor[1]);
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":48 */
    __pyx_1 = ((__pyx_v_scalefactor[2]) > __pyx_v_scaling);
    if (__pyx_1) {
      __pyx_v_scaling = (__pyx_v_scalefactor[2]);
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":49 */
    face_normal(__pyx_v_r->planes,__pyx_v_r->points,(__pyx_v_r->points + 3),(__pyx_v_r->points + 9));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":50 */
    vector_set_length(__pyx_v_r->planes,__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":51 */
    face_normal((__pyx_v_r->planes + 4),(__pyx_v_r->points + 12),(__pyx_v_r->points + 15),__pyx_v_r->points);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":52 */
    vector_set_length((__pyx_v_r->planes + 4),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":53 */
    face_normal((__pyx_v_r->planes + 8),(__pyx_v_r->points + 9),(__pyx_v_r->points + 6),(__pyx_v_r->points + 21));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":54 */
    vector_set_length((__pyx_v_r->planes + 8),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":55 */
    face_normal((__pyx_v_r->planes + 12),(__pyx_v_r->points + 12),__pyx_v_r->points,(__pyx_v_r->points + 21));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":56 */
    vector_set_length((__pyx_v_r->planes + 12),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":57 */
    face_normal((__pyx_v_r->planes + 16),(__pyx_v_r->points + 3),(__pyx_v_r->points + 15),(__pyx_v_r->points + 6));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":58 */
    vector_set_length((__pyx_v_r->planes + 16),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":59 */
    face_normal((__pyx_v_r->planes + 20),(__pyx_v_r->points + 15),(__pyx_v_r->points + 12),(__pyx_v_r->points + 18));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":60 */
    vector_set_length((__pyx_v_r->planes + 20),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":62 */
    (__pyx_v_r->planes[3]) = (-((((__pyx_v_r->planes[0]) * (__pyx_v_r->points[0])) + ((__pyx_v_r->planes[1]) * (__pyx_v_r->points[1]))) + ((__pyx_v_r->planes[2]) * (__pyx_v_r->points[2]))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":63 */
    (__pyx_v_r->planes[7]) = (-((((__pyx_v_r->planes[4]) * (__pyx_v_r->points[0])) + ((__pyx_v_r->planes[5]) * (__pyx_v_r->points[1]))) + ((__pyx_v_r->planes[6]) * (__pyx_v_r->points[2]))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":64 */
    (__pyx_v_r->planes[11]) = (-((((__pyx_v_r->planes[8]) * (__pyx_v_r->points[6])) + ((__pyx_v_r->planes[9]) * (__pyx_v_r->points[7]))) + ((__pyx_v_r->planes[10]) * (__pyx_v_r->points[8]))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":65 */
    (__pyx_v_r->planes[15]) = (-((((__pyx_v_r->planes[12]) * (__pyx_v_r->points[0])) + ((__pyx_v_r->planes[13]) * (__pyx_v_r->points[1]))) + ((__pyx_v_r->planes[14]) * (__pyx_v_r->points[2]))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":66 */
    (__pyx_v_r->planes[19]) = (-((((__pyx_v_r->planes[16]) * (__pyx_v_r->points[6])) + ((__pyx_v_r->planes[17]) * (__pyx_v_r->points[7]))) + ((__pyx_v_r->planes[18]) * (__pyx_v_r->points[8]))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":67 */
    (__pyx_v_r->planes[23]) = (-((((__pyx_v_r->planes[20]) * (__pyx_v_r->points[12])) + ((__pyx_v_r->planes[21]) * (__pyx_v_r->points[13]))) + ((__pyx_v_r->planes[22]) * (__pyx_v_r->points[14]))));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":68 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.frustum_coordsyst_into");
  __pyx_L0:;
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_9CoordSyst___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kargs = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, &__pyx_v_kargs) < 0) return -1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_args);
    Py_XDECREF(__pyx_v_kargs);
    return -1;
  }
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":82 */
  ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__raypick_data = (-1);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.__new__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_args);
  Py_XDECREF(__pyx_v_kargs);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_n_add;

static int __pyx_f_5_soya_9CoordSyst___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst___init__[] = "CoordSyst(PARENT)\n\nCreates a new CoordSyst in the World PARENT.";
static int __pyx_f_5_soya_9CoordSyst___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"parent",0};
  __pyx_v_parent = __pyx_k30;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_parent)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 84; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":88 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[0]) = 1.0;
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[5]) = 1.0;
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[10]) = 1.0;
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[15]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":89 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]) = 1.0;
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]) = 1.0;
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":90 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_parent), __pyx_n_add); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.CoordSyst.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst___getcstate__(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":95 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":96 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":97 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_matrix,19);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":98 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 98; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_9CoordSyst___setcstate__(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":101 */
  __pyx_v_self->_validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":105 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":106 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":107 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_matrix,19);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":108 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_9CoordSyst__into(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,float (*__pyx_v_result)) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":111 */
  memcpy(__pyx_v_result,(__pyx_v_self->_matrix + 12),12);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":112 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_2 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
    __pyx_1 = (!__pyx_2);
    if (__pyx_1) {
      __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == ((PyObject *)__pyx_v_coordsyst);
      __pyx_1 = (!__pyx_2);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":113 */
    point_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base._parent));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":114 */
    point_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_coordsyst));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._into");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_9CoordSyst__out(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,float (*__pyx_v_result)) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":117 */
  memcpy(__pyx_v_result,(__pyx_v_self->_matrix + 12),12);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":118 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":119 */
    point_by_matrix(__pyx_v_result,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base._parent));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._out");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_9CoordSyst__batch(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":122 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static void __pyx_f_5_soya_9CoordSyst__render(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":125 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static int __pyx_f_5_soya_9CoordSyst__shadow(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":128 */

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_9CoordSyst__raypick(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":131 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_9CoordSyst__raypick_b(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":134 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static void __pyx_f_5_soya_9CoordSyst__collect_raypickables(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":137 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_9CoordSyst__contains(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya__CObj *__pyx_v_obj) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_obj);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":140 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._contains");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_obj);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_added_into(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_added_into[] = "CoordSyst.added_into(new_parent)\n\nCalled when the CoordSyst is added into NEW_PARENT, or removed from its previous parent\n(in this case, NEW_PARENT is None).";
static PyObject *__pyx_f_5_soya_9CoordSyst_added_into(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_new_parent = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"new_parent",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_new_parent)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_new_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_new_parent), __pyx_ptype_5_soya__World, 1, "new_parent")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 142; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":147 */
  Py_INCREF(((PyObject *)__pyx_v_new_parent));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent = ((PyObject *)__pyx_v_new_parent);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.added_into");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_new_parent);
  return __pyx_r;
}

static void __pyx_f_5_soya_9CoordSyst__get_sphere(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,float (*__pyx_v_sphere)) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":150 */
  (__pyx_v_sphere[0]) = 0.0;
  (__pyx_v_sphere[1]) = 0.0;
  (__pyx_v_sphere[2]) = 0.0;
  (__pyx_v_sphere[3]) = 0.0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._get_sphere");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_9CoordSyst_get_sphere(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_get_sphere[] = "CoordSyst.get_sphere() -> (Point, float)\n\nReturns a sphere wrapping the given CoordSyst. The sphere is defined by the center\nand the radius (a Point and a float value).";
static PyObject *__pyx_f_5_soya_9CoordSyst_get_sphere(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float (__pyx_v_sphere[4]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":158 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_get_sphere(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_sphere);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":159 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_sphere[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_sphere[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_sphere[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_3 = PyFloat_FromDouble((__pyx_v_sphere[3])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.get_sphere");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_9CoordSyst__get_box(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":162 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._get_box");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_9CoordSyst_get_box(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_get_box[] = "CoordSyst.get_box() -> (Point, Point)\n\nReturns a box wrapping the given CoordSyst. The box is defined by 2 Point corresponding\nto 2 opposite corners of the box, the box being aligned on the X, Y and Z axis.";
static PyObject *__pyx_f_5_soya_9CoordSyst_get_box(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float (__pyx_v_box[6]);
  PyObject *__pyx_r;
  double __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":170 */
  (__pyx_v_box[0]) = 10000000000000.0;
  (__pyx_v_box[1]) = 10000000000000.0;
  (__pyx_v_box[2]) = 10000000000000.0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":171 */
  __pyx_1 = (-10000000000000.0);
  (__pyx_v_box[3]) = __pyx_1;
  (__pyx_v_box[4]) = __pyx_1;
  (__pyx_v_box[5]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":172 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_get_box(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_box,0);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":173 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_box[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_box[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_box[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_box[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_box[4])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((__pyx_v_box[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_7, 0, ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_5);
  PyTuple_SET_ITEM(__pyx_7, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
  __pyx_5 = 0;
  __pyx_2 = 0;
  __pyx_6 = 0;
  __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5);
  __pyx_3 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.CoordSyst.get_box");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_get_dimension(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_get_dimension[] = "CoordSyst.get_dimension() -> (float, float, float)\n\nReturns the dimension of a CoordSyst: a (width, height, depth) tuple.\nFor a World, this includes also all items inside the World.";
static PyObject *__pyx_f_5_soya_9CoordSyst_get_dimension(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float (__pyx_v_box[6]);
  PyObject *__pyx_r;
  double __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":181 */
  (__pyx_v_box[0]) = 10000000000000.0;
  (__pyx_v_box[1]) = 10000000000000.0;
  (__pyx_v_box[2]) = 10000000000000.0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":182 */
  __pyx_1 = (-10000000000000.0);
  (__pyx_v_box[3]) = __pyx_1;
  (__pyx_v_box[4]) = __pyx_1;
  (__pyx_v_box[5]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":183 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_get_box(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_box,0);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":184 */
  __pyx_2 = PyFloat_FromDouble(((__pyx_v_box[3]) - (__pyx_v_box[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 184; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((__pyx_v_box[4]) - (__pyx_v_box[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 184; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((__pyx_v_box[5]) - (__pyx_v_box[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 184; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 184; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.get_dimension");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_scale;

static PyObject *__pyx_f_5_soya_9CoordSyst_set_dimension(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_set_dimension[] = "CoordSyst.set_dimension(width, height, depth)\n\nSets the dimension of a CoordSyst ; in other worlds, scale the coordsyst so as it has\nthe given dimensions.";
static PyObject *__pyx_f_5_soya_9CoordSyst_set_dimension(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_width;
  float __pyx_v_height;
  float __pyx_v_depth;
  float (__pyx_v_box[6]);
  PyObject *__pyx_r;
  double __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"width","height","depth",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_width, &__pyx_v_height, &__pyx_v_depth)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":192 */
  (__pyx_v_box[0]) = 10000000000000.0;
  (__pyx_v_box[1]) = 10000000000000.0;
  (__pyx_v_box[2]) = 10000000000000.0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":193 */
  __pyx_1 = (-10000000000000.0);
  (__pyx_v_box[3]) = __pyx_1;
  (__pyx_v_box[4]) = __pyx_1;
  (__pyx_v_box[5]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":194 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_get_box(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_box,0);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":195 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 195; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_width / ((__pyx_v_box[3]) - (__pyx_v_box[0])))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 195; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_height / ((__pyx_v_box[4]) - (__pyx_v_box[1])))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 195; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_depth / ((__pyx_v_box[5]) - (__pyx_v_box[2])))); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 195; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 195; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_5);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya.CoordSyst.set_dimension");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static float (*__pyx_f_5_soya_9CoordSyst__raypick_data(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data)) {
  float (*__pyx_v_matrix);
  float (*__pyx_v_rdata);
  float __pyx_v_f;
  float (*__pyx_r);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":201 */
  __pyx_1 = (__pyx_v_self->__raypick_data == (-1));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":202 */
    __pyx_v_self->__raypick_data = chunk_register(__pyx_v_data->raypick_data,(7 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":203 */
    __pyx_v_rdata = ((float (*))(__pyx_v_data->raypick_data->content + __pyx_v_self->__raypick_data));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":205 */
    __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_self);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":206 */
    point_by_matrix_copy(__pyx_v_rdata,__pyx_v_data->root_data,__pyx_v_matrix);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":207 */
    vector_by_matrix_copy((__pyx_v_rdata + 3),(__pyx_v_data->root_data + 3),__pyx_v_matrix);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":209 */
    __pyx_1 = ((__pyx_v_matrix[16]) != 1.0);
    if (!__pyx_1) {
      __pyx_1 = ((__pyx_v_matrix[17]) != 1.0);
      if (!__pyx_1) {
        __pyx_1 = ((__pyx_v_matrix[18]) != 1.0);
      }
    }
    if (__pyx_1) {
      vector_normalize((__pyx_v_rdata + 3));
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":211 */
    __pyx_1 = ((__pyx_v_data->root_data[6]) > 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":212 */
      __pyx_1 = ((__pyx_v_matrix[16]) > (__pyx_v_matrix[17]));
      if (__pyx_1) {
        __pyx_v_f = (__pyx_v_matrix[16]);
        goto __pyx_L5;
      }
      /*else*/ {
        __pyx_v_f = (__pyx_v_matrix[17]);
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":214 */
      __pyx_1 = ((__pyx_v_matrix[18]) > __pyx_v_f);
      if (__pyx_1) {
        __pyx_v_f = (__pyx_v_matrix[18]);
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":216 */
      (__pyx_v_rdata[6]) = ((__pyx_v_data->root_data[6]) * __pyx_v_f);
      goto __pyx_L4;
    }
    /*else*/ {
      (__pyx_v_rdata[6]) = (-1.0);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":220 */
    chunk_add_ptr(__pyx_v_data->raypicked,((void (*))((PyObject *)__pyx_v_self)));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":221 */
    __pyx_r = __pyx_v_rdata;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_r = ((float (*))(__pyx_v_data->raypick_data->content + __pyx_v_self->__raypick_data));
    goto __pyx_L0;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._raypick_data");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  return __pyx_r;
}

static float __pyx_f_5_soya_9CoordSyst__distance_out(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self,float __pyx_v_distance) {
  float (*__pyx_v_matrix);
  float __pyx_v_f;
  float __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":228 */
  __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":229 */
  __pyx_1 = ((__pyx_v_matrix[16]) > (__pyx_v_matrix[17]));
  if (__pyx_1) {
    __pyx_v_f = (__pyx_v_matrix[16]);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_f = (__pyx_v_matrix[17]);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":231 */
  __pyx_1 = ((__pyx_v_matrix[18]) > __pyx_v_f);
  if (__pyx_1) {
    __pyx_v_f = (__pyx_v_matrix[18]);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":233 */
  __pyx_r = (__pyx_v_distance / __pyx_v_f);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._distance_out");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_begin_round[] = "CoordSyst.begin_round()\n\nCalled (by the Idler) when a new round begins; default implementation does nothing.";
static PyObject *__pyx_f_5_soya_9CoordSyst_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":239 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_end_round[] = "CoordSyst.end_round()\n\nCalled (by the Idler) when a round is finished; default implementation does nothing.";
static PyObject *__pyx_f_5_soya_9CoordSyst_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":245 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.end_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_advance_time[] = "CoordSyst.advance_time(proportion)\n\nCalled (by the Idler) when a piece of a round is achieved; default implementation does nothing.\nPROPORTION is the proportion of the current round\'s time that has passed (1.0 for an entire round).";
static PyObject *__pyx_f_5_soya_9CoordSyst_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":252 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_6parent___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_6parent___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":256 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.parent.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_7visible___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_7visible___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":262 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_HIDDEN))); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 262; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.visible.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_7visible___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_7visible___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 263; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":264 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & (~__pyx_e_5_soya_HIDDEN));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option | __pyx_e_5_soya_HIDDEN);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.visible.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_5solid___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_5solid___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":269 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_NON_SOLID))); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 269; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.solid.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_5solid___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_5solid___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 270; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":271 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & (~__pyx_e_5_soya_NON_SOLID));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option | __pyx_e_5_soya_NON_SOLID);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.solid.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_9CoordSyst__invalidate(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":275 */
  __pyx_v_self->_validity = __pyx_e_5_soya_COORDSYS_INVALID;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._invalidate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_9CoordSyst_1x___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_1x___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":279 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 279; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.x.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_1x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_1x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 280; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":281 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":282 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.x.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_1y___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_1y___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":286 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.y.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_1y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_1y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 287; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":288 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":289 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.y.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_1z___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_1z___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":293 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 293; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.z.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_1z___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_1z___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 294; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":295 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":296 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.z.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_6matrix___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_6matrix___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  PyObject *__pyx_12 = 0;
  PyObject *__pyx_13 = 0;
  PyObject *__pyx_14 = 0;
  PyObject *__pyx_15 = 0;
  PyObject *__pyx_16 = 0;
  PyObject *__pyx_17 = 0;
  PyObject *__pyx_18 = 0;
  PyObject *__pyx_19 = 0;
  PyObject *__pyx_20 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":300 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[4])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[6])); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[7])); if (!__pyx_8) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[8])); if (!__pyx_9) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[9])); if (!__pyx_10) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[10])); if (!__pyx_11) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[11])); if (!__pyx_12) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12])); if (!__pyx_13) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_14 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13])); if (!__pyx_14) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_15 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14])); if (!__pyx_15) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_16 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[15])); if (!__pyx_16) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_17 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16])); if (!__pyx_17) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_18 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17])); if (!__pyx_18) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_19 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18])); if (!__pyx_19) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_20 = PyTuple_New(19); if (!__pyx_20) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_20, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_20, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_20, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_20, 3, __pyx_4);
  PyTuple_SET_ITEM(__pyx_20, 4, __pyx_5);
  PyTuple_SET_ITEM(__pyx_20, 5, __pyx_6);
  PyTuple_SET_ITEM(__pyx_20, 6, __pyx_7);
  PyTuple_SET_ITEM(__pyx_20, 7, __pyx_8);
  PyTuple_SET_ITEM(__pyx_20, 8, __pyx_9);
  PyTuple_SET_ITEM(__pyx_20, 9, __pyx_10);
  PyTuple_SET_ITEM(__pyx_20, 10, __pyx_11);
  PyTuple_SET_ITEM(__pyx_20, 11, __pyx_12);
  PyTuple_SET_ITEM(__pyx_20, 12, __pyx_13);
  PyTuple_SET_ITEM(__pyx_20, 13, __pyx_14);
  PyTuple_SET_ITEM(__pyx_20, 14, __pyx_15);
  PyTuple_SET_ITEM(__pyx_20, 15, __pyx_16);
  PyTuple_SET_ITEM(__pyx_20, 16, __pyx_17);
  PyTuple_SET_ITEM(__pyx_20, 17, __pyx_18);
  PyTuple_SET_ITEM(__pyx_20, 18, __pyx_19);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_11 = 0;
  __pyx_12 = 0;
  __pyx_13 = 0;
  __pyx_14 = 0;
  __pyx_15 = 0;
  __pyx_16 = 0;
  __pyx_17 = 0;
  __pyx_18 = 0;
  __pyx_19 = 0;
  __pyx_r = __pyx_20;
  __pyx_20 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  Py_XDECREF(__pyx_12);
  Py_XDECREF(__pyx_13);
  Py_XDECREF(__pyx_14);
  Py_XDECREF(__pyx_15);
  Py_XDECREF(__pyx_16);
  Py_XDECREF(__pyx_17);
  Py_XDECREF(__pyx_18);
  Py_XDECREF(__pyx_19);
  Py_XDECREF(__pyx_20);
  __Pyx_AddTraceback("_soya.CoordSyst.matrix.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_6matrix___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_matrix); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_6matrix___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_matrix) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  float __pyx_5;
  float __pyx_6;
  float __pyx_7;
  float __pyx_8;
  float __pyx_9;
  float __pyx_10;
  float __pyx_11;
  float __pyx_12;
  float __pyx_13;
  float __pyx_14;
  float __pyx_15;
  float __pyx_16;
  float __pyx_17;
  float __pyx_18;
  float __pyx_19;
  float __pyx_20;
  float __pyx_21;
  float __pyx_22;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":302 */
  __pyx_1 = PyObject_Length(__pyx_v_matrix); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 302; goto __pyx_L1;}
  __pyx_2 = (__pyx_1 == 16);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":303 */
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[0]) = __pyx_4;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[1]) = __pyx_5;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[2]) = __pyx_6;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 3); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[3]) = __pyx_7;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 4); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_8 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[4]) = __pyx_8;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 5); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_9 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[5]) = __pyx_9;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 6); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_10 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[6]) = __pyx_10;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 7); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_11 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[7]) = __pyx_11;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 8); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_12 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[8]) = __pyx_12;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 9); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_13 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[9]) = __pyx_13;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 10); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_14 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[10]) = __pyx_14;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 11); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_15 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[11]) = __pyx_15;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 12); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_16 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = __pyx_16;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 13); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_17 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = __pyx_17;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 14); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_18 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = __pyx_18;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 15); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_19 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[15]) = __pyx_19;
    if (__Pyx_EndUnpack(__pyx_v_matrix, 16) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 303; goto __pyx_L1;}
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":305 */
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[0]) = __pyx_4;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[1]) = __pyx_5;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[2]) = __pyx_6;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 3); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[3]) = __pyx_7;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 4); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_8 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[4]) = __pyx_8;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 5); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_9 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[5]) = __pyx_9;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 6); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_10 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[6]) = __pyx_10;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 7); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_11 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[7]) = __pyx_11;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 8); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_12 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[8]) = __pyx_12;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 9); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_13 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[9]) = __pyx_13;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 10); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_14 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[10]) = __pyx_14;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 11); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_15 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[11]) = __pyx_15;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 12); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_16 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = __pyx_16;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 13); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_17 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = __pyx_17;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 14); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_18 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = __pyx_18;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 15); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_19 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[15]) = __pyx_19;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 16); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_20 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]) = __pyx_20;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 17); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_21 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]) = __pyx_21;
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 18); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_22 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]) = __pyx_22;
    if (__Pyx_EndUnpack(__pyx_v_matrix, 19) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 305; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":306 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.matrix.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_matrix);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_11root_matrix___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_11root_matrix___get__(PyObject *__pyx_v_self) {
  float (*__pyx_v_m);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  PyObject *__pyx_12 = 0;
  PyObject *__pyx_13 = 0;
  PyObject *__pyx_14 = 0;
  PyObject *__pyx_15 = 0;
  PyObject *__pyx_16 = 0;
  PyObject *__pyx_17 = 0;
  PyObject *__pyx_18 = 0;
  PyObject *__pyx_19 = 0;
  PyObject *__pyx_20 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":311 */
  __pyx_v_m = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":312 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_m[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_m[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_m[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_m[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_m[4])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((__pyx_v_m[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_m[6])); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((__pyx_v_m[7])); if (!__pyx_8) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((__pyx_v_m[8])); if (!__pyx_9) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((__pyx_v_m[9])); if (!__pyx_10) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble((__pyx_v_m[10])); if (!__pyx_11) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((__pyx_v_m[11])); if (!__pyx_12) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble((__pyx_v_m[12])); if (!__pyx_13) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_14 = PyFloat_FromDouble((__pyx_v_m[13])); if (!__pyx_14) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_15 = PyFloat_FromDouble((__pyx_v_m[14])); if (!__pyx_15) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_16 = PyFloat_FromDouble((__pyx_v_m[15])); if (!__pyx_16) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_17 = PyFloat_FromDouble((__pyx_v_m[16])); if (!__pyx_17) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_18 = PyFloat_FromDouble((__pyx_v_m[17])); if (!__pyx_18) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_19 = PyFloat_FromDouble((__pyx_v_m[18])); if (!__pyx_19) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_20 = PyTuple_New(19); if (!__pyx_20) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 312; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_20, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_20, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_20, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_20, 3, __pyx_4);
  PyTuple_SET_ITEM(__pyx_20, 4, __pyx_5);
  PyTuple_SET_ITEM(__pyx_20, 5, __pyx_6);
  PyTuple_SET_ITEM(__pyx_20, 6, __pyx_7);
  PyTuple_SET_ITEM(__pyx_20, 7, __pyx_8);
  PyTuple_SET_ITEM(__pyx_20, 8, __pyx_9);
  PyTuple_SET_ITEM(__pyx_20, 9, __pyx_10);
  PyTuple_SET_ITEM(__pyx_20, 10, __pyx_11);
  PyTuple_SET_ITEM(__pyx_20, 11, __pyx_12);
  PyTuple_SET_ITEM(__pyx_20, 12, __pyx_13);
  PyTuple_SET_ITEM(__pyx_20, 13, __pyx_14);
  PyTuple_SET_ITEM(__pyx_20, 14, __pyx_15);
  PyTuple_SET_ITEM(__pyx_20, 15, __pyx_16);
  PyTuple_SET_ITEM(__pyx_20, 16, __pyx_17);
  PyTuple_SET_ITEM(__pyx_20, 17, __pyx_18);
  PyTuple_SET_ITEM(__pyx_20, 18, __pyx_19);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_11 = 0;
  __pyx_12 = 0;
  __pyx_13 = 0;
  __pyx_14 = 0;
  __pyx_15 = 0;
  __pyx_16 = 0;
  __pyx_17 = 0;
  __pyx_18 = 0;
  __pyx_19 = 0;
  __pyx_r = __pyx_20;
  __pyx_20 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  Py_XDECREF(__pyx_12);
  Py_XDECREF(__pyx_13);
  Py_XDECREF(__pyx_14);
  Py_XDECREF(__pyx_15);
  Py_XDECREF(__pyx_16);
  Py_XDECREF(__pyx_17);
  Py_XDECREF(__pyx_18);
  Py_XDECREF(__pyx_19);
  Py_XDECREF(__pyx_20);
  __Pyx_AddTraceback("_soya.CoordSyst.root_matrix.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_20inverted_root_matrix___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_20inverted_root_matrix___get__(PyObject *__pyx_v_self) {
  float (*__pyx_v_m);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  PyObject *__pyx_12 = 0;
  PyObject *__pyx_13 = 0;
  PyObject *__pyx_14 = 0;
  PyObject *__pyx_15 = 0;
  PyObject *__pyx_16 = 0;
  PyObject *__pyx_17 = 0;
  PyObject *__pyx_18 = 0;
  PyObject *__pyx_19 = 0;
  PyObject *__pyx_20 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":317 */
  __pyx_v_m = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":318 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_m[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_m[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_m[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_m[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_m[4])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((__pyx_v_m[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_m[6])); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((__pyx_v_m[7])); if (!__pyx_8) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((__pyx_v_m[8])); if (!__pyx_9) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((__pyx_v_m[9])); if (!__pyx_10) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble((__pyx_v_m[10])); if (!__pyx_11) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((__pyx_v_m[11])); if (!__pyx_12) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble((__pyx_v_m[12])); if (!__pyx_13) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_14 = PyFloat_FromDouble((__pyx_v_m[13])); if (!__pyx_14) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_15 = PyFloat_FromDouble((__pyx_v_m[14])); if (!__pyx_15) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_16 = PyFloat_FromDouble((__pyx_v_m[15])); if (!__pyx_16) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_17 = PyFloat_FromDouble((__pyx_v_m[16])); if (!__pyx_17) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_18 = PyFloat_FromDouble((__pyx_v_m[17])); if (!__pyx_18) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_19 = PyFloat_FromDouble((__pyx_v_m[18])); if (!__pyx_19) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_20 = PyTuple_New(19); if (!__pyx_20) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 318; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_20, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_20, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_20, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_20, 3, __pyx_4);
  PyTuple_SET_ITEM(__pyx_20, 4, __pyx_5);
  PyTuple_SET_ITEM(__pyx_20, 5, __pyx_6);
  PyTuple_SET_ITEM(__pyx_20, 6, __pyx_7);
  PyTuple_SET_ITEM(__pyx_20, 7, __pyx_8);
  PyTuple_SET_ITEM(__pyx_20, 8, __pyx_9);
  PyTuple_SET_ITEM(__pyx_20, 9, __pyx_10);
  PyTuple_SET_ITEM(__pyx_20, 10, __pyx_11);
  PyTuple_SET_ITEM(__pyx_20, 11, __pyx_12);
  PyTuple_SET_ITEM(__pyx_20, 12, __pyx_13);
  PyTuple_SET_ITEM(__pyx_20, 13, __pyx_14);
  PyTuple_SET_ITEM(__pyx_20, 14, __pyx_15);
  PyTuple_SET_ITEM(__pyx_20, 15, __pyx_16);
  PyTuple_SET_ITEM(__pyx_20, 16, __pyx_17);
  PyTuple_SET_ITEM(__pyx_20, 17, __pyx_18);
  PyTuple_SET_ITEM(__pyx_20, 18, __pyx_19);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_11 = 0;
  __pyx_12 = 0;
  __pyx_13 = 0;
  __pyx_14 = 0;
  __pyx_15 = 0;
  __pyx_16 = 0;
  __pyx_17 = 0;
  __pyx_18 = 0;
  __pyx_19 = 0;
  __pyx_r = __pyx_20;
  __pyx_20 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  Py_XDECREF(__pyx_12);
  Py_XDECREF(__pyx_13);
  Py_XDECREF(__pyx_14);
  Py_XDECREF(__pyx_15);
  Py_XDECREF(__pyx_16);
  Py_XDECREF(__pyx_17);
  Py_XDECREF(__pyx_18);
  Py_XDECREF(__pyx_19);
  Py_XDECREF(__pyx_20);
  __Pyx_AddTraceback("_soya.CoordSyst.inverted_root_matrix.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_10lefthanded___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_10lefthanded___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":322 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_LEFTHANDED) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 322; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.lefthanded.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_7scale_x___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_7scale_x___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":326 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.scale_x.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_7scale_x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_7scale_x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 327; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":328 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_x / (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 328; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.scale_x.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_7scale_y___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_7scale_y___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":332 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 332; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.scale_y.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_7scale_y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_7scale_y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 333; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":334 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_x / (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 334; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 334; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.scale_y.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_7scale_z___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_7scale_z___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":338 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 338; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.scale_z.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_7scale_z___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_7scale_z___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 339; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":340 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 340; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 340; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 340; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_x / (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 340; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 340; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 340; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.scale_z.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_set_scale_factors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_set_scale_factors[] = "CoordSyst.set_scale_factors(SCALE_X, SCALE_Y, SCALE_Z)\n\nSets the scale factors in the X, Y and Z dimension.";
static PyObject *__pyx_f_5_soya_9CoordSyst_set_scale_factors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_scale_x;
  float __pyx_v_scale_y;
  float __pyx_v_scale_z;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"scale_x","scale_y","scale_z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_scale_x, &__pyx_v_scale_y, &__pyx_v_scale_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":346 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_scale_x / (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_scale_y / (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_scale_z / (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.set_scale_factors");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_COORDSYS_LEFTHANDED;

static void __pyx_f_5_soya_9CoordSyst_check_lefthanded(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":350 */
  __pyx_1 = ((((__pyx_v_self->_matrix[16]) * (__pyx_v_self->_matrix[17])) * (__pyx_v_self->_matrix[18])) < 0.0);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(__pyx_v_self->_option); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 350; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_COORDSYS_LEFTHANDED); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 350; goto __pyx_L1;}
    __pyx_4 = PyNumber_Or(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 350; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 350; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_self->_option = __pyx_1;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyInt_FromLong(__pyx_v_self->_option); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_COORDSYS_LEFTHANDED); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; goto __pyx_L1;}
    __pyx_4 = PyNumber_Invert(__pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyNumber_And(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_1 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_self->_option = __pyx_1;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya.CoordSyst.check_lefthanded");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static float (*__pyx_f_5_soya_9CoordSyst__root_matrix(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self)) {
  float (*__pyx_r);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":354 */
  __pyx_1 = (!(__pyx_v_self->_validity & __pyx_e_5_soya_COORDSYS_ROOT_VALID));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":355 */
    __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._parent) == Py_None;
    if (__pyx_1) {
      memcpy(__pyx_v_self->__root_matrix,__pyx_v_self->_matrix,(sizeof(__pyx_v_self->__root_matrix)));
      goto __pyx_L3;
    }
    /*else*/ {
      multiply_matrix(__pyx_v_self->__root_matrix,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base._parent),__pyx_v_self->_matrix);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":357 */
    __pyx_v_self->_validity = (__pyx_v_self->_validity | __pyx_e_5_soya_COORDSYS_ROOT_VALID);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":358 */
  __pyx_r = __pyx_v_self->__root_matrix;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._root_matrix");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static float (*__pyx_f_5_soya_9CoordSyst__inverted_root_matrix(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self)) {
  float (*__pyx_r);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":361 */
  __pyx_1 = (!(__pyx_v_self->_validity & __pyx_e_5_soya_COORDSYS_INVERTED_ROOT_VALID));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":362 */
    matrix_invert(__pyx_v_self->__inverted_root_matrix,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":363 */
  __pyx_r = __pyx_v_self->__inverted_root_matrix;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSyst._inverted_root_matrix");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_get_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_get_root[] = "CoordSyst.get_root() -> World\n\nReturns the \"root parent\" of a coordsyst, i.e. the scene (= the parent world that has no parent).";
static PyObject *__pyx_f_5_soya_9CoordSyst_get_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":370 */
  if (!__Pyx_TypeTest(((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 370; goto __pyx_L1;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":371 */
  __pyx_1 = ((PyObject *)__pyx_v_root) == Py_None;
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":372 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 372; goto __pyx_L1;}
    if (!__pyx_1) break;
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 372; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
    __pyx_v_root = ((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":373 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_r = ((PyObject *)__pyx_v_root);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.get_root");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static struct __pyx_obj_5_soya__World *__pyx_f_5_soya_9CoordSyst__get_root(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  struct __pyx_obj_5_soya__World *__pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":377 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_self->__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 377; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_self->__pyx_base._parent));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = ((PyObject *)__pyx_v_self->__pyx_base._parent);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":378 */
  __pyx_1 = ((PyObject *)__pyx_v_root) == Py_None;
  if (__pyx_1) {
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 378; goto __pyx_L1;}
    Py_INCREF((PyObject *)Py_None);
    __pyx_r = (struct __pyx_obj_5_soya__World *)Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":379 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; goto __pyx_L1;}
    if (!__pyx_1) break;
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
    __pyx_v_root = ((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":380 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_r = (struct __pyx_obj_5_soya__World *)((PyObject *)__pyx_v_root);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst._get_root");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_self);
  return ((struct __pyx_obj_5_soya__World *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_is_inside(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_is_inside[] = "CoordSyst.is_inside(COORDSYST) -> bool\n\nReturns true if self is inside COORDSYST, i.e. if COORDSYST is self, or self.parent, or\nself.parent.parent or...";
static PyObject *__pyx_f_5_soya_9CoordSyst_is_inside(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"coordsyst",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_coordsyst)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_parent = Py_None; Py_INCREF((PyObject *) __pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 382; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":388 */
  Py_INCREF(__pyx_v_self);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_parent));
  __pyx_v_parent = __pyx_v_self;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":389 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 389; goto __pyx_L1;}
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":390 */
    __pyx_1 = ((PyObject *)__pyx_v_parent) == ((PyObject *)__pyx_v_coordsyst);
    if (__pyx_1) {
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 390; goto __pyx_L1;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":391 */
    Py_INCREF(((PyObject *)__pyx_v_parent->__pyx_base._parent));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_parent));
    __pyx_v_parent = ((PyObject *)__pyx_v_parent->__pyx_base._parent);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":392 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 392; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.CoordSyst.is_inside");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_set_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_set_xyz[] = "CoordSyst.set_xyz(x, y, z)\n\nMoves a CoordSyst to X, Y and Z.";
static PyObject *__pyx_f_5_soya_9CoordSyst_set_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":398 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":399 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = __pyx_v_y;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":400 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = __pyx_v_z;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":401 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.set_xyz");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_move(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_move[] = "Position.move(position)\n\nMoves a Position to POSITION.\nCoordinates system conversion is performed if needed (=if the Position and\nPOSITION are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_9CoordSyst_move(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_position = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"position",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_position)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_position);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_position), __pyx_ptype_5_soya_Position, 0, "position")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 403; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":409 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_position->__pyx_base.__pyx_vtab)->_into(__pyx_v_position,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":410 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.move");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_position);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_add_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_add_xyz[] = "Position.add_xyz(x, y, z)\n\nTranslates a Position by X, Y and Z.";
static PyObject *__pyx_f_5_soya_9CoordSyst_add_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":416 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) + __pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":417 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) + __pyx_v_y);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":418 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) + __pyx_v_z);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":419 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.add_xyz");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_shift(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_shift[] = "CoordSyst.shift(x, y, z)\n\nTranslates a CoordSyst by X, Y and Z, given in CoordSyst space.";
static PyObject *__pyx_f_5_soya_9CoordSyst_shift(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":425 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = ((((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) + (__pyx_v_x * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[0]))) + (__pyx_v_y * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[4]))) + (__pyx_v_z * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[8])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":426 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = ((((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) + (__pyx_v_x * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[1]))) + (__pyx_v_y * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[5]))) + (__pyx_v_z * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[9])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":427 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = ((((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) + (__pyx_v_x * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[2]))) + (__pyx_v_y * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[6]))) + (__pyx_v_z * (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[10])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":428 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.shift");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_add_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_add_vector[] = "Position.add_vector(vector)\n\nTranslates a Position IN PLACE.\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).\n\nFor Vector, add_vector means vectorial addition (translating a vector does\nnothing !).";
static PyObject *__pyx_f_5_soya_9CoordSyst_add_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"vector",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_vector)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 430; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":440 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":441 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) + (__pyx_v_v[0]));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":442 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) + (__pyx_v_v[1]));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":443 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) + (__pyx_v_v[2]));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":444 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":445 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.add_vector");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst___iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst___iadd__[] = "__iadd__(vec)\n\n    Same as add_vector.\n    ";
static PyObject *__pyx_f_5_soya_9CoordSyst___iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 447; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":452 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 452; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 452; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_vector);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_vector);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 452; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.__iadd__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_add_mul_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_add_mul_vector[] = "Position.add_mul_vector(k, vector)\n\nTranslates a Position IN PLACE, by K * VECTOR.\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).\n\nFor Vector, add_mul_vector means vectorial addition (translating a vector does\nnothing !).";
static PyObject *__pyx_f_5_soya_9CoordSyst_add_mul_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_k;
  struct __pyx_obj_5_soya__Vector *__pyx_v_vector = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"k","vector",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fO", __pyx_argnames, &__pyx_v_k, &__pyx_v_vector)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 454; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":464 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vector->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vector),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":465 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) + (__pyx_v_k * (__pyx_v_v[0])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":466 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) + (__pyx_v_k * (__pyx_v_v[1])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":467 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) + (__pyx_v_k * (__pyx_v_v[2])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":468 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":469 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.add_mul_vector");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_scale[] = "CoordSyst.scale(x, y, z)\n\nScales a CoordSyst by X, Y and Z (Changes its dimensions).\nNegative values are accepted.";
static PyObject *__pyx_f_5_soya_9CoordSyst_scale(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fff", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":476 */
  matrix_scale(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_x,__pyx_v_y,__pyx_v_z);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":477 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.scale");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_set_identity(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_set_identity[] = "CoordSyst.set_identity()\n\nResets a CoordSyst (moves it to 0,0,0 and removes any rotation or scaling).";
static PyObject *__pyx_f_5_soya_9CoordSyst_set_identity(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":483 */
  matrix_set_identity(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":484 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.set_identity");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_position[] = "Position.position() -> Point\n\nReturns the position (a Point) at the same position than the Position.";
static PyObject *__pyx_f_5_soya_9CoordSyst_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":490 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 490; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 490; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst___add__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst___add__[] = "Position + Vector -> Point\n\nTranslates a Position and returns the result (a new Point).\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_9CoordSyst___add__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya_CoordSyst, 1, "self")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 492; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 492; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":499 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":500 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) + (__pyx_v_v[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) + (__pyx_v_v[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) + (__pyx_v_v[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 500; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 500; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.__add__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst___sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst___sub__[] = "Position - Vector -> Point\n\nTranslates a Position and returns the result (a new Point).\nCoordinates system conversion is performed if needed (=if the Position and\nVECTOR are not defined in the same coordinates system).";
static PyObject *__pyx_f_5_soya_9CoordSyst___sub__(PyObject *__pyx_v_self, PyObject *__pyx_v_vector) {
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vector);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya_CoordSyst, 1, "self")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 502; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 502; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":509 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vector *)__pyx_v_vector)),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":510 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 510; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) - (__pyx_v_v[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 510; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) - (__pyx_v_v[1]))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 510; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) - (__pyx_v_v[2]))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 510; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 510; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 510; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.__sub__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vector);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_distance_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_distance_to[] = "Position.distance_to(other) -> float\n\nGets the distance between a Position and anOTHER.";
static PyObject *__pyx_f_5_soya_9CoordSyst_distance_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_other = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"other",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_other)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 512; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":517 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_other->__pyx_base.__pyx_vtab)->_into(__pyx_v_other,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":518 */
  __pyx_1 = PyFloat_FromDouble(sqrt((((((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) - (__pyx_v_v[0])) * ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) - (__pyx_v_v[0]))) + (((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) - (__pyx_v_v[1])) * ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) - (__pyx_v_v[1])))) + (((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) - (__pyx_v_v[2])) * ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) - (__pyx_v_v[2])))))); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSyst.distance_to");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_vector_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_vector_to[] = "Position.vector_to(other) -> Vector\n\nGets the vector that starts at a Position and ends at OTHER.";
static PyObject *__pyx_f_5_soya_9CoordSyst_vector_to(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_other = 0;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"other",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_other)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 520; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":525 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_other->__pyx_base.__pyx_vtab)->_into(__pyx_v_other,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_v);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":526 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((__pyx_v_v[0]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((__pyx_v_v[1]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]))); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((__pyx_v_v[2]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]))); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 526; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSyst.vector_to");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst___rshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst___rshift__[] = "__rshift__(pos)\n\n    Same as vector_to.\n    ";
static PyObject *__pyx_f_5_soya_9CoordSyst___rshift__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_other);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 528; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":533 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_vector_to); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 533; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 533; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_other);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_other);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 533; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.__rshift__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_other);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_look_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_look_at[] = "CoordSyst.look_at(target)\n\nRotate so that this CoordSyst\'s *negative*-Z points at target.";
static PyObject *__pyx_f_5_soya_9CoordSyst_look_at(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_target = 0;
  float (__pyx_v_f[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"target",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_target)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_target);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_Position, 0, "target")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 535; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":540 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_target->__pyx_base.__pyx_vtab)->_into(__pyx_v_target,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":541 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 541; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 541; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_target));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Vector));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__Vector));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 541; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 541; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":542 */
    (__pyx_v_f[0]) = ((__pyx_v_f[0]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":543 */
    (__pyx_v_f[1]) = ((__pyx_v_f[1]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":544 */
    (__pyx_v_f[2]) = ((__pyx_v_f[2]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":545 */
  matrix_look_to_Z(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":546 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.look_at");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_target);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_look_at_y(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_look_at_y[] = "CoordSyst.look_at_y(target)\n\nRotate so that this object\'s positive-Y points at target.";
static PyObject *__pyx_f_5_soya_9CoordSyst_look_at_y(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_target = 0;
  float (__pyx_v_f[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"target",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_target)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_target);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_Position, 0, "target")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 548; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":553 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_target->__pyx_base.__pyx_vtab)->_into(__pyx_v_target,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":554 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 554; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 554; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_target));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Vector));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__Vector));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 554; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 554; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":555 */
    (__pyx_v_f[0]) = ((__pyx_v_f[0]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":556 */
    (__pyx_v_f[1]) = ((__pyx_v_f[1]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":557 */
    (__pyx_v_f[2]) = ((__pyx_v_f[2]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":558 */
  matrix_look_to_Y(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":559 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.look_at_y");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_target);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_look_at_x(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_look_at_x[] = "CoordSyst.look_at_x(target)\n\nRotate so that this object\'s positive-X points at target.";
static PyObject *__pyx_f_5_soya_9CoordSyst_look_at_x(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_target = 0;
  float (__pyx_v_f[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"target",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_target)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_target);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_Position, 0, "target")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 561; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":566 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_target->__pyx_base.__pyx_vtab)->_into(__pyx_v_target,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":567 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 567; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 567; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_target));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Vector));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__Vector));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 567; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 567; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":568 */
    (__pyx_v_f[0]) = ((__pyx_v_f[0]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":569 */
    (__pyx_v_f[1]) = ((__pyx_v_f[1]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":570 */
    (__pyx_v_f[2]) = ((__pyx_v_f[2]) - (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":571 */
  matrix_look_to_X(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":572 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.look_at_x");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_target);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_turn_lateral(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_turn_lateral[] = "CoordSyst.turn_lateral(angle)\n\nRotate about the *local* Y axis, in degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_turn_lateral(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_angle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":578 */
  matrix_turn_lateral(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":579 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.turn_lateral");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_turn_vertical(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_turn_vertical[] = "CoordSyst.turn_vertical(angle)\n\nRotate about the *local* X axis, in degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_turn_vertical(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_angle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":585 */
  matrix_turn_vertical(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":586 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.turn_vertical");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_turn_incline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_turn_incline[] = "CoordSyst.turn_incline(angle)\n\nRotate about the *local* Z axis, in degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_turn_incline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_angle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":592 */
  matrix_turn_incline(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":593 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.turn_incline");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_lateral(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_lateral[] = "CoordSyst.rotate_lateral(angle)\n    \nRotate about the *parent\'s* Y axis, in degrees.\ne.g., If you are facing positive-Y with head to positive-Z, it\nspins like a car\'s steering wheel.";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_lateral(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_angle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":601 */
  matrix_rotate_lateral(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":602 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.rotate_lateral");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_vertical(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_vertical[] = "CoordSyst.rotate_vertical(angle)\n\nRotate about the *parent\'s* X axis, in degrees.\ne.g., If you are facing positive-Y with head to positive-Z, it\nspins like a car\'s tire.";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_vertical(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_angle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":610 */
  matrix_rotate_vertical(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":611 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.rotate_vertical");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_incline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_incline[] = "CoordSyst.rotate_incline(angle)\n\nRotate about the *parent\'s* Z axis, in degrees.\ne.g., If you are facing positive-Y with head to positive-Z, it\nspins like a spinning top.";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_incline(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_angle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":619 */
  matrix_rotate_incline(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":620 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.rotate_incline");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_axe(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_axe[] = "CoordSyst.rotate_axe(ANGLE, AXE)\n\nRotate a CoordSyst about an axis, of ANGLE degrees.\nThe axis is defined by a Vector AXE, and pass through the origin (0, 0, 0).";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_axe(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  struct __pyx_obj_5_soya_Position *__pyx_v_axe = 0;
  float (__pyx_v_coords[3]);
  float (__pyx_v_f[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle","axe",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fO", __pyx_argnames, &__pyx_v_angle, &__pyx_v_axe)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_axe);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_axe), __pyx_ptype_5_soya_Position, 0, "axe")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 622; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":628 */
  memcpy(__pyx_v_coords,(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12),(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":630 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_axe->__pyx_base.__pyx_vtab)->_into(__pyx_v_axe,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":631 */
  matrix_rotate_axe(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle),(__pyx_v_f[0]),(__pyx_v_f[1]),(__pyx_v_f[2]));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":632 */
  memcpy((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12),__pyx_v_coords,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":633 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.rotate_axe");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_axe);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_axe_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_axe_xyz[] = "CoordSyst.rotate_axe_xyz(ANGLE, X, Y, Z)\n\nRotate a CoordSyst about an (X, Y, Z) axis, of ANGLE degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_axe_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float (__pyx_v_coords[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle","x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ffff", __pyx_argnames, &__pyx_v_angle, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":640 */
  memcpy(__pyx_v_coords,(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12),(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":641 */
  matrix_rotate_axe(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle),__pyx_v_x,__pyx_v_y,__pyx_v_z);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":642 */
  memcpy((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12),__pyx_v_coords,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":643 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.rotate_axe_xyz");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate[] = "CoordSyst.rotate(ANGLE, A, B)\n\nRotate a CoordSyst about an axis, of ANGLE degrees.\nThe axis is defined by a Position A, and another Position or a Vector B.";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  struct __pyx_obj_5_soya_Position *__pyx_v_a = 0;
  struct __pyx_obj_5_soya_Position *__pyx_v_b = 0;
  float (__pyx_v_p1[3]);
  float (__pyx_v_p2[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"angle","a","b",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fOO", __pyx_argnames, &__pyx_v_angle, &__pyx_v_a, &__pyx_v_b)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_a);
  Py_INCREF((PyObject *)__pyx_v_b);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5_soya_Position, 0, "a")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 645; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5_soya_Position, 0, "b")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 645; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":651 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_a->__pyx_base.__pyx_vtab)->_into(__pyx_v_a,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_p1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":652 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_b->__pyx_base.__pyx_vtab)->_into(__pyx_v_b,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base._parent,__pyx_v_p2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":653 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 653; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 653; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_b));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_b));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Vector));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__Vector));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 653; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 653; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":654 */
    (__pyx_v_p2[0]) = ((__pyx_v_p2[0]) - (__pyx_v_p1[0]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":655 */
    (__pyx_v_p2[1]) = ((__pyx_v_p2[1]) - (__pyx_v_p1[1]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":656 */
    (__pyx_v_p2[2]) = ((__pyx_v_p2[2]) - (__pyx_v_p1[2]));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":657 */
  matrix_rotate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle),__pyx_v_p1,__pyx_v_p2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":658 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.CoordSyst.rotate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_a);
  Py_DECREF((PyObject *)__pyx_v_b);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_xyz[] = "CoordSyst.rotate_xyz(ANGLE, X1, Y1, Z1, X2, Y2, Z2)\n\nRotate a CoordSyst about an axis, of ANGLE degrees.\nThe axis is defined by a two point (X1, Y1, Z1) and (X2, Y2, Z2).";
static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_angle;
  float __pyx_v_x1;
  float __pyx_v_y1;
  float __pyx_v_z1;
  float __pyx_v_x2;
  float __pyx_v_y2;
  float __pyx_v_z2;
  float (__pyx_v_coords[3]);
  float (__pyx_v_p1[3]);
  float (__pyx_v_p2[3]);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"angle","x1","y1","z1","x2","y2","z2",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fffffff", __pyx_argnames, &__pyx_v_angle, &__pyx_v_x1, &__pyx_v_y1, &__pyx_v_z1, &__pyx_v_x2, &__pyx_v_y2, &__pyx_v_z2)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":666 */
  memcpy(__pyx_v_coords,(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12),(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":668 */
  (__pyx_v_p1[0]) = __pyx_v_x1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":669 */
  (__pyx_v_p1[1]) = __pyx_v_y1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":670 */
  (__pyx_v_p1[2]) = __pyx_v_z1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":671 */
  (__pyx_v_p2[0]) = (__pyx_v_x2 - __pyx_v_x1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":672 */
  (__pyx_v_p2[1]) = (__pyx_v_y2 - __pyx_v_y2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":673 */
  (__pyx_v_p2[2]) = (__pyx_v_z2 - __pyx_v_z2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":674 */
  matrix_rotate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle),__pyx_v_p1,__pyx_v_p2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":675 */
  memcpy((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix + 12),__pyx_v_coords,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":676 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.rotate_xyz");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k199p;

static char (__pyx_k199[]) = "<%s>";

static PyObject *__pyx_f_5_soya_9CoordSyst___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":679 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 679; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 679; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k199p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 679; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.CoordSyst.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_transform[] = "DEPRECATED";
static PyObject *__pyx_f_5_soya_9CoordSyst_transform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_position = 0;
  float (__pyx_v_p[3]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"position",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_position)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_position);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_position), __pyx_ptype_5_soya_Position, 0, "position")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 682; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":685 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_position->__pyx_base.__pyx_vtab)->_into(__pyx_v_position,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_p);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":686 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 686; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 686; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 686; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 686; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.CoordSyst.transform");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_position);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_transform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_transform_point[] = "DEPRECATED";
static PyObject *__pyx_f_5_soya_9CoordSyst_transform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_from_parent = 0;
  float (__pyx_v_p[3]);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"x","y","z","from_parent",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fffO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_from_parent)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_from_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_from_parent), __pyx_ptype_5_soya_CoordSyst, 1, "from_parent")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 688; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":691 */
  (__pyx_v_p[0]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":692 */
  (__pyx_v_p[1]) = __pyx_v_y;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":693 */
  (__pyx_v_p[2]) = __pyx_v_z;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":694 */
  __pyx_1 = ((PyObject *)__pyx_v_from_parent) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    point_by_matrix(__pyx_v_p,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_from_parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_from_parent));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":695 */
  point_by_matrix(__pyx_v_p,((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":696 */
  __pyx_3 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 696; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_5);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya.CoordSyst.transform_point");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_from_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_transform_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_transform_vector[] = "DEPRECATED";
static PyObject *__pyx_f_5_soya_9CoordSyst_transform_vector(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_from_parent = 0;
  float (__pyx_v_p[3]);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"x","y","z","from_parent",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "fffO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_from_parent)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_from_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_from_parent), __pyx_ptype_5_soya_CoordSyst, 1, "from_parent")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 698; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":701 */
  (__pyx_v_p[0]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":702 */
  (__pyx_v_p[1]) = __pyx_v_y;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":703 */
  (__pyx_v_p[2]) = __pyx_v_z;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":704 */
  __pyx_1 = ((PyObject *)__pyx_v_from_parent) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    vector_by_matrix(__pyx_v_p,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_from_parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_from_parent));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":705 */
  vector_by_matrix(__pyx_v_p,((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":706 */
  __pyx_3 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 706; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_5);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya.CoordSyst.transform_vector");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_from_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_interpolate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_interpolate[] = "CoordSyst.interpolate(state1, state2, factor)\n\nInterpolates between STATE1 and STATE2. FACTOR determine the importance of the two\nstates(0.0 => STATE1, 1.0 => STATE2).";
static PyObject *__pyx_f_5_soya_9CoordSyst_interpolate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSystState *__pyx_v_state1 = 0;
  struct __pyx_obj_5_soya_CoordSystState *__pyx_v_state2 = 0;
  float __pyx_v_factor;
  float (__pyx_v_q[4]);
  float __pyx_v_factor1;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"state1","state2","factor",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOf", __pyx_argnames, &__pyx_v_state1, &__pyx_v_state2, &__pyx_v_factor)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_state1);
  Py_INCREF((PyObject *)__pyx_v_state2);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state1), __pyx_ptype_5_soya_CoordSystState, 1, "state1")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 709; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state2), __pyx_ptype_5_soya_CoordSystState, 1, "state2")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 709; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":716 */
  ((struct __pyx_vtabstruct_5_soya_CoordSystState *)__pyx_v_state1->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_state_validity(__pyx_v_state1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":717 */
  ((struct __pyx_vtabstruct_5_soya_CoordSystState *)__pyx_v_state2->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_state_validity(__pyx_v_state2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":718 */
  __pyx_v_factor1 = (1.0 - __pyx_v_factor);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":723 */
  quaternion_slerp(__pyx_v_q,__pyx_v_state1->_quaternion,__pyx_v_state2->_quaternion,__pyx_v_factor,__pyx_v_factor1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":727 */
  matrix_from_quaternion(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_q);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":731 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = ((__pyx_v_factor1 * (__pyx_v_state1->__pyx_base._matrix[12])) + (__pyx_v_factor * (__pyx_v_state2->__pyx_base._matrix[12])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":732 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = ((__pyx_v_factor1 * (__pyx_v_state1->__pyx_base._matrix[13])) + (__pyx_v_factor * (__pyx_v_state2->__pyx_base._matrix[13])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":733 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = ((__pyx_v_factor1 * (__pyx_v_state1->__pyx_base._matrix[14])) + (__pyx_v_factor * (__pyx_v_state2->__pyx_base._matrix[14])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":734 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]) = ((__pyx_v_factor1 * (__pyx_v_state1->__pyx_base._matrix[16])) + (__pyx_v_factor * (__pyx_v_state2->__pyx_base._matrix[16])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":735 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]) = ((__pyx_v_factor1 * (__pyx_v_state1->__pyx_base._matrix[17])) + (__pyx_v_factor * (__pyx_v_state2->__pyx_base._matrix[17])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":736 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]) = ((__pyx_v_factor1 * (__pyx_v_state1->__pyx_base._matrix[18])) + (__pyx_v_factor * (__pyx_v_state2->__pyx_base._matrix[18])));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":737 */
  __pyx_1 = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]) != 1.0);
  if (!__pyx_1) {
    __pyx_1 = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]) != 1.0);
    if (!__pyx_1) {
      __pyx_1 = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]) != 1.0);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":738 */
    matrix_scale(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[16]),(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[17]),(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[18]));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":739 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CoordSyst.interpolate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_state1);
  Py_DECREF((PyObject *)__pyx_v_state2);
  return __pyx_r;
}

static PyObject *__pyx_n_added_into;

static int __pyx_f_5_soya_14CoordSystState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_14CoordSystState___init__[] = "CoordSystState(coord_syst) -> CoordSystState\n\nCreates a new CoordSystState, with the same position, rotation and scaling than COORD_SYST.";
static int __pyx_f_5_soya_14CoordSystState___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst = 0;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"coord_syst",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_coord_syst)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coord_syst), __pyx_ptype_5_soya_CoordSyst, 1, "coord_syst")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 752; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":756 */
  __pyx_1 = ((PyObject *)__pyx_v_coord_syst) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":757 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_added_into); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 757; goto __pyx_L1;}
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_coord_syst), __pyx_n_parent); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 757; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 757; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 757; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":758 */
    matrix_copy(((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->__pyx_base._matrix,__pyx_v_coord_syst->_matrix);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSystState.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
  return __pyx_r;
}

static void __pyx_f_5_soya_14CoordSystState__invalidate(struct __pyx_obj_5_soya_CoordSystState *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":761 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":762 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_COORDSYST_STATE_VALID));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSystState._invalidate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_14CoordSystState__check_state_validity(struct __pyx_obj_5_soya_CoordSystState *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":765 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_COORDSYST_STATE_VALID));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":766 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_COORDSYST_STATE_VALID);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":767 */
    quaternion_from_matrix(__pyx_v_self->_quaternion,__pyx_v_self->__pyx_base._matrix);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSystState._check_state_validity");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_14CoordSystState___setcstate__(struct __pyx_obj_5_soya_CoordSystState *__pyx_v_self,PyObject *__pyx_v_cstate) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":770 */
  __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":771 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_COORDSYST_STATE_VALID));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.CoordSystState.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_14CoordSystState_10quaternion___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14CoordSystState_10quaternion___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":775 */
  ((struct __pyx_vtabstruct_5_soya_CoordSystState *)((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_state_validity(((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":776 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 776; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 776; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 776; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 776; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 776; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CoordSystState.quaternion.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14CoordSystState_10quaternion___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_q); /*proto*/
static int __pyx_f_5_soya_14CoordSystState_10quaternion___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_q) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_q);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":778 */
  ((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_COORDSYST_STATE_VALID);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":779 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_q, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_q, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_q, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_q, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya_CoordSystState *)__pyx_v_self)->_quaternion[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_q, 4) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 779; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CoordSystState.quaternion.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_q);
  return __pyx_r;
}

static PyObject *__pyx_n_batch;

static void __pyx_f_5_soya_15PythonCoordSyst__batch(struct __pyx_obj_5_soya_PythonCoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  int __pyx_v_result;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  struct __pyx_obj_5_soya__Material *__pyx_v_material;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  __pyx_v_material = Py_None; Py_INCREF((PyObject *) __pyx_v_material);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":788 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":789 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":793 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_batch); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_4, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_result = __pyx_1;
  __pyx_3 = __Pyx_UnpackItem(__pyx_4, 1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
  __pyx_v_coordsyst = __pyx_3;
  __pyx_3 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_4, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_material));
  __pyx_v_material = __pyx_2;
  __pyx_2 = 0;
  if (__Pyx_EndUnpack(__pyx_4, 3) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 793; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":794 */
  __pyx_1 = ((PyObject *)__pyx_v_coordsyst) == ((PyObject *)__pyx_v_self);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":795 */
    multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_parent->_render_matrix,__pyx_v_self->__pyx_base._matrix);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":799 */
  __pyx_1 = (__pyx_v_result == 1);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
    goto __pyx_L4;
  }
  __pyx_1 = (__pyx_v_result == 2);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
    goto __pyx_L4;
  }
  __pyx_1 = (__pyx_v_result == 3);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->secondpass,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
    goto __pyx_L4;
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya.PythonCoordSyst._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static void __pyx_f_5_soya_15PythonCoordSyst__render(struct __pyx_obj_5_soya_PythonCoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":804 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_render); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 804; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 804; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 804; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya.PythonCoordSyst._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_n_shadow;

static int __pyx_f_5_soya_15PythonCoordSyst__shadow(struct __pyx_obj_5_soya_PythonCoordSyst *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":807 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 807; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 807; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_coordsyst));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_light));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_light));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 807; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 807; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_4;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya.PythonCoordSyst._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_15PythonCoordSyst_batch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_15PythonCoordSyst_batch[] = "PythonCoordSyst.batch()\n\nShould return a tuple (TYPE, COORDSYST, MATERIAL), where type can be :\n  0 if invisible / not drawn\n  1 if drawn without alpha\n  2 if drawn with alpha\nCOORDSYST is the coordinate system to use for rendering the object (usually self).";
static PyObject *__pyx_f_5_soya_15PythonCoordSyst_batch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":823 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 823; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 823; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_2, 2, Py_None);
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.PythonCoordSyst.batch");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_15PythonCoordSyst_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_15PythonCoordSyst_render[] = "PythonCoordSyst.render()\n\nShould perform the rendering (e.g. by calling OpenGL operation).";
static PyObject *__pyx_f_5_soya_15PythonCoordSyst_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.PythonCoordSyst.render");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_15PythonCoordSyst_shadow(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_15PythonCoordSyst_shadow(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst = 0;
  struct __pyx_obj_5_soya__Light *__pyx_v_light = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"coordsyst","light",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_coordsyst, &__pyx_v_light)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 830; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_light), __pyx_ptype_5_soya__Light, 1, "light")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 830; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":831 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 831; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.PythonCoordSyst.shadow");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Volume___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7_Volume___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Shape *__pyx_v_shape = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent","shape",0};
  __pyx_v_parent = __pyx_k31;
  __pyx_v_shape = __pyx_k32;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_shape)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_shape);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 23; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Shape, 1, "shape")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 23; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/volume.pyx":24 */
  Py_INCREF(((PyObject *)__pyx_v_shape));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape));
  ((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape = ((PyObject *)__pyx_v_shape);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":25 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Volume.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_shape);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Volume_5shape___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Volume_5shape___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":29 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Volume.shape.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Volume_5shape___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_shape); /*proto*/
static int __pyx_f_5_soya_7_Volume_5shape___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_shape) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shape);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Shape, 1, "shape")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 30; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/volume.pyx":31 */
  Py_INCREF(__pyx_v_shape);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape));
  ((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape = __pyx_v_shape;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Volume.shape.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shape);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Volume_set_shape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Volume_set_shape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Shape *__pyx_v_shape = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"shape",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_shape)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shape);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Shape, 1, "shape")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 33; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/volume.pyx":34 */
  Py_INCREF(((PyObject *)__pyx_v_shape));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape));
  ((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape = ((PyObject *)__pyx_v_shape);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Volume.set_shape");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shape);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Volume___getcstate__(struct __pyx_obj_5_soya__Volume *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":37 */
  __pyx_1 = __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_shape));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_shape));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Volume.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Volume___setcstate__(struct __pyx_obj_5_soya__Volume *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":40 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":41 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Shape)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_shape));
  __pyx_v_self->_shape = __pyx_2;
  __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Volume.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_7_Volume__batch(struct __pyx_obj_5_soya__Volume *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":44 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":46 */
  multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base._matrix);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":47 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":48 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->_shape->__pyx_base.__pyx_vtab)->_batch(__pyx_v_self->_shape,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static int __pyx_f_5_soya_7_Volume__shadow(struct __pyx_obj_5_soya__Volume *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":51 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_r = ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->_shape->__pyx_base.__pyx_vtab)->_shadow(__pyx_v_self->_shape,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_light);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":52 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Volume__raypick(struct __pyx_obj_5_soya__Volume *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":55 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":56 */
  ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->_shape->__pyx_base.__pyx_vtab)->_raypick(__pyx_v_self->_shape,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_7_Volume__raypick_b(struct __pyx_obj_5_soya__Volume *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":59 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":60 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->_shape->__pyx_base.__pyx_vtab)->_raypick_b(__pyx_v_self->_shape,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Volume__collect_raypickables(struct __pyx_obj_5_soya__Volume *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  float (*__pyx_v_matrix);
  float (__pyx_v_s[4]);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":63 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":69 */
  __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya__Volume *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/volume.pyx":70 */
  point_by_matrix_copy(__pyx_v_s,__pyx_v_rsphere,__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":71 */
  (__pyx_v_s[3]) = length_by_matrix((__pyx_v_rsphere[3]),__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":72 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->_shape->__pyx_base.__pyx_vtab)->_collect_raypickables(__pyx_v_self->_shape,__pyx_v_items,__pyx_v_rsphere,__pyx_v_s,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_7_Volume__contains(struct __pyx_obj_5_soya__Volume *__pyx_v_self,struct __pyx_obj_5_soya__CObj *__pyx_v_obj) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_obj);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":75 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == ((PyObject *)__pyx_v_obj);
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":76 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._contains");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_obj);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Volume__get_box(struct __pyx_obj_5_soya__Volume *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  float (__pyx_v_matrix2[19]);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":81 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/volume.pyx":82 */
    __pyx_1 = (__pyx_v_matrix == 0);
    if (__pyx_1) {
      matrix_copy(__pyx_v_matrix2,__pyx_v_self->__pyx_base._matrix);
      goto __pyx_L3;
    }
    /*else*/ {
      multiply_matrix(__pyx_v_matrix2,__pyx_v_matrix,__pyx_v_self->__pyx_base._matrix);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/soya3d/volume.pyx":84 */
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->_shape->__pyx_base.__pyx_vtab)->_get_box(__pyx_v_self->_shape,__pyx_v_box,__pyx_v_matrix2);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Volume._get_box");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_7_Volume__get_sphere(struct __pyx_obj_5_soya__Volume *__pyx_v_self,float (*__pyx_v_sphere)) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":87 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
  if (__pyx_2) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_shape));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_self->_shape));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__SimpleShape));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__SimpleShape));
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
    if (__pyx_2) {
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)((PyObject *)__pyx_v_self->_shape))->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE)); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
    }
  }
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/volume.pyx":88 */
    memcpy(__pyx_v_sphere,((struct __pyx_obj_5_soya__SimpleShape *)((PyObject *)__pyx_v_self->_shape))->_sphere,(4 * (sizeof(float ))));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/volume.pyx":90 */
    (__pyx_v_sphere[0]) = 0.0;
    (__pyx_v_sphere[1]) = 0.0;
    (__pyx_v_sphere[2]) = 0.0;
    (__pyx_v_sphere[3]) = 0.0;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Volume._get_sphere");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k200p;

static char (__pyx_k200[]) = "<%s, shape=%s>";

static PyObject *__pyx_f_5_soya_7_Volume___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Volume___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/volume.pyx":93 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_5_soya__Volume *)__pyx_v_self)->_shape));
  __pyx_2 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k200p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Volume.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_9shapifier___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_World_9shapifier___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/world.pyx":28 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_shapifier));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_shapifier);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World.shapifier.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_World_9shapifier___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_arg); /*proto*/
static int __pyx_f_5_soya_6_World_9shapifier___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_arg) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_arg);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arg), __pyx_ptype_5_soya_Shapifier, 1, "arg")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 29; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":30 */
  Py_INCREF(__pyx_v_arg);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_shapifier));
  ((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_shapifier = __pyx_v_arg;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World.shapifier.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_arg);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_10atmosphere___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_World_10atmosphere___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/world.pyx":34 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_atmosphere));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_atmosphere);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World.atmosphere.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_World_10atmosphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_atmosphere); /*proto*/
static int __pyx_f_5_soya_6_World_10atmosphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_atmosphere) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_atmosphere);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_atmosphere), __pyx_ptype_5_soya__Atmosphere, 1, "atmosphere")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 35; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":36 */
  Py_INCREF(__pyx_v_atmosphere);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_atmosphere));
  ((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_atmosphere = __pyx_v_atmosphere;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World.atmosphere.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_atmosphere);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_World___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_6_World___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Shape *__pyx_v_shape = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent","shape",0};
  __pyx_v_parent = __pyx_k33;
  __pyx_v_shape = __pyx_k34;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_shape)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_shape);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 38; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Shape, 1, "shape")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 38; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":39 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children);
  ((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":40 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Volume), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_shape));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_shape);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World___getcstate__(struct __pyx_obj_5_soya__World *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/world.pyx":44 */
  __pyx_1 = __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 44; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(6); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 44; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base._shape));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->__pyx_base._shape));
  Py_INCREF(__pyx_v_self->_filename);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_self->_filename);
  Py_INCREF(__pyx_v_self->children);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_self->children);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_atmosphere));
  PyTuple_SET_ITEM(__pyx_2, 4, ((PyObject *)__pyx_v_self->_atmosphere));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_shapifier));
  PyTuple_SET_ITEM(__pyx_2, 5, ((PyObject *)__pyx_v_self->_shapifier));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._World.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_World___setcstate__(struct __pyx_obj_5_soya__World *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_cstate2;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":47 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Shape)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base._shape));
  __pyx_v_self->__pyx_base._shape = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_filename);
  __pyx_v_self->_filename = __pyx_3;
  __pyx_3 = 0;
  __pyx_4 = __Pyx_UnpackItem(__pyx_v_cstate, 3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->children);
  __pyx_v_self->children = __pyx_4;
  __pyx_4 = 0;
  __pyx_5 = __Pyx_UnpackItem(__pyx_v_cstate, 4); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Atmosphere)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_atmosphere));
  __pyx_v_self->_atmosphere = __pyx_5;
  __pyx_5 = 0;
  __pyx_6 = __Pyx_UnpackItem(__pyx_v_cstate, 5); if (!__pyx_6) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_6, __pyx_ptype_5_soya_Shapifier)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_shapifier));
  __pyx_v_self->_shapifier = __pyx_6;
  __pyx_6 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 6) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":48 */
  __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/world.pyx":50 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 50; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 50; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 50; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_2;
    __pyx_2 = 0;
    Py_INCREF(((PyObject *)__pyx_v_self));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child->__pyx_base._parent));
    __pyx_v_child->__pyx_base._parent = ((PyObject *)__pyx_v_self);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya._World.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_6_World_get_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_6_World_get_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);

  /* "/home/jiba/src/soya/soya3d/world.pyx":54 */
  Py_INCREF(__pyx_v_self);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = __pyx_v_self;

  /* "/home/jiba/src/soya/soya3d/world.pyx":55 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 55; goto __pyx_L1;}
    if (!__pyx_1) break;
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 55; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
    __pyx_v_root = ((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":56 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_r = ((PyObject *)__pyx_v_root);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World.get_root");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static struct __pyx_obj_5_soya__World *__pyx_f_5_soya_6_World__get_root(struct __pyx_obj_5_soya__World *__pyx_v_self) {
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  struct __pyx_obj_5_soya__World *__pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);

  /* "/home/jiba/src/soya/soya3d/world.pyx":60 */
  Py_INCREF(((PyObject *)__pyx_v_self));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = ((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/world.pyx":61 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 61; goto __pyx_L1;}
    if (!__pyx_1) break;
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 61; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
    __pyx_v_root = ((PyObject *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base._parent);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":62 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_r = (struct __pyx_obj_5_soya__World *)((PyObject *)__pyx_v_root);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World._get_root");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_self);
  return ((struct __pyx_obj_5_soya__World *)__pyx_r) ;
}

static void __pyx_f_5_soya_6_World__invalidate(struct __pyx_obj_5_soya__World *__pyx_v_self) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":66 */
  __pyx_v_self->__pyx_base.__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/world.pyx":67 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 67; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 67; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 67; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_2;
    __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(__pyx_v_child);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._World._invalidate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_extend;

static void __pyx_f_5_soya_6_World__batch(struct __pyx_obj_5_soya__World *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  struct __pyx_obj_5_soya_Context *__pyx_v_old_context;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_old_context = Py_None; Py_INCREF((PyObject *) __pyx_v_old_context);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":72 */
  Py_INCREF(((PyObject *)__pyx_v_5_soya_renderer->current_context));
  Py_DECREF(((PyObject *)__pyx_v_old_context));
  __pyx_v_old_context = ((PyObject *)__pyx_v_5_soya_renderer->current_context);

  /* "/home/jiba/src/soya/soya3d/world.pyx":73 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":75 */
  __pyx_1 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    multiply_matrix(__pyx_v_self->__pyx_base.__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base.__pyx_base._matrix);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":76 */
  __pyx_v_self->__pyx_base.__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/world.pyx":78 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_atmosphere) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":79 */
    __pyx_1 = ((PyObject *)__pyx_v_5_soya_renderer->root_atmosphere) == Py_None;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":80 */
      Py_INCREF(((PyObject *)__pyx_v_self->_atmosphere));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->current_context->atmosphere));
      __pyx_v_5_soya_renderer->current_context->atmosphere = ((PyObject *)__pyx_v_self->_atmosphere);
      Py_INCREF(((PyObject *)__pyx_v_self->_atmosphere));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->root_atmosphere));
      __pyx_v_5_soya_renderer->root_atmosphere = ((PyObject *)__pyx_v_self->_atmosphere);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/world.pyx":82 */
      __pyx_2 = ((PyObject *)__pyx_v_self->_atmosphere) == ((PyObject *)__pyx_v_5_soya_renderer->current_context->atmosphere);
      __pyx_1 = (!__pyx_2);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/world.pyx":83 */
        __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_context(__pyx_v_5_soya_renderer)); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 83; goto __pyx_L1;}
        Py_DECREF(((PyObject *)__pyx_v_5_soya_renderer->current_context));
        __pyx_v_5_soya_renderer->current_context = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/soya3d/world.pyx":84 */
        Py_INCREF(((PyObject *)__pyx_v_self->_atmosphere));
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->current_context->atmosphere));
        __pyx_v_5_soya_renderer->current_context->atmosphere = ((PyObject *)__pyx_v_self->_atmosphere);

        /* "/home/jiba/src/soya/soya3d/world.pyx":85 */
        __pyx_3 = PyObject_GetAttr(__pyx_v_5_soya_renderer->current_context->lights, __pyx_n_extend); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 85; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 85; goto __pyx_L1;}
        Py_INCREF(__pyx_v_old_context->lights);
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_old_context->lights);
        __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 85; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":87 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->__pyx_base._shape->__pyx_base.__pyx_vtab)->_batch(__pyx_v_self->__pyx_base._shape,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":89 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 89; goto __pyx_L1;}
  for (;;) {
    __pyx_L8:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 89; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 89; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_4;
    __pyx_4 = 0;
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_batch(__pyx_v_child,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
  }
  __pyx_L9:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":91 */
  Py_INCREF(((PyObject *)__pyx_v_old_context));
  Py_DECREF(((PyObject *)__pyx_v_5_soya_renderer->current_context));
  __pyx_v_5_soya_renderer->current_context = ((PyObject *)__pyx_v_old_context);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._World._batch");
  __pyx_L0:;
  Py_DECREF(__pyx_v_old_context);
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static int __pyx_f_5_soya_6_World__shadow(struct __pyx_obj_5_soya__World *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  int __pyx_v_result;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":96 */
  __pyx_v_result = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":97 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_v_result = ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->__pyx_base._shape->__pyx_base.__pyx_vtab)->_shadow(__pyx_v_self->__pyx_base._shape,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_light);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":98 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 98; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 98; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 98; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_4;
    __pyx_4 = 0;
    __pyx_v_result = (__pyx_v_result | ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_shadow(__pyx_v_child,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_light));
  }
  __pyx_L4:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":99 */
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._World._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_World__raypick(struct __pyx_obj_5_soya__World *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":104 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":105 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->__pyx_base._shape->__pyx_base.__pyx_vtab)->_raypick(__pyx_v_self->__pyx_base._shape,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":106 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 106; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 106; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 106; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_4;
    __pyx_4 = 0;
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_raypick(__pyx_v_child,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
  }
  __pyx_L5:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._World._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_6_World__raypick_b(struct __pyx_obj_5_soya__World *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":110 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":111 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->__pyx_base._shape->__pyx_base.__pyx_vtab)->_raypick_b(__pyx_v_self->__pyx_base._shape,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)) == 1);
  }
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":112 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 112; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 112; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":113 */
    __pyx_2 = (((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_b(__pyx_v_child,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)) == 1);
    if (__pyx_2) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L5:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":114 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._World._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static PyObject *__pyx_n_shape;

static int __pyx_f_5_soya_6_World__contains(struct __pyx_obj_5_soya__World *__pyx_v_self,struct __pyx_obj_5_soya__CObj *__pyx_v_obj) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_obj);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":118 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 118; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 118; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_obj));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_obj));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya_CoordSyst));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya_CoordSyst));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 118; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 118; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":119 */
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_obj), __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 119; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_obj));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = ((PyObject *)__pyx_v_obj);

    /* "/home/jiba/src/soya/soya3d/world.pyx":120 */
    while (1) {
      __pyx_L3:;
      __pyx_4 = PyObject_IsTrue(((PyObject *)__pyx_v_child)); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 120; goto __pyx_L1;}
      if (!__pyx_4) break;

      /* "/home/jiba/src/soya/soya3d/world.pyx":121 */
      __pyx_4 = ((PyObject *)__pyx_v_child) == ((PyObject *)__pyx_v_self);
      if (__pyx_4) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/world.pyx":122 */
      Py_INCREF(((PyObject *)__pyx_v_child->__pyx_base._parent));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
      __pyx_v_child = ((PyObject *)__pyx_v_child->__pyx_base._parent);
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/world.pyx":124 */
    __pyx_4 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == ((PyObject *)__pyx_v_obj);
    if (__pyx_4) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/soya3d/world.pyx":125 */
    __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 125; goto __pyx_L1;}
    for (;;) {
      __pyx_L7:;
      __pyx_2 = PyIter_Next(__pyx_1);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 125; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 125; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
      __pyx_v_child = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/soya3d/world.pyx":126 */
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 126; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__CObj)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 126; goto __pyx_L1;}
      __pyx_4 = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_contains(__pyx_v_child,((struct __pyx_obj_5_soya__CObj *)__pyx_3));
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (__pyx_4) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    __pyx_L8:;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":127 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._World._contains");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_obj);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_World__get_box(struct __pyx_obj_5_soya__World *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  float (__pyx_v_matrix2[19]);
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":135 */
  __pyx_1 = (__pyx_v_matrix == 0);
  if (__pyx_1) {
    matrix_copy(__pyx_v_matrix2,__pyx_v_self->__pyx_base.__pyx_base._matrix);
    goto __pyx_L2;
  }
  /*else*/ {
    multiply_matrix(__pyx_v_matrix2,__pyx_v_matrix,__pyx_v_self->__pyx_base.__pyx_base._matrix);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":138 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->__pyx_base._shape->__pyx_base.__pyx_vtab)->_get_box(__pyx_v_self->__pyx_base._shape,__pyx_v_box,__pyx_v_matrix2);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":141 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 141; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 141; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 141; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_4;
    __pyx_4 = 0;
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_get_box(__pyx_v_child,__pyx_v_box,__pyx_v_matrix2);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._World._get_box");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_6_World_raypick(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_raypick[] = "World.raypick(ORIGIN, DIRECTION, DISTANCE = -1.0, HALF_LINE = 1, CULL_FACE = 1, P = None, V = None) -> None or (Point, Vector)\n\nPerforms a raypicking, i.e. send an invisible ray and returns what the ray hits.\nRaypicking is a collision detection method.\nOnly objects inside the World are taken into account ; raypick on the root World\nif you want to raypick on the full scene.\n\nORIGIN and DIRECTION are a Position and a Vector that defines the ray.\n\nDISTANCE is the maximum length of the ray, if DISTANCE == -1.0 (default value),\nthere is no length limitation. Shorter DISTANCEs give faster raypicks.\n\nIf HALF_LINE is true (default value), the ray starts at ORIGIN and goes toward DIRECTION.\nIf it is false, the ray is bidirectional : it starts at ORIGIN and goes both toward\nDIRECTION and -DIRECTION.\n\nIf CULL_FACE is true (default value), non double-sided face are only raypicked on their\nvisible side. If false, both side are take into account.\n\nP and V are a Point and a Vector that are re-used in the return value, if given (for speed up purpose).\nBy default, a new Point and a new Vector are created.\n\nThe return value is None if the ray hits nothing, or a (COLLISION, NORMAL) tuple.\nCOLLISION is a Point located where the collision occured, and COLLISION.parent is the\nobject hit.\nNORMAL is the normal of the object at the impact point.\n";
static PyObject *__pyx_f_5_soya_6_World_raypick(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_origin = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction = 0;
  float __pyx_v_distance;
  int __pyx_v_half_line;
  int __pyx_v_cull_face;
  struct __pyx_obj_5_soya__Point *__pyx_v_p = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_v = 0;
  struct __pyx_obj_5_soya_RaypickData *__pyx_v_data;
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  float (*__pyx_v_d);
  int __pyx_v_max;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"origin","direction","distance","half_line","cull_face","p","v",0};
  __pyx_v_distance = __pyx_k35;
  __pyx_v_half_line = __pyx_k36;
  __pyx_v_cull_face = __pyx_k37;
  __pyx_v_p = __pyx_k38;
  __pyx_v_v = __pyx_k39;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|fiiOO", __pyx_argnames, &__pyx_v_origin, &__pyx_v_direction, &__pyx_v_distance, &__pyx_v_half_line, &__pyx_v_cull_face, &__pyx_v_p, &__pyx_v_v)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_origin);
  Py_INCREF((PyObject *)__pyx_v_direction);
  Py_INCREF((PyObject *)__pyx_v_p);
  Py_INCREF((PyObject *)__pyx_v_v);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_origin), __pyx_ptype_5_soya_Position, 0, "origin")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 143; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 143; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya__Point, 1, "p")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 143; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5_soya__Vector, 1, "v")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 143; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":175 */
  __pyx_1 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 175; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":176 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_origin->__pyx_base.__pyx_vtab)->_out(__pyx_v_origin,__pyx_v_data->root_data);

  /* "/home/jiba/src/soya/soya3d/world.pyx":177 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_direction->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_direction),(__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/world.pyx":178 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/world.pyx":179 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/world.pyx":180 */
  __pyx_v_data->option = ((__pyx_e_5_soya_RAYPICK_CULL_FACE * __pyx_v_cull_face) + (__pyx_e_5_soya_RAYPICK_HALF_LINE * __pyx_v_half_line));

  /* "/home/jiba/src/soya/soya3d/world.pyx":182 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 182; goto __pyx_L1;}
  ((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raypick(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)),__pyx_v_data,((struct __pyx_obj_5_soya_CoordSyst *)Py_None));

  /* "/home/jiba/src/soya/soya3d/world.pyx":183 */
  __pyx_2 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
  if (__pyx_2) {
    __pyx_v_d = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_d = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_data->result_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_data->result_coordsyst,__pyx_v_data);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":187 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/world.pyx":188 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":189 */
  while (1) {
    __pyx_L3:;
    __pyx_2 = (__pyx_v_data->raypicked->nb < __pyx_v_max);
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/soya3d/world.pyx":190 */
    __pyx_1 = (PyObject *)chunk_get_ptr(__pyx_v_data->raypicked);
    Py_INCREF((PyObject *)__pyx_1);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":191 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":192 */
  __pyx_1 = __pyx_f_5_soya_make_raypick_result(__pyx_v_d,__pyx_v_data->result,__pyx_v_data->normal,__pyx_v_data->result_coordsyst,__pyx_v_p,__pyx_v_v); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 192; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._World.raypick");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_origin);
  Py_DECREF((PyObject *)__pyx_v_direction);
  Py_DECREF((PyObject *)__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_v);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_raypick_b(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_raypick_b[] = "World.raypick_b(ORIGIN, DIRECTION, DISTANCE = -1.0, HALF_LINE = 1, CULL_FACE = 1) -> bool\n\nPerforms a raypicking, i.e. send an invisible ray and returns true if something was hit.\nRaypicking is a collision detection method.\nThis is a simpler but faster version of raypick ; if you want more information about\nthe collision, see raypick.\nOnly items inside the World are taken into account ; raypick on the root World\nif you want to raypick on the full scene.\n\nORIGIN and DIRECTION are a Position and a Vector that defines the ray.\n\nDISTANCE is the maximum length of the ray, if DISTANCE == -1.0 (default value),\nthere is no length limitation. Shorter DISTANCEs give faster raypicks.\n\nIf HALF_LINE is true (default value), the ray starts at ORIGIN and goes toward DIRECTION.\nIf it is false, the ray is bidirectional : it starts at ORIGIN and goes both toward\nDIRECTION and -DIRECTION.\n\nIf CULL_FACE is true (default value), non double-sided face are only raypicked on their\nvisible side. If false, both side are take into account.\n";
static PyObject *__pyx_f_5_soya_6_World_raypick_b(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_origin = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction = 0;
  float __pyx_v_distance;
  int __pyx_v_half_line;
  int __pyx_v_cull_face;
  struct __pyx_obj_5_soya_RaypickData *__pyx_v_data;
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  int __pyx_v_result;
  int __pyx_v_max;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"origin","direction","distance","half_line","cull_face",0};
  __pyx_v_distance = __pyx_k40;
  __pyx_v_half_line = __pyx_k41;
  __pyx_v_cull_face = __pyx_k42;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|fii", __pyx_argnames, &__pyx_v_origin, &__pyx_v_direction, &__pyx_v_distance, &__pyx_v_half_line, &__pyx_v_cull_face)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_origin);
  Py_INCREF((PyObject *)__pyx_v_direction);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_origin), __pyx_ptype_5_soya_Position, 0, "origin")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 194; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 194; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":220 */
  __pyx_1 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 220; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":221 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_origin->__pyx_base.__pyx_vtab)->_out(__pyx_v_origin,__pyx_v_data->root_data);

  /* "/home/jiba/src/soya/soya3d/world.pyx":222 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_direction->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_direction),(__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/world.pyx":223 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/world.pyx":224 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/world.pyx":225 */
  __pyx_v_data->option = ((__pyx_e_5_soya_RAYPICK_CULL_FACE * __pyx_v_cull_face) + (__pyx_e_5_soya_RAYPICK_HALF_LINE * __pyx_v_half_line));

  /* "/home/jiba/src/soya/soya3d/world.pyx":227 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 227; goto __pyx_L1;}
  __pyx_v_result = ((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raypick_b(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)),__pyx_v_data,((struct __pyx_obj_5_soya_CoordSyst *)Py_None));

  /* "/home/jiba/src/soya/soya3d/world.pyx":230 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/world.pyx":231 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":232 */
  while (1) {
    __pyx_L2:;
    __pyx_2 = (__pyx_v_data->raypicked->nb < __pyx_v_max);
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/soya3d/world.pyx":233 */
    __pyx_1 = (PyObject *)chunk_get_ptr(__pyx_v_data->raypicked);
    Py_INCREF((PyObject *)__pyx_1);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":234 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":235 */
  __pyx_1 = PyInt_FromLong(__pyx_v_result); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._World.raypick_b");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_origin);
  Py_DECREF((PyObject *)__pyx_v_direction);
  return __pyx_r;
}

static PyObject *__pyx_n_is_inside;
static PyObject *__pyx_n_remove;

static PyObject *__pyx_k201p;

static char (__pyx_k201[]) = "Cyclic addition!";

static PyObject *__pyx_f_5_soya_6_World_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_add[] = "add(child)\n\nAdd a child to this World.\n\nWhen the World is moved / rotated / scaled, all its children are moved / rotated / scaled\nwith it.\n";
static PyObject *__pyx_f_5_soya_6_World_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child = 0;
  float (*__pyx_v_m);
  float (*__pyx_v_p);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"child",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_child)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_child);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child), __pyx_ptype_5_soya_CoordSyst, 0, "child")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 237; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":245 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 245; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 245; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__World));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__World));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 245; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 245; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":246 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_is_inside); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 246; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 246; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 246; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 246; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":247 */
      __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 247; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 247; goto __pyx_L1;}
      Py_INCREF(__pyx_k201p);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k201p);
      __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 247; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[9]; __pyx_lineno = 247; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":251 */
  __pyx_4 = ((PyObject *)__pyx_v_child->__pyx_base._parent) == Py_None;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":252 */
    __pyx_v_m = ((float (*))malloc((19 * (sizeof(float )))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":253 */
    __pyx_v_p = ((float (*))malloc((3 * (sizeof(float )))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":254 */
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_child),((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)),__pyx_v_p);

    /* "/home/jiba/src/soya/soya3d/world.pyx":255 */
    matrix_copy(__pyx_v_m,__pyx_v_child->_matrix);

    /* "/home/jiba/src/soya/soya3d/world.pyx":255 */
    multiply_matrix(__pyx_v_child->_matrix,__pyx_v_m,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_child->__pyx_base._parent));

    /* "/home/jiba/src/soya/soya3d/world.pyx":256 */
    matrix_copy(__pyx_v_m,__pyx_v_child->_matrix);

    /* "/home/jiba/src/soya/soya3d/world.pyx":256 */
    multiply_matrix(__pyx_v_child->_matrix,__pyx_v_m,((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":257 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_child->__pyx_base._parent), __pyx_n_remove); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 257; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 257; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 257; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":258 */
    memcpy((__pyx_v_child->_matrix + 12),__pyx_v_p,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":259 */
    free(__pyx_v_m);

    /* "/home/jiba/src/soya/soya3d/world.pyx":260 */
    free(__pyx_v_p);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":261 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 261; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 261; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 261; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":262 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(__pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":264 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_added_into); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 264; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 264; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 264; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.add");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_child);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_append(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_append[] = "append(child)\n\nSame as add(child).\n";
static PyObject *__pyx_f_5_soya_6_World_append(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"child",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_child)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_child);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child), __pyx_ptype_5_soya_CoordSyst, 0, "child")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 266; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":271 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 271; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 271; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 271; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.append");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_child);
  return __pyx_r;
}

static PyObject *__pyx_n_pop;
static PyObject *__pyx_n__parent;

static int __pyx_f_5_soya_6_World___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static int __pyx_f_5_soya_6_World___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_index);

  /* "/home/jiba/src/soya/soya3d/world.pyx":274 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children, __pyx_n_pop); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_INCREF(__pyx_v_index);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_index);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_3, __pyx_n__parent, Py_None) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.__delitem__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_index);
  return __pyx_r;
}

static PyObject *__pyx_n_insert;

static PyObject *__pyx_f_5_soya_6_World_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_insert[] = "insert(index, child)\n\nInsert child at INDEX.\n";
static PyObject *__pyx_f_5_soya_6_World_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"index","child",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iO", __pyx_argnames, &__pyx_v_index, &__pyx_v_child)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_child);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child), __pyx_ptype_5_soya_CoordSyst, 0, "child")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 276; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":281 */
  Py_INCREF(__pyx_v_self);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_child->__pyx_base._parent));
  __pyx_v_child->__pyx_base._parent = __pyx_v_self;

  /* "/home/jiba/src/soya/soya3d/world.pyx":282 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children, __pyx_n_insert); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 282; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 282; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 282; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_child));
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 282; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.insert");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_child);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_remove(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_remove[] = "remove(child)\n\nRemove a child.\n";
static PyObject *__pyx_f_5_soya_6_World_remove(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"child",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_child)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_child);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child), __pyx_ptype_5_soya_CoordSyst, 0, "child")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 284; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":289 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children, __pyx_n_remove); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 289; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 289; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 289; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":290 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_added_into); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_2, 0, Py_None);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.remove");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_child);
  return __pyx_r;
}

static PyObject *__pyx_n_recursive;

static PyObject *__pyx_f_5_soya_6_World_recursive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_recursive[] = "World.recursive() -> list\n\nGets a recursive list of all the children elements in a World (=the World\nchildren, + the children of its children and so on).";
static PyObject *__pyx_f_5_soya_6_World_recursive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_item;
  PyObject *__pyx_v_recursive;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);
  __pyx_v_recursive = Py_None; Py_INCREF(__pyx_v_recursive);

  /* "/home/jiba/src/soya/soya3d/world.pyx":298 */
  __pyx_1 = PySequence_GetSlice(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children, 0, 0x7fffffff); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 298; goto __pyx_L1;}
  Py_DECREF(__pyx_v_recursive);
  __pyx_v_recursive = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":299 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 299; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 299; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 299; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":300 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__World));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__World));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_5) {
      __pyx_2 = PyObject_GetAttr(__pyx_v_recursive, __pyx_n_extend); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
      __pyx_3 = PyObject_GetAttr(((PyObject *)((PyObject *)__pyx_v_item)), __pyx_n_recursive); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
      __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_6);
      __pyx_6 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 300; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":301 */
  Py_INCREF(__pyx_v_recursive);
  __pyx_r = __pyx_v_recursive;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._World.recursive");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_item);
  Py_DECREF(__pyx_v_recursive);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_iter;

static PyObject *__pyx_f_5_soya_6_World___iter__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5_soya_6_World___iter__[] = "Iterate the children.";
static PyObject *__pyx_f_5_soya_6_World___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/world.pyx":305 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_iter); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 305; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 305; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children);
  PyTuple_SET_ITEM(__pyx_2, 0, ((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 305; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.__iter__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_name;

static PyObject *__pyx_k203p;

static char (__pyx_k203[]) = "";

static PyObject *__pyx_f_5_soya_6_World___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static PyObject *__pyx_f_5_soya_6_World___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_item;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_name);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);
  __pyx_v_i = Py_None; Py_INCREF((PyObject *) __pyx_v_i);

  /* "/home/jiba/src/soya/soya3d/world.pyx":310 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 310; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 310; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 310; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":311 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_getattr); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 311; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 311; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(__pyx_n_name);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n_name);
    Py_INCREF(__pyx_k203p);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_k203p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 311; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (PyObject_Cmp(__pyx_4, __pyx_v_name, &__pyx_5) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 311; goto __pyx_L1;}
    __pyx_5 = __pyx_5 == 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_5) {
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
      __pyx_r = ((PyObject *)__pyx_v_item);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":312 */
  __pyx_2 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 312; goto __pyx_L1;}
  for (;;) {
    __pyx_L5:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 312; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 312; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":313 */
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 313; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__World));
    PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject*)__pyx_ptype_5_soya__World));
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 313; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_5) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":314 */
      __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_item), __pyx_v_name); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 314; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 314; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_i));
      __pyx_v_i = __pyx_4;
      __pyx_4 = 0;

      /* "/home/jiba/src/soya/soya3d/world.pyx":315 */
      __pyx_5 = PyObject_IsTrue(((PyObject *)__pyx_v_i)); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 315; goto __pyx_L1;}
      if (__pyx_5) {
        Py_INCREF((PyObject *)((PyObject *)__pyx_v_i));
        __pyx_r = ((PyObject *)__pyx_v_i);
        goto __pyx_L0;
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __pyx_L6:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._World.__getitem__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_item);
  Py_DECREF((PyObject *)__pyx_v_i);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

static PyObject *__pyx_n_split;

static PyObject *__pyx_k204p;

static char (__pyx_k204[]) = ".";

static PyObject *__pyx_f_5_soya_6_World_subitem(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_subitem[] = "World.subitem(namepath) -> 3D element\n\nReturns the 3D element denoted by NAMEPATH.\nNAMEPATH is a string that contains elements\' names, separated by \".\", such as\n\"character.head.mouth\".";
static PyObject *__pyx_f_5_soya_6_World_subitem(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_namepath = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_item;
  PyObject *__pyx_v_name;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"namepath",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_namepath)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_namepath);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);
  __pyx_v_name = Py_None; Py_INCREF(__pyx_v_name);

  /* "/home/jiba/src/soya/soya3d/world.pyx":324 */
  Py_INCREF(__pyx_v_self);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
  __pyx_v_item = __pyx_v_self;

  /* "/home/jiba/src/soya/soya3d/world.pyx":325 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_namepath, __pyx_n_split); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
  Py_INCREF(__pyx_k204p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k204p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_name);
    __pyx_v_name = __pyx_2;
    __pyx_2 = 0;
    __pyx_3 = PyObject_GetItem(((PyObject *)__pyx_v_item), __pyx_v_name); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 325; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_3;
    __pyx_3 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":326 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
  __pyx_r = ((PyObject *)__pyx_v_item);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.subitem");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_item);
  Py_DECREF(__pyx_v_name);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_namepath);
  return __pyx_r;
}

static PyObject *__pyx_n_search;

static PyObject *__pyx_f_5_soya_6_World_search(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_search[] = "World.search(predicate) -> CoordSyst\n\nSearches (recursively) in a World for the first element that satisfies PREDICATE.\nPREDICATE must be a callable of the form PREDICATE(CoordSyst) -> bool.";
static PyObject *__pyx_f_5_soya_6_World_search(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_predicat = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_item;
  PyObject *__pyx_v_subresult;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"predicat",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_predicat)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_predicat);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);
  __pyx_v_subresult = Py_None; Py_INCREF(__pyx_v_subresult);

  /* "/home/jiba/src/soya/soya3d/world.pyx":334 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 334; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 334; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 334; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":335 */
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 335; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_item));
    __pyx_3 = PyObject_CallObject(__pyx_v_predicat, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 335; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 335; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
      __pyx_r = ((PyObject *)__pyx_v_item);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/world.pyx":336 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 336; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 336; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__World));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__World));
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 336; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyObject_IsTrue(__pyx_5); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 336; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":337 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_item), __pyx_n_search); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 337; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 337; goto __pyx_L1;}
      Py_INCREF(__pyx_v_predicat);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_predicat);
      __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 337; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_v_subresult);
      __pyx_v_subresult = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/soya3d/world.pyx":338 */
      __pyx_4 = PyObject_IsTrue(__pyx_v_subresult); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 338; goto __pyx_L1;}
      if (__pyx_4) {
        Py_INCREF(__pyx_v_subresult);
        __pyx_r = __pyx_v_subresult;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":339 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._World.search");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_item);
  Py_DECREF(__pyx_v_subresult);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_predicat);
  return __pyx_r;
}

static PyObject *__pyx_n_predicat;

static PyObject *__pyx_k206p;

static char (__pyx_k206[]) = "";

static PyObject *__pyx_f_5_soya_6_World_search_name(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_search_name[] = "World.search_name(name) -> CoordSyst\n\nSearches (recursively) in a World for the first element named NAME.";
static PyObject *__pyx_f_5_soya_6_World_search_name(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_name = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_item;
  PyObject *__pyx_v_subresult;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {"name",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_name)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_name);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);
  __pyx_v_subresult = Py_None; Py_INCREF(__pyx_v_subresult);

  /* "/home/jiba/src/soya/soya3d/world.pyx":346 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 346; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 346; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 346; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":347 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_getattr); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 347; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 347; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(__pyx_n_name);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n_name);
    Py_INCREF(__pyx_k206p);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_k206p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 347; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (PyObject_Cmp(__pyx_4, __pyx_v_name, &__pyx_5) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 347; goto __pyx_L1;}
    __pyx_5 = __pyx_5 == 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_5) {
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
      __pyx_r = ((PyObject *)__pyx_v_item);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/world.pyx":348 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 348; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 348; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__World));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__World));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 348; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 348; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_5) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":349 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_item), __pyx_n_search); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 349; goto __pyx_L1;}
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_predicat); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 349; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 349; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
      __pyx_3 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 349; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_v_subresult);
      __pyx_v_subresult = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/soya3d/world.pyx":350 */
      __pyx_5 = PyObject_IsTrue(__pyx_v_subresult); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 350; goto __pyx_L1;}
      if (__pyx_5) {
        Py_INCREF(__pyx_v_subresult);
        __pyx_r = __pyx_v_subresult;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":351 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._World.search_name");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_item);
  Py_DECREF(__pyx_v_subresult);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_search_all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_search_all[] = "World.search_all(predicate) -> [CoordSyst, CoordSyst, ...]\n\nSearches (recursively) in a World all elements that satisfy PREDICATE.\nPREDICATE must be a callable of the form PREDICATE(CoordSyst) -> bool.";
static PyObject *__pyx_f_5_soya_6_World_search_all(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_predicat = 0;
  PyObject *__pyx_v_result;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"predicat",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_predicat)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_predicat);
  __pyx_v_result = Py_None; Py_INCREF(__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/world.pyx":358 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":359 */
  ((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_search_all(((struct __pyx_obj_5_soya__World *)__pyx_v_self),__pyx_v_predicat,__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/world.pyx":360 */
  Py_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._World.search_all");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_result);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_predicat);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_World__search_all(struct __pyx_obj_5_soya__World *__pyx_v_self,PyObject *__pyx_v_predicat,PyObject *__pyx_v_result) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_item;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_predicat);
  Py_INCREF(__pyx_v_result);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);

  /* "/home/jiba/src/soya/soya3d/world.pyx":364 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 364; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 364; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 364; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_item));
    __pyx_v_item = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":365 */
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_item));
    __pyx_3 = PyObject_CallObject(__pyx_v_predicat, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {
      __pyx_2 = PyObject_GetAttr(__pyx_v_result, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 365; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 365; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
      __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 365; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/world.pyx":366 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_item));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_item));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__World));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__World));
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyObject_IsTrue(__pyx_5); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_4) {
      ((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)((PyObject *)__pyx_v_item))->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_search_all(((struct __pyx_obj_5_soya__World *)((PyObject *)__pyx_v_item)),__pyx_v_predicat,__pyx_v_result);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._World._search_all");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_item);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_predicat);
  Py_DECREF(__pyx_v_result);
}

static PyObject *__pyx_f_5_soya_6_World_RaypickContext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_RaypickContext[] = "RaypickContext(center, radius, rc = None, items = None) -> RaypickContext\n\nCreates a RaypickContext. RaypickContext allows to raypick only on a subset of the items\nthat are inside the World.\n\nThe subset of items can be either directly given, using the ITEMS argument (a list of\nCoordSyst), or computed as being the list of all items in a sphere. The sphere is defined\nby the CENTER and RADIUS arguments.\n\nRC is an optional RaypickContext that will be re-used if given (for speed up purpose).\n\nThe returned RaypickContext has raypick and raypick_b method similar to the World\'s one.\n";
static PyObject *__pyx_f_5_soya_6_World_RaypickContext(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_center = 0;
  float __pyx_v_radius;
  struct __pyx_obj_5_soya_RaypickContext *__pyx_v_rc = 0;
  PyObject *__pyx_v_items = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsys;
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  float (*__pyx_v_coord);
  float (__pyx_v_sphere[4]);
  struct __pyx_obj_5_soya__CObj *__pyx_v_item;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"center","radius","rc","items",0};
  __pyx_v_rc = __pyx_k43;
  __pyx_v_items = __pyx_k44;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Of|OO", __pyx_argnames, &__pyx_v_center, &__pyx_v_radius, &__pyx_v_rc, &__pyx_v_items)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_center);
  Py_INCREF(__pyx_v_rc);
  Py_INCREF(__pyx_v_items);
  __pyx_v_coordsys = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsys);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);
  __pyx_v_item = Py_None; Py_INCREF((PyObject *) __pyx_v_item);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_center), __pyx_ptype_5_soya_Position, 0, "center")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 368; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rc), __pyx_ptype_5_soya_RaypickContext, 1, "rc")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 368; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":388 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)))); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 388; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":389 */
  __pyx_2 = ((PyObject *)__pyx_v_rc) == Py_None;
  if (__pyx_2) {
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 389; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_root));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_root));
    __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_RaypickContext), __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 389; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_RaypickContext)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 389; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_rc));
    __pyx_v_rc = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/world.pyx":391 */
    __pyx_v_rc->_items->nb = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":392 */
    Py_INCREF(((PyObject *)__pyx_v_root));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_rc->_root));
    __pyx_v_rc->_root = ((PyObject *)__pyx_v_root);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":393 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_center->__pyx_base.__pyx_vtab)->_into(__pyx_v_center,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_root),__pyx_v_sphere);

  /* "/home/jiba/src/soya/soya3d/world.pyx":394 */
  (__pyx_v_sphere[3]) = __pyx_v_radius;

  /* "/home/jiba/src/soya/soya3d/world.pyx":396 */
  __pyx_2 = __pyx_v_items == Py_None;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":397 */
    ((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._collect_raypickables(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)),__pyx_v_rc->_items,__pyx_v_sphere,__pyx_v_sphere);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/world.pyx":399 */
    __pyx_1 = PyObject_GetIter(__pyx_v_items); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 399; goto __pyx_L1;}
    for (;;) {
      __pyx_L4:;
      __pyx_3 = PyIter_Next(__pyx_1);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 399; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__CObj)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 399; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_item));
      __pyx_v_item = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/soya3d/world.pyx":400 */
      chunk_add_ptr(__pyx_v_rc->_items,((void (*))((PyObject *)__pyx_v_item)));
    }
    __pyx_L5:;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":402 */
  Py_INCREF(((PyObject *)__pyx_v_rc));
  __pyx_r = ((PyObject *)__pyx_v_rc);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._World.RaypickContext");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_coordsys);
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF(__pyx_v_item);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_center);
  Py_DECREF(__pyx_v_rc);
  Py_DECREF(__pyx_v_items);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_World__collect_raypickables(struct __pyx_obj_5_soya__World *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  float (*__pyx_v_matrix);
  float (__pyx_v_s[4]);
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":405 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":412 */
  __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/world.pyx":413 */
  point_by_matrix_copy(__pyx_v_s,__pyx_v_rsphere,__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/world.pyx":414 */
  (__pyx_v_s[3]) = length_by_matrix((__pyx_v_rsphere[3]),__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/world.pyx":415 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Shape *)__pyx_v_self->__pyx_base._shape->__pyx_base.__pyx_vtab)->_collect_raypickables(__pyx_v_self->__pyx_base._shape,__pyx_v_items,__pyx_v_rsphere,__pyx_v_s,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":416 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 416; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_4 = PyIter_Next(__pyx_3);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 416; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 416; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":417 */
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_child->__pyx_base.__pyx_base.__pyx_vtab)->_collect_raypickables(__pyx_v_child,__pyx_v_items,__pyx_v_rsphere,__pyx_v_s);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._World._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_6_World_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_begin_round[] = "World.begin_round()\n\nCalled (by the idler) when a new round begins; default implementation calls all children\'s begin_round.";
static PyObject *__pyx_f_5_soya_6_World_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":425 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 425; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 425; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 425; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_begin_round); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 425; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 425; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 425; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._World.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_end_round[] = "World.end_round()\n\nCalled (by the idler) when a round is finished; default implementation calls all children\'s end_round.";
static PyObject *__pyx_f_5_soya_6_World_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":432 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 432; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 432; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 432; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_end_round); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 432; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 432; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 432; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._World.end_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_World_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_advance_time[] = "World.advance_time(proportion)\n\nCalled (by the idler) when a piece of a round is achieved; default implementation calls all children\'s advance_time.\nPROPORTION is the proportion of the current round\'s time that has passed (1.0 for an entire round).";
static PyObject *__pyx_f_5_soya_6_World_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":440 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_advance_time); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 440; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._World.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_shapifier;

static PyObject *__pyx_f_5_soya_6_World_shapify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_shapify[] = "World.shapify() -> Shape\n\nTurns the world into a Shape (a solid optimized / compiled model).\nSee World.shapifier and Shapifier if you want to customize this process (e.g. for using\ntrees, cell-shading or shadow).";
static PyObject *__pyx_f_5_soya_6_World_shapify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/world.pyx":448 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shapifier); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 448; goto __pyx_L1;}
  __pyx_2 = __pyx_1 == Py_None;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {
    __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Shapifier *)__pyx_v_5_soya__DEFAULT_SHAPIFIER->__pyx_base.__pyx_vtab)->_shapify(__pyx_v_5_soya__DEFAULT_SHAPIFIER,((struct __pyx_obj_5_soya__World *)__pyx_v_self))); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 448; goto __pyx_L1;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Shapifier *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_shapifier->__pyx_base.__pyx_vtab)->_shapify(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_shapifier,((struct __pyx_obj_5_soya__World *)__pyx_v_self))); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; goto __pyx_L1;}
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._World.shapify");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_6_Light___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kargs = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, &__pyx_v_kargs) < 0) return -1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_args);
    Py_XDECREF(__pyx_v_kargs);
    return -1;
  }
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":32 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base.__raypick_data = (-1);

  /* "/home/jiba/src/soya/soya3d/light.pyx":33 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_id = (-1);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.__new__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_args);
  Py_XDECREF(__pyx_v_kargs);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_6_Light___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent",0};
  __pyx_v_parent = __pyx_k45;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_parent)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 35; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":36 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":37 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_w = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":38 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_constant = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":39 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->angle = 180.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":40 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":41 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[1]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":42 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":43 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[3]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":44 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[4]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":45 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[5]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":46 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[6]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":47 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[7]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":48 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[8]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":49 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[9]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":50 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[10]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":51 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[11]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":52 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[12]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":53 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[13]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":54 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[14]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":55 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[15]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/light.pyx":56 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_LIGHT_STATIC);

  /* "/home/jiba/src/soya/soya3d/light.pyx":57 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->radius = (-1.0);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Light.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light___getcstate__(struct __pyx_obj_5_soya__Light *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":63 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/light.pyx":64 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/soya3d/light.pyx":65 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/light.pyx":66 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->radius);

  /* "/home/jiba/src/soya/soya3d/light.pyx":67 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->angle);

  /* "/home/jiba/src/soya/soya3d/light.pyx":68 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->exponent);

  /* "/home/jiba/src/soya/soya3d/light.pyx":69 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_linear);

  /* "/home/jiba/src/soya/soya3d/light.pyx":70 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_constant);

  /* "/home/jiba/src/soya/soya3d/light.pyx":71 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_quadratic);

  /* "/home/jiba/src/soya/soya3d/light.pyx":72 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_w);

  /* "/home/jiba/src/soya/soya3d/light.pyx":73 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,16);

  /* "/home/jiba/src/soya/soya3d/light.pyx":74 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Light___setcstate__(struct __pyx_obj_5_soya__Light *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/light.pyx":77 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/light.pyx":81 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/light.pyx":82 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/soya3d/light.pyx":83 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/light.pyx":84 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->radius));

  /* "/home/jiba/src/soya/soya3d/light.pyx":85 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->angle));

  /* "/home/jiba/src/soya/soya3d/light.pyx":86 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->exponent));

  /* "/home/jiba/src/soya/soya3d/light.pyx":87 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_linear));

  /* "/home/jiba/src/soya/soya3d/light.pyx":88 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_constant));

  /* "/home/jiba/src/soya/soya3d/light.pyx":89 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_quadratic));

  /* "/home/jiba/src/soya/soya3d/light.pyx":90 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_w));

  /* "/home/jiba/src/soya/soya3d/light.pyx":91 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,16);

  /* "/home/jiba/src/soya/soya3d/light.pyx":92 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Light.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_6_Light_11directional___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_11directional___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":96 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_w == 0.0)); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.directional.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_11directional___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_11directional___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 97; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":98 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_w = 0.0;
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_w = 1.0;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.directional.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_8constant___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_8constant___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":103 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_constant); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 103; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.constant.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_8constant___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_8constant___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":105 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_constant = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":106 */
  ((struct __pyx_vtabstruct_5_soya__Light *)((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_radius(((struct __pyx_obj_5_soya__Light *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.constant.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_6linear___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_6linear___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":110 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_linear); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 110; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.linear.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_6linear___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_6linear___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 111; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":112 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_linear = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":113 */
  ((struct __pyx_vtabstruct_5_soya__Light *)((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_radius(((struct __pyx_obj_5_soya__Light *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.linear.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_9quadratic___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_9quadratic___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":117 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_quadratic); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 117; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.quadratic.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_9quadratic___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_9quadratic___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 118; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":119 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_quadratic = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":120 */
  ((struct __pyx_vtabstruct_5_soya__Light *)((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_radius(((struct __pyx_obj_5_soya__Light *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.quadratic.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_11cast_shadow___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_11cast_shadow___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":124 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LIGHT_NO_SHADOW) == 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.cast_shadow.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_11cast_shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_11cast_shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 125; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":126 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LIGHT_NO_SHADOW));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_LIGHT_NO_SHADOW);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.cast_shadow.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_9top_level___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_9top_level___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":131 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LIGHT_TOP_LEVEL) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 131; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.top_level.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_9top_level___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_9top_level___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 132; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":133 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_LIGHT_TOP_LEVEL);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LIGHT_TOP_LEVEL));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.top_level.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_6static___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_6static___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":138 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LIGHT_STATIC) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.static.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_6static___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_6static___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 139; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":140 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_LIGHT_STATIC);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LIGHT_STATIC));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Light.static.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_7ambient___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_7ambient___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":145 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 145; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Light.ambient.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_7ambient___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color); /*proto*/
static int __pyx_f_5_soya_6_Light_7ambient___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_color);

  /* "/home/jiba/src/soya/soya3d/light.pyx":147 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_color, 4) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.ambient.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_color);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_7diffuse___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_7diffuse___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":151 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[4])); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[5])); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[6])); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[7])); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 151; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Light.diffuse.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_7diffuse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color); /*proto*/
static int __pyx_f_5_soya_6_Light_7diffuse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_color);

  /* "/home/jiba/src/soya/soya3d/light.pyx":153 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[4]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[5]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[6]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[7]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_color, 4) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 153; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.diffuse.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_color);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_8specular___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_8specular___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":157 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[8])); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[9])); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[10])); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[11])); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 157; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Light.specular.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_8specular___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color); /*proto*/
static int __pyx_f_5_soya_6_Light_8specular___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_color);

  /* "/home/jiba/src/soya/soya3d/light.pyx":159 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[8]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[9]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[10]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[11]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_color, 4) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 159; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.specular.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_color);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Light_12shadow_color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_12shadow_color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":163 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[12])); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 163; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[13])); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 163; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[14])); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 163; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[15])); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 163; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 163; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Light.shadow_color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_12shadow_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color); /*proto*/
static int __pyx_f_5_soya_6_Light_12shadow_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_color) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_color);

  /* "/home/jiba/src/soya/soya3d/light.pyx":165 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[12]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[13]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[14]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[15]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_color, 4) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Light.shadow_color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_color);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light__shadow_at(struct __pyx_obj_5_soya__Light *__pyx_v_self,float (*__pyx_v_position)) {
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  struct __pyx_obj_5_soya_RaypickData *__pyx_v_data;
  float (*__pyx_v_rdata);
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);

  /* "/home/jiba/src/soya/soya3d/light.pyx":171 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self))); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 171; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":172 */
  __pyx_2 = ((PyObject *)__pyx_v_root) == Py_None;
  if (__pyx_2) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":173 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_RaypickData), __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_RaypickData)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":174 */
  __pyx_v_rdata = __pyx_v_data->root_data;

  /* "/home/jiba/src/soya/soya3d/light.pyx":175 */
  __pyx_2 = (__pyx_v_self->_w == 0.0);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":176 */
    (__pyx_v_rdata[3]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":177 */
    (__pyx_v_rdata[4]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":178 */
    (__pyx_v_rdata[5]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/light.pyx":179 */
    vector_by_matrix((__pyx_v_rdata + 3),((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)));

    /* "/home/jiba/src/soya/soya3d/light.pyx":180 */
    vector_normalize((__pyx_v_rdata + 3));

    /* "/home/jiba/src/soya/soya3d/light.pyx":181 */
    (__pyx_v_rdata[6]) = 100.0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":182 */
    point_by_matrix_copy(__pyx_v_rdata,__pyx_v_position,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));

    /* "/home/jiba/src/soya/soya3d/light.pyx":183 */
    (__pyx_v_rdata[0]) = ((__pyx_v_rdata[0]) - ((__pyx_v_rdata[3]) * (__pyx_v_rdata[6])));

    /* "/home/jiba/src/soya/soya3d/light.pyx":184 */
    (__pyx_v_rdata[1]) = ((__pyx_v_rdata[1]) - ((__pyx_v_rdata[4]) * (__pyx_v_rdata[6])));

    /* "/home/jiba/src/soya/soya3d/light.pyx":185 */
    (__pyx_v_rdata[2]) = ((__pyx_v_rdata[2]) - ((__pyx_v_rdata[5]) * (__pyx_v_rdata[6])));

    /* "/home/jiba/src/soya/soya3d/light.pyx":186 */
    (__pyx_v_rdata[6]) = ((__pyx_v_rdata[6]) - 1.0);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/light.pyx":188 */
    vector_from_points((__pyx_v_rdata + 3),(__pyx_v_self->__pyx_base._matrix + 12),__pyx_v_position);

    /* "/home/jiba/src/soya/soya3d/light.pyx":189 */
    __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == Py_None;
    if (__pyx_2) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":190 */
      memcpy(__pyx_v_rdata,(__pyx_v_self->__pyx_base._matrix + 12),(3 * (sizeof(GLfloat ))));
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/light.pyx":192 */
      point_by_matrix_copy(__pyx_v_rdata,(__pyx_v_self->__pyx_base._matrix + 12),((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));

      /* "/home/jiba/src/soya/soya3d/light.pyx":193 */
      vector_by_matrix((__pyx_v_rdata + 2),((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":194 */
    (__pyx_v_rdata[6]) = (vector_length((__pyx_v_rdata + 3)) - 1.0);

    /* "/home/jiba/src/soya/soya3d/light.pyx":195 */
    vector_normalize((__pyx_v_rdata + 3));
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":196 */
  __pyx_v_data->option = __pyx_e_5_soya_RAYPICK_HALF_LINE;

  /* "/home/jiba/src/soya/soya3d/light.pyx":197 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 197; goto __pyx_L1;}
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_root->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raypick_b(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_root),__pyx_v_data,((struct __pyx_obj_5_soya_CoordSyst *)Py_None));
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Light._shadow_at");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static float __pyx_f_5_soya_6_Light__spotlight_at(struct __pyx_obj_5_soya__Light *__pyx_v_self,float (*__pyx_v_position)) {
  float (__pyx_v_v[3]);
  float (__pyx_v_w[3]);
  float __pyx_v_m;
  float __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":202 */
  __pyx_1 = (fabs((__pyx_v_self->angle - 180.0)) < EPSILON);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->_w == 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":203 */
    __pyx_r = 1.0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":204 */
  (__pyx_v_v[0]) = ((__pyx_v_position[0]) - (__pyx_v_self->__pyx_base._matrix[12]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":205 */
  (__pyx_v_v[1]) = ((__pyx_v_position[1]) - (__pyx_v_self->__pyx_base._matrix[13]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":206 */
  (__pyx_v_v[2]) = ((__pyx_v_position[2]) - (__pyx_v_self->__pyx_base._matrix[14]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":207 */
  (__pyx_v_w[0]) = (-(__pyx_v_self->__pyx_base._matrix[8]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":208 */
  (__pyx_v_w[1]) = (-(__pyx_v_self->__pyx_base._matrix[9]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":209 */
  (__pyx_v_w[2]) = (-(__pyx_v_self->__pyx_base._matrix[10]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":210 */
  __pyx_v_m = vector_dot_product(__pyx_v_v,__pyx_v_w);

  /* "/home/jiba/src/soya/soya3d/light.pyx":211 */
  __pyx_1 = (__pyx_v_m < 0.0);
  if (__pyx_1) {
    __pyx_v_m = 0.0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":212 */
  __pyx_1 = (__pyx_v_m <= cos(__pyx_v_self->angle));
  if (__pyx_1) {
    __pyx_r = 0.0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_r = pow(__pyx_v_m,__pyx_v_self->exponent);
    goto __pyx_L0;
  }
  __pyx_L4:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Light._spotlight_at");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static float __pyx_f_5_soya_6_Light__attenuation_at(struct __pyx_obj_5_soya__Light *__pyx_v_self,float (*__pyx_v_position)) {
  float __pyx_v_d;
  float __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":217 */
  __pyx_1 = (__pyx_v_self->_w == 0.0);
  if (__pyx_1) {
    __pyx_r = 1.0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":218 */
  __pyx_v_d = point_distance_to((__pyx_v_self->__pyx_base._matrix + 12),__pyx_v_position);

  /* "/home/jiba/src/soya/soya3d/light.pyx":219 */
  __pyx_r = (1.0 / ((__pyx_v_self->_constant + (__pyx_v_self->_linear * __pyx_v_d)) + ((__pyx_v_self->_quadratic * __pyx_v_d) * __pyx_v_d)));
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Light._attenuation_at");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Light__static_light_at(struct __pyx_obj_5_soya__Light *__pyx_v_self,float (*__pyx_v_position),float (*__pyx_v_normal),int __pyx_v_shadow,float (*__pyx_v_result)) {
  float __pyx_v_f;
  float __pyx_v_g;
  float __pyx_v_angle;
  float __pyx_v_attenuation;
  float __pyx_v_spotlight;
  float (__pyx_v_v[3]);
  float (__pyx_v_n[3]);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":224 */
  __pyx_v_attenuation = ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_attenuation_at(__pyx_v_self,__pyx_v_position);

  /* "/home/jiba/src/soya/soya3d/light.pyx":225 */
  __pyx_v_spotlight = ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_spotlight_at(__pyx_v_self,__pyx_v_position);

  /* "/home/jiba/src/soya/soya3d/light.pyx":226 */
  __pyx_v_f = (__pyx_v_attenuation * __pyx_v_spotlight);

  /* "/home/jiba/src/soya/soya3d/light.pyx":228 */
  __pyx_1 = (__pyx_v_f == 0.0);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":229 */
  __pyx_1 = __pyx_v_shadow;
  if (__pyx_1) {
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_shadow_at(__pyx_v_self,__pyx_v_position);
  }
  if (__pyx_1) {
    __pyx_v_g = 0.0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/light.pyx":231 */
    __pyx_1 = (__pyx_v_normal == 0);
    if (__pyx_1) {
      __pyx_v_angle = 1.0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/light.pyx":233 */
      memcpy(__pyx_v_n,__pyx_v_normal,(sizeof(__pyx_v_n)));

      /* "/home/jiba/src/soya/soya3d/light.pyx":234 */
      vector_normalize(__pyx_v_n);

      /* "/home/jiba/src/soya/soya3d/light.pyx":235 */
      __pyx_1 = (__pyx_v_self->_w == 0.0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/light.pyx":236 */
        (__pyx_v_v[0]) = 0.0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":237 */
        (__pyx_v_v[1]) = 0.0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":238 */
        (__pyx_v_v[2]) = 1.0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":239 */
        vector_by_matrix(__pyx_v_v,__pyx_v_self->__pyx_base._matrix);
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/soya3d/light.pyx":241 */
        vector_from_points(__pyx_v_v,(__pyx_v_self->__pyx_base._matrix + 12),__pyx_v_position);

        /* "/home/jiba/src/soya/soya3d/light.pyx":242 */
        vector_normalize(__pyx_v_v);
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/light.pyx":243 */
      __pyx_v_angle = vector_dot_product(__pyx_v_n,__pyx_v_v);

      /* "/home/jiba/src/soya/soya3d/light.pyx":245 */
      __pyx_1 = (__pyx_v_angle > 0.0);
      if (__pyx_1) {
        __pyx_v_angle = 0.0;
        goto __pyx_L6;
      }
      /*else*/ {
        __pyx_v_angle = (-__pyx_v_angle);
      }
      __pyx_L6:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":247 */
    __pyx_v_g = __pyx_v_angle;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":249 */
  (__pyx_v_result[0]) = ((__pyx_v_result[0]) + (__pyx_v_f * ((__pyx_v_self->_colors[0]) + (__pyx_v_g * (__pyx_v_self->_colors[4])))));

  /* "/home/jiba/src/soya/soya3d/light.pyx":250 */
  (__pyx_v_result[1]) = ((__pyx_v_result[1]) + (__pyx_v_f * ((__pyx_v_self->_colors[1]) + (__pyx_v_g * (__pyx_v_self->_colors[5])))));

  /* "/home/jiba/src/soya/soya3d/light.pyx":251 */
  (__pyx_v_result[2]) = ((__pyx_v_result[2]) + (__pyx_v_f * ((__pyx_v_self->_colors[2]) + (__pyx_v_g * (__pyx_v_self->_colors[6])))));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Light._static_light_at");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_6_Light__cast_into(struct __pyx_obj_5_soya__Light *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/soya3d/light.pyx":255 */
  __pyx_1 = (__pyx_v_self->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":256 */
    (__pyx_v_self->_data[0]) = (-(__pyx_v_self->__pyx_base._matrix[8]));

    /* "/home/jiba/src/soya/soya3d/light.pyx":257 */
    (__pyx_v_self->_data[1]) = (-(__pyx_v_self->__pyx_base._matrix[9]));

    /* "/home/jiba/src/soya/soya3d/light.pyx":258 */
    (__pyx_v_self->_data[2]) = (-(__pyx_v_self->__pyx_base._matrix[10]));

    /* "/home/jiba/src/soya/soya3d/light.pyx":259 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 259; goto __pyx_L1;}
    __pyx_3 = __pyx_2 == Py_None;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_1 = (!__pyx_3);
    if (__pyx_1) {
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 259; goto __pyx_L1;}
      __pyx_3 = __pyx_2 == ((PyObject *)__pyx_v_coordsyst);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_1 = (!__pyx_3);
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":260 */
      vector_by_matrix(__pyx_v_self->_data,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));

      /* "/home/jiba/src/soya/soya3d/light.pyx":261 */
      vector_by_matrix(__pyx_v_self->_data,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_coordsyst));

      /* "/home/jiba/src/soya/soya3d/light.pyx":262 */
      vector_normalize(__pyx_v_self->_data);
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/light.pyx":264 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_3 = __pyx_2 == Py_None;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (!__pyx_3) {
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 264; goto __pyx_L1;}
      __pyx_3 = __pyx_2 == ((PyObject *)__pyx_v_coordsyst);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":265 */
      memcpy(__pyx_v_self->_data,(__pyx_v_self->__pyx_base._matrix + 12),(sizeof(__pyx_v_self->_data)));
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/light.pyx":267 */
      point_by_matrix_copy(__pyx_v_self->_data,(__pyx_v_self->__pyx_base._matrix + 12),((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));

      /* "/home/jiba/src/soya/soya3d/light.pyx":268 */
      point_by_matrix(__pyx_v_self->_data,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_coordsyst));
    }
    __pyx_L4:;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Light._cast_into");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_6_Light__batch(struct __pyx_obj_5_soya__Light *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/soya3d/light.pyx":272 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":274 */
  multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base._matrix);

  /* "/home/jiba/src/soya/soya3d/light.pyx":282 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LIGHT_TOP_LEVEL);
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_5_soya_renderer->top_lights, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 282; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 282; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_self));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 282; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_2 = PyObject_GetAttr(__pyx_v_5_soya_renderer->current_context->lights, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 283; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 283; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_self));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 283; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Light._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_k207p;

static char (__pyx_k207[]) = "Too many lights!";

static void __pyx_f_5_soya_6_Light__activate(struct __pyx_obj_5_soya__Light *__pyx_v_self) {
  int __pyx_v_id;
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  GLfloat (__pyx_v_p[4]);
  GLfloat (__pyx_v_q[3]);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/light.pyx":291 */
  (__pyx_v_p[3]) = __pyx_v_self->_w;

  /* "/home/jiba/src/soya/soya3d/light.pyx":292 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":293 */
    glLoadMatrixf(__pyx_v_self->__pyx_base._render_matrix);

    /* "/home/jiba/src/soya/soya3d/light.pyx":294 */
    __pyx_1 = (__pyx_v_self->_id == (-1));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":295 */
      __pyx_v_id = 0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":296 */
      __pyx_2 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 296; goto __pyx_L1;}
      for (;;) {
        __pyx_L4:;
        __pyx_3 = PyIter_Next(__pyx_2);
        if (!__pyx_3) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 296; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 296; goto __pyx_L1;}
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
        __pyx_v_light = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":297 */
        __pyx_1 = ((PyObject *)__pyx_v_light) == Py_None;
        if (__pyx_1) {

          /* "/home/jiba/src/soya/soya3d/light.pyx":298 */
          __pyx_v_self->_id = __pyx_v_id;

          /* "/home/jiba/src/soya/soya3d/light.pyx":299 */
          __pyx_3 = PyInt_FromLong(__pyx_v_id); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 299; goto __pyx_L1;}
          if (PyObject_SetItem(__pyx_v_5_soya_LIGHTS, __pyx_3, ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 299; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;

          /* "/home/jiba/src/soya/soya3d/light.pyx":300 */
          goto __pyx_L5;
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "/home/jiba/src/soya/soya3d/light.pyx":301 */
        __pyx_v_id = (__pyx_v_id + 1);
      }
      /*else*/ {

        /* "/home/jiba/src/soya/soya3d/light.pyx":303 */
        if (__Pyx_PrintItem(__pyx_k207p) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 303; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 303; goto __pyx_L1;}

        /* "/home/jiba/src/soya/soya3d/light.pyx":305 */
        goto __pyx_L0;
      }
      __pyx_L5:;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":307 */
    __pyx_v_id = (GL_LIGHT0 + __pyx_v_self->_id);

    /* "/home/jiba/src/soya/soya3d/light.pyx":309 */
    __pyx_3 = PyInt_FromLong(__pyx_v_self->_id); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 309; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_5_soya_LAST_LIGHTS, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 309; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = ((PyObject *)__pyx_v_self) == __pyx_2;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = (!__pyx_1);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":310 */
      __pyx_3 = PyInt_FromLong(__pyx_v_self->_id); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 310; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_5_soya_LAST_LIGHTS, __pyx_3, ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 310; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":311 */
      glLightf(__pyx_v_id,GL_SPOT_EXPONENT,__pyx_v_self->exponent);

      /* "/home/jiba/src/soya/soya3d/light.pyx":312 */
      glLightf(__pyx_v_id,GL_SPOT_CUTOFF,__pyx_v_self->angle);

      /* "/home/jiba/src/soya/soya3d/light.pyx":313 */
      glLightfv(__pyx_v_id,GL_AMBIENT,__pyx_v_self->_colors);

      /* "/home/jiba/src/soya/soya3d/light.pyx":314 */
      glLightfv(__pyx_v_id,GL_DIFFUSE,(__pyx_v_self->_colors + 4));

      /* "/home/jiba/src/soya/soya3d/light.pyx":315 */
      glLightfv(__pyx_v_id,GL_SPECULAR,(__pyx_v_self->_colors + 8));

      /* "/home/jiba/src/soya/soya3d/light.pyx":316 */
      glLightf(__pyx_v_id,GL_CONSTANT_ATTENUATION,__pyx_v_self->_constant);

      /* "/home/jiba/src/soya/soya3d/light.pyx":317 */
      glLightf(__pyx_v_id,GL_LINEAR_ATTENUATION,__pyx_v_self->_linear);

      /* "/home/jiba/src/soya/soya3d/light.pyx":318 */
      glLightf(__pyx_v_id,GL_QUADRATIC_ATTENUATION,__pyx_v_self->_quadratic);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":320 */
    __pyx_1 = (__pyx_v_self->_w == 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":321 */
      (__pyx_v_p[0]) = 0.0;
      (__pyx_v_p[1]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":322 */
      (__pyx_v_p[2]) = 1.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":323 */
      glLightfv(__pyx_v_id,GL_POSITION,__pyx_v_p);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/light.pyx":325 */
      (__pyx_v_p[0]) = 0.0;
      (__pyx_v_p[1]) = 0.0;
      (__pyx_v_p[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":326 */
      (__pyx_v_q[0]) = 0.0;
      (__pyx_v_q[1]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":327 */
      (__pyx_v_q[2]) = (-1.0);

      /* "/home/jiba/src/soya/soya3d/light.pyx":328 */
      glLightfv(__pyx_v_id,GL_POSITION,__pyx_v_p);

      /* "/home/jiba/src/soya/soya3d/light.pyx":329 */
      glLightfv(__pyx_v_id,GL_SPOT_DIRECTION,__pyx_v_q);
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":330 */
    glEnable(__pyx_v_id);

    /* "/home/jiba/src/soya/soya3d/light.pyx":331 */
    __pyx_v_self->_gl_id_enabled = 1;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Light._activate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_6_Light__compute_radius(struct __pyx_obj_5_soya__Light *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/light.pyx":335 */
  __pyx_1 = (__pyx_v_self->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":336 */
    __pyx_v_self->radius = (-1.0);
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->_linear == 0.0);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_quadratic == 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":338 */
    __pyx_v_self->radius = (-1.0);
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->_linear != 0.0);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_quadratic == 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":340 */
    __pyx_v_self->radius = (((1.0 / __pyx_v_5_soya_LIGHT_NULL_ATTENUATION) - __pyx_v_self->_constant) / __pyx_v_self->_linear);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/light.pyx":343 */
    __pyx_v_self->radius = (((1.0 / __pyx_v_5_soya_LIGHT_NULL_ATTENUATION) - __pyx_v_self->_constant) / (__pyx_v_self->_linear + __pyx_v_self->_quadratic));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Light._compute_radius");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static char (__pyx_k208[]) = "Disable all lights.";

static void __pyx_f_5_soya_disable_all_lights(void) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/light.pyx":347 */
  __pyx_k208;

  /* "/home/jiba/src/soya/soya3d/light.pyx":349 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 349; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 349; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":350 */
    __pyx_3 = ((PyObject *)__pyx_v_light) == Py_None;
    __pyx_4 = (!__pyx_3);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":351 */
      __pyx_3 = __pyx_v_light->_gl_id_enabled;
      if (__pyx_3) {

        /* "/home/jiba/src/soya/soya3d/light.pyx":352 */
        glDisable((GL_LIGHT0 + __pyx_v_light->_id));

        /* "/home/jiba/src/soya/soya3d/light.pyx":353 */
        __pyx_v_light->_gl_id_enabled = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/light.pyx":354 */
      __pyx_2 = PyInt_FromLong(__pyx_v_light->_id); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 354; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_5_soya_LIGHTS, __pyx_2, Py_None) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 354; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":355 */
      __pyx_v_light->_id = (-1);
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya.disable_all_lights");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
}

static char (__pyx_k209[]) = "Disable all static lights. Static lights are disabled when rendering static lit\nshape (Soya assume the effect of static lights was already taken into account at the\nshape computation time).";

static void __pyx_f_5_soya_disable_static_lights(void) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/light.pyx":358 */
  __pyx_k209;

  /* "/home/jiba/src/soya/soya3d/light.pyx":362 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 362; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 362; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":363 */
    __pyx_4 = ((PyObject *)__pyx_v_light) == Py_None;
    __pyx_3 = (!__pyx_4);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_light->_gl_id_enabled == 1);
      if (__pyx_3) {
        __pyx_3 = (__pyx_v_light->__pyx_base._option & __pyx_e_5_soya_LIGHT_STATIC);
      }
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":364 */
      glDisable((GL_LIGHT0 + __pyx_v_light->_id));

      /* "/home/jiba/src/soya/soya3d/light.pyx":365 */
      __pyx_v_light->_gl_id_enabled = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya.disable_static_lights");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
}

static char (__pyx_k210[]) = "Enable all static lights. Static lights are disabled when rendering static lit\nobject (Soya assume the effect of static lights was already taken into account at the\nshape computation time).";

static void __pyx_f_5_soya_enable_static_lights(void) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/light.pyx":368 */
  __pyx_k210;

  /* "/home/jiba/src/soya/soya3d/light.pyx":372 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 372; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 372; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 372; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":373 */
    __pyx_4 = ((PyObject *)__pyx_v_light) == Py_None;
    __pyx_3 = (!__pyx_4);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_light->_gl_id_enabled == 0);
      if (__pyx_3) {
        __pyx_3 = (__pyx_v_light->__pyx_base._option & __pyx_e_5_soya_LIGHT_STATIC);
      }
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":374 */
      glEnable((GL_LIGHT0 + __pyx_v_light->_id));

      /* "/home/jiba/src/soya/soya3d/light.pyx":375 */
      __pyx_v_light->_gl_id_enabled = 1;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya.enable_static_lights");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
}

static PyObject *__pyx_n_i;

static char (__pyx_k211[]) = "Disable all non top level lights.";

static void __pyx_f_5_soya_disable_deep_lights(void) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  GLenum __pyx_7;
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/light.pyx":378 */
  __pyx_k211;

  /* "/home/jiba/src/soya/soya3d/light.pyx":380 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 380; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 380; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":381 */
    __pyx_4 = ((PyObject *)__pyx_v_light) == Py_None;
    __pyx_3 = (!__pyx_4);
    if (__pyx_3) {
      __pyx_3 = (__pyx_v_light->__pyx_base._option & __pyx_e_5_soya_LIGHT_TOP_LEVEL);
      if (__pyx_3) {
        __pyx_3 = (__pyx_v_light->_gl_id_enabled == 1);
      }
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":382 */
      __pyx_2 = PyInt_FromLong(GL_LIGHT0); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_i); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 382; goto __pyx_L1;}
      __pyx_6 = PyNumber_Add(__pyx_2, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 382; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_7 = PyInt_AsLong(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 382; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      glDisable(__pyx_7);

      /* "/home/jiba/src/soya/soya3d/light.pyx":383 */
      __pyx_v_light->_gl_id_enabled = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya.disable_deep_lights");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
}

static int __pyx_f_5_soya_7_Camera___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7_Camera___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kargs = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, &__pyx_v_kargs) < 0) return -1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_args);
    Py_XDECREF(__pyx_v_kargs);
    return -1;
  }
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":26 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__raypick_data = (-1);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":27 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._render_matrix[15]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":28 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_frustum = ((__pyx_t_5_soya_Frustum (*))malloc((sizeof(__pyx_t_5_soya_Frustum ))));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":29 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_5_soya_renderer->screen_width;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":30 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_5_soya_renderer->screen_height;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.__new__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_args);
  Py_XDECREF(__pyx_v_kargs);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Camera___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_7_Camera___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":33 */
  free(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_frustum);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_7_Camera___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7_Camera___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent",0};
  __pyx_v_parent = __pyx_k46;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_parent)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 35; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":36 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":37 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov = 60.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":38 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_front = 0.1;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":39 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_back = 100.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":40 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Camera.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera___getcstate__(struct __pyx_obj_5_soya__Camera *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":45 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":46 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":47 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":48 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_front);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":49 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_back);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":50 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fov);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":51 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 51; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_to_render));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_to_render));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Camera.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Camera___setcstate__(struct __pyx_obj_5_soya__Camera *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_cstate2;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":54 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":56 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 56; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_to_render));
  __pyx_v_self->_to_render = __pyx_2;
  __pyx_2 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 2) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 56; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":59 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":60 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":61 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":62 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_front));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":63 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_back));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":64 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fov));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":65 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Camera.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_7_Camera_6master___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_6master___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":69 */
  Py_INCREF(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_master);
  __pyx_r = ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_master;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.master.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_6master___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_master); /*proto*/
static int __pyx_f_5_soya_7_Camera_6master___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_master) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_master);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":71 */
  Py_INCREF(__pyx_v_master);
  Py_DECREF(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_master);
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_master = __pyx_v_master;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.master.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_master);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_9to_render___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_9to_render___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":75 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_to_render));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_to_render);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.to_render.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_9to_render___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_to_render); /*proto*/
static int __pyx_f_5_soya_7_Camera_9to_render___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_to_render) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_to_render);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_to_render), __pyx_ptype_5_soya__World, 1, "to_render")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 76; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":77 */
  Py_INCREF(__pyx_v_to_render);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_to_render));
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_to_render = __pyx_v_to_render;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.to_render.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_to_render);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_5front___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_5front___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":81 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_front); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 81; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.front.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_5front___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_5front___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 82; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":83 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_front = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":84 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.front.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_4back___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_4back___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":88 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_back); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 88; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.back.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_4back___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_4back___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 89; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":90 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_back = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":91 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.back.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_3fov___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_3fov___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":95 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 95; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.fov.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_3fov___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_3fov___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 96; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":97 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":98 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.fov.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_4left___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_4left___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":102 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 102; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.left.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_4left___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_4left___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 103; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":104 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[0]) = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.left.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_3top___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_3top___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":108 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[1])); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 108; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.top.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_3top___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_3top___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 109; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":110 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[1]) = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.top.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_5width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":114 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_5width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_5width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 115; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":116 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":117 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.width.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_6height___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_6height___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":121 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 121; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.height.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_6height___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_6height___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 122; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":123 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":124 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.height.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_set_viewport(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Camera_set_viewport[] = "Camera.set_viewport(LEFT, TOP, WIDTH, HEIGHT)\n\nSets the Camera\'s viewport, i.e. the part of the screen where it renders.\nLEFT, TOP, WIDTH, HEIGHT are integer pixel values.";
static PyObject *__pyx_f_5_soya_7_Camera_set_viewport(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_left;
  int __pyx_v_top;
  int __pyx_v_width;
  int __pyx_v_height;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"left","top","width","height",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iiii", __pyx_argnames, &__pyx_v_left, &__pyx_v_top, &__pyx_v_width, &__pyx_v_height)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":131 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[0]) = __pyx_v_left;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":132 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[1]) = __pyx_v_top;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":133 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_width;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":134 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_height;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":135 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.set_viewport");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_7partial___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_7partial___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":139 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_CAMERA_PARTIAL) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 139; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.partial.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_7partial___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_7partial___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 140; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":141 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_CAMERA_PARTIAL);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_CAMERA_PARTIAL));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.partial.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_5ortho___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_5ortho___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":146 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 146; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.ortho.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_5ortho___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_5ortho___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 147; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":148 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_CAMERA_ORTHO);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_CAMERA_ORTHO));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":150 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.ortho.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_resize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_resize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_left;
  int __pyx_v_top;
  int __pyx_v_width;
  int __pyx_v_height;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"left","top","width","height",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iiii", __pyx_argnames, &__pyx_v_left, &__pyx_v_top, &__pyx_v_width, &__pyx_v_height)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":153 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[0]) = __pyx_v_left;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":154 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[1]) = __pyx_v_top;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":155 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_width;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":156 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_height;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":157 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init_frustum(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.resize");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_get_screen_width(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Camera_get_screen_width[] = "Camera.get_screen_width() -> int\n\nGets the width of the rendering screen, in pixel.";
static PyObject *__pyx_f_5_soya_7_Camera_get_screen_width(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":163 */
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 163; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.get_screen_width");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_get_screen_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Camera_get_screen_height[] = "Camera.get_screen_height() -> int\n\nGets the height of the rendering screen, in pixel.";
static PyObject *__pyx_f_5_soya_7_Camera_get_screen_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":168 */
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 168; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Camera.get_screen_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Camera__init_frustum(struct __pyx_obj_5_soya__Camera *__pyx_v_self) {
  float __pyx_v_l;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_ff;
  float __pyx_v_ratio;
  __pyx_t_5_soya_Frustum (*__pyx_v_f);
  float __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":173 */
  __pyx_v_f = __pyx_v_self->_frustum;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":174 */
  (__pyx_v_f->position[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":175 */
  (__pyx_v_f->position[1]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":176 */
  (__pyx_v_f->position[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":177 */
  __pyx_v_ratio = (((float )(__pyx_v_self->_viewport[3])) / ((float )(__pyx_v_self->_viewport[2])));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":179 */
  __pyx_1 = (-__pyx_v_self->_front);
  (__pyx_v_f->points[2]) = __pyx_1;
  (__pyx_v_f->points[5]) = __pyx_1;
  (__pyx_v_f->points[8]) = __pyx_1;
  (__pyx_v_f->points[11]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":180 */
  __pyx_1 = (-__pyx_v_self->_back);
  (__pyx_v_f->points[14]) = __pyx_1;
  (__pyx_v_f->points[17]) = __pyx_1;
  (__pyx_v_f->points[20]) = __pyx_1;
  (__pyx_v_f->points[23]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":181 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":182 */
    __pyx_v_l = (__pyx_v_self->_fov / 20.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":183 */
    __pyx_v_ratio = (__pyx_v_l * __pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":184 */
    (__pyx_v_f->points[0]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":184 */
    (__pyx_v_f->points[1]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":185 */
    (__pyx_v_f->points[3]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":185 */
    (__pyx_v_f->points[4]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":186 */
    (__pyx_v_f->points[6]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":186 */
    (__pyx_v_f->points[7]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":187 */
    (__pyx_v_f->points[9]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":187 */
    (__pyx_v_f->points[10]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":188 */
    (__pyx_v_f->points[12]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":188 */
    (__pyx_v_f->points[13]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":189 */
    (__pyx_v_f->points[15]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":189 */
    (__pyx_v_f->points[16]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":190 */
    (__pyx_v_f->points[18]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":190 */
    (__pyx_v_f->points[19]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":191 */
    (__pyx_v_f->points[21]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":191 */
    (__pyx_v_f->points[22]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":192 */
    (__pyx_v_f->planes[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":192 */
    (__pyx_v_f->planes[1]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":192 */
    (__pyx_v_f->planes[2]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":192 */
    (__pyx_v_f->planes[3]) = (-__pyx_v_self->_front);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":193 */
    (__pyx_v_f->planes[4]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":193 */
    (__pyx_v_f->planes[5]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":193 */
    (__pyx_v_f->planes[6]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":193 */
    (__pyx_v_f->planes[7]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":194 */
    (__pyx_v_f->planes[8]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":194 */
    (__pyx_v_f->planes[9]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":194 */
    (__pyx_v_f->planes[10]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":194 */
    (__pyx_v_f->planes[11]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":195 */
    (__pyx_v_f->planes[12]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":195 */
    (__pyx_v_f->planes[13]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":195 */
    (__pyx_v_f->planes[14]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":195 */
    (__pyx_v_f->planes[15]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":196 */
    (__pyx_v_f->planes[16]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":196 */
    (__pyx_v_f->planes[17]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":196 */
    (__pyx_v_f->planes[18]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":196 */
    (__pyx_v_f->planes[19]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":197 */
    (__pyx_v_f->planes[20]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":197 */
    (__pyx_v_f->planes[21]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":197 */
    (__pyx_v_f->planes[22]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":197 */
    (__pyx_v_f->planes[23]) = (-__pyx_v_self->_back);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":199 */
    __pyx_v_l = tan((to_radians(__pyx_v_self->_fov) / 2.0));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":200 */
    __pyx_v_y = (__pyx_v_self->_back * __pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":201 */
    __pyx_v_x = (__pyx_v_y / __pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":202 */
    (__pyx_v_f->points[12]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":202 */
    (__pyx_v_f->points[13]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":203 */
    (__pyx_v_f->points[15]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":203 */
    (__pyx_v_f->points[16]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":204 */
    (__pyx_v_f->points[18]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":204 */
    (__pyx_v_f->points[19]) = (-__pyx_v_y);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":205 */
    (__pyx_v_f->points[21]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":205 */
    (__pyx_v_f->points[22]) = (-__pyx_v_y);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[1]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[2]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[3]) = (-__pyx_v_self->_front);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":207 */
    __pyx_v_ff = sqrt(((__pyx_v_y * __pyx_v_y) + (__pyx_v_self->_back * __pyx_v_self->_back)));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":208 */
    (__pyx_v_f->planes[4]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":208 */
    (__pyx_v_f->planes[5]) = (__pyx_v_self->_back / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":208 */
    (__pyx_v_f->planes[6]) = (__pyx_v_y / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":208 */
    (__pyx_v_f->planes[7]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":209 */
    (__pyx_v_f->planes[8]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":209 */
    (__pyx_v_f->planes[9]) = (-(__pyx_v_f->planes[5]));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":209 */
    (__pyx_v_f->planes[10]) = (__pyx_v_f->planes[6]);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":209 */
    (__pyx_v_f->planes[11]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":210 */
    __pyx_v_ff = sqrt(((__pyx_v_x * __pyx_v_x) + (__pyx_v_self->_back * __pyx_v_self->_back)));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":211 */
    (__pyx_v_f->planes[12]) = (__pyx_v_self->_back / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":211 */
    (__pyx_v_f->planes[13]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":211 */
    (__pyx_v_f->planes[14]) = (__pyx_v_x / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":211 */
    (__pyx_v_f->planes[15]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":212 */
    (__pyx_v_f->planes[16]) = (-(__pyx_v_f->planes[12]));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":212 */
    (__pyx_v_f->planes[17]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":212 */
    (__pyx_v_f->planes[18]) = (__pyx_v_f->planes[14]);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":212 */
    (__pyx_v_f->planes[19]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":213 */
    (__pyx_v_f->planes[20]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":213 */
    (__pyx_v_f->planes[21]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":213 */
    (__pyx_v_f->planes[22]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":213 */
    (__pyx_v_f->planes[23]) = (-__pyx_v_self->_back);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":214 */
    __pyx_v_y = (__pyx_v_self->_front * __pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":215 */
    __pyx_v_x = (__pyx_v_y / __pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":216 */
    (__pyx_v_f->points[0]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":216 */
    (__pyx_v_f->points[1]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":217 */
    (__pyx_v_f->points[3]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":217 */
    (__pyx_v_f->points[4]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":218 */
    (__pyx_v_f->points[6]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":218 */
    (__pyx_v_f->points[7]) = (-__pyx_v_y);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":219 */
    (__pyx_v_f->points[9]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":219 */
    (__pyx_v_f->points[10]) = (-__pyx_v_y);
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Camera._init_frustum");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_to_render;

static void __pyx_f_5_soya_7_Camera__subrender_scene(struct __pyx_obj_5_soya__Camera *__pyx_v_self) {
  float __pyx_v_v1;
  float __pyx_v_v2;
  float (*__pyx_v_m);
  float (*__pyx_v_p);
  float (*__pyx_v_r);
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_root;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":226 */
  __pyx_1 = ((__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_INITED) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":227 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":229 */
  Py_INCREF(((PyObject *)__pyx_v_self));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->current_camera));
  __pyx_v_5_soya_renderer->current_camera = ((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":231 */
  __pyx_v_m = ((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":232 */
  __pyx_v_r = ((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":235 */
  __pyx_v_p = __pyx_v_self->__pyx_base._render_matrix;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":236 */
  (__pyx_v_p[0]) = (__pyx_v_m[0]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":237 */
  (__pyx_v_p[4]) = (__pyx_v_m[4]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":238 */
  (__pyx_v_p[8]) = (__pyx_v_m[8]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":239 */
  (__pyx_v_p[12]) = ((((-(__pyx_v_r[12])) * (__pyx_v_m[0])) - ((__pyx_v_r[13]) * (__pyx_v_m[4]))) - ((__pyx_v_r[14]) * (__pyx_v_m[8])));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":240 */
  (__pyx_v_p[1]) = (__pyx_v_m[1]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":241 */
  (__pyx_v_p[5]) = (__pyx_v_m[5]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":242 */
  (__pyx_v_p[9]) = (__pyx_v_m[9]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":243 */
  (__pyx_v_p[13]) = ((((-(__pyx_v_r[12])) * (__pyx_v_m[1])) - ((__pyx_v_r[13]) * (__pyx_v_m[5]))) - ((__pyx_v_r[14]) * (__pyx_v_m[9])));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":244 */
  (__pyx_v_p[2]) = (__pyx_v_m[2]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":245 */
  (__pyx_v_p[6]) = (__pyx_v_m[6]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":246 */
  (__pyx_v_p[10]) = (__pyx_v_m[10]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":247 */
  (__pyx_v_p[14]) = ((((-(__pyx_v_r[12])) * (__pyx_v_m[2])) - ((__pyx_v_r[13]) * (__pyx_v_m[6]))) - ((__pyx_v_r[14]) * (__pyx_v_m[10])));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":248 */
  (__pyx_v_p[16]) = (__pyx_v_m[16]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":249 */
  (__pyx_v_p[17]) = (__pyx_v_m[17]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":250 */
  (__pyx_v_p[18]) = (__pyx_v_m[18]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":254 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":255 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":256 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":257 */
    __pyx_v_v1 = (__pyx_v_self->_fov / 20.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":258 */
    __pyx_v_v2 = ((__pyx_v_v1 * ((float )(__pyx_v_self->_viewport[3]))) / ((float )(__pyx_v_self->_viewport[2])));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":259 */
    glOrtho((-__pyx_v_v1),__pyx_v_v1,(-__pyx_v_v2),__pyx_v_v2,__pyx_v_self->_front,__pyx_v_self->_back);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":262 */
    gluPerspective(__pyx_v_self->_fov,(((float )(__pyx_v_self->_viewport[2])) / ((float )(__pyx_v_self->_viewport[3]))),__pyx_v_self->_front,__pyx_v_self->_back);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":263 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":266 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_to_render); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 266; goto __pyx_L1;}
  __pyx_1 = __pyx_2 == Py_None;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":267 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self))); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 267; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
    __pyx_v_root = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":268 */
    __pyx_1 = ((PyObject *)__pyx_v_root) == Py_None;
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L5;
    }
    /*else*/ {
      if (!__Pyx_TypeTest(((PyObject *)__pyx_v_root), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 269; goto __pyx_L1;}
      Py_INCREF(((PyObject *)__pyx_v_root));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->root_object));
      __pyx_v_5_soya_renderer->root_object = ((PyObject *)__pyx_v_root);
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_to_render); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 270; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 270; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->root_object));
    __pyx_v_5_soya_renderer->root_object = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":272 */
  __pyx_f_5_soya_frustum_coordsyst_into(__pyx_v_5_soya_renderer->root_frustum,__pyx_v_self->_frustum,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)),0);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":274 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_render(__pyx_v_5_soya_renderer);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Camera._subrender_scene");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_7_Camera__render_scene(struct __pyx_obj_5_soya__Camera *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":277 */
  glPushAttrib(GL_VIEWPORT);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":278 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":279 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":280 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":281 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":282 */
  glViewport((__pyx_v_self->_viewport[0]),((__pyx_v_5_soya_renderer->screen_height - (__pyx_v_self->_viewport[1])) - (__pyx_v_self->_viewport[3])),(__pyx_v_self->_viewport[2]),(__pyx_v_self->_viewport[3]));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":283 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":284 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":285 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":286 */
  glEnable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":288 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_subrender_scene(__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":290 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":291 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":292 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":293 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":294 */
  glPopAttrib();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":295 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":296 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":297 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":298 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":299 */
  glDisable(GL_CULL_FACE);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Camera._render_scene");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_7_Camera_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":302 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_scene(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.render");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_texture;
static PyObject *__pyx_n_width;
static PyObject *__pyx_n_height;

static PyObject *__pyx_f_5_soya_7_Camera_render_to_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Camera_render_to_material[] = " render_to_material(self, material, what)\n    render the camera to a soya.Material\'s texture.\n    \'what\' is one of GL_LUMINANCE, GL_RGBA, GL_ALPHA.. etc. \n    ";
static PyObject *__pyx_f_5_soya_7_Camera_render_to_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_mat = 0;
  int __pyx_v_what;
  int __pyx_v_w;
  int __pyx_v_h;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  static char *__pyx_argnames[] = {"mat","what",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_mat, &__pyx_v_what)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_mat);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mat), __pyx_ptype_5_soya__Material, 1, "mat")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 304; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":312 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_mat), __pyx_n_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_width); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_mat), __pyx_n_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_height); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_w = __pyx_3;
  __pyx_v_h = __pyx_4;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":314 */
  glPushAttrib(GL_VIEWPORT_BIT);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":315 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":316 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":317 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":318 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":319 */
  glViewport(0,0,__pyx_v_w,__pyx_v_h);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":320 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":321 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":322 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":323 */
  glEnable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":325 */
  ((struct __pyx_vtabstruct_5_soya__Camera *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_subrender_scene(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":327 */
  glBindTexture(GL_TEXTURE_2D,__pyx_v_mat->_id);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":329 */
  glCopyTexImage2D(GL_TEXTURE_2D,0,__pyx_v_what,0,0,__pyx_v_w,__pyx_v_h,0);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":331 */
  glBindTexture(GL_TEXTURE_2D,0);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":333 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":334 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":335 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":336 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":337 */
  glPopAttrib();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":338 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":339 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":340 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":341 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":342 */
  glDisable(GL_CULL_FACE);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Camera.render_to_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_mat);
  return __pyx_r;
}

static PyObject *__pyx_n_set_xyz;
static PyObject *__pyx_n_float;

static PyObject *__pyx_f_5_soya_7_Camera_coord2d_to_3d(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Camera_coord2d_to_3d[] = "coord2d_to_3d(x, y, z = -1.0, result) -> Point\n\nConverts 2D coordinates X and Y in pixel (e.g. mouse position) into 3D coordinates.\nZ is the point Z coordinates (in the camera coordinates system) ; it should be negative\nand defaults to -1.0.\nRESULT is an optionnal Point that is used to store the result, if you want to avoid the\ncreation of a new object and prefer reuse an existant one (for speed purpose).";
static PyObject *__pyx_f_5_soya_7_Camera_coord2d_to_3d(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_y;
  float __pyx_v_z;
  struct __pyx_obj_5_soya__Point *__pyx_v_result = 0;
  float __pyx_v_k;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"x","y","z","result",0};
  __pyx_v_z = __pyx_k47;
  __pyx_v_result = __pyx_k48;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii|fO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_result)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_result);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_result), __pyx_ptype_5_soya__Point, 1, "result")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 345; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":354 */
  __pyx_1 = ((PyObject *)__pyx_v_result) == Py_None;
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 354; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 354; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 354; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 354; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_result));
    __pyx_v_result = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":355 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":356 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_set_xyz); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 356; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_x); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyFloat_FromDouble(0.5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_3 = PyNumber_Subtract(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_5 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyFloat_FromDouble(2.0); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_3 = PyNumber_Multiply(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_5 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyFloat_FromDouble(20.0); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyFloat_FromDouble(0.75); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    __pyx_3 = PyNumber_Multiply(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 357; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_y); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_5 = PyNumber_Negative(__pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_6 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_4 = PyNumber_Divide(__pyx_5, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_5 = PyFloat_FromDouble(0.5); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_6 = PyNumber_Add(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_4 = PyFloat_FromDouble(2.0); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_6 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_5, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_5 = PyFloat_FromDouble(20.0); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_6 = PyNumber_Divide(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_4 = PyFloat_FromDouble(0.75); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_6 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 359; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 356; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_5);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_6);
    __pyx_3 = 0;
    __pyx_5 = 0;
    __pyx_6 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 356; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":363 */
    __pyx_v_k = tan((to_radians(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov) / 2.0));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":364 */
    __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_set_xyz); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(__pyx_v_x); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_6, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyNumber_Negative(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_6 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_4 = PyNumber_Divide(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = PyFloat_FromDouble(0.5); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_2 = PyNumber_Add(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_6 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_6 = PyFloat_FromDouble(2.0); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = PyFloat_FromDouble(__pyx_v_k); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_6 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 365; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(__pyx_v_y); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_6 = PyNumber_Divide(__pyx_2, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_3 = PyNumber_Subtract(__pyx_6, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_6 = PyFloat_FromDouble(2.0); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_3, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = PyFloat_FromDouble(__pyx_v_k); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_6 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_3 = PyNumber_Multiply(__pyx_6, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 366; goto __pyx_L1;}
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_6 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 367; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 364; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_2, 2, __pyx_6);
    __pyx_4 = 0;
    __pyx_3 = 0;
    __pyx_6 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 364; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":369 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Camera.coord2d_to_3d");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_result);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_coord3d_to_2d(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Camera_coord3d_to_2d[] = "coord3d_to_2d(position) -> x, y\n\nConverts a 3D Position into 2D screen coordinates X, Y in pixel.";
static PyObject *__pyx_f_5_soya_7_Camera_coord3d_to_2d(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_p = 0;
  float (__pyx_v_f[3]);
  float __pyx_v_k;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"p",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_p)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_p);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya_Position, 1, "p")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":377 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_p->__pyx_base.__pyx_vtab)->_into(__pyx_v_p,((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)),__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":378 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":379 */
    __pyx_2 = PyFloat_FromDouble((-(__pyx_v_f[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyNumber_Divide(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyFloat_FromDouble(20.0); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyFloat_FromDouble(2.0); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyFloat_FromDouble(0.5); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_4 = PyNumber_Add(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyFloat_FromDouble(((((((__pyx_v_f[1]) / ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov) * 20.0) / 2.0) + 0.5) * (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]))); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 381; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 380; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_5);
    __pyx_2 = 0;
    __pyx_5 = 0;
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":384 */
    __pyx_v_k = tan((to_radians(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov) / 2.0));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":385 */
    __pyx_3 = PyFloat_FromDouble((-(__pyx_v_f[0]))); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_5 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3])); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_4 = PyNumber_Divide(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_5 = PyFloat_FromDouble(2.0); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_4 = PyFloat_FromDouble(__pyx_v_k); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyFloat_FromDouble((__pyx_v_f[2])); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_5 = PyNumber_Divide(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_3 = PyNumber_Add(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyInt_FromLong((((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyFloat_FromDouble(((((__pyx_v_f[1]) / ((2.0 * __pyx_v_k) * (__pyx_v_f[2]))) + 0.5) * (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]))); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 387; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
    __pyx_5 = 0;
    __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Camera.coord3d_to_2d");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_p);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_widget_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_widget_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.widget_begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_widget_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_widget_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_proportion = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_proportion);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.widget_advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_proportion);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Camera_widget_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_widget_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.widget_end_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_is_in_frustum;

static PyObject *__pyx_f_5_soya_7_Camera_is_in_frustum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_is_in_frustum(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  float (__pyx_v_sphere[4]);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"coordsyst",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_coordsyst)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 394; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":398 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_World); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_coordsyst));
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":400 */
    __pyx_vtabptr_5_soya__Volume->__pyx_base._get_sphere(__pyx_v_coordsyst,__pyx_v_sphere);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":401 */
    __pyx_v_coordsyst->_frustum_id = (-1);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":402 */
    __pyx_4 = sphere_in_frustum(((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst),__pyx_v_sphere);
    if (__pyx_4) {
      __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 402; goto __pyx_L1;}
      __pyx_r = __pyx_1;
      __pyx_1 = 0;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":404 */
    __pyx_3 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)((PyObject *)__pyx_v_coordsyst))->children); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 404; goto __pyx_L1;}
    for (;;) {
      __pyx_L4:;
      __pyx_2 = PyIter_Next(__pyx_3);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 404; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 404; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
      __pyx_v_child = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/soya3d/camera.pyx":405 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_is_in_frustum); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 405; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 405; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_child));
      PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_child));
      __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 405; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyObject_IsTrue(__pyx_5); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 405; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      if (__pyx_4) {
        __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 405; goto __pyx_L1;}
        __pyx_r = __pyx_1;
        __pyx_1 = 0;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    __pyx_L5:;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":406 */
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 406; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":408 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_get_sphere(__pyx_v_coordsyst,__pyx_v_sphere);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":409 */
  __pyx_v_coordsyst->_frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":424 */
  __pyx_5 = PyInt_FromLong(sphere_in_frustum(((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst),__pyx_v_sphere)); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 424; goto __pyx_L1;}
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Camera.is_in_frustum");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Portal_6beyond___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Portal_6beyond___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":29 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.beyond.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k212p;

static char (__pyx_k212[]) = "";

static int __pyx_f_5_soya_7_Portal_6beyond___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_beyond); /*proto*/
static int __pyx_f_5_soya_7_Portal_6beyond___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_beyond) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_beyond);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_beyond), __pyx_ptype_5_soya__World, 1, "beyond")) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 30; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":31 */
  Py_INCREF(__pyx_v_beyond);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond));
  ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond = __pyx_v_beyond;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":32 */
  __pyx_1 = __pyx_v_beyond == Py_None;
  if (__pyx_1) {
    Py_INCREF(__pyx_k212p);
    Py_DECREF(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name);
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name = __pyx_k212p;
    goto __pyx_L2;
  }
  /*else*/ {
    Py_INCREF(((struct __pyx_obj_5_soya__World *)__pyx_v_beyond)->_filename);
    Py_DECREF(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name);
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name = ((struct __pyx_obj_5_soya__World *)__pyx_v_beyond)->_filename;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.beyond.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_beyond);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Portal_11beyond_name___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Portal_11beyond_name___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":37 */
  Py_INCREF(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name);
  __pyx_r = ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.beyond_name.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Portal_11beyond_name___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_name); /*proto*/
static int __pyx_f_5_soya_7_Portal_11beyond_name___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_name);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":39 */
  Py_INCREF(__pyx_v_name);
  Py_DECREF(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name);
  ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond_name = __pyx_v_name;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.beyond_name.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_name);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Portal_14nb_clip_planes___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Portal_14nb_clip_planes___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":43 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 43; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":44 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(5); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 44; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":45 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 45; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Portal.nb_clip_planes.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Portal_14nb_clip_planes___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Portal_14nb_clip_planes___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 46; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":47 */
  __pyx_1 = (__pyx_v_x == 4);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":48 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":49 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":50 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation = ((double (*))realloc(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation,(16 * (sizeof(double )))));
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_x == 5);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":52 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":53 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":54 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation = ((double (*))realloc(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation,(20 * (sizeof(double )))));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":56 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":57 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":58 */
    free(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":59 */
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation = 0;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.nb_clip_planes.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Portal_16bound_atmosphere___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Portal_16bound_atmosphere___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":70 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE)); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 70; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Portal.bound_atmosphere.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Portal_16bound_atmosphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Portal_16bound_atmosphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 71; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":72 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.bound_atmosphere.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Portal___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7_Portal___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent",0};
  __pyx_v_parent = __pyx_k49;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_parent)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 75; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":76 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 76; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 76; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":77 */
  ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option = ((((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES) | __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":78 */
  ((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation = ((double (*))malloc((16 * (sizeof(double )))));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Portal.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_n_beyond_name;
static PyObject *__pyx_n_get;

static PyObject *__pyx_f_5_soya_7_Portal_load_beyond(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Portal_load_beyond[] = "Loads and returns the World beyond the portal.\nThe default implementation call World.get(self.beyond_name), but you can overrides\nit, e.g. if you want to create the world beyond from scratch.";
static PyObject *__pyx_f_5_soya_7_Portal_load_beyond(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":84 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_beyond_name); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_World); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_beyond_name); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 84; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":85 */
  Py_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Portal.load_beyond");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Portal_unload_beyond(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Portal_unload_beyond[] = "Called when the portal is no longer visible.\nThe default implementation does nothing, but you can override it, e.g. to remove\nportal.beyond from memory (with \'portal.beyond = None\').";
static PyObject *__pyx_f_5_soya_7_Portal_unload_beyond(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":91 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Portal.unload_beyond");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Portal__compute_clipping_planes(struct __pyx_obj_5_soya__Portal *__pyx_v_self) {
  float (*__pyx_v_m);
  float (__pyx_v_p1[3]);
  float (__pyx_v_p2[3]);
  float (__pyx_v_v1[3]);
  float (__pyx_v_v2[3]);
  double __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":98 */
  __pyx_1 = (-0.5);
  (__pyx_v_p1[0]) = __pyx_1;
  (__pyx_v_p1[1]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":99 */
  (__pyx_v_p1[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":100 */
  (__pyx_v_p2[0]) = 0.5;
  (__pyx_v_p2[1]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":101 */
  (__pyx_v_p2[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":102 */
  (__pyx_v_v1[0]) = 0.0;
  (__pyx_v_v1[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":103 */
  (__pyx_v_v1[1]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":104 */
  (__pyx_v_v2[1]) = 0.0;
  (__pyx_v_v2[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":105 */
  (__pyx_v_v2[0]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":107 */
  __pyx_v_m = ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":108 */
  point_by_matrix(__pyx_v_p1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":109 */
  point_by_matrix(__pyx_v_p2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":110 */
  vector_by_matrix(__pyx_v_v1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":111 */
  vector_by_matrix(__pyx_v_v2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":113 */
  __pyx_v_m = ((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":114 */
  point_by_matrix(__pyx_v_p1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":115 */
  point_by_matrix(__pyx_v_p2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":116 */
  vector_by_matrix(__pyx_v_v1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":117 */
  vector_by_matrix(__pyx_v_v2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":120 */
  (__pyx_v_self->_equation[0]) = ((double )(((__pyx_v_p1[1]) * (__pyx_v_v1[2])) - ((__pyx_v_p1[2]) * (__pyx_v_v1[1]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":121 */
  (__pyx_v_self->_equation[1]) = ((double )(((-(__pyx_v_p1[0])) * (__pyx_v_v1[2])) + ((__pyx_v_p1[2]) * (__pyx_v_v1[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":122 */
  (__pyx_v_self->_equation[2]) = ((double )(((__pyx_v_p1[0]) * (__pyx_v_v1[1])) - ((__pyx_v_p1[1]) * (__pyx_v_v1[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":123 */
  (__pyx_v_self->_equation[3]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":124 */
  (__pyx_v_self->_equation[4]) = ((double )(((-(__pyx_v_p2[1])) * (__pyx_v_v1[2])) + ((__pyx_v_p2[2]) * (__pyx_v_v1[1]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":125 */
  (__pyx_v_self->_equation[5]) = ((double )(((__pyx_v_p2[0]) * (__pyx_v_v1[2])) - ((__pyx_v_p2[2]) * (__pyx_v_v1[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":126 */
  (__pyx_v_self->_equation[6]) = ((double )(((-(__pyx_v_p2[0])) * (__pyx_v_v1[1])) + ((__pyx_v_p2[1]) * (__pyx_v_v1[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":127 */
  (__pyx_v_self->_equation[7]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":128 */
  (__pyx_v_self->_equation[8]) = ((double )(((-(__pyx_v_p1[1])) * (__pyx_v_v2[2])) + ((__pyx_v_p1[2]) * (__pyx_v_v2[1]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":129 */
  (__pyx_v_self->_equation[9]) = ((double )(((__pyx_v_p1[0]) * (__pyx_v_v2[2])) - ((__pyx_v_p1[2]) * (__pyx_v_v2[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":130 */
  (__pyx_v_self->_equation[10]) = ((double )(((-(__pyx_v_p1[0])) * (__pyx_v_v2[1])) + ((__pyx_v_p1[1]) * (__pyx_v_v2[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":131 */
  (__pyx_v_self->_equation[11]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":132 */
  (__pyx_v_self->_equation[12]) = ((double )(((__pyx_v_p2[1]) * (__pyx_v_v2[2])) - ((__pyx_v_p2[2]) * (__pyx_v_v2[1]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":133 */
  (__pyx_v_self->_equation[13]) = ((double )(((-(__pyx_v_p2[0])) * (__pyx_v_v2[2])) + ((__pyx_v_p2[2]) * (__pyx_v_v2[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":134 */
  (__pyx_v_self->_equation[14]) = ((double )(((__pyx_v_p2[0]) * (__pyx_v_v2[1])) - ((__pyx_v_p2[1]) * (__pyx_v_v2[0]))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":135 */
  (__pyx_v_self->_equation[15]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":136 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":137 */
    (__pyx_v_self->_equation[16]) = ((double )(((__pyx_v_v1[1]) * (__pyx_v_v2[2])) - ((__pyx_v_v1[2]) * (__pyx_v_v2[1]))));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":138 */
    (__pyx_v_self->_equation[17]) = ((double )(((-(__pyx_v_v1[0])) * (__pyx_v_v2[2])) + ((__pyx_v_v1[2]) * (__pyx_v_v2[0]))));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":139 */
    (__pyx_v_self->_equation[18]) = ((double )(((__pyx_v_v1[0]) * (__pyx_v_v2[1])) - ((__pyx_v_v1[1]) * (__pyx_v_v2[0]))));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":140 */
    (__pyx_v_self->_equation[19]) = ((double )(-((((__pyx_v_self->_equation[16]) * (__pyx_v_p1[0])) + ((__pyx_v_self->_equation[17]) * (__pyx_v_p1[1]))) + ((__pyx_v_self->_equation[18]) * (__pyx_v_p1[2])))));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Portal._compute_clipping_planes");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_7_Portal__compute_points(struct __pyx_obj_5_soya__Portal *__pyx_v_self) {
  int __pyx_v_nb;
  int __pyx_v_i;
  float __pyx_v_v;
  float __pyx_v_f;
  float (*__pyx_v_p1);
  float (*__pyx_v_p2);
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  float (__pyx_v_p[12]);
  double __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":151 */
  __pyx_1 = (-0.5);
  (__pyx_v_p[0]) = __pyx_1;
  (__pyx_v_p[1]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":152 */
  (__pyx_v_p[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":153 */
  (__pyx_v_p[3]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":154 */
  (__pyx_v_p[4]) = (-0.5);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":155 */
  (__pyx_v_p[5]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":156 */
  (__pyx_v_p[6]) = 0.5;
  (__pyx_v_p[7]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":157 */
  (__pyx_v_p[8]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":158 */
  (__pyx_v_p[9]) = (-0.5);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":159 */
  (__pyx_v_p[10]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":160 */
  (__pyx_v_p[11]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":163 */
  point_by_matrix(__pyx_v_p,__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":164 */
  point_by_matrix((__pyx_v_p + 3),__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":165 */
  point_by_matrix((__pyx_v_p + 6),__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":166 */
  point_by_matrix((__pyx_v_p + 9),__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":169 */
  free(__pyx_v_self->_coords);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":170 */
  __pyx_2 = ((__pyx_v_p[2]) > (-__pyx_v_5_soya_renderer->current_camera->_front));
  if (!__pyx_2) {
    __pyx_2 = ((__pyx_v_p[5]) > (-__pyx_v_5_soya_renderer->current_camera->_front));
    if (!__pyx_2) {
      __pyx_2 = ((__pyx_v_p[8]) > (-__pyx_v_5_soya_renderer->current_camera->_front));
      if (!__pyx_2) {
        __pyx_2 = ((__pyx_v_p[11]) > (-__pyx_v_5_soya_renderer->current_camera->_front));
      }
    }
  }
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":172 */
    __pyx_v_frustum = __pyx_v_5_soya_renderer->current_camera->_frustum;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":173 */
    __pyx_v_p2 = ((float (*))malloc((4 * (sizeof(float )))));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":174 */
    (__pyx_v_p2[0]) = (-(__pyx_v_frustum->planes[0]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":175 */
    (__pyx_v_p2[1]) = (-(__pyx_v_frustum->planes[1]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":176 */
    (__pyx_v_p2[2]) = (-(__pyx_v_frustum->planes[2]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":177 */
    (__pyx_v_p2[3]) = (__pyx_v_frustum->planes[3]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":178 */
    face_intersect_plane(__pyx_v_p,4,__pyx_v_p2,(&__pyx_v_p1),(&__pyx_v_nb));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":179 */
    free(__pyx_v_p2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":181 */
    face_intersect_plane(__pyx_v_p1,__pyx_v_nb,(__pyx_v_frustum->planes + 4),(&__pyx_v_p2),(&__pyx_v_nb));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":181 */
    free(__pyx_v_p1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":182 */
    face_intersect_plane(__pyx_v_p2,__pyx_v_nb,(__pyx_v_frustum->planes + 8),(&__pyx_v_p1),(&__pyx_v_nb));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":182 */
    free(__pyx_v_p2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":183 */
    face_intersect_plane(__pyx_v_p1,__pyx_v_nb,(__pyx_v_frustum->planes + 12),(&__pyx_v_p2),(&__pyx_v_nb));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":183 */
    free(__pyx_v_p1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":184 */
    face_intersect_plane(__pyx_v_p2,__pyx_v_nb,(__pyx_v_frustum->planes + 16),(&__pyx_v_self->_coords),(&__pyx_v_self->_nb_vertices));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":185 */
    free(__pyx_v_p2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":190 */
    __pyx_v_p1 = __pyx_v_self->_coords;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":191 */
    __pyx_v_f = ((-(__pyx_v_5_soya_renderer->current_camera->_front + __pyx_v_5_soya_renderer->current_camera->_back)) * 0.5);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":192 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":193 */
    while (1) {
      __pyx_L3:;
      __pyx_2 = (__pyx_v_i < (3 * __pyx_v_self->_nb_vertices));
      if (!__pyx_2) break;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":194 */
      __pyx_v_v = (__pyx_v_f / (__pyx_v_p1[(__pyx_v_i + 2)]));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":195 */
      (__pyx_v_p1[__pyx_v_i]) = (__pyx_v_v * (__pyx_v_p1[__pyx_v_i]));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":196 */
      (__pyx_v_p1[(__pyx_v_i + 1)]) = (__pyx_v_v * (__pyx_v_p1[(__pyx_v_i + 1)]));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":197 */
      (__pyx_v_p1[(__pyx_v_i + 2)]) = __pyx_v_f;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":198 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":200 */
    __pyx_v_self->_coords = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":201 */
    __pyx_v_self->_nb_vertices = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":203 */
  __pyx_v_self->_coords = ((float (*))realloc(__pyx_v_self->_coords,(((__pyx_v_self->_nb_vertices + 4) * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":204 */
  __pyx_v_nb = (__pyx_v_self->_nb_vertices * 3);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":205 */
  memcpy((__pyx_v_self->_coords + __pyx_v_nb),__pyx_v_p,(12 * (sizeof(float ))));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Portal._compute_points");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_unload_beyond;
static PyObject *__pyx_n_load_beyond;

static void __pyx_f_5_soya_7_Portal__batch(struct __pyx_obj_5_soya__Portal *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_v_i;
  float __pyx_v_p;
  float (__pyx_v_sphere[4]);
  float (*__pyx_v_matrix);
  float (*__pyx_v_ptr);
  __pyx_t_5_soya_Frustum (*__pyx_v_f);
  struct __pyx_obj_5_soya_Context *__pyx_v_ctx;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_ctx = Py_None; Py_INCREF((PyObject *) __pyx_v_ctx);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":215 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":216 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":219 */
  __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":220 */
  __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":221 */
  __pyx_v_p = (((((__pyx_v_ptr[0]) * (__pyx_v_matrix[2])) + ((__pyx_v_ptr[1]) * (__pyx_v_matrix[6]))) + ((__pyx_v_ptr[2]) * (__pyx_v_matrix[10]))) + (__pyx_v_matrix[14]));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":222 */
  __pyx_1 = (__pyx_v_p < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":223 */
    __pyx_1 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
    __pyx_2 = (!__pyx_1);
    if (__pyx_2) {
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_unload_beyond); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 223; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 223; goto __pyx_L1;}
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 223; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":224 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":228 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & (__pyx_e_5_soya_PORTAL_USE_4_CLIP_PLANES | __pyx_e_5_soya_PORTAL_USE_5_CLIP_PLANES));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":229 */
    __pyx_v_f = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_self->__pyx_base.__pyx_base._parent);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":230 */
    (__pyx_v_sphere[0]) = (__pyx_v_self->__pyx_base._matrix[12]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":231 */
    (__pyx_v_sphere[1]) = (__pyx_v_self->__pyx_base._matrix[13]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":232 */
    (__pyx_v_sphere[2]) = (__pyx_v_self->__pyx_base._matrix[14]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":233 */
    __pyx_2 = ((__pyx_v_self->__pyx_base._matrix[16]) > (__pyx_v_self->__pyx_base._matrix[17]));
    if (__pyx_2) {
      (__pyx_v_sphere[3]) = (sqrt_2 * (__pyx_v_self->__pyx_base._matrix[16]));
      goto __pyx_L6;
    }
    /*else*/ {
      (__pyx_v_sphere[3]) = (sqrt_2 * (__pyx_v_self->__pyx_base._matrix[17]));
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":235 */
    __pyx_1 = (sphere_in_frustum(__pyx_v_f,__pyx_v_sphere) == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/portal.pyx":236 */
      __pyx_2 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
      __pyx_1 = (!__pyx_2);
      if (__pyx_1) {
        __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_unload_beyond); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 236; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 236; goto __pyx_L1;}
        __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 236; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":237 */
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":239 */
    __pyx_v_f = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":240 */
    __pyx_v_i = 2;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":241 */
    while (1) {
      __pyx_L9:;
      __pyx_2 = (__pyx_v_i < 24);
      if (!__pyx_2) break;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":242 */
      __pyx_1 = ((__pyx_v_f->points[__pyx_v_i]) <= 0.0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/portal.pyx":243 */
        __pyx_2 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
        __pyx_1 = (!__pyx_2);
        if (__pyx_1) {
          __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_unload_beyond); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 243; goto __pyx_L1;}
          __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 243; goto __pyx_L1;}
          __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 243; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          goto __pyx_L12;
        }
        __pyx_L12:;

        /* "/home/jiba/src/soya/soya3d/portal.pyx":244 */
        goto __pyx_L0;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":245 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L10:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":248 */
  __pyx_2 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":249 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_load_beyond); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; goto __pyx_L1;}
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_beyond));
    __pyx_v_self->_beyond = __pyx_5;
    __pyx_5 = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":250 */
    __pyx_1 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L14;
    }
    __pyx_L14:;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":253 */
  __pyx_2 = (__pyx_v_self->_equation != 0);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_clipping_planes(__pyx_v_self);
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":254 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":257 */
    multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base._matrix);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":258 */
    ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_points(__pyx_v_self);
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":260 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_5_soya_renderer->portals, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 260; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 260; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_self));
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 260; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":262 */
  __pyx_2 = (__pyx_v_self->_beyond->__pyx_base.__pyx_base._option & __pyx_e_5_soya_WORLD_BATCHED);
  if (__pyx_2) {
    goto __pyx_L0;
    goto __pyx_L17;
  }
  __pyx_L17:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":263 */
  __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_5_soya_renderer->current_camera), __pyx_n_to_render); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 263; goto __pyx_L1;}
  __pyx_1 = __pyx_3 == Py_None;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":264 */
    __pyx_4 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera))); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__World *)((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera))->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._contains(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera))),((struct __pyx_obj_5_soya__CObj *)__pyx_v_self->_beyond));
    Py_DECREF((PyObject *)__pyx_4); __pyx_4 = 0;
    if (__pyx_2) {
      goto __pyx_L0;
      goto __pyx_L19;
    }
    __pyx_L19:;
    goto __pyx_L18;
  }
  __pyx_1 = ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_5_soya_renderer->current_camera->_to_render->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._contains(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera->_to_render),((struct __pyx_obj_5_soya__CObj *)__pyx_v_self->_beyond));
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L18;
  }
  __pyx_L18:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":268 */
  Py_INCREF(((PyObject *)__pyx_v_5_soya_renderer->current_context));
  Py_DECREF(((PyObject *)__pyx_v_ctx));
  __pyx_v_ctx = ((PyObject *)__pyx_v_5_soya_renderer->current_context);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":269 */
  __pyx_5 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_context(__pyx_v_5_soya_renderer)); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 269; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_self->_context));
  __pyx_v_self->_context = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":270 */
  Py_INCREF(((PyObject *)__pyx_v_self->_beyond->_atmosphere));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_context->atmosphere));
  __pyx_v_self->_context->atmosphere = ((PyObject *)__pyx_v_self->_beyond->_atmosphere);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":271 */
  Py_INCREF(((PyObject *)__pyx_v_self));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_context->portal));
  __pyx_v_self->_context->portal = ((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":272 */
  Py_INCREF(((PyObject *)__pyx_v_self->_context));
  Py_DECREF(((PyObject *)__pyx_v_5_soya_renderer->current_context));
  __pyx_v_5_soya_renderer->current_context = ((PyObject *)__pyx_v_self->_context);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":273 */
  __pyx_v_self->_beyond->__pyx_base.__pyx_base._option = (__pyx_v_self->_beyond->__pyx_base.__pyx_base._option | __pyx_e_5_soya_WORLD_BATCHED);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":274 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_5_soya_renderer->worlds_made, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_beyond));
  PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_self->_beyond));
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":275 */
  multiply_matrix(__pyx_v_self->_beyond->__pyx_base.__pyx_base._render_matrix,__pyx_v_5_soya_renderer->current_camera->__pyx_base._render_matrix,((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->_beyond->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->_beyond)));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":276 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 276; goto __pyx_L1;}
  ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->_beyond->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._batch(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->_beyond),((struct __pyx_obj_5_soya_CoordSyst *)Py_None));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":277 */
  Py_INCREF(((PyObject *)__pyx_v_ctx));
  Py_DECREF(((PyObject *)__pyx_v_5_soya_renderer->current_context));
  __pyx_v_5_soya_renderer->current_context = ((PyObject *)__pyx_v_ctx);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._Portal._batch");
  __pyx_L0:;
  Py_DECREF(__pyx_v_ctx);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static int __pyx_f_5_soya_7_Portal__shadow(struct __pyx_obj_5_soya__Portal *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":280 */
  __pyx_1 = (__pyx_v_light->__pyx_base._option & __pyx_e_5_soya_LIGHT_TOP_LEVEL);
  if (__pyx_1) {
    __pyx_2 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
    __pyx_1 = (!__pyx_2);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":281 */
    __pyx_r = ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->_beyond->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._shadow(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->_beyond),__pyx_v_coordsyst,__pyx_v_light);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":282 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Portal._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Portal__atmosphere_clear_part(struct __pyx_obj_5_soya__Portal *__pyx_v_self) {
  int __pyx_v_i;
  float (*__pyx_v_ptr);
  struct __pyx_obj_5_soya__Atmosphere *__pyx_v_atmosphere;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_atmosphere = Py_None; Py_INCREF((PyObject *) __pyx_v_atmosphere);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":288 */
  Py_INCREF(((PyObject *)__pyx_v_self->_beyond->_atmosphere));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_atmosphere));
  __pyx_v_atmosphere = ((PyObject *)__pyx_v_self->_beyond->_atmosphere);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":291 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":292 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":293 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":294 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":295 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":296 */
  glColor4fv(__pyx_v_atmosphere->_bg_color);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":297 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":298 */
  __pyx_v_ptr = (__pyx_v_self->_coords + (__pyx_v_self->_nb_vertices * 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":299 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":300 */
  glVertex3fv(__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":301 */
  glVertex3fv((__pyx_v_ptr + 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":302 */
  glVertex3fv((__pyx_v_ptr + 6));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":303 */
  glVertex3fv((__pyx_v_ptr + 9));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":304 */
  glEnd();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":307 */
  __pyx_1 = (__pyx_v_self->_nb_vertices > 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":308 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":309 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":310 */
    while (1) {
      __pyx_L3:;
      __pyx_1 = (__pyx_v_i < (__pyx_v_self->_nb_vertices * 3));
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":311 */
      glVertex3fv((__pyx_v_self->_coords + __pyx_v_i));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":312 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":313 */
    glEnd();
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":316 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 316; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 316; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_atmosphere));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_atmosphere));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__SkyAtmosphere));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__SkyAtmosphere));
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 316; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 316; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":318 */
    __pyx_1 = (__pyx_v_self->_equation == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/portal.pyx":319 */
      __pyx_v_self->_equation = ((double (*))malloc((16 * (sizeof(double )))));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":320 */
      ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_clipping_planes(__pyx_v_self);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":321 */
    glClipPlane(GL_CLIP_PLANE0,__pyx_v_self->_equation);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":322 */
    glClipPlane(GL_CLIP_PLANE1,(__pyx_v_self->_equation + 4));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":323 */
    glClipPlane(GL_CLIP_PLANE2,(__pyx_v_self->_equation + 8));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":324 */
    glClipPlane(GL_CLIP_PLANE3,(__pyx_v_self->_equation + 12));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":325 */
    glEnable(GL_CLIP_PLANE0);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":326 */
    glEnable(GL_CLIP_PLANE1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":327 */
    glEnable(GL_CLIP_PLANE2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":328 */
    glEnable(GL_CLIP_PLANE3);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":329 */
    ((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_atmosphere->__pyx_base.__pyx_vtab)->_draw_bg(__pyx_v_atmosphere);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":330 */
    glDisable(GL_CLIP_PLANE0);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":331 */
    glDisable(GL_CLIP_PLANE1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":332 */
    glDisable(GL_CLIP_PLANE2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":333 */
    glDisable(GL_CLIP_PLANE3);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":335 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":336 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":337 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":338 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":339 */
  glEnable(GL_LIGHTING);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Portal._atmosphere_clear_part");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_atmosphere);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_7_Portal__draw_fog(struct __pyx_obj_5_soya__Portal *__pyx_v_self,struct __pyx_obj_5_soya__Atmosphere *__pyx_v_atmosphere) {
  float (*__pyx_v_ptr);
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_atmosphere);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":346 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":347 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":348 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":350 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":352 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":353 */
  __pyx_v_ptr = (__pyx_v_self->_coords + (__pyx_v_self->_nb_vertices * 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":354 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":355 */
  glColor4f((__pyx_v_atmosphere->_fog_color[0]),(__pyx_v_atmosphere->_fog_color[1]),(__pyx_v_atmosphere->_fog_color[2]),((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_atmosphere->__pyx_base.__pyx_vtab)->_fog_factor_at(__pyx_v_atmosphere,__pyx_v_ptr));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":355 */
  glVertex3fv(__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":356 */
  glColor4f((__pyx_v_atmosphere->_fog_color[0]),(__pyx_v_atmosphere->_fog_color[1]),(__pyx_v_atmosphere->_fog_color[2]),((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_atmosphere->__pyx_base.__pyx_vtab)->_fog_factor_at(__pyx_v_atmosphere,(__pyx_v_ptr + 3)));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":356 */
  glVertex3fv((__pyx_v_ptr + 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":357 */
  glColor4f((__pyx_v_atmosphere->_fog_color[0]),(__pyx_v_atmosphere->_fog_color[1]),(__pyx_v_atmosphere->_fog_color[2]),((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_atmosphere->__pyx_base.__pyx_vtab)->_fog_factor_at(__pyx_v_atmosphere,(__pyx_v_ptr + 6)));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":357 */
  glVertex3fv((__pyx_v_ptr + 6));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":358 */
  glColor4f((__pyx_v_atmosphere->_fog_color[0]),(__pyx_v_atmosphere->_fog_color[1]),(__pyx_v_atmosphere->_fog_color[2]),((struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_v_atmosphere->__pyx_base.__pyx_vtab)->_fog_factor_at(__pyx_v_atmosphere,(__pyx_v_ptr + 9)));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":358 */
  glVertex3fv((__pyx_v_ptr + 9));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":359 */
  glEnd();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":367 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":369 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":370 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":371 */
  glEnable(GL_LIGHTING);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Portal._draw_fog");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_atmosphere);
}

static void __pyx_f_5_soya_7_Portal__raypick(struct __pyx_obj_5_soya__Portal *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":374 */
  ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->_beyond->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raypick(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->_beyond),__pyx_v_raypick_data,__pyx_v_raypickable);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Portal._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_7_Portal__raypick_b(struct __pyx_obj_5_soya__Portal *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":377 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->_beyond->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._raypick_b(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->_beyond),__pyx_v_raypick_data,__pyx_v_raypickable);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Portal._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static PyObject *__pyx_n_OBJECT_NON_SOLID;

static void __pyx_f_5_soya_7_Portal__collect_raypickables(struct __pyx_obj_5_soya__Portal *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  float (*__pyx_v_matrix);
  float (__pyx_v_s[4]);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":380 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->__pyx_base._option); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 380; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OBJECT_NON_SOLID); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 380; goto __pyx_L1;}
  __pyx_3 = PyNumber_And(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 380; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 380; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":387 */
  __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya__Portal *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":388 */
  point_by_matrix_copy(__pyx_v_s,__pyx_v_rsphere,__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":389 */
  (__pyx_v_s[3]) = length_by_matrix((__pyx_v_rsphere[3]),__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":391 */
  __pyx_4 = (vector_length(__pyx_v_s) < ((__pyx_v_s[3]) + 0.5));
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":392 */
    ((struct __pyx_vtabstruct_5_soya__World *)__pyx_v_self->_beyond->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._collect_raypickables(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self->_beyond),__pyx_v_items,__pyx_v_rsphere,__pyx_v_sphere);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Portal._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_child);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_7_Portal_has_passed_through(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Portal_has_passed_through[] = "Portal.has_passed_though(self, old_pos, new_pos) -> bool\n\nReturn true if moving from OLD_POS to NEW_POS pass through the portal.\nNEW_POS can be either the new position or the speed vector.";
static PyObject *__pyx_f_5_soya_7_Portal_has_passed_through(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_old_pos = 0;
  struct __pyx_obj_5_soya_Position *__pyx_v_new_pos = 0;
  float (__pyx_v_old[3]);
  float (__pyx_v_new[3]);
  float __pyx_v_f;
  float __pyx_v_f1;
  float __pyx_v_f2;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  float __pyx_5;
  static char *__pyx_argnames[] = {"old_pos","new_pos",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_old_pos, &__pyx_v_new_pos)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_old_pos);
  Py_INCREF((PyObject *)__pyx_v_new_pos);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_old_pos), __pyx_ptype_5_soya_Position, 1, "old_pos")) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 395; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_new_pos), __pyx_ptype_5_soya_Position, 1, "new_pos")) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 395; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":400 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_beyond) == Py_None;
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 400; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":404 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_old_pos->__pyx_base.__pyx_vtab)->_into(__pyx_v_old_pos,((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)),__pyx_v_old);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":405 */
  ((struct __pyx_vtabstruct_5_soya_Position *)__pyx_v_new_pos->__pyx_base.__pyx_vtab)->_into(__pyx_v_new_pos,((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)),__pyx_v_new);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":406 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_new_pos));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_new_pos));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Vector));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__Vector));
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":407 */
    (__pyx_v_new[0]) = ((__pyx_v_old[0]) + (__pyx_v_new[0]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":408 */
    (__pyx_v_new[1]) = ((__pyx_v_old[1]) + (__pyx_v_new[1]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":409 */
    (__pyx_v_new[2]) = ((__pyx_v_old[2]) + (__pyx_v_new[2]));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":411 */
  __pyx_v_f = ((__pyx_v_old[2]) * (__pyx_v_new[2]));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":412 */
  __pyx_1 = (__pyx_v_f > 0.0);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 412; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":413 */
  __pyx_1 = (__pyx_v_f == 0.0);
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_old[2]) == 0.0);
  }
  if (__pyx_1) {
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":414 */
  __pyx_v_f1 = ((__pyx_v_old[2]) / ((__pyx_v_old[2]) + (__pyx_v_new[2])));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":415 */
  __pyx_v_f2 = (1.0 - __pyx_v_f1);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":416 */
  __pyx_5 = (((__pyx_v_old[0]) * __pyx_v_f1) + ((__pyx_v_new[0]) * __pyx_v_f2));
  __pyx_1 = (-0.5) < __pyx_5;
  if (__pyx_1) {
    __pyx_1 = __pyx_5 < 0.5;
  }
  if (__pyx_1) {
    __pyx_5 = (((__pyx_v_old[1]) * __pyx_v_f1) + ((__pyx_v_new[1]) * __pyx_v_f2));
    __pyx_1 = (-0.5) < __pyx_5;
    if (__pyx_1) {
      __pyx_1 = __pyx_5 < 0.5;
    }
  }
  __pyx_4 = PyInt_FromLong(__pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 416; goto __pyx_L1;}
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Portal.has_passed_through");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_old_pos);
  Py_DECREF((PyObject *)__pyx_v_new_pos);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Portal___getcstate__(struct __pyx_obj_5_soya__Portal *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":423 */
  __pyx_1 = __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_v_self->_beyond_name);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self->_beyond_name);
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Portal.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Portal___setcstate__(struct __pyx_obj_5_soya__Portal *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":426 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 426; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 426; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":427 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 427; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->_beyond_name);
  __pyx_v_self->_beyond_name = __pyx_2;
  __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Portal.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_9traveling___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_9traveling___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._TravelingCamera.traveling.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_10travelings___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_10travelings___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings);
  __pyx_r = ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._TravelingCamera.travelings.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_5speed___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_5speed___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 31; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._TravelingCamera.speed.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_16_TravelingCamera_5speed___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_16_TravelingCamera_5speed___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._TravelingCamera.speed.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_16_TravelingCamera___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_16_TravelingCamera___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_parent = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent",0};
  __pyx_v_parent = __pyx_k50;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_parent)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_parent);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":35 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Camera), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 35; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_parent);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_parent);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":37 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 37; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings);
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":38 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Traveling)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling));
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling = Py_None;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":39 */
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value = 0.3;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":40 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed = __pyx_1;
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._TravelingCamera.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_parent);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_add_traveling(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_add_traveling(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Traveling *__pyx_v_traveling = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"traveling",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_traveling)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_traveling);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_traveling), __pyx_ptype_5_soya_Traveling, 1, "traveling")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":43 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_traveling));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_traveling));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":44 */
  Py_INCREF(((PyObject *)__pyx_v_traveling));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling));
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling = ((PyObject *)__pyx_v_traveling);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":45 */
  ((struct __pyx_vtabstruct_5_soya__TravelingCamera *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_traveling_changed(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._TravelingCamera.add_traveling");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_traveling);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_pop_traveling(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_pop_traveling(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":48 */
  __pyx_1 = PyInt_FromLong((-1)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 48; goto __pyx_L1;}
  if (PyObject_DelItem(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings, __pyx_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 48; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":49 */
  __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_Traveling)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling));
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":50 */
  ((struct __pyx_vtabstruct_5_soya__TravelingCamera *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_traveling_changed(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._TravelingCamera.pop_traveling");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_remove_traveling(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_remove_traveling(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Traveling *__pyx_v_traveling = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"traveling",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_traveling)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_traveling);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_traveling), __pyx_ptype_5_soya_Traveling, 1, "traveling")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 52; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":53 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings, __pyx_n_remove); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 53; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 53; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_traveling));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_traveling));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 53; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":54 */
  __pyx_4 = ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling) == ((PyObject *)__pyx_v_traveling);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":55 */
    __pyx_1 = PyInt_FromLong((-1)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 55; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_travelings, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 55; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_Traveling)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 55; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling));
    ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":56 */
    ((struct __pyx_vtabstruct_5_soya__TravelingCamera *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_traveling_changed(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._TravelingCamera.remove_traveling");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_traveling);
  return __pyx_r;
}

static PyObject *__pyx_n_turn_incline;

static void __pyx_f_5_soya_16_TravelingCamera__traveling_changed(struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_self) {
  float (__pyx_v_v[3]);
  float (__pyx_v_up[3]);
  float __pyx_v_angle;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":62 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_traveling->_incline_as) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":63 */
    (__pyx_v_v[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":64 */
    (__pyx_v_v[1]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":65 */
    (__pyx_v_v[2]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":66 */
    vector_by_matrix(__pyx_v_v,((struct __pyx_vtabstruct_5_soya__TravelingCamera *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)));

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":68 */
    __pyx_1 = ((__pyx_v_v[0]) != 0.0);
    if (!__pyx_1) {
      __pyx_1 = ((__pyx_v_v[1]) != 0.0);
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":69 */
      (__pyx_v_up[0]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":70 */
      (__pyx_v_up[1]) = 1.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":71 */
      (__pyx_v_up[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":72 */
      (__pyx_v_v[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":74 */
      __pyx_v_angle = vector_angle(__pyx_v_up,__pyx_v_v);

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":75 */
      __pyx_1 = ((__pyx_v_v[0]) > 0);
      if (__pyx_1) {
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_turn_incline); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 75; goto __pyx_L1;}
        __pyx_3 = PyFloat_FromDouble((-__pyx_v_angle)); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 75; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 75; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 75; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        goto __pyx_L4;
      }
      /*else*/ {
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_turn_incline); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; goto __pyx_L1;}
        __pyx_4 = PyFloat_FromDouble(__pyx_v_angle); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
        __pyx_4 = 0;
        __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._TravelingCamera._traveling_changed");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_will_render;
static PyObject *__pyx_n_set_start_end;
static PyObject *__pyx_n_best_position;
static PyObject *__pyx_n_add_mul_vector;
static PyObject *__pyx_n_move;
static PyObject *__pyx_n_best_direction;
static PyObject *__pyx_n_normalize;
static PyObject *__pyx_n_look_at;
static PyObject *__pyx_n_min;


static PyObject *__pyx_f_5_soya_16_TravelingCamera_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_v_soya;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction;
  struct __pyx_obj_5_soya__Vector *__pyx_v_current;
  float (__pyx_v_v[3]);
  float (__pyx_v_up[3]);
  float __pyx_v_angle;
  PyObject *__pyx_v_r;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  float __pyx_7;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);
  __pyx_v_direction = Py_None; Py_INCREF((PyObject *) __pyx_v_direction);
  __pyx_v_current = Py_None; Py_INCREF((PyObject *) __pyx_v_current);
  __pyx_v_r = Py_None; Py_INCREF(__pyx_v_r);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":84 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 84; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":85 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_IDLER); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_will_render); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_3) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; goto __pyx_L1;}
  __pyx_3 = __pyx_3 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_3) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":86 */
    ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_proportion = (((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_proportion + __pyx_v_proportion);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":87 */
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":89 */
  __pyx_v_proportion = (__pyx_v_proportion + ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_proportion);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":95 */
  __pyx_3 = ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_smooth_move;
  if (__pyx_3) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":96 */
    while (1) {
      __pyx_L4:;
      __pyx_3 = (__pyx_v_proportion > 1.0);
      if (!__pyx_3) break;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":97 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed), __pyx_n_set_start_end); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; goto __pyx_L1;}
      __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_position); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; goto __pyx_L1;}
      Py_INCREF((PyObject *)__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
      __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; goto __pyx_L1;}
      Py_INCREF((PyObject *)__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);
      __pyx_5 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":98 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_mul_vector); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; goto __pyx_L1;}
      __pyx_2 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; goto __pyx_L1;}
      __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
      Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
      PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
      __pyx_2 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":99 */
      __pyx_v_proportion = (__pyx_v_proportion - 1.0);
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":101 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed), __pyx_n_set_start_end); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
    __pyx_5 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_position); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
    __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    __pyx_4 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":102 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_mul_vector); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
    __pyx_2 = PyFloat_FromDouble((__pyx_v_proportion * ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value)); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
    Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
    PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
    __pyx_2 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":105 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_move); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    __pyx_4 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_position); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
    __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":107 */
  __pyx_3 = ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_smooth_rotation;
  if (__pyx_3) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":108 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_direction); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 108; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 108; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 108; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":109 */
    __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_INCREF(__pyx_v_r);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_r);
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Vector));
    PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject*)__pyx_ptype_5_soya__Vector));
    __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyObject_IsTrue(__pyx_2); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_3) {
      if (!__Pyx_TypeTest(__pyx_v_r, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
      Py_INCREF(__pyx_v_r);
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_direction));
      __pyx_v_direction = __pyx_v_r;
      goto __pyx_L7;
    }
    /*else*/ {
      __pyx_4 = PyNumber_Rshift(__pyx_v_self, __pyx_v_r); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 110; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 110; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_direction));
      __pyx_v_direction = __pyx_4;
      __pyx_4 = 0;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":111 */
    __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_convert_to); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 111; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 111; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
    __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 111; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":112 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_normalize); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 112; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 112; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":113 */
    __pyx_3 = ((__pyx_v_direction->__pyx_base._matrix[0]) < (-0.02));
    if (__pyx_3) {
      (__pyx_v_direction->__pyx_base._matrix[0]) = (-0.02);
      goto __pyx_L8;
    }
    __pyx_3 = ((__pyx_v_direction->__pyx_base._matrix[0]) > 0.02);
    if (__pyx_3) {
      (__pyx_v_direction->__pyx_base._matrix[0]) = 0.02;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":115 */
    __pyx_3 = ((__pyx_v_direction->__pyx_base._matrix[1]) < (-0.02));
    if (__pyx_3) {
      (__pyx_v_direction->__pyx_base._matrix[1]) = (-0.02);
      goto __pyx_L9;
    }
    __pyx_3 = ((__pyx_v_direction->__pyx_base._matrix[1]) > 0.02);
    if (__pyx_3) {
      (__pyx_v_direction->__pyx_base._matrix[1]) = 0.02;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":117 */
    (__pyx_v_direction->__pyx_base._matrix[2]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":118 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_look_at); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 118; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 118; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_direction));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_direction));
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 118; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":121 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_look_at); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 121; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_direction); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 121; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 121; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 121; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 121; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 121; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":135 */
  __pyx_3 = ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_incline_as) == Py_None;
  __pyx_6 = (!__pyx_3);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":136 */
    (__pyx_v_v[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":137 */
    (__pyx_v_v[1]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":138 */
    (__pyx_v_v[2]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":139 */
    vector_by_matrix(__pyx_v_v,((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_incline_as->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_incline_as));

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":140 */
    vector_by_matrix(__pyx_v_v,((struct __pyx_vtabstruct_5_soya__TravelingCamera *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self))));

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":142 */
    __pyx_3 = ((__pyx_v_v[0]) != 0.0);
    if (!__pyx_3) {
      __pyx_3 = ((__pyx_v_v[1]) != 0.0);
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":143 */
      (__pyx_v_up[0]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":144 */
      (__pyx_v_up[1]) = 1.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":145 */
      (__pyx_v_up[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":146 */
      (__pyx_v_v[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":148 */
      __pyx_v_angle = vector_angle(__pyx_v_up,__pyx_v_v);

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":149 */
      __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      __pyx_1 = PyFloat_FromDouble((2.0 * ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      __pyx_2 = PyFloat_FromDouble(__pyx_v_angle); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
      __pyx_1 = 0;
      __pyx_2 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      __pyx_5 = PyNumber_Multiply(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_7 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 149; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_v_angle = __pyx_7;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":150 */
      __pyx_6 = ((__pyx_v_v[0]) > 0);
      if (__pyx_6) {
        __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_turn_incline); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 150; goto __pyx_L1;}
        __pyx_1 = PyFloat_FromDouble((-__pyx_v_angle)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 150; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 150; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
        __pyx_1 = 0;
        __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 150; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L12;
      }
      /*else*/ {
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_turn_incline); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 151; goto __pyx_L1;}
        __pyx_4 = PyFloat_FromDouble(__pyx_v_angle); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 151; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 151; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
        __pyx_4 = 0;
        __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 151; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }
      __pyx_L12:;
      goto __pyx_L11;
    }
    __pyx_L11:;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":153 */
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_proportion = 0.0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._TravelingCamera.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_soya);
  Py_DECREF((PyObject *)__pyx_v_direction);
  Py_DECREF((PyObject *)__pyx_v_current);
  Py_DECREF(__pyx_v_r);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_TravelingCamera_zap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_16_TravelingCamera_zap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":157 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_move); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_position); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 157; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 157; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 157; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 157; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":158 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_look_at); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 158; goto __pyx_L1;}
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_direction); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 158; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 158; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 158; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 158; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 158; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._TravelingCamera.zap");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9Traveling_10incline_as___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9Traveling_10incline_as___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":167 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_incline_as));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_incline_as);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Traveling.incline_as.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9Traveling_10incline_as___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_9Traveling_10incline_as___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya_CoordSyst, 1, "x")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 168; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":169 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_incline_as));
  ((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_incline_as = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Traveling.incline_as.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9Traveling_11smooth_move___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9Traveling_11smooth_move___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":173 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_smooth_move); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Traveling.smooth_move.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9Traveling_11smooth_move___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9Traveling_11smooth_move___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 174; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":175 */
  ((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_smooth_move = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Traveling.smooth_move.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9Traveling_15smooth_rotation___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9Traveling_15smooth_rotation___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":179 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_smooth_rotation); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Traveling.smooth_rotation.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9Traveling_15smooth_rotation___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9Traveling_15smooth_rotation___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 180; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":181 */
  ((struct __pyx_obj_5_soya_Traveling *)__pyx_v_self)->_smooth_rotation = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Traveling.smooth_rotation.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_NotImplementedError;

static PyObject *__pyx_f_5_soya_9Traveling_best_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_9Traveling_best_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_camera = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"camera",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_camera)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_camera);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_camera), __pyx_ptype_5_soya__TravelingCamera, 1, "camera")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 183; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":184 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NotImplementedError); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 184; goto __pyx_L1;}
  __Pyx_Raise(__pyx_1, 0, 0);
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  {__pyx_filename = __pyx_f[13]; __pyx_lineno = 184; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Traveling.best_position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_camera);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9Traveling_best_direction(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_9Traveling_best_direction(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_camera = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"camera",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_camera)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_camera);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_camera), __pyx_ptype_5_soya__TravelingCamera, 1, "camera")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 186; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":187 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NotImplementedError); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 187; goto __pyx_L1;}
  __Pyx_Raise(__pyx_1, 0, 0);
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  {__pyx_filename = __pyx_f[13]; __pyx_lineno = 187; goto __pyx_L1;}

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Traveling.best_direction");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_camera);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13_FixTraveling_6target___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_13_FixTraveling_6target___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":197 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._FixTraveling.target.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_13_FixTraveling_6target___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_13_FixTraveling_6target___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya_Position, 1, "x")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":199 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target));
  ((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._FixTraveling.target.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13_FixTraveling_9direction___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_13_FixTraveling_9direction___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":203 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._FixTraveling.direction.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_13_FixTraveling_9direction___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_13_FixTraveling_9direction___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya_Position, 1, "x")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 204; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":205 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction));
  ((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._FixTraveling.direction.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static int __pyx_f_5_soya_13_FixTraveling___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_13_FixTraveling___init__[] = "FixTraveling(target, direction, smooth_move = 1, smooth_rotation = 0)\nTARGET is the position of the camera, and DIRECTION the direction to look at.\nSMOOTH_MOVE and SMOOTH_ROTATION defines wether the camera moves and rotates smoothly or\nnot.";
static int __pyx_f_5_soya_13_FixTraveling___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_target = 0;
  struct __pyx_obj_5_soya_Position *__pyx_v_direction = 0;
  int __pyx_v_smooth_move;
  int __pyx_v_smooth_rotation;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static char *__pyx_argnames[] = {"target","direction","smooth_move","smooth_rotation",0};
  __pyx_v_smooth_move = __pyx_k51;
  __pyx_v_smooth_rotation = __pyx_k52;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|ii", __pyx_argnames, &__pyx_v_target, &__pyx_v_direction, &__pyx_v_smooth_move, &__pyx_v_smooth_rotation)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_target);
  Py_INCREF((PyObject *)__pyx_v_direction);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_Position, 1, "target")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 207; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya_Position, 1, "direction")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 207; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":213 */
  Py_INCREF(((PyObject *)__pyx_v_target));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target));
  ((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target = ((PyObject *)__pyx_v_target);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":214 */
  __pyx_1 = ((PyObject *)__pyx_v_direction);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
  if (!__pyx_2) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(0.0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((-1.0)); if (!__pyx_6) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_7, 0, Py_None);
    PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
    PyTuple_SET_ITEM(__pyx_7, 2, __pyx_5);
    PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_6 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_7); __pyx_7 = 0;
  }
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya_Position)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 214; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction));
  ((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":215 */
  ((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->__pyx_base._smooth_move = __pyx_v_smooth_move;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":216 */
  ((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->__pyx_base._smooth_rotation = __pyx_v_smooth_rotation;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya._FixTraveling.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_target);
  Py_DECREF((PyObject *)__pyx_v_direction);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13_FixTraveling_best_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_13_FixTraveling_best_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_camera = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"camera",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_camera)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_camera);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_camera), __pyx_ptype_5_soya__TravelingCamera, 1, "camera")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 218; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":219 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_target);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 219; goto __pyx_L1;}
  if (!__pyx_2) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_1 = ((PyObject *)__pyx_v_camera);
    Py_INCREF((PyObject *)__pyx_1);
  }
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._FixTraveling.best_position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_camera);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13_FixTraveling_best_direction(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_13_FixTraveling_best_direction(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_camera = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"camera",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_camera)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_camera);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_camera), __pyx_ptype_5_soya__TravelingCamera, 1, "camera")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 221; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":222 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__FixTraveling *)__pyx_v_self)->_direction);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._FixTraveling.best_direction");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_camera);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_5speed___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_5speed___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":237 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 237; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.speed.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_5speed___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_5speed___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 238; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":239 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.speed.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_6target___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_6target___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":243 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.target.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_6target___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_6target___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya_Position, 1, "x")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 244; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":245 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.target.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_9direction___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_9direction___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":249 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.direction.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_9direction___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_9direction___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Vector, 1, "x")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 250; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":251 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.direction.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_8distance___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_8distance___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":255 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.distance.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_8distance___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_8distance___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 256; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":257 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.distance.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_8offset_y___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_8offset_y___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":261 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 261; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.offset_y.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_8offset_y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_8offset_y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 262; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":263 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.offset_y.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_9offset_y2___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_9offset_y2___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":267 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 267; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.offset_y2.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_9offset_y2___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_9offset_y2___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 268; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":269 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y2 = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.offset_y2.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_13lateral_angle___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_13lateral_angle___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":273 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.lateral_angle.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_13lateral_angle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_13lateral_angle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 274; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":275 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.lateral_angle.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_8top_view___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_8top_view___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":279 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_top_view); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 279; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.top_view.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling_8top_view___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling_8top_view___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  float __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":281 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 281; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_top_view = __pyx_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.top_view.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static int __pyx_f_5_soya_21_ThirdPersonTraveling___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_21_ThirdPersonTraveling___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Position *__pyx_v_target = 0;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction = 0;
  int __pyx_v_smooth_move;
  int __pyx_v_smooth_rotation;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static char *__pyx_argnames[] = {"target","direction","smooth_move","smooth_rotation",0};
  __pyx_v_target = __pyx_k53;
  __pyx_v_direction = __pyx_k54;
  __pyx_v_smooth_move = __pyx_k55;
  __pyx_v_smooth_rotation = __pyx_k56;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOii", __pyx_argnames, &__pyx_v_target, &__pyx_v_direction, &__pyx_v_smooth_move, &__pyx_v_smooth_rotation)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_target);
  Py_INCREF((PyObject *)__pyx_v_direction);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_Position, 1, "target")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 283; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 1, "direction")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 283; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":284 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 284; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_target));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base._incline_as));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base._incline_as = ((PyObject *)__pyx_v_target);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":285 */
  Py_INCREF(((PyObject *)__pyx_v_target));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target = ((PyObject *)__pyx_v_target);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":286 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 286; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 286; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__target));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__target = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":287 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_best));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_best = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":288 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 288; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 288; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 288; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 288; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_result));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_result = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":289 */
  __pyx_1 = ((PyObject *)__pyx_v_direction);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_4 = PyObject_IsTrue(__pyx_1); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble(2.0); if (!__pyx_6) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
    Py_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_7, 0, Py_None);
    PyTuple_SET_ITEM(__pyx_7, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_7, 2, __pyx_5);
    PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
    __pyx_3 = 0;
    __pyx_5 = 0;
    __pyx_6 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_7); __pyx_7 = 0;
  }
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 289; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":290 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_6, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction = __pyx_6;
  __pyx_6 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":291 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(0); if (!__pyx_7) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__normal));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__normal = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":292 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base._smooth_move = __pyx_v_smooth_move;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":293 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base._smooth_rotation = __pyx_v_smooth_rotation;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":294 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance = 5.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":295 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y = 1.5;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":296 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y2 = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":297 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":298 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_top_view = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":299 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed = 1.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":300 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_RaypickContext)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 300; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context = Py_None;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_target);
  Py_DECREF((PyObject *)__pyx_v_direction);
  return __pyx_r;
}

static PyObject *__pyx_n_clone;
static PyObject *__pyx_n_RaypickContext;
static PyObject *__pyx_n_transform;
static PyObject *__pyx_n_cmp;

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_best_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_best_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_camera = 0;
  struct __pyx_obj_5_soya__World *__pyx_v_root;
  struct __pyx_obj_5_soya__Point *__pyx_v_target;
  struct __pyx_obj_5_soya__Point *__pyx_v_result;
  struct __pyx_obj_5_soya__Point *__pyx_v_best;
  struct __pyx_obj_5_soya__Vector *__pyx_v_direction;
  int __pyx_v_i;
  int __pyx_v_j;
  float __pyx_v_best_dist;
  float __pyx_v_dist;
  float __pyx_v_px;
  float __pyx_v_py;
  float __pyx_v_pz;
  float __pyx_v_a;
  float __pyx_v_old_dirx;
  float __pyx_v_old_diry;
  float __pyx_v_c;
  float __pyx_v_s;
  int __pyx_v_lat;
  int __pyx_v_vert;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  float __pyx_5;
  float __pyx_6;
  int __pyx_7;
  PyObject *__pyx_8 = 0;
  static char *__pyx_argnames[] = {"camera",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_camera)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_camera);
  __pyx_v_root = Py_None; Py_INCREF((PyObject *) __pyx_v_root);
  __pyx_v_target = Py_None; Py_INCREF((PyObject *) __pyx_v_target);
  __pyx_v_result = Py_None; Py_INCREF((PyObject *) __pyx_v_result);
  __pyx_v_best = Py_None; Py_INCREF((PyObject *) __pyx_v_best);
  __pyx_v_direction = Py_None; Py_INCREF((PyObject *) __pyx_v_direction);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_camera), __pyx_ptype_5_soya__TravelingCamera, 1, "camera")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 302; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":310 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__TravelingCamera *)__pyx_v_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_camera))); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 310; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_root));
  __pyx_v_root = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":311 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__target));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_target));
  __pyx_v_target = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__target);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":312 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_result));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_result));
  __pyx_v_result = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":313 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_best));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_best));
  __pyx_v_best = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_best);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":314 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_direction));
  __pyx_v_direction = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_direction);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":316 */
  if (!__Pyx_TypeTest(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target), __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 316; goto __pyx_L1;}
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_target->__pyx_base._parent));
  __pyx_v_target->__pyx_base._parent = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":317 */
  (__pyx_v_target->_matrix[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":318 */
  (__pyx_v_target->_matrix[1]) = ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":319 */
  (__pyx_v_target->_matrix[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":320 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_target), __pyx_n_convert_to); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 320; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 320; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_root));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_root));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 320; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":322 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 322; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 322; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_target));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 322; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":323 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_add_mul_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 323; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 323; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 323; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_direction));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_direction));
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 323; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":324 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_root), __pyx_n_RaypickContext); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance * 0.6)); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_best));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_best));
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context));
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_RaypickContext)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; goto __pyx_L1;}
  Py_DECREF(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context));
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":326 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target), __pyx_n_transform); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_camera));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_camera));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_px = __pyx_4;
  __pyx_2 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_py = __pyx_5;
  __pyx_1 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_pz = __pyx_6;
  if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 326; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":328 */
  __pyx_7 = (((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle != 0);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":329 */
    __pyx_v_c = cos(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":330 */
    __pyx_v_s = sin(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":331 */
    __pyx_v_a = __pyx_v_px;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":332 */
    __pyx_v_px = ((__pyx_v_c * __pyx_v_px) + (__pyx_v_s * __pyx_v_pz));

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":333 */
    __pyx_v_pz = ((__pyx_v_c * __pyx_v_pz) - (__pyx_v_s * __pyx_v_a));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":335 */
  __pyx_v_py = (__pyx_v_py - (((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_top_view * ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance));

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":337 */
  __pyx_7 = (fabs(__pyx_v_px) < 1.0);
  if (__pyx_7) {
    __pyx_7 = (__pyx_v_pz > 0.0);
  }
  if (__pyx_7) {
    __pyx_v_lat = 0;
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_cmp); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    __pyx_1 = PyFloat_FromDouble(__pyx_v_px); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    __pyx_8 = PyTuple_New(2); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_8, 0, __pyx_1);
    PyTuple_SET_ITEM(__pyx_8, 1, __pyx_3);
    __pyx_1 = 0;
    __pyx_3 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_8); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_8); __pyx_8 = 0;
    __pyx_3 = PyNumber_Negative(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_7 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 338; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_lat = __pyx_7;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":339 */
  __pyx_7 = (fabs((__pyx_v_py - 3.0)) < 1.0);
  if (__pyx_7) {
    __pyx_v_vert = 0;
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_cmp); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    __pyx_8 = PyFloat_FromDouble(__pyx_v_py); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    __pyx_1 = PyFloat_FromDouble(3.0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_8);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);
    __pyx_8 = 0;
    __pyx_1 = 0;
    __pyx_8 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyNumber_Negative(__pyx_8); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    Py_DECREF(__pyx_8); __pyx_8 = 0;
    __pyx_7 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 340; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_v_vert = __pyx_7;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":342 */
  __pyx_v_best_dist = ((struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self),((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context,((struct __pyx_obj_5_soya_Position *)__pyx_v_target),__pyx_v_direction,__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":343 */
  __pyx_7 = (__pyx_v_best_dist > (((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance - 0.1));
  if (__pyx_7) {
    __pyx_7 = (__pyx_v_lat == 0);
    if (__pyx_7) {
      __pyx_7 = (__pyx_v_vert == 0);
    }
  }
  if (__pyx_7) {
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    __pyx_r = ((PyObject *)__pyx_v_result);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 344; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_result));
    __pyx_8 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 344; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_8); __pyx_8 = 0;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":346 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_convert_to); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 346; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_camera));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_camera));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 346; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":348 */
  __pyx_v_old_dirx = (__pyx_v_direction->__pyx_base._matrix[0]);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":349 */
  __pyx_v_old_diry = (__pyx_v_direction->__pyx_base._matrix[1]);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":352 */
  (__pyx_v_direction->__pyx_base._matrix[0]) = (__pyx_v_old_dirx - (0.3 * ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed));

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":353 */
  __pyx_v_dist = ((struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self),((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context,((struct __pyx_obj_5_soya_Position *)__pyx_v_target),__pyx_v_direction,__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":354 */
  __pyx_7 = (__pyx_v_lat == (-1));
  if (__pyx_7) {
    __pyx_v_dist = (__pyx_v_dist + 0.1);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":356 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":356 */
    __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 356; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 356; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_result));
    __pyx_2 = PyObject_CallObject(__pyx_8, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 356; goto __pyx_L1;}
    Py_DECREF(__pyx_8); __pyx_8 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":356 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":358 */
  (__pyx_v_direction->__pyx_base._matrix[0]) = (__pyx_v_old_dirx + (0.3 * ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed));

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":359 */
  __pyx_v_dist = ((struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self),((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context,((struct __pyx_obj_5_soya_Position *)__pyx_v_target),__pyx_v_direction,__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":360 */
  __pyx_7 = (__pyx_v_lat == 1);
  if (__pyx_7) {
    __pyx_v_dist = (__pyx_v_dist + 0.1);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":362 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":362 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 362; goto __pyx_L1;}
    __pyx_8 = PyTuple_New(1); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    PyTuple_SET_ITEM(__pyx_8, 0, ((PyObject *)__pyx_v_result));
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_8); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_8); __pyx_8 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":362 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":364 */
  (__pyx_v_direction->__pyx_base._matrix[0]) = __pyx_v_old_dirx;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":365 */
  (__pyx_v_direction->__pyx_base._matrix[1]) = (__pyx_v_old_diry - (0.2 * ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed));

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":366 */
  __pyx_v_dist = ((struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self),((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context,((struct __pyx_obj_5_soya_Position *)__pyx_v_target),__pyx_v_direction,__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":367 */
  __pyx_7 = (__pyx_v_vert == (-1));
  if (__pyx_7) {
    __pyx_v_dist = (__pyx_v_dist + 0.1);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":369 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":369 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 369; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 369; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_result));
    __pyx_8 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 369; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_8); __pyx_8 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":369 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":371 */
  (__pyx_v_direction->__pyx_base._matrix[1]) = (__pyx_v_old_diry + (0.2 * ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed));

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":372 */
  __pyx_v_dist = ((struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self),((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_context,((struct __pyx_obj_5_soya_Position *)__pyx_v_target),__pyx_v_direction,__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":373 */
  __pyx_7 = (__pyx_v_vert == 1);
  if (__pyx_7) {
    __pyx_v_dist = (__pyx_v_dist + 0.1);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":375 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":375 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 375; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 375; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_result));
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 375; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":375 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":390 */
  __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_set_start_end); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 390; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 390; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_target));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_best));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_best));
  __pyx_2 = PyObject_CallObject(__pyx_8, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 390; goto __pyx_L1;}
  Py_DECREF(__pyx_8); __pyx_8 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":392 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_best));
  __pyx_r = ((PyObject *)__pyx_v_best);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.best_position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_target);
  Py_DECREF((PyObject *)__pyx_v_result);
  Py_DECREF((PyObject *)__pyx_v_best);
  Py_DECREF((PyObject *)__pyx_v_direction);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_camera);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_best_direction(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_21_ThirdPersonTraveling_best_direction(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__TravelingCamera *__pyx_v_camera = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"camera",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_camera)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_camera);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_camera), __pyx_ptype_5_soya__TravelingCamera, 1, "camera")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 394; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":396 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction), __pyx_n_clone); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 396; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 396; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_target));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 396; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":397 */
  (((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction->_matrix[1]) = (((((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction->_matrix[1]) + ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y) + ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y2);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":398 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->__direction);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._ThirdPersonTraveling.best_direction");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_camera);
  return __pyx_r;
}

static PyObject *__pyx_n_raypick;
static PyObject *__pyx_n_set_length;
static PyObject *__pyx_n_distance_to;

static float __pyx_f_5_soya_21_ThirdPersonTraveling__check(struct __pyx_obj_5_soya__ThirdPersonTraveling *__pyx_v_self,struct __pyx_obj_5_soya_RaypickContext *__pyx_v_root,struct __pyx_obj_5_soya_Position *__pyx_v_target,struct __pyx_obj_5_soya__Vector *__pyx_v_direction,struct __pyx_obj_5_soya__Point *__pyx_v_result) {
  float __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  int __pyx_7;
  float __pyx_8;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_root);
  Py_INCREF((PyObject *)__pyx_v_target);
  Py_INCREF((PyObject *)__pyx_v_direction);
  Py_INCREF((PyObject *)__pyx_v_result);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":403 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_root), __pyx_n_raypick); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->_distance); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(7); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_target));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_direction));
  PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)__pyx_v_direction));
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 4, __pyx_4);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_result));
  PyTuple_SET_ITEM(__pyx_5, 5, ((PyObject *)__pyx_v_result));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__normal));
  PyTuple_SET_ITEM(__pyx_5, 6, ((PyObject *)__pyx_v_self->__normal));
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_6 = PyObject_IsTrue(__pyx_2); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 403; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_7 = (!__pyx_6);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":404 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_set_length); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 404; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(__pyx_v_self->_distance); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 404; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 404; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 404; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":405 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_clone); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 405; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 405; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_target));
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 405; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":406 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_add_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 406; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 406; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_direction));
    PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_direction));
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 406; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":407 */
    __pyx_r = __pyx_v_self->_distance;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":409 */
  __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_distance_to); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 409; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 409; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_target));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_target));
  __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 409; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_8 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 409; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_8;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._ThirdPersonTraveling._check");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_root);
  Py_DECREF((PyObject *)__pyx_v_target);
  Py_DECREF((PyObject *)__pyx_v_direction);
  Py_DECREF((PyObject *)__pyx_v_result);
  return __pyx_r;
}

static PyObject *__pyx_n_open;

static PyObject *__pyx_k214p;

static char (__pyx_k214[]) = "PIL.Image";

static PyObject *__pyx_f_5_soya_open_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_open_image[] = "open_image(filename) -> Image\n\nCreates and returns a Soya image from file FILENAME.\nThe image is loaded with PIL; the supported image formats are the same than PIL.";
static PyObject *__pyx_f_5_soya_open_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  struct __pyx_obj_5_soya__Image *__pyx_v_image;
  PyObject *__pyx_v_PIL;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF(__pyx_v_filename);
  __pyx_v_image = Py_None; Py_INCREF((PyObject *) __pyx_v_image);
  __pyx_v_PIL = Py_None; Py_INCREF(__pyx_v_PIL);

  /* "/home/jiba/src/soya/model/image.pyx":25 */
  __pyx_1 = __Pyx_Import(__pyx_k214p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 25; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":26 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_image_from_pil); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_open); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_filename);
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_image));
  __pyx_v_image = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":27 */
  Py_INCREF(__pyx_v_filename);
  Py_DECREF(__pyx_v_image->_filename);
  __pyx_v_image->_filename = __pyx_v_filename;

  /* "/home/jiba/src/soya/model/image.pyx":28 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_image));
  __pyx_r = ((PyObject *)__pyx_v_image);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.open_image");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_image);
  Py_DECREF(__pyx_v_PIL);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_n_size;
static PyObject *__pyx_n_mode;
static PyObject *__pyx_n_RGB;
static PyObject *__pyx_n_RGBA;
static PyObject *__pyx_n_L;
static PyObject *__pyx_n_P;
static PyObject *__pyx_n_tostring;
static PyObject *__pyx_n_pixels;

static PyObject *__pyx_k219p;

static char (__pyx_k219[]) = "unknown image mode (%s)";

static PyObject *__pyx_f_5_soya_image_from_pil(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_image_from_pil[] = "image_from_pil(pil_image) -> Image\n\nCreates and returns a Soya image from PIL image PIL_IMAGE.";
static PyObject *__pyx_f_5_soya_image_from_pil(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pil_image = 0;
  struct __pyx_obj_5_soya__Image *__pyx_v_image;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"pil_image",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_pil_image)) return 0;
  Py_INCREF(__pyx_v_pil_image);
  __pyx_v_image = Py_None; Py_INCREF((PyObject *) __pyx_v_image);

  /* "/home/jiba/src/soya/model/image.pyx":35 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 35; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 35; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_image));
  __pyx_v_image = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":36 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_image->width = __pyx_4;
  __pyx_3 = __Pyx_UnpackItem(__pyx_1, 1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_image->height = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_1, 2) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":37 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_n_RGB, &__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {
    __pyx_v_image->nb_color = 3;
    goto __pyx_L2;
  }
  __pyx_3 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 38; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_3, __pyx_n_RGBA, &__pyx_5) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_5 = __pyx_5 == 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_5) {
    __pyx_v_image->nb_color = 4;
    goto __pyx_L2;
  }
  __pyx_1 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 39; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_1, __pyx_n_L, &__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_4) {
    __pyx_v_image->nb_color = 1;
    goto __pyx_L2;
  }
  __pyx_2 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 40; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_n_P, &__pyx_5) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_5 = __pyx_5 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_5) {
    __pyx_v_image->nb_color = 1;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; goto __pyx_L1;}
    __pyx_1 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; goto __pyx_L1;}
    __pyx_2 = PyNumber_Remainder(__pyx_k219p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":42 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_tostring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 42; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(((PyObject *)__pyx_v_image), __pyx_n_pixels, __pyx_2) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 42; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":43 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_image));
  __pyx_r = ((PyObject *)__pyx_v_image);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.image_from_pil");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_image);
  Py_DECREF(__pyx_v_pil_image);
  return __pyx_r;
}

static PyObject *__pyx_n_fromstring;
static PyObject *__pyx_n_transpose;
static PyObject *__pyx_n_FLIP_TOP_BOTTOM;
static PyObject *__pyx_n_save;

static PyObject *__pyx_k220p;

static char (__pyx_k220[]) = "PIL.Image";

static PyObject *__pyx_f_5_soya_screenshot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_screenshot[] = "screenshot(filename = None, x = 0, y = 0, width = soya.get_screen_width(), height = soya.get_screen_height()) -> PIL.Image.Image\n\nTake a screenshot of the soya rendering screen, and return it as a PIL image object.\nIf given, the image is saved under FILENAME.\nYou must have rendered something before (e.g. by calling soya.render, or by running\nan Idler).";
static PyObject *__pyx_f_5_soya_screenshot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_width;
  int __pyx_v_height;
  PyObject *__pyx_v_PIL;
  GLubyte (*__pyx_v_pixels);
  int __pyx_v_size;
  PyObject *__pyx_v_image;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  static char *__pyx_argnames[] = {"filename","x","y","width","height",0};
  __pyx_v_filename = __pyx_k57;
  __pyx_v_x = __pyx_k58;
  __pyx_v_y = __pyx_k59;
  __pyx_v_width = __pyx_k60;
  __pyx_v_height = __pyx_k61;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|Oiiii", __pyx_argnames, &__pyx_v_filename, &__pyx_v_x, &__pyx_v_y, &__pyx_v_width, &__pyx_v_height)) return 0;
  Py_INCREF(__pyx_v_filename);
  __pyx_v_PIL = Py_None; Py_INCREF(__pyx_v_PIL);
  __pyx_v_image = Py_None; Py_INCREF(__pyx_v_image);

  /* "/home/jiba/src/soya/model/image.pyx":52 */
  __pyx_1 = __Pyx_Import(__pyx_k220p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 52; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":55 */
  __pyx_2 = __pyx_v_width;
  if (!__pyx_2) {
    __pyx_2 = __pyx_v_5_soya_renderer->screen_width;
  }
  __pyx_v_width = __pyx_2;

  /* "/home/jiba/src/soya/model/image.pyx":56 */
  __pyx_2 = __pyx_v_height;
  if (!__pyx_2) {
    __pyx_2 = __pyx_v_5_soya_renderer->screen_height;
  }
  __pyx_v_height = __pyx_2;

  /* "/home/jiba/src/soya/model/image.pyx":57 */
  __pyx_v_size = ((3 * __pyx_v_width) * __pyx_v_height);

  /* "/home/jiba/src/soya/model/image.pyx":58 */
  __pyx_v_pixels = ((GLubyte (*))malloc((__pyx_v_size * (sizeof(GLubyte )))));

  /* "/home/jiba/src/soya/model/image.pyx":59 */
  glReadBuffer(GL_FRONT);

  /* "/home/jiba/src/soya/model/image.pyx":60 */
  glReadPixels(__pyx_v_x,__pyx_v_y,__pyx_v_width,__pyx_v_height,GL_RGB,GL_UNSIGNED_BYTE,__pyx_v_pixels);

  /* "/home/jiba/src/soya/model/image.pyx":61 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyInt_FromLong(__pyx_v_width); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_height); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_1 = PyString_FromStringAndSize(((char (*))__pyx_v_pixels),__pyx_v_size); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_INCREF(__pyx_n_RGB);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_RGB);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_5);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_1);
  __pyx_5 = 0;
  __pyx_1 = 0;
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_v_image);
  __pyx_v_image = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":62 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_image, __pyx_n_transpose); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_FLIP_TOP_BOTTOM); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_v_image);
  __pyx_v_image = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":63 */
  free(__pyx_v_pixels);

  /* "/home/jiba/src/soya/model/image.pyx":64 */
  __pyx_2 = __pyx_v_filename == Py_None;
  __pyx_6 = (!__pyx_2);
  if (__pyx_6) {
    __pyx_4 = PyObject_GetAttr(__pyx_v_image, __pyx_n_save); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 64; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 64; goto __pyx_L1;}
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_filename);
    __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 64; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":65 */
  Py_INCREF(__pyx_v_image);
  __pyx_r = __pyx_v_image;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.screenshot");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_PIL);
  Py_DECREF(__pyx_v_image);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Image___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Image___init__[] = "Image(pixels = None, int width = 0, int height = 0, int nb_color = 0) -> Image\n\nCreates a Soya image of dimension WIDTH and HEIGHT, with NB_COLOR color channels\n(4 for RGBA), and with data PIXELS (a raw image in a string).\n\nSee Image.get(filename), open_image(filename) or image_from_pil(pil_image) for higher\nlevel image loading functions.";
static int __pyx_f_5_soya_6_Image___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pixels = 0;
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_nb_color;
  int __pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"pixels","width","height","nb_color",0};
  __pyx_v_pixels = __pyx_k62;
  __pyx_v_width = __pyx_k63;
  __pyx_v_height = __pyx_k64;
  __pyx_v_nb_color = __pyx_k65;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|Oiii", __pyx_argnames, &__pyx_v_pixels, &__pyx_v_width, &__pyx_v_height, &__pyx_v_nb_color)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_pixels);

  /* "/home/jiba/src/soya/model/image.pyx":85 */
  __pyx_1 = (__pyx_v_nb_color == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/image.pyx":86 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels = 0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/image.pyx":88 */
    __pyx_1 = __pyx_v_pixels == Py_None;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/image.pyx":89 */
      ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels = ((GLubyte (*))malloc((((__pyx_v_width * __pyx_v_height) * __pyx_v_nb_color) * (sizeof(GLubyte )))));
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/image.pyx":91 */
      ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels = ((GLubyte (*))__pyx_f_5_soya_dup(PyString_AS_STRING(__pyx_v_pixels),((__pyx_v_width * __pyx_v_height) * __pyx_v_nb_color)));
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/image.pyx":92 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width = __pyx_v_width;

    /* "/home/jiba/src/soya/model/image.pyx":93 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height = __pyx_v_height;

    /* "/home/jiba/src/soya/model/image.pyx":94 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color = __pyx_v_nb_color;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Image.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_pixels);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Image___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_6_Image___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/image.pyx":97 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Image.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_6_Image___getcstate__(struct __pyx_obj_5_soya__Image *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/image.pyx":102 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/image.pyx":103 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->nb_color);

  /* "/home/jiba/src/soya/model/image.pyx":104 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->width);

  /* "/home/jiba/src/soya/model/image.pyx":105 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->height);

  /* "/home/jiba/src/soya/model/image.pyx":106 */
  chunk_add_chars_endian_safe(__pyx_v_chunk,((char (*))__pyx_v_self->_pixels),((__pyx_v_self->nb_color * __pyx_v_self->width) * __pyx_v_self->height));

  /* "/home/jiba/src/soya/model/image.pyx":107 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 107; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 107; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_v_self->_filename);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self->_filename);
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Image.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_tuple;

static void __pyx_f_5_soya_6_Image___setcstate__(struct __pyx_obj_5_soya__Image *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/image.pyx":112 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 112; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 112; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 112; goto __pyx_L1;}
  Py_INCREF(__pyx_v_cstate);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cstate);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 112; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 112; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/image.pyx":113 */
    __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 113; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 113; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_v_self->_filename);
    __pyx_v_self->_filename = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/image.pyx":114 */
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 114; goto __pyx_L1;}
    __pyx_1 = PyObject_GetItem(__pyx_v_cstate, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 114; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_cstate);
    __pyx_v_cstate = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":116 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/image.pyx":117 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->nb_color));

  /* "/home/jiba/src/soya/model/image.pyx":118 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->width));

  /* "/home/jiba/src/soya/model/image.pyx":119 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->height));

  /* "/home/jiba/src/soya/model/image.pyx":120 */
  __pyx_v_self->_pixels = ((GLubyte (*))malloc((((__pyx_v_self->nb_color * __pyx_v_self->width) * __pyx_v_self->height) * (sizeof(GLubyte )))));

  /* "/home/jiba/src/soya/model/image.pyx":121 */
  chunk_get_chars_endian_safe(__pyx_v_chunk,((char (*))__pyx_v_self->_pixels),((__pyx_v_self->nb_color * __pyx_v_self->width) * __pyx_v_self->height));

  /* "/home/jiba/src/soya/model/image.pyx":122 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Image.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_6_Image___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Image___deepcopy__[] = "Images are immutable.";
static PyObject *__pyx_f_5_soya_6_Image___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_memo = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"memo",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_memo)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_memo);

  /* "/home/jiba/src/soya/model/image.pyx":126 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Image.__deepcopy__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_memo);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Image_6pixels___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Image_6pixels___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/image.pyx":130 */
  __pyx_1 = PyString_FromStringAndSize(((char (*))((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels),((((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color * ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width) * ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height)); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 130; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Image.pixels.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Image_6pixels___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_string); /*proto*/
static int __pyx_f_5_soya_6_Image_6pixels___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_string) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_string);

  /* "/home/jiba/src/soya/model/image.pyx":132 */
  ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels = ((GLubyte (*))__pyx_f_5_soya_dup(PyString_AS_STRING(__pyx_v_string),((((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color * ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width) * ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height)));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Image.pixels.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_string);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Image_has_border(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_6_Image_has_border(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyInt_FromLong((((struct __pyx_vtabstruct_5_soya__Image *)((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->__pyx_base.__pyx_vtab)->check_for_gl(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)) == 2)); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Image.has_border");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static char (__pyx_k222[]) = "_Image.check_for_gl() -> int\n\nReturns 1 if the image is suitable for OpenGL (=if both dimension are power of 2).\nReturns 2 if the image is suitable for OpenGL, with a border (=if both dimension are power of 2 + 2 (for the border)).\nElse returns 0.";

static int __pyx_f_5_soya_6_Image_check_for_gl(struct __pyx_obj_5_soya__Image *__pyx_v_self) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/image.pyx":137 */
  __pyx_k222;

  /* "/home/jiba/src/soya/model/image.pyx":142 */
  __pyx_1 = (__pyx_v_self->width == __pyx_f_5_soya_power_of_2(__pyx_v_self->width));
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->height == __pyx_f_5_soya_power_of_2(__pyx_v_self->height));
  }
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":143 */
  __pyx_1 = ((__pyx_v_self->width - 2) == __pyx_f_5_soya_power_of_2((__pyx_v_self->width - 2)));
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_self->height - 2) == __pyx_f_5_soya_power_of_2((__pyx_v_self->height - 2)));
  }
  if (__pyx_1) {
    __pyx_r = 2;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/image.pyx":144 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Image.check_for_gl");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k224p;

static char (__pyx_k223[]) = "_Image.typ() -> GLuint\n\nReturns the image type, depending on the number of color channels,\ni.e. either GL_LUMINANCE, GL_RGB or GL_RGBA.";
static char (__pyx_k224[]) = "unknown image number of color (%s)";

static GLuint __pyx_f_5_soya_6_Image_typ(struct __pyx_obj_5_soya__Image *__pyx_v_self) {
  GLuint __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/image.pyx":158 */
  __pyx_k223;

  /* "/home/jiba/src/soya/model/image.pyx":162 */
  __pyx_1 = (__pyx_v_self->nb_color == 1);
  if (__pyx_1) {
    __pyx_r = GL_LUMINANCE;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->nb_color == 3);
  if (__pyx_1) {
    __pyx_r = GL_RGB;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->nb_color == 4);
  if (__pyx_1) {
    __pyx_r = GL_RGBA;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":165 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_self->nb_color); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_4 = PyNumber_Remainder(__pyx_k224p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 165; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __Pyx_Raise(__pyx_4, 0, 0);
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  {__pyx_filename = __pyx_f[14]; __pyx_lineno = 165; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Image.typ");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k226p;

static char (__pyx_k225[]) = "_Image.internal_format() -> GLuint\n\nReturns the image internal format, depending on the number of color channels and the\nrendering quality.";
static char (__pyx_k226[]) = "unknown image number of color (%s)";

static GLuint __pyx_f_5_soya_6_Image_internal_format(struct __pyx_obj_5_soya__Image *__pyx_v_self) {
  GLuint __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/image.pyx":168 */
  __pyx_k225;

  /* "/home/jiba/src/soya/model/image.pyx":172 */
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_LOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/image.pyx":173 */
    __pyx_1 = (__pyx_v_self->nb_color == 1);
    if (__pyx_1) {
      __pyx_r = GL_LUMINANCE;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_self->nb_color == 3);
    if (__pyx_1) {
      __pyx_r = GL_RGB;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_self->nb_color == 4);
    if (__pyx_1) {
      __pyx_r = GL_RGBA;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_MEDIUM);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/image.pyx":177 */
    __pyx_1 = (__pyx_v_self->nb_color == 1);
    if (__pyx_1) {
      __pyx_r = GL_LUMINANCE8;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_1 = (__pyx_v_self->nb_color == 3);
    if (__pyx_1) {
      __pyx_r = GL_RGB8;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_1 = (__pyx_v_self->nb_color == 4);
    if (__pyx_1) {
      __pyx_r = GL_RGBA8;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_HIGH);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/image.pyx":181 */
    __pyx_1 = (__pyx_v_self->nb_color == 1);
    if (__pyx_1) {
      __pyx_r = GL_LUMINANCE16;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_1 = (__pyx_v_self->nb_color == 3);
    if (__pyx_1) {
      __pyx_r = GL_RGB16;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_1 = (__pyx_v_self->nb_color == 4);
    if (__pyx_1) {
      __pyx_r = GL_RGBA16;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":184 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_self->nb_color); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; goto __pyx_L1;}
  __pyx_4 = PyNumber_Remainder(__pyx_k226p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __Pyx_Raise(__pyx_4, 0, 0);
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  {__pyx_filename = __pyx_f[14]; __pyx_lineno = 184; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Image.internal_format");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k227p;

static char (__pyx_k227[]) = "<Image %s>";

static PyObject *__pyx_f_5_soya_6_Image___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Image___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyNumber_Remainder(__pyx_k227p, ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 186; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Image.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k228p;

static char (__pyx_k228[]) = "PIL.Image";

static PyObject *__pyx_f_5_soya_6_Image_to_pil(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_6_Image_to_pil(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_PIL;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_PIL = Py_None; Py_INCREF(__pyx_v_PIL);

  /* "/home/jiba/src/soya/model/image.pyx":189 */
  __pyx_1 = __Pyx_Import(__pyx_k228p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 189; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":190 */
  __pyx_2 = (((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color == 1);
  if (__pyx_2) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    __pyx_1 = 0;
    __pyx_4 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_pixels); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    Py_INCREF(__pyx_n_L);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_L);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_5);
    PyTuple_SET_ITEM(__pyx_4, 2, __pyx_1);
    __pyx_5 = 0;
    __pyx_1 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_r = __pyx_5;
    __pyx_5 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_2 = (((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color == 3);
  if (__pyx_2) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_4 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_5 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_pixels); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    Py_INCREF(__pyx_n_RGB);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_n_RGB);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);
    PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
    __pyx_1 = 0;
    __pyx_4 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 191; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_r = __pyx_1;
    __pyx_1 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_2 = (((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color == 4);
  if (__pyx_2) {
    __pyx_4 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_5 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
    __pyx_5 = 0;
    __pyx_1 = 0;
    __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_pixels); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    Py_INCREF(__pyx_n_RGBA);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_RGBA);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4);
    PyTuple_SET_ITEM(__pyx_1, 2, __pyx_5);
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 192; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_r = __pyx_4;
    __pyx_4 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Image.to_pil");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_PIL);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_power_of_2(int __pyx_v_i) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/image.pyx":196 */
  __pyx_1 = (__pyx_v_i <= 1);
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":197 */
  __pyx_1 = (__pyx_v_i <= 2);
  if (__pyx_1) {
    __pyx_r = 2;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/image.pyx":198 */
  __pyx_1 = (__pyx_v_i <= 4);
  if (__pyx_1) {
    __pyx_r = 4;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/image.pyx":199 */
  __pyx_1 = (__pyx_v_i <= 8);
  if (__pyx_1) {
    __pyx_r = 8;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/image.pyx":200 */
  __pyx_1 = (__pyx_v_i <= 16);
  if (__pyx_1) {
    __pyx_r = 16;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/image.pyx":201 */
  __pyx_1 = (__pyx_v_i <= 32);
  if (__pyx_1) {
    __pyx_r = 32;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/image.pyx":202 */
  __pyx_1 = (__pyx_v_i <= 64);
  if (__pyx_1) {
    __pyx_r = 64;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/image.pyx":203 */
  __pyx_1 = (__pyx_v_i <= 128);
  if (__pyx_1) {
    __pyx_r = 128;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/image.pyx":204 */
  __pyx_1 = (__pyx_v_i <= 256);
  if (__pyx_1) {
    __pyx_r = 256;
    goto __pyx_L0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/image.pyx":205 */
  __pyx_1 = (__pyx_v_i <= 512);
  if (__pyx_1) {
    __pyx_r = 512;
    goto __pyx_L0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/image.pyx":206 */
  __pyx_1 = (__pyx_v_i <= 1024);
  if (__pyx_1) {
    __pyx_r = 1024;
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/model/image.pyx":207 */
  __pyx_1 = (__pyx_v_i <= 2048);
  if (__pyx_1) {
    __pyx_r = 2048;
    goto __pyx_L0;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/model/image.pyx":208 */
  __pyx_r = 4096;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.power_of_2");
  __pyx_L0:;
  return __pyx_r;
}

static char (__pyx_k232[]) = "pixels_scale_down_2(int nb_color, GLuint* w, GLuint* h, int border, GLubyte* pixels) -> GLubyte*\n\nReturns a reduced version of an image. Each dimension is divided by 2.\nThe image is given by PIXELS, NB_COLOR. W and H are pointers on the dimensions (i.e. the old image dimension at the beginning and then half of the image dimensions).\nThe returned image is malloc\'ed, and must be free\'d by the caller.\n";

static GLubyte (*__pyx_f_5_soya_pixels_scale_down_2(int __pyx_v_nb_color,GLuint (*__pyx_v_w),GLuint (*__pyx_v_h),int __pyx_v_border,GLubyte (*__pyx_v_pixels))) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_m;
  int __pyx_v_x;
  int __pyx_v_y;
  GLubyte (*__pyx_v_new_pixels);
  GLubyte (*__pyx_r);
  int __pyx_1;
  unsigned long __pyx_2;
  unsigned long __pyx_3;

  /* "/home/jiba/src/soya/model/image.pyx":211 */
  __pyx_k232;

  /* "/home/jiba/src/soya/model/image.pyx":220 */
  __pyx_1 = ((__pyx_v_w[0]) == 1);
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_h[0]) == 1);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/image.pyx":221 */
    __pyx_1 = ((__pyx_v_w[0]) != 1);
    if (__pyx_1) {
      (__pyx_v_w[0]) = ((__pyx_v_w[0]) >> 1);
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/image.pyx":222 */
    __pyx_1 = ((__pyx_v_h[0]) != 1);
    if (__pyx_1) {
      (__pyx_v_h[0]) = ((__pyx_v_h[0]) >> 1);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/image.pyx":223 */
    __pyx_v_new_pixels = ((GLubyte (*))malloc((((((__pyx_v_h[0]) + (2 * __pyx_v_border)) * ((__pyx_v_w[0]) + (2 * __pyx_v_border))) * __pyx_v_nb_color) * (sizeof(GLubyte )))));

    /* "/home/jiba/src/soya/model/image.pyx":224 */
    __pyx_2 = ((__pyx_v_h[0]) + (2 * __pyx_v_border));
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/image.pyx":225 */
      __pyx_3 = ((__pyx_v_w[0]) + (2 * __pyx_v_border));
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {

        /* "/home/jiba/src/soya/model/image.pyx":226 */
        for (__pyx_v_m = 0; __pyx_v_m < __pyx_v_nb_color; ++__pyx_v_m) {

          /* "/home/jiba/src/soya/model/image.pyx":227 */
          (__pyx_v_new_pixels[(((__pyx_v_i + ((__pyx_v_w[0]) * __pyx_v_j)) * __pyx_v_nb_color) + __pyx_v_m)]) = (__pyx_v_pixels[((((__pyx_v_i + ((__pyx_v_w[0]) * __pyx_v_j)) * __pyx_v_nb_color) * 2) + __pyx_v_m)]);
          __pyx_L9:;
        }
        __pyx_L10:;
        __pyx_L7:;
      }
      __pyx_L8:;
      __pyx_L5:;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/image.pyx":229 */
    (__pyx_v_w[0]) = ((__pyx_v_w[0]) >> 1);

    /* "/home/jiba/src/soya/model/image.pyx":230 */
    (__pyx_v_h[0]) = ((__pyx_v_h[0]) >> 1);

    /* "/home/jiba/src/soya/model/image.pyx":231 */
    __pyx_v_new_pixels = ((GLubyte (*))malloc((((((__pyx_v_h[0]) + (2 * __pyx_v_border)) * ((__pyx_v_w[0]) + (2 * __pyx_v_border))) * __pyx_v_nb_color) * (sizeof(GLubyte )))));

    /* "/home/jiba/src/soya/model/image.pyx":234 */
    __pyx_3 = ((__pyx_v_h[0]) + (2 * __pyx_v_border));
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/image.pyx":235 */
      __pyx_v_y = (2 * __pyx_v_j);

      /* "/home/jiba/src/soya/model/image.pyx":236 */
      __pyx_2 = ((__pyx_v_w[0]) + (2 * __pyx_v_border));
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

        /* "/home/jiba/src/soya/model/image.pyx":237 */
        __pyx_v_x = (2 * __pyx_v_i);

        /* "/home/jiba/src/soya/model/image.pyx":238 */
        for (__pyx_v_m = 0; __pyx_v_m < __pyx_v_nb_color; ++__pyx_v_m) {

          /* "/home/jiba/src/soya/model/image.pyx":239 */
          (__pyx_v_new_pixels[(((__pyx_v_i + ((__pyx_v_w[0]) * __pyx_v_j)) * __pyx_v_nb_color) + __pyx_v_m)]) = ((GLubyte )((((((float )(__pyx_v_pixels[(((__pyx_v_x + ((2 * (__pyx_v_w[0])) * __pyx_v_y)) * __pyx_v_nb_color) + __pyx_v_m)])) + ((float )(__pyx_v_pixels[((((__pyx_v_x + 1) + ((2 * (__pyx_v_w[0])) * __pyx_v_y)) * __pyx_v_nb_color) + __pyx_v_m)]))) + ((float )(__pyx_v_pixels[(((__pyx_v_x + ((2 * (__pyx_v_w[0])) * (__pyx_v_y + 1))) * __pyx_v_nb_color) + __pyx_v_m)]))) + ((float )(__pyx_v_pixels[((((__pyx_v_x + 1) + ((2 * (__pyx_v_w[0])) * (__pyx_v_y + 1))) * __pyx_v_nb_color) + __pyx_v_m)]))) / 4.0));
          __pyx_L15:;
        }
        __pyx_L16:;
        __pyx_L13:;
      }
      __pyx_L14:;
      __pyx_L11:;
    }
    __pyx_L12:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":245 */
  __pyx_r = __pyx_v_new_pixels;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.pixels_scale_down_2");
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_k233p;
static PyObject *__pyx_k234p;

static char (__pyx_k233[]) = "";
static char (__pyx_k234[]) = "Image dimensions must be power of 2 (dimensions are %s x %s)";

static int __pyx_f_5_soya_9_Material___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9_Material___init__[] = "Material(Image texture) -> Material\n\nCreates a new Material with texture TEXTURE.";
static int __pyx_f_5_soya_9_Material___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Image *__pyx_v_texture = 0;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"texture",0};
  __pyx_v_texture = __pyx_k66;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_texture)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_texture);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_texture), __pyx_ptype_5_soya__Image, 1, "texture")) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 30; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":34 */
  ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->shininess = 128.0;

  /* "/home/jiba/src/soya/model/material.pyx":35 */
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[0]) = 1.0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[1]) = 1.0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[2]) = 1.0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[3]) = 1.0;

  /* "/home/jiba/src/soya/model/material.pyx":36 */
  Py_INCREF(__pyx_k233p);
  Py_DECREF(((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_filename);
  ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_filename = __pyx_k233p;

  /* "/home/jiba/src/soya/model/material.pyx":37 */
  __pyx_1 = ((PyObject *)__pyx_v_texture) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/material.pyx":38 */
    __pyx_1 = (((struct __pyx_vtabstruct_5_soya__Image *)__pyx_v_texture->__pyx_base.__pyx_vtab)->check_for_gl(__pyx_v_texture) == 0);
    if (__pyx_1) {
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_texture->width); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(__pyx_v_texture->height); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
      __pyx_4 = 0;
      __pyx_5 = 0;
      __pyx_4 = PyNumber_Remainder(__pyx_k234p, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
      __pyx_4 = 0;
      __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __Pyx_Raise(__pyx_6, 0, 0);
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/material.pyx":39 */
    Py_INCREF(((PyObject *)__pyx_v_texture));
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture));
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture = ((PyObject *)__pyx_v_texture);

    /* "/home/jiba/src/soya/model/material.pyx":40 */
    ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_compute_alpha(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

    /* "/home/jiba/src/soya/model/material.pyx":41 */
    ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Material.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_texture);
  return __pyx_r;
}

static void __pyx_f_5_soya_9_Material___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_9_Material___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":44 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_id != 0);
  if (__pyx_1) {
    glDeleteTextures(1,(&((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_id));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_9_Material___getcstate__(struct __pyx_obj_5_soya__Material *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":49 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/material.pyx":50 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/material.pyx":51 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->shininess);

  /* "/home/jiba/src/soya/model/material.pyx":52 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_diffuse,4);

  /* "/home/jiba/src/soya/model/material.pyx":53 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_specular,4);

  /* "/home/jiba/src/soya/model/material.pyx":54 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_emissive,4);

  /* "/home/jiba/src/soya/model/material.pyx":55 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 55; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 55; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_v_self->_filename);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self->_filename);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_texture));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_self->_texture));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Material.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_9_Material___setcstate__(struct __pyx_obj_5_soya__Material *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/material.pyx":62 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_filename);
  __pyx_v_self->_filename = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 62; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_texture));
  __pyx_v_self->_texture = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 3) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 62; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":63 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/material.pyx":64 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/model/material.pyx":65 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->shininess));

  /* "/home/jiba/src/soya/model/material.pyx":66 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_diffuse,4);

  /* "/home/jiba/src/soya/model/material.pyx":67 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_specular,4);

  /* "/home/jiba/src/soya/model/material.pyx":68 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_emissive,4);

  /* "/home/jiba/src/soya/model/material.pyx":69 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Material.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static char (__pyx_k235[]) = "_Material._pack(int option) -> Pack*\n\nReturns a pack corresponding to this material and the given OPTION flags.\nA pack is a couple (material, drawing option) (see below).\nA new pack is created if needed, but calling this method with the same arguments will\nreturn the same pack.\nYou shouldn\'t free the returned pack.";

static struct __pyx_t_5_soya__Pack (*__pyx_f_5_soya_9_Material__pack(struct __pyx_obj_5_soya__Material *__pyx_v_self,int __pyx_v_option)) {
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  int __pyx_v_opt;
  int __pyx_v_i;
  struct __pyx_t_5_soya__Pack (*__pyx_r);
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":77 */
  __pyx_k235;

  /* "/home/jiba/src/soya/model/material.pyx":86 */
  __pyx_v_opt = (__pyx_v_option & __pyx_e_5_soya_PACK_OPTIONS);

  /* "/home/jiba/src/soya/model/material.pyx":88 */
  __pyx_1 = __pyx_v_self->_nb_packs;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/material.pyx":89 */
    __pyx_v_pack = (__pyx_v_self->_packs[__pyx_v_i]);

    /* "/home/jiba/src/soya/model/material.pyx":90 */
    __pyx_2 = (__pyx_v_pack->option == __pyx_v_opt);
    if (__pyx_2) {
      __pyx_r = __pyx_v_pack;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/material.pyx":92 */
  __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))malloc((sizeof(struct __pyx_t_5_soya__Pack ))));

  /* "/home/jiba/src/soya/model/material.pyx":93 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 93; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_self));
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_2 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_v_pack->material_id = __pyx_2;

  /* "/home/jiba/src/soya/model/material.pyx":94 */
  __pyx_v_pack->option = __pyx_v_opt;

  /* "/home/jiba/src/soya/model/material.pyx":96 */
  __pyx_v_pack->batched_faces = 0;

  /* "/home/jiba/src/soya/model/material.pyx":97 */
  __pyx_v_pack->secondpass = 0;
  __pyx_v_pack->alpha = 0;

  /* "/home/jiba/src/soya/model/material.pyx":98 */
  __pyx_v_self->_packs = ((struct __pyx_t_5_soya__Pack (*(*)))realloc(__pyx_v_self->_packs,((__pyx_v_self->_nb_packs + 1) * (sizeof(struct __pyx_t_5_soya__Pack (*))))));

  /* "/home/jiba/src/soya/model/material.pyx":99 */
  (__pyx_v_self->_packs[__pyx_v_self->_nb_packs]) = __pyx_v_pack;

  /* "/home/jiba/src/soya/model/material.pyx":100 */
  __pyx_v_self->_nb_packs = (__pyx_v_self->_nb_packs + 1);

  /* "/home/jiba/src/soya/model/material.pyx":101 */
  __pyx_r = __pyx_v_pack;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._Material._pack");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static char (__pyx_k236[]) = "_Material._init_texture()\n\nInits the texture, by creating an OpenGL texture name, and setting the different options\ncorresponding to the material attributes (texture, clamp) and the quality level (mipmap).";

static void __pyx_f_5_soya_9_Material__init_texture(struct __pyx_obj_5_soya__Material *__pyx_v_self) {
  int __pyx_v_border;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":104 */
  __pyx_k236;

  /* "/home/jiba/src/soya/model/material.pyx":110 */
  __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_INITED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":111 */
    __pyx_1 = ((PyObject *)__pyx_v_self->_texture) == Py_None;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/material.pyx":112 */
      __pyx_1 = (__pyx_v_self->_id != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":113 */
        glDeleteTextures(1,(&__pyx_v_self->_id));

        /* "/home/jiba/src/soya/model/material.pyx":114 */
        __pyx_v_self->_id = 0;
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/material.pyx":117 */
      __pyx_1 = (__pyx_v_self->_id == 0);
      if (__pyx_1) {
        glGenTextures(1,(&__pyx_v_self->_id));
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/model/material.pyx":118 */
      glPushAttrib(GL_TEXTURE_BIT);

      /* "/home/jiba/src/soya/model/material.pyx":119 */
      glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_id);

      /* "/home/jiba/src/soya/model/material.pyx":120 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":121 */
        glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/material.pyx":123 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_CLAMP);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":124 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);

        /* "/home/jiba/src/soya/model/material.pyx":125 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
        goto __pyx_L7;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/material.pyx":127 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);

        /* "/home/jiba/src/soya/model/material.pyx":128 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/model/material.pyx":130 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_BORDER);
      if (__pyx_1) {
        __pyx_v_border = 1;
        goto __pyx_L8;
      }
      /*else*/ {
        __pyx_v_border = 0;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/model/material.pyx":133 */
      __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_USE_MIPMAP);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_MIPMAP);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":134 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);

        /* "/home/jiba/src/soya/model/material.pyx":135 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

        /* "/home/jiba/src/soya/model/material.pyx":136 */
        ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->__pyx_base.__pyx_vtab)->_build_2D_mipmaps(__pyx_v_self,__pyx_v_border);
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/material.pyx":138 */
        __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_CLAMP);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_border == 0);
        }
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/material.pyx":140 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

          /* "/home/jiba/src/soya/model/material.pyx":141 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
          goto __pyx_L10;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/material.pyx":143 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

          /* "/home/jiba/src/soya/model/material.pyx":144 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/model/material.pyx":146 */
        glTexImage2D(GL_TEXTURE_2D,0,((struct __pyx_vtabstruct_5_soya__Image *)__pyx_v_self->_texture->__pyx_base.__pyx_vtab)->internal_format(__pyx_v_self->_texture),__pyx_v_self->_texture->width,__pyx_v_self->_texture->height,__pyx_v_border,((struct __pyx_vtabstruct_5_soya__Image *)__pyx_v_self->_texture->__pyx_base.__pyx_vtab)->typ(__pyx_v_self->_texture),GL_UNSIGNED_BYTE,__pyx_v_self->_texture->_pixels);
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/model/material.pyx":151 */
      glPopAttrib();
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Material._init_texture");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static char (__pyx_k237[]) = "_Material._build_2D_mipmaps(int border)\n\nCreates the mipmap textures, and set them up in this material\'s OpenGL texture name.";

static void __pyx_f_5_soya_9_Material__build_2D_mipmaps(struct __pyx_obj_5_soya__Material *__pyx_v_self,int __pyx_v_border) {
  GLuint __pyx_v_w;
  GLuint __pyx_v_h;
  GLuint __pyx_v_level;
  GLubyte (*__pyx_v_pixels);
  GLubyte (*__pyx_v_new_pixels);
  int __pyx_v_typ;
  int __pyx_v_internal_format;
  long __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":155 */
  __pyx_k237;

  /* "/home/jiba/src/soya/model/material.pyx":164 */
  __pyx_v_w = (__pyx_v_self->_texture->width - (2 * __pyx_v_border));

  /* "/home/jiba/src/soya/model/material.pyx":165 */
  __pyx_v_h = (__pyx_v_self->_texture->height - (2 * __pyx_v_border));

  /* "/home/jiba/src/soya/model/material.pyx":166 */
  __pyx_v_level = 0;

  /* "/home/jiba/src/soya/model/material.pyx":167 */
  __pyx_v_pixels = __pyx_v_self->_texture->_pixels;

  /* "/home/jiba/src/soya/model/material.pyx":168 */
  __pyx_v_typ = ((struct __pyx_vtabstruct_5_soya__Image *)__pyx_v_self->_texture->__pyx_base.__pyx_vtab)->typ(__pyx_v_self->_texture);

  /* "/home/jiba/src/soya/model/material.pyx":169 */
  __pyx_v_internal_format = ((struct __pyx_vtabstruct_5_soya__Image *)__pyx_v_self->_texture->__pyx_base.__pyx_vtab)->internal_format(__pyx_v_self->_texture);

  /* "/home/jiba/src/soya/model/material.pyx":171 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/material.pyx":172 */
    glTexImage2D(GL_TEXTURE_2D,__pyx_v_level,__pyx_v_internal_format,(__pyx_v_w + (2 * __pyx_v_border)),(__pyx_v_h + (2 * __pyx_v_border)),__pyx_v_border,__pyx_v_typ,GL_UNSIGNED_BYTE,__pyx_v_pixels);

    /* "/home/jiba/src/soya/model/material.pyx":173 */
    __pyx_2 = (__pyx_v_w == 1);
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_h == 1);
    }
    if (__pyx_2) {
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/material.pyx":175 */
    __pyx_v_new_pixels = __pyx_f_5_soya_pixels_scale_down_2(__pyx_v_self->_texture->nb_color,(&__pyx_v_w),(&__pyx_v_h),__pyx_v_border,__pyx_v_pixels);

    /* "/home/jiba/src/soya/model/material.pyx":176 */
    __pyx_2 = (__pyx_v_pixels != __pyx_v_self->_texture->_pixels);
    if (__pyx_2) {
      free(__pyx_v_pixels);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/material.pyx":177 */
    __pyx_v_pixels = __pyx_v_new_pixels;

    /* "/home/jiba/src/soya/model/material.pyx":179 */
    __pyx_v_level = (__pyx_v_level + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/material.pyx":181 */
  __pyx_2 = (__pyx_v_pixels != __pyx_v_self->_texture->_pixels);
  if (__pyx_2) {
    free(__pyx_v_pixels);
    goto __pyx_L6;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Material._build_2D_mipmaps");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static char (__pyx_k238[]) = "_Material._compute_alpha()\n\nComputes wether this material use alpha blending, or mask-based transparency,\nand set the corresponding flags (MATERIAL_ALPHA, MATERIAL_MASK)\nin the _option attribute.";

static void __pyx_f_5_soya_9_Material__compute_alpha(struct __pyx_obj_5_soya__Material *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":184 */
  __pyx_k238;

  /* "/home/jiba/src/soya/model/material.pyx":190 */
  __pyx_v_self->_option = (__pyx_v_self->_option & (~(__pyx_e_5_soya_MATERIAL_ALPHA | __pyx_e_5_soya_MATERIAL_MASK)));

  /* "/home/jiba/src/soya/model/material.pyx":191 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING);
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_self->_diffuse[3]) < (1.0 - EPSILON));
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":192 */
    __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MATERIAL_ALPHA);
    goto __pyx_L2;
  }
  __pyx_2 = ((PyObject *)__pyx_v_self->_texture) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_texture->nb_color == 4);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":195 */
    __pyx_2 = (__pyx_v_self->_texture->width * __pyx_v_self->_texture->height);
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/material.pyx":196 */
      __pyx_1 = ((__pyx_v_self->_texture->_pixels[((4 * __pyx_v_i) + 3)]) != 0);
      if (__pyx_1) {
        __pyx_1 = ((__pyx_v_self->_texture->_pixels[((4 * __pyx_v_i) + 3)]) != 255);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":197 */
        __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MATERIAL_ALPHA);

        /* "/home/jiba/src/soya/model/material.pyx":198 */
        goto __pyx_L4;
        goto __pyx_L5;
      }
      __pyx_L5:;
      __pyx_L3:;
    }
    /*else*/ {
      __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MATERIAL_MASK);
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Material._compute_alpha");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static char (__pyx_k239[]) = "_Material._activate()\n\nSet this material as the current activated one. The material properties will apply to\nany further OpenGL drawing.\nThe previously active material is inactivated first. A single material can be active\nat the same time ; you can get it with renderer.current_material.";

static void __pyx_f_5_soya_9_Material__activate(struct __pyx_obj_5_soya__Material *__pyx_v_self) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":202 */
  __pyx_k239;

  /* "/home/jiba/src/soya/model/material.pyx":209 */
  __pyx_1 = ((PyObject *)__pyx_v_self) == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/material.pyx":210 */
    ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya_renderer->current_material->__pyx_base.__pyx_vtab)->_inactivate(__pyx_v_5_soya_renderer->current_material);

    /* "/home/jiba/src/soya/model/material.pyx":211 */
    Py_INCREF(((PyObject *)__pyx_v_self));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->current_material));
    __pyx_v_5_soya_renderer->current_material = ((PyObject *)__pyx_v_self);

    /* "/home/jiba/src/soya/model/material.pyx":212 */
    __pyx_1 = ((PyObject *)__pyx_v_self->_texture) == Py_None;
    if (__pyx_1) {
      glDisable(GL_TEXTURE_2D);
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/material.pyx":214 */
      __pyx_2 = (__pyx_v_self->_id == 0);
      if (__pyx_2) {
        ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->__pyx_base.__pyx_vtab)->_init_texture(__pyx_v_self);
        goto __pyx_L4;
      }
      __pyx_L4:;

      /* "/home/jiba/src/soya/model/material.pyx":215 */
      glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_id);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/material.pyx":217 */
    __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_SEPARATE_SPECULAR);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_5_soya_quality != __pyx_e_5_soya_QUALITY_LOW);
    }
    if (__pyx_1) {
      glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/material.pyx":219 */
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,__pyx_v_self->shininess);

    /* "/home/jiba/src/soya/model/material.pyx":220 */
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,__pyx_v_self->_specular);

    /* "/home/jiba/src/soya/model/material.pyx":221 */
    __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_MASK);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/material.pyx":222 */
      glDisable(GL_ALPHA_TEST);

      /* "/home/jiba/src/soya/model/material.pyx":223 */
      glAlphaFunc(GL_NOTEQUAL,0.0);

      /* "/home/jiba/src/soya/model/material.pyx":224 */
      glEnable(GL_ALPHA_TEST);

      /* "/home/jiba/src/soya/model/material.pyx":225 */
      glDepthMask(GL_TRUE);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/material.pyx":226 */
    __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/material.pyx":227 */
      glBlendFunc(GL_SRC_ALPHA,GL_ONE);

      /* "/home/jiba/src/soya/model/material.pyx":230 */
      glPushAttrib(GL_FOG_BIT);

      /* "/home/jiba/src/soya/model/material.pyx":231 */
      glDisable(GL_FOG);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/material.pyx":232 */
    __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/material.pyx":233 */
      glEnable(GL_TEXTURE_GEN_S);

      /* "/home/jiba/src/soya/model/material.pyx":234 */
      glEnable(GL_TEXTURE_GEN_T);

      /* "/home/jiba/src/soya/model/material.pyx":235 */
      glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);

      /* "/home/jiba/src/soya/model/material.pyx":236 */
      glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":241 */
  glColor4fv(__pyx_v_self->_diffuse);

  /* "/home/jiba/src/soya/model/material.pyx":242 */
  glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,__pyx_v_self->_emissive);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Material._activate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static char (__pyx_k240[]) = "_Material._inactivate()\n\nDe-activates this material, and reset OpenGL to the \"default\" state, suitable for another\nmaterial activation.\nAutomatically called by _Material._activate().";

static void __pyx_f_5_soya_9_Material__inactivate(struct __pyx_obj_5_soya__Material *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":246 */
  __pyx_k240;

  /* "/home/jiba/src/soya/model/material.pyx":252 */
  glBindTexture(GL_TEXTURE_2D,0);

  /* "/home/jiba/src/soya/model/material.pyx":253 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_texture) == Py_None;
  if (__pyx_1) {
    glEnable(GL_TEXTURE_2D);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":254 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_MASK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":255 */
    glDisable(GL_ALPHA_TEST);

    /* "/home/jiba/src/soya/model/material.pyx":256 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_ALPHA);
    if (__pyx_1) {
      glDepthMask(GL_FALSE);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/material.pyx":257 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_SEPARATE_SPECULAR);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_5_soya_quality != __pyx_e_5_soya_QUALITY_LOW);
  }
  if (__pyx_1) {
    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/material.pyx":258 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":259 */
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    /* "/home/jiba/src/soya/model/material.pyx":260 */
    glPopAttrib();
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/material.pyx":261 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":262 */
    glDisable(GL_TEXTURE_GEN_S);

    /* "/home/jiba/src/soya/model/material.pyx":263 */
    glDisable(GL_TEXTURE_GEN_T);
    goto __pyx_L7;
  }
  __pyx_L7:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Material._inactivate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_9_Material_activate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9_Material_activate[] = "Material.activate()\n\nSet this material as the current activated one. The material properties will apply to\nany further OpenGL drawing.\nThe previously active material is inactivated first. A single material can be active\nat the same time. This method is a Python wrapper for _Material._activate().";
static PyObject *__pyx_f_5_soya_9_Material_activate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":272 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.activate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_inactivate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9_Material_inactivate[] = "Material.inactivate()\n\n";
static PyObject *__pyx_f_5_soya_9_Material_inactivate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":278 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya_renderer->current_material->__pyx_base.__pyx_vtab)->_inactivate(__pyx_v_5_soya_renderer->current_material);

  /* "/home/jiba/src/soya/model/material.pyx":279 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 279; goto __pyx_L1;}
  Py_INCREF(Py_None);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->current_material));
  __pyx_v_5_soya_renderer->current_material = Py_None;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.inactivate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_is_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9_Material_is_alpha[] = "Returns true if this material use alpha blending (i.e. semi-transparency).";
static PyObject *__pyx_f_5_soya_9_Material_is_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":283 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_ALPHA) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 283; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.is_alpha");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_has_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9_Material_has_mask[] = "Returns true if this material has a mask (i.e. all-or-nothing transparency).";
static PyObject *__pyx_f_5_soya_9_Material_has_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":287 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_MASK) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 287; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.has_mask");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_17separate_specular___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_17separate_specular___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":291 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_SEPARATE_SPECULAR) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.separate_specular.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_17separate_specular___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9_Material_17separate_specular___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 292; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":293 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option | __pyx_e_5_soya_MATERIAL_SEPARATE_SPECULAR);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & (~__pyx_e_5_soya_MATERIAL_SEPARATE_SPECULAR));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.separate_specular.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_5clamp___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_5clamp___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":298 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_CLAMP) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 298; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.clamp.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_5clamp___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9_Material_5clamp___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 299; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":300 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option | __pyx_e_5_soya_MATERIAL_CLAMP);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & (~__pyx_e_5_soya_MATERIAL_CLAMP));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":302 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.clamp.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_19environment_mapping___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_19environment_mapping___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":306 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 306; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.environment_mapping.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_19environment_mapping___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9_Material_19environment_mapping___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 307; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":308 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option | __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & (~__pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":310 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.environment_mapping.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_7mip_map___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_7mip_map___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":314 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_MIPMAP) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 314; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.mip_map.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_7mip_map___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9_Material_7mip_map___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 315; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":316 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option | __pyx_e_5_soya_MATERIAL_MIPMAP);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & (~__pyx_e_5_soya_MATERIAL_MIPMAP));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":318 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.mip_map.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_17additive_blending___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_17additive_blending___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":322 */
  __pyx_1 = PyInt_FromLong(((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING) != 0)); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 322; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.additive_blending.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_17additive_blending___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9_Material_17additive_blending___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 323; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":324 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option | __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & (~__pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":326 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_compute_alpha(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.additive_blending.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_7texture___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_7texture___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":330 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.texture.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k241p;

static char (__pyx_k241[]) = "Image dimensions must be power of 2 (dimensions are %s x %s)";

static int __pyx_f_5_soya_9_Material_7texture___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_image); /*proto*/
static int __pyx_f_5_soya_9_Material_7texture___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_image) {
  int __pyx_v_check;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_image);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image), __pyx_ptype_5_soya__Image, 1, "image")) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 331; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":333 */
  __pyx_1 = __pyx_v_image == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/material.pyx":334 */
    __pyx_v_check = ((struct __pyx_vtabstruct_5_soya__Image *)((struct __pyx_obj_5_soya__Image *)__pyx_v_image)->__pyx_base.__pyx_vtab)->check_for_gl(((struct __pyx_obj_5_soya__Image *)__pyx_v_image));

    /* "/home/jiba/src/soya/model/material.pyx":335 */
    __pyx_1 = (__pyx_v_check == 1);
    if (__pyx_1) {
      ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option & (~__pyx_e_5_soya_MATERIAL_BORDER));
      goto __pyx_L3;
    }
    __pyx_2 = (__pyx_v_check == 2);
    if (__pyx_2) {
      ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_option | __pyx_e_5_soya_MATERIAL_BORDER);
      goto __pyx_L3;
    }
    /*else*/ {
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_image)->width); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_image)->height); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_4);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
      __pyx_4 = 0;
      __pyx_5 = 0;
      __pyx_4 = PyNumber_Remainder(__pyx_k241p, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
      __pyx_4 = 0;
      __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __Pyx_Raise(__pyx_6, 0, 0);
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      {__pyx_filename = __pyx_f[15]; __pyx_lineno = 337; goto __pyx_L1;}
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":338 */
  Py_INCREF(__pyx_v_image);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture));
  ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture = __pyx_v_image;

  /* "/home/jiba/src/soya/model/material.pyx":339 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_compute_alpha(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":340 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Material.texture.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_image);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_5image___get__(PyObject *__pyx_v_self); /*proto*/
static char __pyx_doc_5_soya_9_Material_5image___get__[] = "DEPRECATED, alias for texture";
static PyObject *__pyx_f_5_soya_9_Material_5image___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":345 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_texture);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Material.image.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_7diffuse___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_7diffuse___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":349 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 349; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Material.diffuse.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_7diffuse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_9_Material_7diffuse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  GLfloat __pyx_2;
  GLfloat __pyx_3;
  GLfloat __pyx_4;
  GLfloat __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/material.pyx":351 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_diffuse[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":352 */
  ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_compute_alpha(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.diffuse.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_8specular___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_8specular___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":356 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 356; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 356; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 356; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 356; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 356; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Material.specular.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_8specular___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_9_Material_8specular___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  GLfloat __pyx_2;
  GLfloat __pyx_3;
  GLfloat __pyx_4;
  GLfloat __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/material.pyx":358 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_specular[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.specular.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_8emissive___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_8emissive___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":362 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 362; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 362; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 362; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 362; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 362; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Material.emissive.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9_Material_8emissive___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_9_Material_8emissive___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  GLfloat __pyx_2;
  GLfloat __pyx_3;
  GLfloat __pyx_4;
  GLfloat __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/material.pyx":364 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_emissive[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.emissive.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9_Material_9opengl_id___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material_9opengl_id___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":368 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_id); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 368; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.opengl_id.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k242p;

static char (__pyx_k242[]) = "<Material %s>";

static PyObject *__pyx_f_5_soya_9_Material___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9_Material___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyNumber_Remainder(__pyx_k242p, ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 370; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Material.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_16_IdleingMaterial___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_16_IdleingMaterial___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Image *__pyx_v_texture = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"texture",0};
  __pyx_v_texture = __pyx_k67;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_texture)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_texture);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_texture), __pyx_ptype_5_soya__Image, 1, "texture")) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 376; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":377 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Material), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 377; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 377; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_texture));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_texture));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 377; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/material.pyx":378 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 378; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_IDLEING_ITEMS); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 378; goto __pyx_L1;}
  if (PyObject_SetItem(__pyx_2, __pyx_v_self, __pyx_1) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 378; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._IdleingMaterial.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_texture);
  return __pyx_r;
}

static void __pyx_f_5_soya_16_IdleingMaterial___setcstate__(struct __pyx_obj_5_soya__IdleingMaterial *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/material.pyx":381 */
  __pyx_vtabptr_5_soya__Material->__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/material.pyx":382 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 382; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_IDLEING_ITEMS); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 382; goto __pyx_L1;}
  if (PyObject_SetItem(__pyx_2, ((PyObject *)__pyx_v_self), __pyx_1) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 382; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._IdleingMaterial.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_16_IdleingMaterial_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_16_IdleingMaterial_begin_round[] = "_IdleingMaterial.begin_round()\n\nCalled by the Idler when a new round begins; default implementation does nothing.";
static PyObject *__pyx_f_5_soya_16_IdleingMaterial_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":388 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._IdleingMaterial.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_IdleingMaterial_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_16_IdleingMaterial_end_round[] = "_IdleingMaterial.end_round()\n\nCalled by the Idler when a round is finished; default implementation does nothing.";
static PyObject *__pyx_f_5_soya_16_IdleingMaterial_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":394 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._IdleingMaterial.end_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16_IdleingMaterial_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_16_IdleingMaterial_advance_time[] = "_IdleingMaterial.advance_time(proportion)\n\nCalled by the Idler when a piece of a round has occured; does nothing.\nPROPORTION is the proportion of the current round\'s time that has passed (1.0 for an entire round).";
static PyObject *__pyx_f_5_soya_16_IdleingMaterial_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":401 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._IdleingMaterial.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_init_texture;

static void __pyx_f_5_soya_15_PythonMaterial__init_texture(struct __pyx_obj_5_soya__PythonMaterial *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":412 */
  __pyx_vtabptr_5_soya__Material->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":413 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_init_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 413; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 413; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 413; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._PythonMaterial._init_texture");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_15_PythonMaterial_init_texture(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_15_PythonMaterial_init_texture(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":416 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._PythonMaterial.init_texture");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_activated;

static void __pyx_f_5_soya_15_PythonMaterial__activate(struct __pyx_obj_5_soya__PythonMaterial *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":419 */
  __pyx_vtabptr_5_soya__Material->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":420 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_activated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 420; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 420; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 420; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._PythonMaterial._activate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_15_PythonMaterial_activated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_15_PythonMaterial_activated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":423 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._PythonMaterial.activated");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_inactivated;

static void __pyx_f_5_soya_15_PythonMaterial__inactivate(struct __pyx_obj_5_soya__PythonMaterial *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":426 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_inactivated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 426; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 426; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 426; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/material.pyx":427 */
  __pyx_vtabptr_5_soya__Material->_inactivate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._PythonMaterial._inactivate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_15_PythonMaterial_inactivated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_15_PythonMaterial_inactivated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":430 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._PythonMaterial.inactivated");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_22_PythonIdleingMaterial__init_texture(struct __pyx_obj_5_soya__PythonIdleingMaterial *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":442 */
  __pyx_vtabptr_5_soya__Material->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":443 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_init_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 443; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 443; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 443; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._PythonIdleingMaterial._init_texture");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_22_PythonIdleingMaterial_init_texture(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_22_PythonIdleingMaterial_init_texture(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":446 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._PythonIdleingMaterial.init_texture");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_22_PythonIdleingMaterial__activate(struct __pyx_obj_5_soya__PythonIdleingMaterial *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":449 */
  __pyx_vtabptr_5_soya__Material->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":450 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_activated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 450; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 450; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 450; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._PythonIdleingMaterial._activate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_22_PythonIdleingMaterial_activated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_22_PythonIdleingMaterial_activated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":453 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._PythonIdleingMaterial.activated");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_22_PythonIdleingMaterial__inactivate(struct __pyx_obj_5_soya__PythonIdleingMaterial *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":456 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_inactivated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 456; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 456; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 456; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/material.pyx":457 */
  __pyx_vtabptr_5_soya__Material->_inactivate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._PythonIdleingMaterial._inactivate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_22_PythonIdleingMaterial_inactivated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_22_PythonIdleingMaterial_inactivated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":460 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._PythonIdleingMaterial.inactivated");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static char (__pyx_k243[]) = "pack_get_alpha(Pack* pack) -> Pack*\n\nReturns a pack with the same material and drawing options, but that uses the alpha\nrenderer batching state (for drawing alpha triangle / quad).\nIf called twice with the same argument, the returned pack is the same, and it should\nnot be free\'ed.";

static struct __pyx_t_5_soya__Pack (*__pyx_f_5_soya_pack_get_alpha(struct __pyx_t_5_soya__Pack (*__pyx_v_pack))) {
  struct __pyx_t_5_soya__Pack (*__pyx_r);
  int __pyx_1;

  /* "/home/jiba/src/soya/model/material.pyx":496 */
  __pyx_k243;

  /* "/home/jiba/src/soya/model/material.pyx":502 */
  __pyx_1 = (__pyx_v_pack->alpha == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":503 */
    __pyx_v_pack->alpha = ((struct __pyx_t_5_soya__Pack (*))malloc((sizeof(struct __pyx_t_5_soya__Pack ))));

    /* "/home/jiba/src/soya/model/material.pyx":504 */
    __pyx_v_pack->alpha->material_id = __pyx_v_pack->material_id;

    /* "/home/jiba/src/soya/model/material.pyx":505 */
    __pyx_v_pack->alpha->option = (__pyx_v_pack->option | __pyx_e_5_soya_FACE_ALPHA);

    /* "/home/jiba/src/soya/model/material.pyx":507 */
    __pyx_v_pack->alpha->batched_faces = 0;

    /* "/home/jiba/src/soya/model/material.pyx":508 */
    __pyx_v_pack->alpha->secondpass = 0;
    __pyx_v_pack->alpha->alpha = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":509 */
  __pyx_r = __pyx_v_pack->alpha;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.pack_get_alpha");
  __pyx_L0:;
  return __pyx_r;
}

static char (__pyx_k244[]) = "pack_get_secondpass(Pack* pack) -> Pack*\n\nReturns a pack with the same material and drawing options, but that uses the second pass\nrenderer batching state (for drawing triangle / quad after all the other).\nIf called twice with the same argument, the returned pack is the same, and it should\nnot be free\'ed.";

static struct __pyx_t_5_soya__Pack (*__pyx_f_5_soya_pack_get_secondpass(struct __pyx_t_5_soya__Pack (*__pyx_v_pack))) {
  struct __pyx_t_5_soya__Pack (*__pyx_r);
  int __pyx_1;

  /* "/home/jiba/src/soya/model/material.pyx":512 */
  __pyx_k244;

  /* "/home/jiba/src/soya/model/material.pyx":518 */
  __pyx_1 = (__pyx_v_pack->secondpass == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":519 */
    __pyx_v_pack->secondpass = ((struct __pyx_t_5_soya__Pack (*))malloc((sizeof(struct __pyx_t_5_soya__Pack ))));

    /* "/home/jiba/src/soya/model/material.pyx":520 */
    __pyx_v_pack->secondpass->material_id = __pyx_v_pack->material_id;

    /* "/home/jiba/src/soya/model/material.pyx":521 */
    __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_PACK_SECONDPASS);
    if (__pyx_1) {
      __pyx_v_pack->secondpass->option = (__pyx_v_pack->option | __pyx_e_5_soya_PACK_SPECIAL);
      goto __pyx_L3;
    }
    /*else*/ {
      __pyx_v_pack->secondpass->option = (__pyx_v_pack->option | __pyx_e_5_soya_PACK_SECONDPASS);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/material.pyx":524 */
    __pyx_v_pack->secondpass->batched_faces = 0;

    /* "/home/jiba/src/soya/model/material.pyx":525 */
    __pyx_v_pack->secondpass->secondpass = 0;
    __pyx_v_pack->secondpass->alpha = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":526 */
  __pyx_r = __pyx_v_pack->secondpass;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.pack_get_secondpass");
  __pyx_L0:;
  return __pyx_r;
}

static char (__pyx_k245[]) = "pack_batch_face(Pack* pack, void* face)\n\nBatches face, i.e. store a pointer to face for a future rendering (at the rendering time)\nusing the pack\'s attributes.";

static void __pyx_f_5_soya_pack_batch_face(struct __pyx_t_5_soya__Pack (*__pyx_v_pack),void (*__pyx_v_face)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/material.pyx":530 */
  __pyx_k245;

  /* "/home/jiba/src/soya/model/material.pyx":534 */
  __pyx_1 = (__pyx_v_pack->batched_faces == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":535 */
    __pyx_v_pack->batched_faces = get_chunk();

    /* "/home/jiba/src/soya/model/material.pyx":536 */
    __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_FACE_ALPHA);
    if (__pyx_1) {
      chunk_add_ptr(__pyx_v_5_soya_renderer->used_alpha_packs,__pyx_v_pack);
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_PACK_SECONDPASS);
    if (__pyx_1) {
      chunk_add_ptr(__pyx_v_5_soya_renderer->used_secondpass_packs,__pyx_v_pack);
      goto __pyx_L3;
    }
    /*else*/ {
      chunk_add_ptr(__pyx_v_5_soya_renderer->used_opaque_packs,__pyx_v_pack);
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":539 */
  chunk_add_ptr(__pyx_v_pack->batched_faces,__pyx_v_face);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.pack_batch_face");
  __pyx_L0:;
}

static void __pyx_f_5_soya_pack_batch_end(PyObject *__pyx_v_batched_object,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  int __pyx_1;
  Py_INCREF(__pyx_v_batched_object);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/material.pyx":546 */
  __pyx_1 = __pyx_v_5_soya_renderer->used_opaque_packs->nb;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":547 */
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,__pyx_v_batched_object,__pyx_v_coordsyst,__pyx_v_5_soya_renderer->data->nb);

    /* "/home/jiba/src/soya/model/material.pyx":548 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->used_opaque_packs,0);

    /* "/home/jiba/src/soya/model/material.pyx":549 */
    __pyx_v_5_soya_renderer->used_opaque_packs->nb = 0;

    /* "/home/jiba/src/soya/model/material.pyx":550 */
    __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->used_opaque_packs));

    /* "/home/jiba/src/soya/model/material.pyx":551 */
    while (1) {
      __pyx_L3:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/material.pyx":552 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,__pyx_v_pack);

      /* "/home/jiba/src/soya/model/material.pyx":553 */
      chunk_add(__pyx_v_5_soya_renderer->data,__pyx_v_pack->batched_faces->content,__pyx_v_pack->batched_faces->nb);

      /* "/home/jiba/src/soya/model/material.pyx":554 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

      /* "/home/jiba/src/soya/model/material.pyx":555 */
      drop_chunk(__pyx_v_pack->batched_faces);

      /* "/home/jiba/src/soya/model/material.pyx":555 */
      __pyx_v_pack->batched_faces = 0;

      /* "/home/jiba/src/soya/model/material.pyx":556 */
      __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->used_opaque_packs));
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/material.pyx":557 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

    /* "/home/jiba/src/soya/model/material.pyx":558 */
    __pyx_v_5_soya_renderer->used_opaque_packs->nb = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":560 */
  __pyx_1 = __pyx_v_5_soya_renderer->used_alpha_packs->nb;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":561 */
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,__pyx_v_batched_object,__pyx_v_coordsyst,__pyx_v_5_soya_renderer->data->nb);

    /* "/home/jiba/src/soya/model/material.pyx":562 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->used_alpha_packs,0);

    /* "/home/jiba/src/soya/model/material.pyx":563 */
    __pyx_v_5_soya_renderer->used_alpha_packs->nb = 0;

    /* "/home/jiba/src/soya/model/material.pyx":564 */
    __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->used_alpha_packs));

    /* "/home/jiba/src/soya/model/material.pyx":565 */
    while (1) {
      __pyx_L6:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/material.pyx":566 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,__pyx_v_pack);

      /* "/home/jiba/src/soya/model/material.pyx":567 */
      chunk_add(__pyx_v_5_soya_renderer->data,__pyx_v_pack->batched_faces->content,__pyx_v_pack->batched_faces->nb);

      /* "/home/jiba/src/soya/model/material.pyx":568 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

      /* "/home/jiba/src/soya/model/material.pyx":569 */
      drop_chunk(__pyx_v_pack->batched_faces);

      /* "/home/jiba/src/soya/model/material.pyx":569 */
      __pyx_v_pack->batched_faces = 0;

      /* "/home/jiba/src/soya/model/material.pyx":570 */
      __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->used_alpha_packs));
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/material.pyx":571 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

    /* "/home/jiba/src/soya/model/material.pyx":572 */
    __pyx_v_5_soya_renderer->used_alpha_packs->nb = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/material.pyx":574 */
  __pyx_1 = __pyx_v_5_soya_renderer->used_secondpass_packs->nb;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":575 */
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->secondpass,__pyx_v_batched_object,__pyx_v_coordsyst,__pyx_v_5_soya_renderer->data->nb);

    /* "/home/jiba/src/soya/model/material.pyx":576 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->used_secondpass_packs,0);

    /* "/home/jiba/src/soya/model/material.pyx":577 */
    __pyx_v_5_soya_renderer->used_secondpass_packs->nb = 0;

    /* "/home/jiba/src/soya/model/material.pyx":578 */
    __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->used_secondpass_packs));

    /* "/home/jiba/src/soya/model/material.pyx":579 */
    while (1) {
      __pyx_L9:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/material.pyx":580 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,__pyx_v_pack);

      /* "/home/jiba/src/soya/model/material.pyx":581 */
      chunk_add(__pyx_v_5_soya_renderer->data,__pyx_v_pack->batched_faces->content,__pyx_v_pack->batched_faces->nb);

      /* "/home/jiba/src/soya/model/material.pyx":582 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

      /* "/home/jiba/src/soya/model/material.pyx":583 */
      drop_chunk(__pyx_v_pack->batched_faces);

      /* "/home/jiba/src/soya/model/material.pyx":583 */
      __pyx_v_pack->batched_faces = 0;

      /* "/home/jiba/src/soya/model/material.pyx":584 */
      __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->used_secondpass_packs));
    }
    __pyx_L10:;

    /* "/home/jiba/src/soya/model/material.pyx":585 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

    /* "/home/jiba/src/soya/model/material.pyx":586 */
    __pyx_v_5_soya_renderer->used_secondpass_packs->nb = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.pack_batch_end");
  __pyx_L0:;
  Py_DECREF(__pyx_v_batched_object);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_f_5_soya_7_Vertex___getcstate__(struct __pyx_obj_5_soya__Vertex *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":27 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/face.pyx":28 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,3);

  /* "/home/jiba/src/soya/model/face.pyx":31 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_x),1);

  /* "/home/jiba/src/soya/model/face.pyx":32 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_y),1);

  /* "/home/jiba/src/soya/model/face.pyx":33 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 33; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 33; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
  Py_INCREF(__pyx_v_self->_diffuse);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_self->_diffuse);
  Py_INCREF(__pyx_v_self->_emissive);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_self->_emissive);
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Vertex.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Vertex___setcstate__(struct __pyx_obj_5_soya__Vertex *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_cstate2;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/face.pyx":36 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 36; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
  __pyx_v_self->__pyx_base.__pyx_base._parent = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_diffuse);
  __pyx_v_self->_diffuse = __pyx_3;
  __pyx_3 = 0;
  __pyx_4 = __Pyx_UnpackItem(__pyx_v_cstate, 3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_emissive);
  __pyx_v_self->_emissive = __pyx_4;
  __pyx_4 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 4) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 36; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":41 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/face.pyx":42 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,3);

  /* "/home/jiba/src/soya/model/face.pyx":45 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_x));

  /* "/home/jiba/src/soya/model/face.pyx":46 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_y));

  /* "/home/jiba/src/soya/model/face.pyx":47 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Vertex.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_7_Vertex_5tex_x___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vertex_5tex_x___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":59 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_x); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 59; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Vertex.tex_x.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Vertex_5tex_x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Vertex_5tex_x___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 60; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":61 */
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_x = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.tex_x.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vertex_5tex_y___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vertex_5tex_y___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":65 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_y); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 65; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Vertex.tex_y.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Vertex_5tex_y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Vertex_5tex_y___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 66; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":67 */
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_y = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.tex_y.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vertex_5color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vertex_5color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":71 */
  Py_INCREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse);
  __pyx_r = ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Vertex_5color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_7_Vertex_5color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/face.pyx":73 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse);
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vertex_7diffuse___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vertex_7diffuse___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":77 */
  Py_INCREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse);
  __pyx_r = ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.diffuse.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Vertex_7diffuse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_7_Vertex_7diffuse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/face.pyx":79 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse);
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.diffuse.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vertex_8emissive___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vertex_8emissive___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":83 */
  Py_INCREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_emissive);
  __pyx_r = ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_emissive;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.emissive.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Vertex_8emissive___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_7_Vertex_8emissive___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/face.pyx":85 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_emissive);
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_emissive = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.emissive.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Vertex_4face___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Vertex_4face___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":89 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_face));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_face);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Vertex.face.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Vertex___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_7_Vertex___init__[] = "Vertex(parent = None, x = 0.0, y = 0.0, z = 0.0, tex_x = 0.0, tex_y = 0.0, diffuse = None, emissive = None)\n\nCreates a new Vertex in coordinate systems PARENT, at position X, Y, Z, with texture\ncoordinates TEX_X and TEX_Y, and the given DIFFUSE and EMISSIVE colors.";
static int __pyx_f_5_soya_7_Vertex___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent = 0;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float __pyx_v_tex_x;
  float __pyx_v_tex_y;
  PyObject *__pyx_v_diffuse = 0;
  PyObject *__pyx_v_emissive = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"parent","x","y","z","tex_x","tex_y","diffuse","emissive",0};
  __pyx_v_parent = __pyx_k68;
  __pyx_v_x = __pyx_k69;
  __pyx_v_y = __pyx_k70;
  __pyx_v_z = __pyx_k71;
  __pyx_v_tex_x = __pyx_k72;
  __pyx_v_tex_y = __pyx_k73;
  __pyx_v_diffuse = __pyx_k74;
  __pyx_v_emissive = __pyx_k75;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OfffffOO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_tex_x, &__pyx_v_tex_y, &__pyx_v_diffuse, &__pyx_v_emissive)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF(__pyx_v_diffuse);
  Py_INCREF(__pyx_v_emissive);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya_CoordSyst, 1, "parent")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 91; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":96 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___init__); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyFloat_FromDouble(__pyx_v_x); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_y); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(5); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 4, __pyx_4);
  __pyx_1 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 96; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":97 */
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_x = __pyx_v_tex_x;

  /* "/home/jiba/src/soya/model/face.pyx":98 */
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_y = __pyx_v_tex_y;

  /* "/home/jiba/src/soya/model/face.pyx":99 */
  Py_INCREF(__pyx_v_diffuse);
  Py_DECREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse);
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_diffuse = __pyx_v_diffuse;

  /* "/home/jiba/src/soya/model/face.pyx":100 */
  Py_INCREF(__pyx_v_emissive);
  Py_DECREF(((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_emissive);
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_emissive = __pyx_v_emissive;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Vertex.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF(__pyx_v_diffuse);
  Py_DECREF(__pyx_v_emissive);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Vertex__render(struct __pyx_obj_5_soya__Vertex *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  float (__pyx_v_coords[3]);
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  GLfloat __pyx_5;
  GLfloat __pyx_6;
  GLfloat __pyx_7;
  GLfloat __pyx_8;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/face.pyx":104 */
  glTexCoord2f(__pyx_v_self->_tex_x,__pyx_v_self->_tex_y);

  /* "/home/jiba/src/soya/model/face.pyx":105 */
  __pyx_1 = __pyx_v_self->_diffuse == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/face.pyx":109 */
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_5 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_8 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    glColor4f(__pyx_5,__pyx_6,__pyx_7,__pyx_8);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":110 */
  __pyx_1 = __pyx_v_self->_emissive == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/face.pyx":111 */
    glMaterialfv(GL_FRONT,GL_EMISSION,((float (*))__pyx_v_self->_emissive));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/face.pyx":112 */
  __pyx_1 = ((PyObject *)__pyx_v_coord_syst) == Py_None;
  if (__pyx_1) {
    glVertex3fv(__pyx_v_self->__pyx_base._matrix);
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/face.pyx":114 */
    ((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_self),__pyx_v_coord_syst,__pyx_v_coords);

    /* "/home/jiba/src/soya/model/face.pyx":115 */
    glVertex3fv(__pyx_v_coords);
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Vertex._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static PyObject *__pyx_n_index;

static float __pyx_f_5_soya_7_Vertex__angle_at(struct __pyx_obj_5_soya__Vertex *__pyx_v_self) {
  float (__pyx_v_u1[3]);
  float (__pyx_v_u2[3]);
  int __pyx_v_index;
  float __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":120 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_face->_vertices, __pyx_n_index); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 120; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_self));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_index = __pyx_4;

  /* "/home/jiba/src/soya/model/face.pyx":121 */
  __pyx_4 = PyObject_Length(__pyx_v_self->_face->_vertices); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 121; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(((__pyx_v_index + 1) % __pyx_4)); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 121; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_self->_face->_vertices, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 121; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  vector_from_points(__pyx_v_u1,((struct __pyx_obj_5_soya__Vertex *)__pyx_2)->__pyx_base._matrix,__pyx_v_self->__pyx_base._matrix);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":122 */
  __pyx_3 = PyInt_FromLong((__pyx_v_index - 1)); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 122; goto __pyx_L1;}
  __pyx_1 = PyObject_GetItem(__pyx_v_self->_face->_vertices, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 122; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  vector_from_points(__pyx_v_u2,((struct __pyx_obj_5_soya__Vertex *)__pyx_1)->__pyx_base._matrix,__pyx_v_self->__pyx_base._matrix);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":123 */
  __pyx_r = vector_angle(__pyx_v_u1,__pyx_v_u2);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Vertex._angle_at");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_3lit___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_3lit___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":133 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_FACE2_LIT)); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 133; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Face.lit.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Face_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_5_Face_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 134; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":135 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_FACE2_LIT);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_FACE2_LIT));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.lit.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_10smooth_lit___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_10smooth_lit___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":140 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_FACE2_SMOOTH_LIT)); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Face.smooth_lit.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Face_10smooth_lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_5_Face_10smooth_lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 141; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":142 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_FACE2_SMOOTH_LIT);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_FACE2_SMOOTH_LIT));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.smooth_lit.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_10static_lit___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_10static_lit___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":147 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_FACE2_STATIC_LIT)); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 147; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Face.static_lit.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Face_10static_lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_5_Face_10static_lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 148; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":149 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_FACE2_STATIC_LIT);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_FACE2_STATIC_LIT));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.static_lit.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_12double_sided___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_12double_sided___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":154 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED)); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 154; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Face.double_sided.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Face_12double_sided___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_5_Face_12double_sided___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 155; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":156 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_FACE2_DOUBLE_SIDED);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_FACE2_DOUBLE_SIDED));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.double_sided.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_8material___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_8material___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":161 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.material.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Face_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_5_Face_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 0, "x")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 162; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":163 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.material.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_8vertices___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_8vertices___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":167 */
  Py_INCREF(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices);
  __pyx_r = ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.vertices.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_6normal___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face_6normal___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":171 */
  ((struct __pyx_vtabstruct_5_soya__Face *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normal(((struct __pyx_obj_5_soya__Face *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/face.pyx":172 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_normal));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_normal);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.normal.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_vertices;

static int __pyx_f_5_soya_5_Face___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face___init__[] = "Face(parent = None, vertices = None, material = None) -> Face\n\nCreates a new Face in World PARENT, with the given list of VERTICES,\nand the given Material.";
static int __pyx_f_5_soya_5_Face___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  PyObject *__pyx_v_vertices = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"parent","vertices","material",0};
  __pyx_v_parent = __pyx_k76;
  __pyx_v_vertices = __pyx_k77;
  __pyx_v_material = __pyx_k78;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_vertices, &__pyx_v_material)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF(__pyx_v_vertices);
  Py_INCREF((PyObject *)__pyx_v_material);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 174; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 174; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":180 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 180; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 180; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 180; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":181 */
  __pyx_1 = __pyx_v_vertices;
  Py_INCREF(__pyx_1);
  __pyx_4 = PyObject_IsTrue(__pyx_1); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 181; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 181; goto __pyx_L1;}
  }
  Py_DECREF(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices);
  ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":182 */
  __pyx_2 = ((PyObject *)__pyx_v_material);
  Py_INCREF((PyObject *)__pyx_2);
  __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 182; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;
    __pyx_2 = ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_2);
  }
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 182; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":183 */
  ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base._option = (__pyx_e_5_soya_FACE2_LIT | __pyx_e_5_soya_FACE2_STATIC_LIT);

  /* "/home/jiba/src/soya/model/face.pyx":184 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; goto __pyx_L1;}
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 184; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_2;
    __pyx_2 = 0;
    Py_INCREF(__pyx_v_self);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex->_face));
    __pyx_v_vertex->_face = __pyx_v_self;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Face.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF(__pyx_v_vertices);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face___getcstate__(struct __pyx_obj_5_soya__Face *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":189 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/face.pyx":190 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/face.pyx":191 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/face.pyx":192 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 192; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 192; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF(__pyx_v_self->_vertices);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_self->_vertices);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_self->_material));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Face.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Face___setcstate__(struct __pyx_obj_5_soya__Face *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_cstate2;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);

  /* "/home/jiba/src/soya/model/face.pyx":195 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_vertices);
  __pyx_v_self->_vertices = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 195; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  __pyx_v_self->_material = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 3) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 195; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":198 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 198; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 198; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 198; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_2;
    __pyx_2 = 0;
    Py_INCREF(((PyObject *)__pyx_v_self));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex->_face));
    __pyx_v_vertex->_face = ((PyObject *)__pyx_v_self);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":201 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/face.pyx":202 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/face.pyx":203 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/face.pyx":204 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/face.pyx":205 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Face.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_5_Face_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_insert[] = "Face.insert(index, vertex)\n\nInserts the given VERTEX to the Face at position INDEX.";
static PyObject *__pyx_f_5_soya_5_Face_insert(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"index","vertex",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iO", __pyx_argnames, &__pyx_v_index, &__pyx_v_vertex)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vertex);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vertex), __pyx_ptype_5_soya__Vertex, 0, "vertex")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 207; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":211 */
  Py_INCREF(__pyx_v_self);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex->_face));
  __pyx_v_vertex->_face = __pyx_v_self;

  /* "/home/jiba/src/soya/model/face.pyx":212 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices, __pyx_n_insert); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 212; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 212; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 212; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_vertex));
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 212; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Face.insert");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_append(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_append[] = "Face.append(vertex)\n\nAppends the given VERTEX to the Face.";
static PyObject *__pyx_f_5_soya_5_Face_append(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"vertex",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_vertex)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vertex);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vertex), __pyx_ptype_5_soya__Vertex, 0, "vertex")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 214; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":218 */
  Py_INCREF(__pyx_v_self);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex->_face));
  __pyx_v_vertex->_face = __pyx_v_self;

  /* "/home/jiba/src/soya/model/face.pyx":219 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 219; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 219; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_vertex));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 219; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Face.append");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_add[] = "Face.add(vertex)\n\nAppends the given VERTEX to the Face.";
static PyObject *__pyx_f_5_soya_5_Face_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"vertex",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_vertex)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vertex);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vertex), __pyx_ptype_5_soya__Vertex, 0, "vertex")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 221; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":225 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 225; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_vertex));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Face.add");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Face__compute_normal(struct __pyx_obj_5_soya__Face *__pyx_v_self) {
  float (__pyx_v_a[3]);
  float (__pyx_v_b[3]);
  float (__pyx_v_c[3]);
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":230 */
  (__pyx_v_a[0]) = 0.0;
  (__pyx_v_a[1]) = 0.0;
  (__pyx_v_a[2]) = 0.0;
  (__pyx_v_b[0]) = 0.0;
  (__pyx_v_b[1]) = 0.0;
  (__pyx_v_b[2]) = 0.0;
  (__pyx_v_c[0]) = 0.0;
  (__pyx_v_c[1]) = 0.0;
  (__pyx_v_c[2]) = 0.0;

  /* "/home/jiba/src/soya/model/face.pyx":231 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_2 = (__pyx_1 > 2);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/face.pyx":232 */
    __pyx_1 = ((PyObject *)__pyx_v_self->_normal) == Py_None;
    if (__pyx_1) {
      __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 232; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 232; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
      PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 232; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 232; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_normal));
      __pyx_v_self->_normal = __pyx_5;
      __pyx_5 = 0;
      goto __pyx_L3;
    }
    /*else*/ {
      Py_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_normal->__pyx_base.__pyx_base._parent));
      __pyx_v_self->_normal->__pyx_base.__pyx_base._parent = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/face.pyx":234 */
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 234; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 234; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_4)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_4)),__pyx_v_self->__pyx_base.__pyx_base._parent,__pyx_v_a);
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":235 */
    __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 235; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 235; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)),__pyx_v_self->__pyx_base.__pyx_base._parent,__pyx_v_b);
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":236 */
    __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 236; goto __pyx_L1;}
    __pyx_5 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 236; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_5)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_5)),__pyx_v_self->__pyx_base.__pyx_base._parent,__pyx_v_c);
    Py_DECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":237 */
    face_normal(__pyx_v_self->_normal->__pyx_base._matrix,__pyx_v_a,__pyx_v_b,__pyx_v_c);

    /* "/home/jiba/src/soya/model/face.pyx":238 */
    vector_normalize(__pyx_v_self->_normal->__pyx_base._matrix);
    goto __pyx_L2;
  }
  /*else*/ {
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 239; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_normal));
    __pyx_v_self->_normal = Py_None;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._Face._compute_normal");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_5_Face_is_coplanar(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_is_coplanar[] = "is_coplanar(threshold = 0.005) -> boolean\n\nReturns true if the Face\'s vertices are all coplanar.";
static PyObject *__pyx_f_5_soya_5_Face_is_coplanar(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_threshold;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  struct __pyx_obj_5_soya__Vector *__pyx_v_n1;
  struct __pyx_obj_5_soya__Vector *__pyx_v_n2;
  float (__pyx_v_a[3]);
  float (__pyx_v_b[3]);
  float (__pyx_v_c[3]);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"threshold",0};
  __pyx_v_threshold = __pyx_k79;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|f", __pyx_argnames, &__pyx_v_threshold)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);
  __pyx_v_n1 = Py_None; Py_INCREF((PyObject *) __pyx_v_n1);
  __pyx_v_n2 = Py_None; Py_INCREF((PyObject *) __pyx_v_n2);

  /* "/home/jiba/src/soya/model/face.pyx":246 */
  __pyx_1 = PyObject_Length(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_2 = (__pyx_1 < 4);
  if (__pyx_2) {
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 246; goto __pyx_L1;}
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":250 */
  ((struct __pyx_vtabstruct_5_soya__Face *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normal(((struct __pyx_obj_5_soya__Face *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/face.pyx":251 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_normal));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_n1));
  __pyx_v_n1 = ((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_normal);

  /* "/home/jiba/src/soya/model/face.pyx":252 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 252; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 252; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base._parent));
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 252; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 252; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_n2));
  __pyx_v_n2 = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":255 */
  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_4 = PyObject_GetItem(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_4)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_4)),((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_a);
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":256 */
  __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 256; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 256; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)),((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_b);
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":258 */
  __pyx_4 = PySequence_GetSlice(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices, 2, 0x7fffffff); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 258; goto __pyx_L1;}
  __pyx_5 = PyObject_GetIter(__pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 258; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  for (;;) {
    __pyx_L3:;
    __pyx_3 = PyIter_Next(__pyx_5);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 258; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 258; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":259 */
    ((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_vertex->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vertex),((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->__pyx_base.__pyx_base._parent,__pyx_v_c);

    /* "/home/jiba/src/soya/model/face.pyx":260 */
    face_normal(__pyx_v_n2->__pyx_base._matrix,__pyx_v_a,__pyx_v_b,__pyx_v_c);

    /* "/home/jiba/src/soya/model/face.pyx":261 */
    vector_normalize(__pyx_v_n2->__pyx_base._matrix);

    /* "/home/jiba/src/soya/model/face.pyx":263 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_n1), __pyx_n_distance_to); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 263; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 263; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_n2));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_n2));
    __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 263; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_4 = PyFloat_FromDouble(__pyx_v_threshold); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 263; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_6, __pyx_4, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 263; goto __pyx_L1;}
    __pyx_1 = __pyx_1 > 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {
      __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 263; goto __pyx_L1;}
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L4:;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":264 */
  __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 264; goto __pyx_L1;}
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Face.is_coplanar");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_n1);
  Py_DECREF((PyObject *)__pyx_v_n2);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_is_colored(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_is_colored[] = "is_colored() -> boolean\n\nReturns true if the Face is colored, i.e. at least one of its Vertices is colored.";
static PyObject *__pyx_f_5_soya_5_Face_is_colored(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);

  /* "/home/jiba/src/soya/model/face.pyx":271 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 271; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 271; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 271; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":272 */
    __pyx_3 = __pyx_v_vertex->_diffuse == Py_None;
    __pyx_4 = (!__pyx_3);
    if (__pyx_4) {
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 272; goto __pyx_L1;}
      __pyx_r = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":273 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Face.is_colored");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_is_alpha;
static PyObject *__pyx_n_has_alpha_vertex;

static PyObject *__pyx_f_5_soya_5_Face_is_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_is_alpha[] = "is_alpha() -> boolean\n\nReturns true if the Face is alpha-blended.";
static PyObject *__pyx_f_5_soya_5_Face_is_alpha(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":279 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
  if (__pyx_2) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material), __pyx_n_is_alpha); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
  if (!__pyx_2) {
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_has_alpha_vertex); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 279; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Face.is_alpha");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face_has_alpha_vertex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Face_has_alpha_vertex[] = "has_alpha_vertex() -> boolean\n\nReturns true if the Face has at least one alpha blended Vertex.";
static PyObject *__pyx_f_5_soya_5_Face_has_alpha_vertex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);

  /* "/home/jiba/src/soya/model/face.pyx":286 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 286; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 286; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 286; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":287 */
    __pyx_4 = __pyx_v_vertex->_diffuse == Py_None;
    __pyx_3 = (!__pyx_4);
    if (__pyx_3) {
      __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 287; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 287; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 287; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_5, __pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 287; goto __pyx_L1;}
      __pyx_3 = __pyx_3 < 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
    }
    if (__pyx_3) {
      __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 287; goto __pyx_L1;}
      __pyx_r = __pyx_5;
      __pyx_5 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":288 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 288; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Face.has_alpha_vertex");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Face__batch(struct __pyx_obj_5_soya__Face *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/face.pyx":291 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_is_alpha); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),__pyx_v_coord_syst,(-1));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,((PyObject *)__pyx_v_self),__pyx_v_coord_syst,(-1));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Face._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static void __pyx_f_5_soya_5_Face__render(struct __pyx_obj_5_soya__Face *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  struct __pyx_obj_5_soya__Vector *__pyx_v_at_camera;
  int __pyx_v_i;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);
  __pyx_v_at_camera = Py_None; Py_INCREF((PyObject *) __pyx_v_at_camera);

  /* "/home/jiba/src/soya/model/face.pyx":298 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 298; goto __pyx_L1;}
  __pyx_v_i = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":299 */
  __pyx_1 = (__pyx_v_i == 0);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":301 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_self->_material);

  /* "/home/jiba/src/soya/model/face.pyx":303 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_FACE2_LIT));
  if (__pyx_1) {
    glDisable(GL_LIGHTING);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/face.pyx":304 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/face.pyx":305 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/face.pyx":306 */
    glDisable(GL_CULL_FACE);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/face.pyx":308 */
  ((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normal(__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":309 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_normal) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/face.pyx":310 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_5_soya_renderer->current_camera));
    PyTuple_SET_ITEM(__pyx_6, 0, ((PyObject *)__pyx_v_5_soya_renderer->current_camera));
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
    PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 310; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_at_camera));
    __pyx_v_at_camera = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":311 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_at_camera), __pyx_n_convert_to); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 311; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 311; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
    PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent));
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 311; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":312 */
    glNormal3fv(__pyx_v_at_camera->__pyx_base._matrix);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/face.pyx":314 */
    glNormal3fv(__pyx_v_self->_normal->__pyx_base._matrix);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/face.pyx":316 */
  __pyx_1 = (__pyx_v_i == 1);
  if (__pyx_1) {
    glBegin(GL_POINTS);
    goto __pyx_L6;
  }
  __pyx_1 = (__pyx_v_i == 2);
  if (__pyx_1) {
    glBegin(GL_LINES);
    goto __pyx_L6;
  }
  __pyx_1 = (__pyx_v_i == 3);
  if (__pyx_1) {
    glBegin(GL_TRIANGLES);
    goto __pyx_L6;
  }
  __pyx_1 = (__pyx_v_i == 4);
  if (__pyx_1) {
    glBegin(GL_QUADS);
    goto __pyx_L6;
  }
  /*else*/ {
    glBegin(GL_POLYGON);
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/face.pyx":322 */
  __pyx_6 = PyObject_GetIter(__pyx_v_self->_vertices); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 322; goto __pyx_L1;}
  for (;;) {
    __pyx_L7:;
    __pyx_3 = PyIter_Next(__pyx_6);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 322; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 322; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_3;
    __pyx_3 = 0;
    ((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_vertex->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render(__pyx_v_vertex,__pyx_v_self->__pyx_base.__pyx_base._parent);
  }
  __pyx_L8:;
  Py_DECREF(__pyx_6); __pyx_6 = 0;

  /* "/home/jiba/src/soya/model/face.pyx":323 */
  glEnd();

  /* "/home/jiba/src/soya/model/face.pyx":325 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/face.pyx":326 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);

    /* "/home/jiba/src/soya/model/face.pyx":327 */
    glEnable(GL_CULL_FACE);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/face.pyx":329 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_FACE2_LIT));
  if (__pyx_1) {
    glEnable(GL_LIGHTING);
    goto __pyx_L10;
  }
  __pyx_L10:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya._Face._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_at_camera);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static PyObject *__pyx_f_5_soya_5_Face___iter__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face___iter__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":332 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_iter); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 332; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 332; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices);
  PyTuple_SET_ITEM(__pyx_2, 0, ((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 332; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Face.__iter__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Face___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_index);

  /* "/home/jiba/src/soya/model/face.pyx":334 */
  __pyx_1 = PyObject_GetItem(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices, __pyx_v_index); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Face.__getitem__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_index);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Face___len__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_f_5_soya_5_Face___len__(PyObject *__pyx_v_self) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":339 */
  __pyx_1 = PyObject_Length(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Face.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_filename;

static PyObject *__pyx_k246p;
static PyObject *__pyx_k247p;
static PyObject *__pyx_k248p;
static PyObject *__pyx_k249p;
static PyObject *__pyx_k250p;
static PyObject *__pyx_k251p;
static PyObject *__pyx_k252p;

static char (__pyx_k246[]) = "<Plot";
static char (__pyx_k247[]) = "<Line";
static char (__pyx_k248[]) = "<Triangle";
static char (__pyx_k249[]) = "<Quad";
static char (__pyx_k250[]) = "<Polygon";
static char (__pyx_k251[]) = ", material %s";
static char (__pyx_k252[]) = ">";

static PyObject *__pyx_f_5_soya_5_Face___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Face___repr__(PyObject *__pyx_v_self) {
  int __pyx_v_i;
  PyObject *__pyx_v_r;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_r = Py_None; Py_INCREF(__pyx_v_r);

  /* "/home/jiba/src/soya/model/face.pyx":343 */
  __pyx_1 = PyObject_Length(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 343; goto __pyx_L1;}
  __pyx_v_i = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":344 */
  __pyx_1 = (__pyx_v_i == 1);
  if (__pyx_1) {
    Py_INCREF(__pyx_k246p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k246p;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_i == 2);
  if (__pyx_1) {
    Py_INCREF(__pyx_k247p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k247p;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_i == 3);
  if (__pyx_1) {
    Py_INCREF(__pyx_k248p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k248p;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_i == 4);
  if (__pyx_1) {
    Py_INCREF(__pyx_k249p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k249p;
    goto __pyx_L2;
  }
  /*else*/ {
    Py_INCREF(__pyx_k250p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k250p;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":349 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material) == ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL);
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_material), __pyx_n_filename); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k251p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyNumber_Add(__pyx_v_r, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/face.pyx":350 */
  __pyx_4 = PyNumber_Add(__pyx_v_r, __pyx_k252p); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 350; goto __pyx_L1;}
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Face.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_r);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Face__get_box(struct __pyx_obj_5_soya__Face *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  float (__pyx_v_coord[3]);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);

  /* "/home/jiba/src/soya/model/face.pyx":356 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 356; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 356; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 356; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
    __pyx_v_vertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/face.pyx":357 */
    __pyx_3 = (__pyx_v_matrix == 0);
    if (__pyx_3) {
      memcpy(__pyx_v_coord,__pyx_v_vertex->__pyx_base._matrix,(3 * (sizeof(float ))));
      goto __pyx_L4;
    }
    /*else*/ {
      point_by_matrix_copy(__pyx_v_coord,__pyx_v_vertex->__pyx_base._matrix,__pyx_v_matrix);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/face.pyx":360 */
    __pyx_3 = ((__pyx_v_coord[0]) < (__pyx_v_box[0]));
    if (__pyx_3) {
      (__pyx_v_box[0]) = (__pyx_v_coord[0]);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/face.pyx":361 */
    __pyx_3 = ((__pyx_v_coord[1]) < (__pyx_v_box[1]));
    if (__pyx_3) {
      (__pyx_v_box[1]) = (__pyx_v_coord[1]);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/face.pyx":362 */
    __pyx_3 = ((__pyx_v_coord[2]) < (__pyx_v_box[2]));
    if (__pyx_3) {
      (__pyx_v_box[2]) = (__pyx_v_coord[2]);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/face.pyx":363 */
    __pyx_3 = ((__pyx_v_coord[0]) > (__pyx_v_box[3]));
    if (__pyx_3) {
      (__pyx_v_box[3]) = (__pyx_v_coord[0]);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/face.pyx":364 */
    __pyx_3 = ((__pyx_v_coord[1]) > (__pyx_v_box[4]));
    if (__pyx_3) {
      (__pyx_v_box[4]) = (__pyx_v_coord[1]);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/model/face.pyx":365 */
    __pyx_3 = ((__pyx_v_coord[2]) > (__pyx_v_box[5]));
    if (__pyx_3) {
      (__pyx_v_box[5]) = (__pyx_v_coord[2]);
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Face._get_box");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_double_sided;

static PyObject *__pyx_k253p;

static char (__pyx_k253[]) = "Raypicking on a face with more than 4 vertices is not supported yet.";

static void __pyx_f_5_soya_5_Face__raypick(struct __pyx_obj_5_soya__Face *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_p);
  float __pyx_v_r;
  float __pyx_v_root_r;
  float (__pyx_v_normal[3]);
  int __pyx_v_nb_vertices;
  int __pyx_v_i;
  int __pyx_v_option;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/face.pyx":371 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 371; goto __pyx_L1;}
  __pyx_v_nb_vertices = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":372 */
  __pyx_1 = (__pyx_v_nb_vertices < 3);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":373 */
  __pyx_v_option = __pyx_v_data->option;

  /* "/home/jiba/src/soya/model/face.pyx":374 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_double_sided); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 374; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_1 = __pyx_1 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_1) {
    __pyx_v_option = (__pyx_v_option & (~__pyx_e_5_soya_RAYPICK_CULL_FACE));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/face.pyx":377 */
  __pyx_v_p = ((float (*))malloc(((__pyx_v_nb_vertices * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/face.pyx":378 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_vertices; ++__pyx_v_i) {
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 378; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 378; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),(__pyx_v_p + (3 * __pyx_v_i)));
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/face.pyx":380 */
  face_normal(__pyx_v_normal,__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6));

  /* "/home/jiba/src/soya/model/face.pyx":381 */
  vector_normalize(__pyx_v_normal);

  /* "/home/jiba/src/soya/model/face.pyx":382 */
  __pyx_1 = (__pyx_v_nb_vertices == 3);
  if (__pyx_1) {
    __pyx_v_i = triangle_raypick(((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_data),__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6),__pyx_v_normal,__pyx_v_option,(&__pyx_v_r));
    goto __pyx_L6;
  }
  __pyx_1 = (__pyx_v_nb_vertices == 4);
  if (__pyx_1) {
    __pyx_v_i = quad_raypick(((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_data),__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6),(__pyx_v_p + 9),__pyx_v_normal,__pyx_v_option,(&__pyx_v_r));
    goto __pyx_L6;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 384; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 384; goto __pyx_L1;}
    Py_INCREF(__pyx_k253p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k253p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 384; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[16]; __pyx_lineno = 384; goto __pyx_L1;}
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/face.pyx":386 */
  __pyx_1 = (__pyx_v_i != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/face.pyx":387 */
    __pyx_v_root_r = ((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._distance_out(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_r);

    /* "/home/jiba/src/soya/model/face.pyx":388 */
    __pyx_1 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
    if (!__pyx_1) {
      __pyx_1 = (fabs(__pyx_v_root_r) < fabs(__pyx_v_data->root_result));
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/face.pyx":389 */
      __pyx_1 = (__pyx_v_i == __pyx_e_5_soya_RAYPICK_DIRECT);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/face.pyx":390 */
        __pyx_v_data->result = __pyx_v_r;

        /* "/home/jiba/src/soya/model/face.pyx":391 */
        __pyx_v_data->root_result = __pyx_v_root_r;

        /* "/home/jiba/src/soya/model/face.pyx":392 */
        Py_INCREF(((PyObject *)__pyx_v_self));
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
        __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_self);

        /* "/home/jiba/src/soya/model/face.pyx":393 */
        memcpy(__pyx_v_data->normal,__pyx_v_normal,(3 * (sizeof(float ))));
        goto __pyx_L9;
      }
      __pyx_1 = (__pyx_v_i == __pyx_e_5_soya_RAYPICK_INDIRECT);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/face.pyx":395 */
        __pyx_v_data->result = __pyx_v_r;

        /* "/home/jiba/src/soya/model/face.pyx":396 */
        Py_INCREF(((PyObject *)__pyx_v_self));
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
        __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_self);

        /* "/home/jiba/src/soya/model/face.pyx":397 */
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_double_sided); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 397; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 397; goto __pyx_L1;}
        if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 397; goto __pyx_L1;}
        __pyx_1 = __pyx_1 == 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/face.pyx":398 */
          (__pyx_v_data->normal[0]) = (-(__pyx_v_normal[0]));

          /* "/home/jiba/src/soya/model/face.pyx":399 */
          (__pyx_v_data->normal[1]) = (-(__pyx_v_normal[1]));

          /* "/home/jiba/src/soya/model/face.pyx":400 */
          (__pyx_v_data->normal[2]) = (-(__pyx_v_normal[2]));
          goto __pyx_L10;
        }
        /*else*/ {
          memcpy(__pyx_v_data->normal,__pyx_v_normal,(3 * (sizeof(float ))));
        }
        __pyx_L10:;
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/face.pyx":403 */
  free(__pyx_v_p);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Face._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static PyObject *__pyx_k254p;

static char (__pyx_k254[]) = "Raypicking on a face with more than 4 vertices is not supported yet.";

static int __pyx_f_5_soya_5_Face__raypick_b(struct __pyx_obj_5_soya__Face *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_p);
  float __pyx_v_r;
  float (__pyx_v_normal[3]);
  int __pyx_v_nb_vertices;
  int __pyx_v_i;
  int __pyx_v_option;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/face.pyx":410 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 410; goto __pyx_L1;}
  __pyx_v_nb_vertices = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":411 */
  __pyx_1 = (__pyx_v_nb_vertices < 3);
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":412 */
  __pyx_v_option = __pyx_v_data->option;

  /* "/home/jiba/src/soya/model/face.pyx":413 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_RAYPICK_CULL_FACE);
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_double_sided); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 413; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 413; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  if (__pyx_1) {
    __pyx_v_option = (__pyx_v_option & (~__pyx_e_5_soya_RAYPICK_CULL_FACE));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/face.pyx":416 */
  __pyx_v_p = ((float (*))malloc(((__pyx_v_nb_vertices * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/face.pyx":417 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_vertices; ++__pyx_v_i) {
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 417; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 417; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__Vertex *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__Vertex *)__pyx_3)),__pyx_v_self->__pyx_base.__pyx_base._parent,(__pyx_v_p + (3 * __pyx_v_i)));
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/face.pyx":419 */
  face_normal(__pyx_v_normal,__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6));

  /* "/home/jiba/src/soya/model/face.pyx":420 */
  vector_normalize(__pyx_v_normal);

  /* "/home/jiba/src/soya/model/face.pyx":421 */
  __pyx_1 = (__pyx_v_nb_vertices == 3);
  if (__pyx_1) {
    __pyx_v_i = triangle_raypick(((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_data),__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6),__pyx_v_normal,__pyx_v_option,(&__pyx_v_r));
    goto __pyx_L6;
  }
  __pyx_1 = (__pyx_v_nb_vertices == 4);
  if (__pyx_1) {
    __pyx_v_i = quad_raypick(((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_data),__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6),(__pyx_v_p + 9),__pyx_v_normal,__pyx_v_option,(&__pyx_v_r));
    goto __pyx_L6;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 423; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 423; goto __pyx_L1;}
    Py_INCREF(__pyx_k254p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k254p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 423; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[16]; __pyx_lineno = 423; goto __pyx_L1;}
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/face.pyx":425 */
  free(__pyx_v_p);

  /* "/home/jiba/src/soya/model/face.pyx":426 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Face._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Face__collect_raypickables(struct __pyx_obj_5_soya__Face *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/face.pyx":429 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":432 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_self)));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Face._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k255p;

static char (__pyx_k255[]) = "<%s %s>";

static PyObject *__pyx_f_5_soya_6_Shape___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Shape___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":22 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 22; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  Py_INCREF(((struct __pyx_obj_5_soya__Shape *)__pyx_v_self)->_filename);
  PyTuple_SET_ITEM(__pyx_1, 1, ((struct __pyx_obj_5_soya__Shape *)__pyx_v_self)->_filename);
  __pyx_2 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k255p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Shape.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Shape__batch(struct __pyx_obj_5_soya__Shape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/shape.pyx":25 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static void __pyx_f_5_soya_6_Shape__render(struct __pyx_obj_5_soya__Shape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/shape.pyx":28 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static int __pyx_f_5_soya_6_Shape__shadow(struct __pyx_obj_5_soya__Shape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/model/shape.pyx":31 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Shape__get_box(struct __pyx_obj_5_soya__Shape *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":34 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._get_box");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_6_Shape__raypick(struct __pyx_obj_5_soya__Shape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/model/shape.pyx":37 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_6_Shape__raypick_b(struct __pyx_obj_5_soya__Shape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/model/shape.pyx":40 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Shape__collect_raypickables(struct __pyx_obj_5_soya__Shape *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere),struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/shape.pyx":43 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Shape._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static PyObject *__pyx_f_5_soya_6_Shape___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Shape___deepcopy__[] = "Shapes are immutable.";
static PyObject *__pyx_f_5_soya_6_Shape___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_memo = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"memo",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_memo)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_memo);

  /* "/home/jiba/src/soya/model/shape.pyx":47 */
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_r = __pyx_v_self;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Shape.__deepcopy__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_memo);
  return __pyx_r;
}

static int __pyx_f_5_soya_face_vertices_number(__pyx_t_5_soya_ShapeFace (*__pyx_v_self)) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":69 */
  __pyx_1 = (__pyx_v_self->option & __pyx_e_5_soya_FACE_TRIANGLE);
  if (__pyx_1) {
    __pyx_r = 3;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_self->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {
    __pyx_r = 4;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":71 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.face_vertices_number");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape__get_box(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  float (*__pyx_v_coord);
  float (__pyx_v_coord2[3]);
  PyObject *__pyx_v_i;
  long __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_i = Py_None; Py_INCREF(__pyx_v_i);

  /* "/home/jiba/src/soya/model/shape.pyx":91 */
  __pyx_v_coord = __pyx_v_self->_coords;

  /* "/home/jiba/src/soya/model/shape.pyx":92 */
  __pyx_2 = __pyx_v_self->_nb_coords;
  for (__pyx_1 = 0; __pyx_1 < __pyx_2; ++__pyx_1) {
    __pyx_3 = PyInt_FromLong(__pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 92; goto __pyx_L1;}
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":93 */
    point_by_matrix_copy(__pyx_v_coord2,__pyx_v_coord,__pyx_v_matrix);

    /* "/home/jiba/src/soya/model/shape.pyx":95 */
    __pyx_4 = ((__pyx_v_coord2[0]) < (__pyx_v_box[0]));
    if (__pyx_4) {
      (__pyx_v_box[0]) = (__pyx_v_coord2[0]);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/shape.pyx":96 */
    __pyx_4 = ((__pyx_v_coord2[1]) < (__pyx_v_box[1]));
    if (__pyx_4) {
      (__pyx_v_box[1]) = (__pyx_v_coord2[1]);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/shape.pyx":97 */
    __pyx_4 = ((__pyx_v_coord2[2]) < (__pyx_v_box[2]));
    if (__pyx_4) {
      (__pyx_v_box[2]) = (__pyx_v_coord2[2]);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/shape.pyx":98 */
    __pyx_4 = ((__pyx_v_coord2[0]) > (__pyx_v_box[3]));
    if (__pyx_4) {
      (__pyx_v_box[3]) = (__pyx_v_coord2[0]);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/shape.pyx":99 */
    __pyx_4 = ((__pyx_v_coord2[1]) > (__pyx_v_box[4]));
    if (__pyx_4) {
      (__pyx_v_box[4]) = (__pyx_v_coord2[1]);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/shape.pyx":100 */
    __pyx_4 = ((__pyx_v_coord2[2]) > (__pyx_v_box[5]));
    if (__pyx_4) {
      (__pyx_v_box[5]) = (__pyx_v_coord2[2]);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/model/shape.pyx":102 */
    __pyx_v_coord = (__pyx_v_coord + 3);
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SimpleShape._get_box");
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_12_SimpleShape___getcstate__(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int __pyx_v_i;
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  PyObject *__pyx_v_material_id2index;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_material_id2index = Py_None; Py_INCREF(__pyx_v_material_id2index);

  /* "/home/jiba/src/soya/model/shape.pyx":109 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 109; goto __pyx_L1;}
  Py_DECREF(__pyx_v_material_id2index);
  __pyx_v_material_id2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":110 */
  __pyx_2 = PyObject_Length(__pyx_v_self->_materials); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {
    __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    __pyx_5 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (PyObject_SetItem(__pyx_v_material_id2index, __pyx_5, __pyx_1) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 110; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":112 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/shape.pyx":113 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/shape.pyx":114 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vertices);

  /* "/home/jiba/src/soya/model/shape.pyx":115 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_coords);

  /* "/home/jiba/src/soya/model/shape.pyx":116 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vnormals);

  /* "/home/jiba/src/soya/model/shape.pyx":117 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_colors);

  /* "/home/jiba/src/soya/model/shape.pyx":118 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_values);

  /* "/home/jiba/src/soya/model/shape.pyx":119 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_faces);

  /* "/home/jiba/src/soya/model/shape.pyx":121 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_coords,(3 * __pyx_v_self->_nb_coords));

  /* "/home/jiba/src/soya/model/shape.pyx":122 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_vnormals,(3 * __pyx_v_self->_nb_vnormals));

  /* "/home/jiba/src/soya/model/shape.pyx":123 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/shape.pyx":124 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_values,__pyx_v_self->_nb_values);

  /* "/home/jiba/src/soya/model/shape.pyx":126 */
  chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_coords,__pyx_v_self->_nb_vertices);

  /* "/home/jiba/src/soya/model/shape.pyx":127 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
  if (__pyx_2) {
    chunk_add_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_options,__pyx_v_self->_nb_vertices);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":128 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_2) {
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_texcoords,__pyx_v_self->_nb_vertices);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":129 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_2) {
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_diffuses,__pyx_v_self->_nb_vertices);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/shape.pyx":130 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_2) {
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_emissives,__pyx_v_self->_nb_vertices);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/shape.pyx":131 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_2) {
    chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sphere,4);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/shape.pyx":133 */
  __pyx_2 = __pyx_v_self->_nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":134 */
    __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/shape.pyx":135 */
    chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_face->option);

    /* "/home/jiba/src/soya/model/shape.pyx":136 */
    __pyx_3 = PyInt_FromLong(__pyx_v_face->pack->material_id); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 136; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_material_id2index, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 136; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_6 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 136; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_6);

    /* "/home/jiba/src/soya/model/shape.pyx":137 */
    chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_face->normal);

    /* "/home/jiba/src/soya/model/shape.pyx":138 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_face->v,4);
    __pyx_L9:;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/shape.pyx":140 */
  __pyx_6 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_NEIGHBORS);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/model/shape.pyx":141 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/shape.pyx":142 */
    chunk_add_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_neighbors_side,(__pyx_v_self->_nb_faces * 4));
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/shape.pyx":144 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":145 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_simple_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/shape.pyx":146 */
    chunk_add_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_simple_neighbors_side,(__pyx_v_self->_nb_faces * 4));
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/model/shape.pyx":148 */
  __pyx_5 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 148; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 148; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_5);
  Py_INCREF(__pyx_v_self->__pyx_base._filename);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_self->__pyx_base._filename);
  Py_INCREF(__pyx_v_self->_materials);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_self->_materials);
  __pyx_5 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._SimpleShape.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_material_id2index);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape___setcstate_data__(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,PyObject *__pyx_v_cstate) {
  int __pyx_v_i;
  int __pyx_v_temp;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/shape.pyx":155 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->__pyx_base._filename);
  __pyx_v_self->__pyx_base._filename = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_materials);
  __pyx_v_self->_materials = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 3) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 155; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shape.pyx":156 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/shape.pyx":158 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/model/shape.pyx":159 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vertices));

  /* "/home/jiba/src/soya/model/shape.pyx":160 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_coords));

  /* "/home/jiba/src/soya/model/shape.pyx":161 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vnormals));

  /* "/home/jiba/src/soya/model/shape.pyx":162 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/shape.pyx":163 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_values));

  /* "/home/jiba/src/soya/model/shape.pyx":164 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_faces));

  /* "/home/jiba/src/soya/model/shape.pyx":166 */
  __pyx_v_self->_faces = ((__pyx_t_5_soya_ShapeFace (*))malloc((__pyx_v_self->_nb_faces * (sizeof(__pyx_t_5_soya_ShapeFace )))));

  /* "/home/jiba/src/soya/model/shape.pyx":167 */
  __pyx_v_self->_coords = ((float (*))malloc(((3 * __pyx_v_self->_nb_coords) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":168 */
  __pyx_v_self->_vnormals = ((float (*))malloc(((3 * __pyx_v_self->_nb_vnormals) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":169 */
  __pyx_v_self->_colors = ((float (*))malloc(((4 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":170 */
  __pyx_v_self->_values = ((float (*))malloc((__pyx_v_self->_nb_values * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":172 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_coords,(3 * __pyx_v_self->_nb_coords));

  /* "/home/jiba/src/soya/model/shape.pyx":173 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_vnormals,(3 * __pyx_v_self->_nb_vnormals));

  /* "/home/jiba/src/soya/model/shape.pyx":174 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/shape.pyx":175 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_values,__pyx_v_self->_nb_values);

  /* "/home/jiba/src/soya/model/shape.pyx":177 */
  __pyx_v_self->_vertex_coords = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/shape.pyx":178 */
  chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_coords,__pyx_v_self->_nb_vertices);

  /* "/home/jiba/src/soya/model/shape.pyx":179 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":179 */
    __pyx_v_self->_vertex_options = ((char (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/shape.pyx":179 */
    chunk_get_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_options,__pyx_v_self->_nb_vertices);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":180 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":180 */
    __pyx_v_self->_vertex_texcoords = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":180 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_texcoords,__pyx_v_self->_nb_vertices);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":181 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":181 */
    __pyx_v_self->_vertex_diffuses = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":181 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_diffuses,__pyx_v_self->_nb_vertices);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":182 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":182 */
    __pyx_v_self->_vertex_emissives = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":182 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_emissives,__pyx_v_self->_nb_vertices);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":183 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":183 */
    __pyx_v_self->_sphere = ((float (*))malloc((4 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/shape.pyx":183 */
    chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sphere,4);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/shape.pyx":185 */
  __pyx_4 = __pyx_v_self->_nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_4; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":186 */
    __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/shape.pyx":187 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_face->option));

    /* "/home/jiba/src/soya/model/shape.pyx":188 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_temp));

    /* "/home/jiba/src/soya/model/shape.pyx":189 */
    __pyx_1 = PyInt_FromLong(__pyx_v_temp); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 189; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 189; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_v_face->pack = ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_2)->__pyx_base.__pyx_vtab)->_pack(((struct __pyx_obj_5_soya__Material *)__pyx_2),__pyx_v_face->option);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":190 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/shape.pyx":192 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[0])));

    /* "/home/jiba/src/soya/model/shape.pyx":193 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[1])));

    /* "/home/jiba/src/soya/model/shape.pyx":194 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[2])));

    /* "/home/jiba/src/soya/model/shape.pyx":195 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[3])));
    __pyx_L7:;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/shape.pyx":197 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_NEIGHBORS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":198 */
    __pyx_v_self->_neighbors = ((int (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":199 */
    __pyx_v_self->_neighbors_side = ((char (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/shape.pyx":200 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/shape.pyx":201 */
    chunk_get_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_neighbors_side,(__pyx_v_self->_nb_faces * 4));
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/shape.pyx":203 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":204 */
    __pyx_v_self->_simple_neighbors = ((int (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":205 */
    __pyx_v_self->_simple_neighbors_side = ((char (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/shape.pyx":206 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_simple_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/shape.pyx":207 */
    chunk_get_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_simple_neighbors_side,(__pyx_v_self->_nb_faces * 4));
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/shape.pyx":209 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/shape.pyx":211 */
  __pyx_v_self->_option = (__pyx_v_self->_option & (~__pyx_e_5_soya_SHAPE_INITED));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SimpleShape.__setcstate_data__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_12_SimpleShape___setcstate__(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,PyObject *__pyx_v_cstate) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/shape.pyx":214 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__setcstate_data__(__pyx_v_self,__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/shape.pyx":215 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_build_display_list(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_6option___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_6option___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":219 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 219; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SimpleShape.option.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_9materials___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_9materials___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":223 */
  Py_INCREF(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials);
  __pyx_r = ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SimpleShape.materials.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_9nb_coords___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_9nb_coords___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":227 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_coords); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 227; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SimpleShape.nb_coords.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_11nb_vertices___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_11nb_vertices___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":231 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SimpleShape.nb_vertices.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_8nb_faces___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_8nb_faces___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":235 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._SimpleShape.nb_faces.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_face(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_SimpleShape_get_face[] = "Debugging functions";
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_face(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":240 */
  __pyx_v_face = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_faces + __pyx_v_index);

  /* "/home/jiba/src/soya/model/shape.pyx":241 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong((__pyx_v_face->v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 241; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((__pyx_v_face->v[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 241; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((__pyx_v_face->v[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 241; goto __pyx_L1;}
    __pyx_5 = PyInt_FromLong((__pyx_v_face->v[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 241; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 241; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
    PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_5 = 0;
    __pyx_r = __pyx_6;
    __pyx_6 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyInt_FromLong((__pyx_v_face->v[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 242; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((__pyx_v_face->v[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 242; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((__pyx_v_face->v[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 242; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 242; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
    __pyx_2 = 0;
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_r = __pyx_5;
    __pyx_5 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._SimpleShape.get_face");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_vertex_index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_SimpleShape_get_vertex_index[] = "Debugging functions";
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_vertex_index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  PyObject *__pyx_v_l;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_l = Py_None; Py_INCREF(__pyx_v_l);

  /* "/home/jiba/src/soya/model/shape.pyx":246 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_coords[__pyx_v_index])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 246; goto __pyx_L1;}
  PyList_SET_ITEM(__pyx_2, 0, __pyx_1);
  __pyx_1 = 0;
  Py_DECREF(__pyx_v_l);
  __pyx_v_l = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":247 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 247; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_options[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 247; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 247; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 247; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 248; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 248; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 248; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":249 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 249; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_texcoords[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 249; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 249; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 249; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 250; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":251 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 251; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 251; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 251; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 251; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 252; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 252; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 252; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 252; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":253 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_emissives[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 253; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 254; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":255 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_INCREF(__pyx_v_l);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_l);
  __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 255; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._SimpleShape.get_vertex_index");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_l);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_vertex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_SimpleShape_get_vertex[] = "Debugging functions";
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_vertex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  PyObject *__pyx_v_l;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_l = Py_None; Py_INCREF(__pyx_v_l);

  /* "/home/jiba/src/soya/model/shape.pyx":259 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_coords[(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_coords[__pyx_v_index])])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 259; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_coords[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_coords[__pyx_v_index]) + 1)])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 259; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_coords[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_coords[__pyx_v_index]) + 2)])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 259; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 259; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 259; goto __pyx_L1;}
  PyList_SET_ITEM(__pyx_1, 0, __pyx_4);
  __pyx_4 = 0;
  Py_DECREF(__pyx_v_l);
  __pyx_v_l = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":260 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
  if (__pyx_5) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 260; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_options[__pyx_v_index])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 260; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 260; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 260; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_3 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 261; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 261; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 261; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 261; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":262 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_5) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 262; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_values[(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_texcoords[__pyx_v_index])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 262; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_values[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_texcoords[__pyx_v_index]) + 1)])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 262; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 262; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4);
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 262; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
    __pyx_1 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 262; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 263; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 263; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 263; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 263; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":264 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_5) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index])])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index]) + 1)])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index]) + 2)])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index]) + 3)])); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
    PyTuple_SET_ITEM(__pyx_7, 1, __pyx_3);
    PyTuple_SET_ITEM(__pyx_7, 2, __pyx_4);
    PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
    __pyx_1 = 0;
    __pyx_3 = 0;
    __pyx_4 = 0;
    __pyx_6 = 0;
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7);
    __pyx_7 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 264; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_4 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 265; goto __pyx_L1;}
    __pyx_6 = PyInt_FromLong((-1)); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 265; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 265; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_7, 0, __pyx_6);
    __pyx_6 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 265; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_7); __pyx_7 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":266 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_5) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_emissives[__pyx_v_index])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_emissives[__pyx_v_index]) + 1)])); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_emissives[__pyx_v_index]) + 2)])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_7 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_emissives[__pyx_v_index]) + 3)])); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_6);
    PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4);
    PyTuple_SET_ITEM(__pyx_2, 3, __pyx_7);
    __pyx_3 = 0;
    __pyx_6 = 0;
    __pyx_4 = 0;
    __pyx_7 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_6 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 266; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    goto __pyx_L5;
  }
  /*else*/ {
    __pyx_4 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 267; goto __pyx_L1;}
    __pyx_7 = PyInt_FromLong((-1)); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 267; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 267; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_7);
    __pyx_7 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 267; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":268 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 268; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 268; goto __pyx_L1;}
  Py_INCREF(__pyx_v_l);
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_l);
  __pyx_7 = PyObject_CallObject(__pyx_3, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 268; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_r = __pyx_7;
  __pyx_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya._SimpleShape.get_vertex");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_l);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_neighbor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_neighbor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  int (*__pyx_v_neighbor);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":271 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_NEIGHBORS));
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":273 */
  __pyx_v_neighbor = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_neighbors + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/shape.pyx":274 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 274; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._SimpleShape.get_neighbor");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_neighbor_side(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_neighbor_side(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  char (*__pyx_v_neighbor_side);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":277 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_NEIGHBORS));
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":279 */
  __pyx_v_neighbor_side = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_neighbors_side + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/shape.pyx":280 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor_side[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 280; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor_side[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 280; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor_side[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 280; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor_side[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 280; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 280; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._SimpleShape.get_neighbor_side");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_simple_neighbor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_simple_neighbor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  int (*__pyx_v_neighbor);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":283 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS));
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":285 */
  __pyx_v_neighbor = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_simple_neighbors + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/shape.pyx":286 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 286; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 286; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._SimpleShape.get_simple_neighbor");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_get_simple_neighbor_side(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_get_simple_neighbor_side(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  char (*__pyx_v_neighbor_side);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":289 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS));
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":291 */
  __pyx_v_neighbor_side = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_simple_neighbors_side + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/shape.pyx":292 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor_side[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor_side[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor_side[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor_side[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 292; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._SimpleShape.get_simple_neighbor_side");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleShape_6sphere___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleShape_6sphere___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":296 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_sphere[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_sphere[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_sphere[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_sphere[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 296; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._SimpleShape.sphere.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape__register_material(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya__Material *__pyx_v_material) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_material);

  /* "/home/jiba/src/soya/model/shape.pyx":299 */
  __pyx_1 = PySequence_Contains(__pyx_v_self->_materials, ((PyObject *)__pyx_v_material)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 299; goto __pyx_L1;}
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":300 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 300; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_material));
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 300; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleShape._register_material");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
}

static void __pyx_f_5_soya_12_SimpleShape__add_coord(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vertex);

  /* "/home/jiba/src/soya/model/shape.pyx":303 */
  ((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_vertex->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_vertex),(__pyx_v_self->_coords + (3 * __pyx_v_self->_nb_coords)));

  /* "/home/jiba/src/soya/model/shape.pyx":304 */
  __pyx_v_self->_nb_coords = (__pyx_v_self->_nb_coords + 1);

  /* "/home/jiba/src/soya/model/shape.pyx":305 */
  __pyx_1 = ((PyObject *)__pyx_v_vertex->_normal) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":306 */
    ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vertex->_normal->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_vertex->_normal),(__pyx_v_self->_vnormals + (3 * __pyx_v_self->_nb_vnormals)));

    /* "/home/jiba/src/soya/model/shape.pyx":307 */
    vector_normalize((__pyx_v_self->_vnormals + (3 * __pyx_v_self->_nb_vnormals)));

    /* "/home/jiba/src/soya/model/shape.pyx":308 */
    __pyx_v_self->_nb_vnormals = (__pyx_v_self->_nb_vnormals + 1);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._add_coord");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vertex);
}

static int __pyx_f_5_soya_12_SimpleShape__register_value(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,float (*__pyx_v_value),int __pyx_v_nb) {
  int __pyx_v_r;
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":312 */
  __pyx_1 = (__pyx_v_self->_nb_values - __pyx_v_nb);
  for (__pyx_v_r = 0; __pyx_v_r <= __pyx_1; ++__pyx_v_r) {

    /* "/home/jiba/src/soya/model/shape.pyx":313 */
    __pyx_2 = (float_array_compare(__pyx_v_value,(__pyx_v_self->_values + __pyx_v_r),__pyx_v_nb) == 1);
    if (__pyx_2) {
      __pyx_r = __pyx_v_r;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":314 */
  __pyx_v_r = __pyx_v_self->_nb_values;

  /* "/home/jiba/src/soya/model/shape.pyx":315 */
  __pyx_v_self->_nb_values = (__pyx_v_self->_nb_values + __pyx_v_nb);

  /* "/home/jiba/src/soya/model/shape.pyx":316 */
  __pyx_v_self->_values = ((float (*))realloc(__pyx_v_self->_values,(__pyx_v_self->_nb_values * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":317 */
  memcpy((__pyx_v_self->_values + __pyx_v_r),__pyx_v_value,(__pyx_v_nb * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/shape.pyx":318 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._register_value");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_SimpleShape__register_color(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,float (*__pyx_v_color)) {
  float (*__pyx_v_ptr);
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":323 */
  __pyx_v_ptr = __pyx_v_self->_colors;

  /* "/home/jiba/src/soya/model/shape.pyx":324 */
  __pyx_1 = __pyx_v_self->_nb_colors;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":325 */
    __pyx_2 = (fabs(((__pyx_v_color[0]) - (__pyx_v_ptr[0]))) < EPSILON);
    if (__pyx_2) {
      __pyx_2 = (fabs(((__pyx_v_color[1]) - (__pyx_v_ptr[1]))) < EPSILON);
      if (__pyx_2) {
        __pyx_2 = (fabs(((__pyx_v_color[2]) - (__pyx_v_ptr[2]))) < EPSILON);
        if (__pyx_2) {
          __pyx_2 = (fabs(((__pyx_v_color[3]) - (__pyx_v_ptr[3]))) < EPSILON);
        }
      }
    }
    if (__pyx_2) {
      __pyx_r = (4 * __pyx_v_i);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/shape.pyx":329 */
    __pyx_v_ptr = (__pyx_v_ptr + 4);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":331 */
  __pyx_v_i = (__pyx_v_self->_nb_colors * 4);

  /* "/home/jiba/src/soya/model/shape.pyx":332 */
  __pyx_v_self->_nb_colors = (__pyx_v_self->_nb_colors + 1);

  /* "/home/jiba/src/soya/model/shape.pyx":333 */
  __pyx_v_self->_colors = ((float (*))realloc(__pyx_v_self->_colors,((__pyx_v_self->_nb_colors * 4) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":334 */
  memcpy((__pyx_v_self->_colors + __pyx_v_i),__pyx_v_color,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/shape.pyx":335 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._register_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k256p;

static char (__pyx_k256[]) = "Face with %s vertices are not supported in shape.";

static void __pyx_f_5_soya_12_SimpleShape__add_face(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya__Face *__pyx_v_face,PyObject *__pyx_v_vertex2ivertex,PyObject *__pyx_v_ivertex2index,PyObject *__pyx_v_lights,int __pyx_v_static_shadow) {
  __pyx_t_5_soya_ShapeFace (*__pyx_v_sf);
  int __pyx_v_nb_vertices;
  float (__pyx_v_n[4]);
  float (*__pyx_v_p);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_face);
  Py_INCREF(__pyx_v_vertex2ivertex);
  Py_INCREF(__pyx_v_ivertex2index);
  Py_INCREF(__pyx_v_lights);

  /* "/home/jiba/src/soya/model/shape.pyx":342 */
  __pyx_v_sf = (__pyx_v_self->_faces + __pyx_v_self->_nb_faces);

  /* "/home/jiba/src/soya/model/shape.pyx":344 */
  __pyx_v_sf->option = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":345 */
  (__pyx_v_n[0]) = 0.0;
  (__pyx_v_n[1]) = 0.0;
  (__pyx_v_n[2]) = 0.0;
  (__pyx_v_n[3]) = 0.0;

  /* "/home/jiba/src/soya/model/shape.pyx":346 */
  __pyx_1 = PyObject_Length(__pyx_v_face->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_v_nb_vertices = __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":347 */
  __pyx_1 = (__pyx_v_nb_vertices == 3);
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_TRIANGLE);
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_nb_vertices == 4);
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_QUAD);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_nb_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k256p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":350 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_is_alpha); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 350; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 350; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 350; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 350; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_ALPHA);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":351 */
  __pyx_1 = (__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED);
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_DOUBLE_SIDED);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":352 */
  __pyx_1 = (__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_FACE2_SMOOTH_LIT);
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_SMOOTH_LIT);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":353 */
  __pyx_1 = (!(__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_FACE2_LIT));
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_NON_LIT);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/shape.pyx":354 */
  __pyx_1 = (__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    __pyx_v_sf->option = (__pyx_v_sf->option | __pyx_e_5_soya_FACE_NON_SOLID);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/shape.pyx":358 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 358; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 358; goto __pyx_L1;}
  (__pyx_v_sf->v[0]) = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_add_vertex(__pyx_v_self,((struct __pyx_obj_5_soya__Vertex *)__pyx_3),__pyx_v_vertex2ivertex,__pyx_v_ivertex2index,__pyx_v_lights,__pyx_v_static_shadow);
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":359 */
  __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 359; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 359; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 359; goto __pyx_L1;}
  (__pyx_v_sf->v[1]) = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_add_vertex(__pyx_v_self,((struct __pyx_obj_5_soya__Vertex *)__pyx_2),__pyx_v_vertex2ivertex,__pyx_v_ivertex2index,__pyx_v_lights,__pyx_v_static_shadow);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":360 */
  __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 360; goto __pyx_L1;}
  __pyx_4 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 360; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 360; goto __pyx_L1;}
  (__pyx_v_sf->v[2]) = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_add_vertex(__pyx_v_self,((struct __pyx_obj_5_soya__Vertex *)__pyx_4),__pyx_v_vertex2ivertex,__pyx_v_ivertex2index,__pyx_v_lights,__pyx_v_static_shadow);
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":361 */
  __pyx_1 = (__pyx_v_nb_vertices == 4);
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 361; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 361; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 361; goto __pyx_L1;}
    (__pyx_v_sf->v[3]) = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_add_vertex(__pyx_v_self,((struct __pyx_obj_5_soya__Vertex *)__pyx_3),__pyx_v_vertex2ivertex,__pyx_v_ivertex2index,__pyx_v_lights,__pyx_v_static_shadow);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/shape.pyx":363 */
  ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_face->_normal->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_face->_normal),__pyx_v_n);

  /* "/home/jiba/src/soya/model/shape.pyx":364 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_PLANE_EQUATION);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":365 */
    __pyx_v_p = (__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_sf->v[0])]));

    /* "/home/jiba/src/soya/model/shape.pyx":366 */
    (__pyx_v_n[3]) = (-((((__pyx_v_p[0]) * (__pyx_v_n[0])) + ((__pyx_v_p[1]) * (__pyx_v_n[1]))) + ((__pyx_v_p[2]) * (__pyx_v_n[2]))));

    /* "/home/jiba/src/soya/model/shape.pyx":367 */
    plane_vector_normalize(__pyx_v_n);

    /* "/home/jiba/src/soya/model/shape.pyx":368 */
    __pyx_v_sf->normal = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_register_value(__pyx_v_self,__pyx_v_n,4);
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/shape.pyx":370 */
    vector_normalize(__pyx_v_n);

    /* "/home/jiba/src/soya/model/shape.pyx":371 */
    __pyx_v_sf->normal = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_register_value(__pyx_v_self,__pyx_v_n,3);
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/shape.pyx":374 */
  __pyx_1 = PySequence_Contains(__pyx_v_self->_materials, ((PyObject *)__pyx_v_face->_material)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 374; goto __pyx_L1;}
  __pyx_5 = (!__pyx_1);
  if (__pyx_5) {
    __pyx_4 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 374; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 374; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_face->_material));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_face->_material));
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 374; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/shape.pyx":375 */
  __pyx_v_sf->pack = ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_face->_material->__pyx_base.__pyx_vtab)->_pack(__pyx_v_face->_material,__pyx_v_sf->option);

  /* "/home/jiba/src/soya/model/shape.pyx":377 */
  __pyx_v_self->_nb_faces = (__pyx_v_self->_nb_faces + 1);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleShape._add_face");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_face);
  Py_DECREF(__pyx_v_vertex2ivertex);
  Py_DECREF(__pyx_v_ivertex2index);
  Py_DECREF(__pyx_v_lights);
}

static int __pyx_f_5_soya_12_SimpleShape__add_vertex(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex,PyObject *__pyx_v_vertex2ivertex,PyObject *__pyx_v_ivertex2index,PyObject *__pyx_v_lights,int __pyx_v_static_shadow) {
  float (__pyx_v_value[4]);
  float (__pyx_v_p[3]);
  float (__pyx_v_v[3]);
  int __pyx_v_coord;
  int __pyx_v_texcoord;
  int __pyx_v_diffuse;
  int __pyx_v_emissive;
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_ivertex;
  int __pyx_v_i;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  float __pyx_6;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_vertex);
  Py_INCREF(__pyx_v_vertex2ivertex);
  Py_INCREF(__pyx_v_ivertex2index);
  Py_INCREF(__pyx_v_lights);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);
  __pyx_v_ivertex = Py_None; Py_INCREF((PyObject *) __pyx_v_ivertex);

  /* "/home/jiba/src/soya/model/shape.pyx":384 */
  __pyx_1 = PyObject_GetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex)); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 384; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 384; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
  __pyx_v_ivertex = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":386 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 386; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex)); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 386; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_ivertex2index, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 386; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyNumber_Multiply(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 386; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 386; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_coord = __pyx_4;

  /* "/home/jiba/src/soya/model/shape.pyx":388 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":389 */
    (__pyx_v_value[0]) = __pyx_v_vertex->_tex_x;

    /* "/home/jiba/src/soya/model/shape.pyx":390 */
    (__pyx_v_value[1]) = __pyx_v_vertex->_tex_y;

    /* "/home/jiba/src/soya/model/shape.pyx":391 */
    __pyx_v_texcoord = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_register_value(__pyx_v_self,__pyx_v_value,2);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_texcoord = (-1);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":394 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":395 */
    __pyx_4 = __pyx_v_vertex->_diffuse == Py_None;
    __pyx_5 = (!__pyx_4);
    if (__pyx_5) {

      /* "/home/jiba/src/soya/model/shape.pyx":396 */
      __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 396; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (__pyx_v_value[0]) = __pyx_6;

      /* "/home/jiba/src/soya/model/shape.pyx":397 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 397; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 397; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 397; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      (__pyx_v_value[1]) = __pyx_6;

      /* "/home/jiba/src/soya/model/shape.pyx":398 */
      __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 398; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 398; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      (__pyx_v_value[2]) = __pyx_6;

      /* "/home/jiba/src/soya/model/shape.pyx":399 */
      __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (__pyx_v_value[3]) = __pyx_6;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/shape.pyx":401 */
      memcpy(__pyx_v_value,__pyx_v_vertex->_face->_material->_diffuse,(4 * (sizeof(float ))));
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/shape.pyx":402 */
    __pyx_v_diffuse = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_register_color(__pyx_v_self,__pyx_v_value);
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_v_diffuse = (-1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":405 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":406 */
    __pyx_5 = __pyx_v_vertex->_emissive == Py_None;
    __pyx_4 = (!__pyx_5);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/model/shape.pyx":407 */
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 407; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 407; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 407; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      (__pyx_v_value[0]) = __pyx_6;

      /* "/home/jiba/src/soya/model/shape.pyx":408 */
      __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 408; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 408; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 408; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      (__pyx_v_value[1]) = __pyx_6;

      /* "/home/jiba/src/soya/model/shape.pyx":409 */
      __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 409; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 409; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 409; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (__pyx_v_value[2]) = __pyx_6;

      /* "/home/jiba/src/soya/model/shape.pyx":410 */
      __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 410; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 410; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 410; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      (__pyx_v_value[3]) = __pyx_6;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/shape.pyx":412 */
      (__pyx_v_value[0]) = 0.0;
      (__pyx_v_value[1]) = 0.0;
      (__pyx_v_value[2]) = 0.0;

      /* "/home/jiba/src/soya/model/shape.pyx":413 */
      (__pyx_v_value[3]) = 1.0;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_5 = PyObject_IsTrue(__pyx_v_lights); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 415; goto __pyx_L1;}
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/shape.pyx":416 */
    (__pyx_v_value[0]) = 0.0;
    (__pyx_v_value[1]) = 0.0;
    (__pyx_v_value[2]) = 0.0;

    /* "/home/jiba/src/soya/model/shape.pyx":417 */
    (__pyx_v_value[3]) = 1.0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":419 */
  __pyx_4 = PyObject_IsTrue(__pyx_v_lights); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 419; goto __pyx_L1;}
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":420 */
    __pyx_3 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 420; goto __pyx_L1;}
    for (;;) {
      __pyx_L8:;
      __pyx_2 = PyIter_Next(__pyx_3);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 420; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 420; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
      __pyx_v_light = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":421 */
      ((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_vertex->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vertex),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_light),__pyx_v_p);

      /* "/home/jiba/src/soya/model/shape.pyx":422 */
      __pyx_5 = (__pyx_v_vertex->_face->__pyx_base._option & __pyx_e_5_soya_FACE2_SMOOTH_LIT);
      if (__pyx_5) {
        ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_ivertex->_normal->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_ivertex->_normal),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_light),__pyx_v_v);
        goto __pyx_L10;
      }
      /*else*/ {
        ((struct __pyx_vtabstruct_5_soya__Vector *)__pyx_v_vertex->_face->_normal->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._into(((struct __pyx_obj_5_soya_Position *)__pyx_v_vertex->_face->_normal),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_light),__pyx_v_v);
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/model/shape.pyx":424 */
      ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_static_light_at(__pyx_v_light,__pyx_v_p,__pyx_v_v,__pyx_v_static_shadow,__pyx_v_value);
    }
    __pyx_L9:;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/shape.pyx":425 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_4) {
    __pyx_v_emissive = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_register_color(__pyx_v_self,__pyx_v_value);
    goto __pyx_L11;
  }
  /*else*/ {
    __pyx_v_emissive = (-1);
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/shape.pyx":429 */
  __pyx_5 = __pyx_v_self->_nb_vertices;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":430 */
    __pyx_4 = ((__pyx_v_self->_vertex_coords[__pyx_v_i]) == __pyx_v_coord);
    if (__pyx_4) {
      __pyx_4 = (__pyx_v_texcoord == (-1));
      if (!__pyx_4) {
        __pyx_4 = ((__pyx_v_self->_vertex_texcoords[__pyx_v_i]) == __pyx_v_texcoord);
      }
      if (__pyx_4) {
        __pyx_4 = (__pyx_v_diffuse == (-1));
        if (!__pyx_4) {
          __pyx_4 = ((__pyx_v_self->_vertex_diffuses[__pyx_v_i]) == __pyx_v_diffuse);
        }
        if (__pyx_4) {
          __pyx_4 = (__pyx_v_emissive == (-1));
          if (!__pyx_4) {
            __pyx_4 = ((__pyx_v_self->_vertex_emissives[__pyx_v_i]) == __pyx_v_emissive);
          }
        }
      }
    }
    if (__pyx_4) {
      __pyx_r = __pyx_v_i;
      goto __pyx_L0;
      goto __pyx_L14;
    }
    __pyx_L14:;
    __pyx_L12:;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/model/shape.pyx":435 */
  __pyx_v_i = __pyx_v_self->_nb_vertices;

  /* "/home/jiba/src/soya/model/shape.pyx":436 */
  __pyx_v_self->_nb_vertices = (__pyx_v_self->_nb_vertices + 1);

  /* "/home/jiba/src/soya/model/shape.pyx":437 */
  __pyx_v_self->_vertex_coords = ((int (*))realloc(__pyx_v_self->_vertex_coords,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/shape.pyx":438 */
  (__pyx_v_self->_vertex_coords[__pyx_v_i]) = __pyx_v_coord;

  /* "/home/jiba/src/soya/model/shape.pyx":440 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":440 */
    __pyx_v_self->_vertex_texcoords = ((int (*))realloc(__pyx_v_self->_vertex_texcoords,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":440 */
    (__pyx_v_self->_vertex_texcoords[__pyx_v_i]) = __pyx_v_texcoord;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/model/shape.pyx":441 */
  __pyx_5 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/shape.pyx":441 */
    __pyx_v_self->_vertex_diffuses = ((int (*))realloc(__pyx_v_self->_vertex_diffuses,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":441 */
    (__pyx_v_self->_vertex_diffuses[__pyx_v_i]) = __pyx_v_diffuse;
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/jiba/src/soya/model/shape.pyx":442 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/shape.pyx":442 */
    __pyx_v_self->_vertex_emissives = ((int (*))realloc(__pyx_v_self->_vertex_emissives,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":442 */
    (__pyx_v_self->_vertex_emissives[__pyx_v_i]) = __pyx_v_emissive;
    goto __pyx_L17;
  }
  __pyx_L17:;

  /* "/home/jiba/src/soya/model/shape.pyx":443 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SimpleShape._add_vertex");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_ivertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF(__pyx_v_vertex2ivertex);
  Py_DECREF(__pyx_v_ivertex2index);
  Py_DECREF(__pyx_v_lights);
  return __pyx_r;
}

static PyObject *__pyx_n_sets;
static PyObject *__pyx_n_Set;
static PyObject *__pyx_n_values;
static PyObject *__pyx_n_face;
static PyObject *__pyx_n_normal;
static PyObject *__pyx_n_angle_to;
static PyObject *__pyx_n_sort;

static char (__pyx_k257[]) = "Finds which vertices are at the same position, for vertex sharing capabilities.\n2 vertices are considered at the same position if the distance between them is > EPSILON,\nand if the angle between their 2 faces is < ANGLE.";

static PyObject *__pyx_f_5_soya_12_SimpleShape__identify_vertices(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,PyObject *__pyx_v_faces,float __pyx_v_angle) {
  struct __pyx_obj_5_soya__Face *__pyx_v_face;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_ivertex;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex2;
  int __pyx_v_i;
  int __pyx_v_j;
  float (__pyx_v_p[3]);
  float __pyx_v_amin;
  float __pyx_v_a;
  PyObject *__pyx_v_ivertices;
  PyObject *__pyx_v_vertex2ivertex;
  PyObject *__pyx_v_ivertex2vertices;
  PyObject *__pyx_v_hashcube;
  PyObject *__pyx_v_hash;
  PyObject *__pyx_v_vertex2ivertex2;
  PyObject *__pyx_v_ivertex2vertices2;
  PyObject *__pyx_v_Set;
  PyObject *__pyx_v_vertices;
  PyObject *__pyx_v_couples;
  PyObject *__pyx_v_shared_vertices;
  PyObject *__pyx_v_vertex1;
  PyObject *__pyx_v_shared_vertex1;
  PyObject *__pyx_v_shared_vertex2;
  PyObject *__pyx_v_shared_vertex;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  int __pyx_7;
  int __pyx_8;
  float __pyx_9;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_faces);
  __pyx_v_face = Py_None; Py_INCREF((PyObject *) __pyx_v_face);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);
  __pyx_v_ivertex = Py_None; Py_INCREF((PyObject *) __pyx_v_ivertex);
  __pyx_v_vertex2 = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex2);
  __pyx_v_ivertices = Py_None; Py_INCREF(__pyx_v_ivertices);
  __pyx_v_vertex2ivertex = Py_None; Py_INCREF(__pyx_v_vertex2ivertex);
  __pyx_v_ivertex2vertices = Py_None; Py_INCREF(__pyx_v_ivertex2vertices);
  __pyx_v_hashcube = Py_None; Py_INCREF(__pyx_v_hashcube);
  __pyx_v_hash = Py_None; Py_INCREF(__pyx_v_hash);
  __pyx_v_vertex2ivertex2 = Py_None; Py_INCREF(__pyx_v_vertex2ivertex2);
  __pyx_v_ivertex2vertices2 = Py_None; Py_INCREF(__pyx_v_ivertex2vertices2);
  __pyx_v_Set = Py_None; Py_INCREF(__pyx_v_Set);
  __pyx_v_vertices = Py_None; Py_INCREF(__pyx_v_vertices);
  __pyx_v_couples = Py_None; Py_INCREF(__pyx_v_couples);
  __pyx_v_shared_vertices = Py_None; Py_INCREF(__pyx_v_shared_vertices);
  __pyx_v_vertex1 = Py_None; Py_INCREF(__pyx_v_vertex1);
  __pyx_v_shared_vertex1 = Py_None; Py_INCREF(__pyx_v_shared_vertex1);
  __pyx_v_shared_vertex2 = Py_None; Py_INCREF(__pyx_v_shared_vertex2);
  __pyx_v_shared_vertex = Py_None; Py_INCREF(__pyx_v_shared_vertex);

  /* "/home/jiba/src/soya/model/shape.pyx":457 */
  __pyx_k257;

  /* "/home/jiba/src/soya/model/shape.pyx":467 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 467; goto __pyx_L1;}
  Py_DECREF(__pyx_v_vertex2ivertex);
  __pyx_v_vertex2ivertex = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":468 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 468; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2vertices);
  __pyx_v_ivertex2vertices = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":469 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 469; goto __pyx_L1;}
  Py_DECREF(__pyx_v_hashcube);
  __pyx_v_hashcube = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":470 */
  __pyx_1 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 470; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 470; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 470; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":471 */
    __pyx_2 = PyObject_GetIter(__pyx_v_face->_vertices); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 471; goto __pyx_L1;}
    for (;;) {
      __pyx_L4:;
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 471; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 471; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":472 */
      ((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_vertex->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_vertex),__pyx_v_p);

      /* "/home/jiba/src/soya/model/shape.pyx":473 */
      (__pyx_v_p[0]) = (((float )((int )((__pyx_v_p[0]) / EPSILON))) * EPSILON);

      /* "/home/jiba/src/soya/model/shape.pyx":474 */
      (__pyx_v_p[1]) = (((float )((int )((__pyx_v_p[1]) / EPSILON))) * EPSILON);

      /* "/home/jiba/src/soya/model/shape.pyx":475 */
      (__pyx_v_p[2]) = (((float )((int )((__pyx_v_p[2]) / EPSILON))) * EPSILON);

      /* "/home/jiba/src/soya/model/shape.pyx":477 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 477; goto __pyx_L1;}
      __pyx_4 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 477; goto __pyx_L1;}
      __pyx_5 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 477; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 477; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_3);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
      PyTuple_SET_ITEM(__pyx_6, 2, __pyx_5);
      __pyx_3 = 0;
      __pyx_4 = 0;
      __pyx_5 = 0;
      Py_DECREF(__pyx_v_hash);
      __pyx_v_hash = __pyx_6;
      __pyx_6 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":478 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_hashcube, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 478; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 478; goto __pyx_L1;}
      Py_INCREF(__pyx_v_hash);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_hash);
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 478; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 478; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
      __pyx_v_ivertex = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":479 */
      __pyx_7 = ((PyObject *)__pyx_v_ivertex) == Py_None;
      if (__pyx_7) {

        /* "/home/jiba/src/soya/model/shape.pyx":480 */
        if (PyObject_SetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex), ((PyObject *)__pyx_v_vertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 480; goto __pyx_L1;}
        if (PyObject_SetItem(__pyx_v_hashcube, __pyx_v_hash, ((PyObject *)__pyx_v_vertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 480; goto __pyx_L1;}
        Py_INCREF(((PyObject *)__pyx_v_vertex));
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
        __pyx_v_ivertex = ((PyObject *)__pyx_v_vertex);

        /* "/home/jiba/src/soya/model/shape.pyx":481 */
        __pyx_6 = PyList_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 481; goto __pyx_L1;}
        Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex));
        PyList_SET_ITEM(__pyx_6, 0, ((PyObject *)__pyx_v_vertex));
        if (PyObject_SetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_ivertex), __pyx_6) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 481; goto __pyx_L1;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/shape.pyx":483 */
        if (PyObject_SetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex), ((PyObject *)__pyx_v_ivertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 483; goto __pyx_L1;}

        /* "/home/jiba/src/soya/model/shape.pyx":484 */
        __pyx_3 = PyObject_GetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_ivertex)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 484; goto __pyx_L1;}
        __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 484; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 484; goto __pyx_L1;}
        Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex));
        PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_vertex));
        __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 484; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
      }
      __pyx_L6:;
    }
    __pyx_L5:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":486 */
  __pyx_7 = (__pyx_v_angle > 180.0);
  if (__pyx_7) {
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 486; goto __pyx_L1;}
    Py_INCREF(__pyx_v_vertex2ivertex);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_vertex2ivertex);
    Py_INCREF(__pyx_v_ivertex2vertices);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_ivertex2vertices);
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/shape.pyx":533 */
  __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 533; goto __pyx_L1;}
  Py_DECREF(__pyx_v_vertex2ivertex2);
  __pyx_v_vertex2ivertex2 = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":534 */
  __pyx_5 = PyDict_New(); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 534; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2vertices2);
  __pyx_v_ivertex2vertices2 = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":535 */
  __pyx_6 = PyList_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 535; goto __pyx_L1;}
  Py_INCREF(__pyx_n_Set);
  PyList_SET_ITEM(__pyx_6, 0, __pyx_n_Set);
  __pyx_2 = __Pyx_Import(__pyx_n_sets, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 535; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_Set); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 535; goto __pyx_L1;}
  Py_DECREF(__pyx_v_Set);
  __pyx_v_Set = __pyx_1;
  __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":536 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_values); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 536; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_6 = PyObject_GetIter(__pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 536; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  for (;;) {
    __pyx_L8:;
    __pyx_2 = PyIter_Next(__pyx_6);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 536; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_vertices);
    __pyx_v_vertices = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":537 */
    __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 537; goto __pyx_L1;}
    Py_DECREF(__pyx_v_couples);
    __pyx_v_couples = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":538 */
    __pyx_7 = PyObject_Length(__pyx_v_vertices); if (__pyx_7 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 538; goto __pyx_L1;}
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":539 */
      __pyx_8 = PyObject_Length(__pyx_v_vertices); if (__pyx_8 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 539; goto __pyx_L1;}
      for (__pyx_v_j = (__pyx_v_i + 1); __pyx_v_j < __pyx_8; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/shape.pyx":540 */
        __pyx_3 = PyObject_GetAttr(__pyx_v_couples, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        __pyx_5 = PyObject_GetItem(__pyx_v_vertices, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_face); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_normal); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_4 = PyObject_GetAttr(__pyx_1, __pyx_n_angle_to); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        __pyx_5 = PyInt_FromLong(__pyx_v_j); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        __pyx_2 = PyObject_GetItem(__pyx_v_vertices, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_face); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_normal); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);
        __pyx_5 = 0;
        __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_5 = PyInt_FromLong(__pyx_v_i); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_v_vertices, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_2 = PyInt_FromLong(__pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        __pyx_5 = PyObject_GetItem(__pyx_v_vertices, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
        PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4);
        PyTuple_SET_ITEM(__pyx_2, 2, __pyx_5);
        __pyx_1 = 0;
        __pyx_4 = 0;
        __pyx_5 = 0;
        __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
        __pyx_2 = 0;
        __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 540; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_L12:;
      }
      __pyx_L13:;
      __pyx_L10:;
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/model/shape.pyx":542 */
    __pyx_5 = PyObject_GetAttr(__pyx_v_couples, __pyx_n_sort); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 542; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 542; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 542; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":544 */
    __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 544; goto __pyx_L1;}
    Py_DECREF(__pyx_v_shared_vertices);
    __pyx_v_shared_vertices = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":545 */
    __pyx_4 = PyObject_GetIter(__pyx_v_vertices); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
    for (;;) {
      __pyx_L14:;
      __pyx_5 = PyIter_Next(__pyx_4);
      if (!__pyx_5) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_5;
      __pyx_5 = 0;
      __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex));
      PyList_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_vertex));
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
      __pyx_2 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_v_Set, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (PyObject_SetItem(__pyx_v_shared_vertices, ((PyObject *)__pyx_v_vertex), __pyx_1) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 545; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    __pyx_L15:;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":547 */
    __pyx_5 = PyObject_GetIter(__pyx_v_couples); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
    for (;;) {
      __pyx_L16:;
      __pyx_2 = PyIter_Next(__pyx_5);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
        break;
      }
      __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
      __pyx_9 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_v_a = __pyx_9;
      __pyx_1 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
      Py_DECREF(__pyx_v_vertex1);
      __pyx_v_vertex1 = __pyx_1;
      __pyx_1 = 0;
      __pyx_4 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex2));
      __pyx_v_vertex2 = __pyx_4;
      __pyx_4 = 0;
      if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 547; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":548 */
      __pyx_8 = (__pyx_v_a > __pyx_v_angle);
      if (__pyx_8) {
        goto __pyx_L17;
        goto __pyx_L18;
      }
      __pyx_L18:;

      /* "/home/jiba/src/soya/model/shape.pyx":549 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_shared_vertices, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 549; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 549; goto __pyx_L1;}
      Py_INCREF(__pyx_v_vertex1);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_vertex1);
      __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 549; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_shared_vertex1);
      __pyx_v_shared_vertex1 = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":550 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_shared_vertices, __pyx_n_get); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 550; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 550; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex2));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_vertex2));
      __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 550; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_v_shared_vertex2);
      __pyx_v_shared_vertex2 = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":551 */
      __pyx_1 = PyNumber_Or(__pyx_v_shared_vertex1, __pyx_v_shared_vertex2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 551; goto __pyx_L1;}
      Py_DECREF(__pyx_v_shared_vertex);
      __pyx_v_shared_vertex = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":552 */
      __pyx_4 = PyObject_GetIter(__pyx_v_shared_vertex); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 552; goto __pyx_L1;}
      for (;;) {
        __pyx_L19:;
        __pyx_3 = PyIter_Next(__pyx_4);
        if (!__pyx_3) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 552; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 552; goto __pyx_L1;}
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
        __pyx_v_vertex = __pyx_3;
        __pyx_3 = 0;
        if (PyObject_SetItem(__pyx_v_shared_vertices, ((PyObject *)__pyx_v_vertex), __pyx_v_shared_vertex) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 552; goto __pyx_L1;}
      }
      __pyx_L20:;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    __pyx_L17:;
    Py_DECREF(__pyx_5); __pyx_5 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":554 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_shared_vertices, __pyx_n_values); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_v_Set, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyObject_GetIter(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    for (;;) {
      __pyx_L21:;
      __pyx_1 = PyIter_Next(__pyx_2);
      if (!__pyx_1) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 554; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_shared_vertex);
      __pyx_v_shared_vertex = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":555 */
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 555; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 555; goto __pyx_L1;}
      Py_INCREF(__pyx_v_shared_vertex);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_shared_vertex);
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 555; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_v_shared_vertex);
      __pyx_v_shared_vertex = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":556 */
      __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 556; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_shared_vertex, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 556; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 556; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
      __pyx_v_ivertex = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":557 */
      if (PyObject_SetItem(__pyx_v_ivertex2vertices2, ((PyObject *)__pyx_v_ivertex), __pyx_v_shared_vertex) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 557; goto __pyx_L1;}

      /* "/home/jiba/src/soya/model/shape.pyx":558 */
      __pyx_4 = PyObject_GetIter(__pyx_v_shared_vertex); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 558; goto __pyx_L1;}
      for (;;) {
        __pyx_L23:;
        __pyx_5 = PyIter_Next(__pyx_4);
        if (!__pyx_5) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 558; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 558; goto __pyx_L1;}
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
        __pyx_v_vertex = __pyx_5;
        __pyx_5 = 0;

        /* "/home/jiba/src/soya/model/shape.pyx":559 */
        if (PyObject_SetItem(__pyx_v_vertex2ivertex2, ((PyObject *)__pyx_v_vertex), ((PyObject *)__pyx_v_ivertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 559; goto __pyx_L1;}
      }
      __pyx_L24:;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
    }
    __pyx_L22:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L9:;
  Py_DECREF(__pyx_6); __pyx_6 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":561 */
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 561; goto __pyx_L1;}
  Py_INCREF(__pyx_v_vertex2ivertex2);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_vertex2ivertex2);
  Py_INCREF(__pyx_v_ivertex2vertices2);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_ivertex2vertices2);
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._SimpleShape._identify_vertices");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_face);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_ivertex);
  Py_DECREF((PyObject *)__pyx_v_vertex2);
  Py_DECREF(__pyx_v_ivertices);
  Py_DECREF(__pyx_v_vertex2ivertex);
  Py_DECREF(__pyx_v_ivertex2vertices);
  Py_DECREF(__pyx_v_hashcube);
  Py_DECREF(__pyx_v_hash);
  Py_DECREF(__pyx_v_vertex2ivertex2);
  Py_DECREF(__pyx_v_ivertex2vertices2);
  Py_DECREF(__pyx_v_Set);
  Py_DECREF(__pyx_v_vertices);
  Py_DECREF(__pyx_v_couples);
  Py_DECREF(__pyx_v_shared_vertices);
  Py_DECREF(__pyx_v_vertex1);
  Py_DECREF(__pyx_v_shared_vertex1);
  Py_DECREF(__pyx_v_shared_vertex2);
  Py_DECREF(__pyx_v_shared_vertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_faces);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape__compute_face_normals(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,PyObject *__pyx_v_faces) {
  struct __pyx_obj_5_soya__Face *__pyx_v_face;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_faces);
  __pyx_v_face = Py_None; Py_INCREF((PyObject *) __pyx_v_face);

  /* "/home/jiba/src/soya/model/shape.pyx":565 */
  __pyx_1 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 565; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 565; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 565; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_2;
    __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_face->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normal(__pyx_v_face);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._SimpleShape._compute_face_normals");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_face);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_faces);
}

static void __pyx_f_5_soya_12_SimpleShape__compute_vertex_normals(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,PyObject *__pyx_v_faces,PyObject *__pyx_v_vertex2ivertex,PyObject *__pyx_v_ivertex2vertices) {
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_ivertex;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_faces);
  Py_INCREF(__pyx_v_vertex2ivertex);
  Py_INCREF(__pyx_v_ivertex2vertices);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);
  __pyx_v_ivertex = Py_None; Py_INCREF((PyObject *) __pyx_v_ivertex);

  /* "/home/jiba/src/soya/model/shape.pyx":569 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_keys); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 569; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 569; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 569; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 569; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 569; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 569; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":570 */
    __pyx_3 = PyObject_GetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_ivertex)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 570; goto __pyx_L1;}
    __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 570; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    for (;;) {
      __pyx_L4:;
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 570; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 570; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":571 */
      __pyx_4 = (__pyx_v_vertex->_face->__pyx_base._option & __pyx_e_5_soya_FACE2_SMOOTH_LIT);
      if (__pyx_4) {

        /* "/home/jiba/src/soya/model/shape.pyx":572 */
        __pyx_4 = ((PyObject *)__pyx_v_ivertex->_normal) == Py_None;
        if (__pyx_4) {
          __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_vertex->_face), __pyx_n_get_root); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          __pyx_6 = PyTuple_New(0); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_7);
          __pyx_7 = 0;
          __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          if (!__Pyx_TypeTest(__pyx_6, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 572; goto __pyx_L1;}
          Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex->_normal));
          __pyx_v_ivertex->_normal = __pyx_6;
          __pyx_6 = 0;
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/model/shape.pyx":573 */
        ((struct __pyx_vtabstruct_5_soya__Face *)__pyx_v_vertex->_face->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normal(__pyx_v_vertex->_face);

        /* "/home/jiba/src/soya/model/shape.pyx":574 */
        __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_ivertex->_normal), __pyx_n_add_mul_vector); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 574; goto __pyx_L1;}
        __pyx_3 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_v_vertex->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_angle_at(__pyx_v_vertex)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 574; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 574; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
        Py_INCREF((PyObject *)((PyObject *)__pyx_v_vertex->_face->_normal));
        PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)__pyx_v_vertex->_face->_normal));
        __pyx_3 = 0;
        __pyx_6 = PyObject_CallObject(__pyx_7, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 574; goto __pyx_L1;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
    __pyx_L5:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_WriteUnraisable("_soya._SimpleShape._compute_vertex_normals");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_ivertex);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_faces);
  Py_DECREF(__pyx_v_vertex2ivertex);
  Py_DECREF(__pyx_v_ivertex2vertices);
}

static void __pyx_f_5_soya_12_SimpleShape__compute_face_neighbors(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,PyObject *__pyx_v_faces,PyObject *__pyx_v_vertex2ivertex,PyObject *__pyx_v_ivertex2vertices,int (*__pyx_v_neighbor),char (*__pyx_v_neighbor_side)) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_v1_neighbor_index;
  int __pyx_v_v2_neighbor_index;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_v1;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_v2;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_v1_neighbor;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_v2_neighbor;
  struct __pyx_obj_5_soya__Face *__pyx_v_face;
  PyObject *__pyx_v_face2index;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  int __pyx_7;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_faces);
  Py_INCREF(__pyx_v_vertex2ivertex);
  Py_INCREF(__pyx_v_ivertex2vertices);
  __pyx_v_v1 = Py_None; Py_INCREF((PyObject *) __pyx_v_v1);
  __pyx_v_v2 = Py_None; Py_INCREF((PyObject *) __pyx_v_v2);
  __pyx_v_v1_neighbor = Py_None; Py_INCREF((PyObject *) __pyx_v_v1_neighbor);
  __pyx_v_v2_neighbor = Py_None; Py_INCREF((PyObject *) __pyx_v_v2_neighbor);
  __pyx_v_face = Py_None; Py_INCREF((PyObject *) __pyx_v_face);
  __pyx_v_face2index = Py_None; Py_INCREF(__pyx_v_face2index);

  /* "/home/jiba/src/soya/model/shape.pyx":583 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":584 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 584; goto __pyx_L1;}
  Py_DECREF(__pyx_v_face2index);
  __pyx_v_face2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":585 */
  __pyx_1 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 585; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 585; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 585; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":586 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 586; goto __pyx_L1;}
    if (PyObject_SetItem(__pyx_v_face2index, ((PyObject *)__pyx_v_face), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 586; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":587 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":589 */
  __pyx_2 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 589; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 589; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 589; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":590 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 590; goto __pyx_L1;}
    __pyx_3 = PyObject_Length(__pyx_1); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 590; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":591 */
      (__pyx_v_neighbor[__pyx_v_i]) = (-1);

      /* "/home/jiba/src/soya/model/shape.pyx":593 */
      __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex2ivertex, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_v1));
      __pyx_v_v1 = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":594 */
      __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      __pyx_6 = PyObject_Length(__pyx_5); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_4 = PyInt_FromLong(((__pyx_v_i + 1) < __pyx_6)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      __pyx_6 = PyObject_IsTrue(__pyx_4); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      if (__pyx_6) {
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
        __pyx_5 = PyInt_FromLong((__pyx_v_i + 1)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }
      __pyx_6 = PyObject_IsTrue(__pyx_4); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      if (!__pyx_6) {
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
        __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
      }
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex2ivertex, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 594; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_v2));
      __pyx_v_v2 = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":596 */
      __pyx_5 = PyObject_GetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_v1)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 596; goto __pyx_L1;}
      __pyx_4 = PyObject_GetIter(__pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 596; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      for (;;) {
        __pyx_L8:;
        __pyx_1 = PyIter_Next(__pyx_4);
        if (!__pyx_1) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 596; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 596; goto __pyx_L1;}
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_v1_neighbor));
        __pyx_v_v1_neighbor = __pyx_1;
        __pyx_1 = 0;

        /* "/home/jiba/src/soya/model/shape.pyx":600 */
        __pyx_6 = ((__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED) != (__pyx_v_v1_neighbor->_face->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED));
        if (__pyx_6) {
          goto __pyx_L8;
          goto __pyx_L10;
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/model/shape.pyx":602 */
        __pyx_6 = ((PyObject *)__pyx_v_v1_neighbor->_face) == ((PyObject *)__pyx_v_face);
        __pyx_7 = (!__pyx_6);
        if (__pyx_7) {

          /* "/home/jiba/src/soya/model/shape.pyx":603 */
          __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_v1_neighbor->_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 603; goto __pyx_L1;}
          __pyx_1 = PyObject_GetIter(__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 603; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          for (;;) {
            __pyx_L12:;
            __pyx_5 = PyIter_Next(__pyx_1);
            if (!__pyx_5) {
              if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 603; goto __pyx_L1;}
              break;
            }
            if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 603; goto __pyx_L1;}
            Py_DECREF((PyObject *)((PyObject *)__pyx_v_v2_neighbor));
            __pyx_v_v2_neighbor = __pyx_5;
            __pyx_5 = 0;

            /* "/home/jiba/src/soya/model/shape.pyx":604 */
            __pyx_5 = PyObject_GetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_v2_neighbor)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 604; goto __pyx_L1;}
            __pyx_6 = __pyx_5 == ((PyObject *)__pyx_v_v2);
            Py_DECREF(__pyx_5); __pyx_5 = 0;
            if (__pyx_6) {

              /* "/home/jiba/src/soya/model/shape.pyx":606 */
              __pyx_5 = PyObject_GetItem(__pyx_v_face2index, ((PyObject *)__pyx_v_v1_neighbor->_face)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 606; goto __pyx_L1;}
              __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 606; goto __pyx_L1;}
              Py_DECREF(__pyx_5); __pyx_5 = 0;
              (__pyx_v_neighbor[__pyx_v_i]) = __pyx_7;

              /* "/home/jiba/src/soya/model/shape.pyx":608 */
              __pyx_6 = (__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED);
              if (__pyx_6) {

                /* "/home/jiba/src/soya/model/shape.pyx":609 */
                __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_v1_neighbor->_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; goto __pyx_L1;}
                __pyx_8 = PyObject_GetAttr(__pyx_5, __pyx_n_index); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; goto __pyx_L1;}
                Py_DECREF(__pyx_5); __pyx_5 = 0;
                __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; goto __pyx_L1;}
                Py_INCREF((PyObject *)((PyObject *)__pyx_v_v1_neighbor));
                PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_v1_neighbor));
                __pyx_9 = PyObject_CallObject(__pyx_8, __pyx_5); if (!__pyx_9) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; goto __pyx_L1;}
                Py_DECREF(__pyx_8); __pyx_8 = 0;
                Py_DECREF(__pyx_5); __pyx_5 = 0;
                __pyx_7 = PyInt_AsLong(__pyx_9); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; goto __pyx_L1;}
                Py_DECREF(__pyx_9); __pyx_9 = 0;
                __pyx_v_v1_neighbor_index = __pyx_7;

                /* "/home/jiba/src/soya/model/shape.pyx":610 */
                __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_v1_neighbor->_face), __pyx_n_vertices); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; goto __pyx_L1;}
                __pyx_5 = PyObject_GetAttr(__pyx_8, __pyx_n_index); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; goto __pyx_L1;}
                Py_DECREF(__pyx_8); __pyx_8 = 0;
                __pyx_9 = PyTuple_New(1); if (!__pyx_9) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; goto __pyx_L1;}
                Py_INCREF((PyObject *)((PyObject *)__pyx_v_v2_neighbor));
                PyTuple_SET_ITEM(__pyx_9, 0, ((PyObject *)__pyx_v_v2_neighbor));
                __pyx_8 = PyObject_CallObject(__pyx_5, __pyx_9); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; goto __pyx_L1;}
                Py_DECREF(__pyx_5); __pyx_5 = 0;
                Py_DECREF(__pyx_9); __pyx_9 = 0;
                __pyx_6 = PyInt_AsLong(__pyx_8); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; goto __pyx_L1;}
                Py_DECREF(__pyx_8); __pyx_8 = 0;
                __pyx_v_v2_neighbor_index = __pyx_6;

                /* "/home/jiba/src/soya/model/shape.pyx":611 */
                __pyx_7 = (__pyx_v_v1_neighbor_index == (__pyx_v_v2_neighbor_index - 1));
                if (!__pyx_7) {
                  __pyx_7 = (__pyx_v_v1_neighbor_index > 1);
                  if (__pyx_7) {
                    __pyx_7 = (__pyx_v_v2_neighbor_index == 0);
                  }
                }
                if (__pyx_7) {

                  /* "/home/jiba/src/soya/model/shape.pyx":612 */
                  (__pyx_v_neighbor_side[__pyx_v_i]) = 1;
                  goto __pyx_L16;
                }
                /*else*/ {
                  (__pyx_v_neighbor_side[__pyx_v_i]) = (-1);
                }
                __pyx_L16:;
                goto __pyx_L15;
              }
              /*else*/ {
                (__pyx_v_neighbor_side[__pyx_v_i]) = 1;
              }
              __pyx_L15:;

              /* "/home/jiba/src/soya/model/shape.pyx":616 */
              goto __pyx_L13;
              goto __pyx_L14;
            }
            __pyx_L14:;
          }
          /*else*/ {
            goto __pyx_L8;
          }
          __pyx_L13:;
          Py_DECREF(__pyx_1); __pyx_1 = 0;

          /* "/home/jiba/src/soya/model/shape.pyx":618 */
          goto __pyx_L9;
          goto __pyx_L11;
        }
        __pyx_L11:;
      }
      __pyx_L9:;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_L6:;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/shape.pyx":620 */
    __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 620; goto __pyx_L1;}
    __pyx_6 = PyObject_Length(__pyx_5); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 620; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_7 = (__pyx_6 < 4);
    if (__pyx_7) {
      (__pyx_v_neighbor[3]) = (-1);
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "/home/jiba/src/soya/model/shape.pyx":621 */
    __pyx_v_neighbor = (__pyx_v_neighbor + 4);

    /* "/home/jiba/src/soya/model/shape.pyx":622 */
    __pyx_v_neighbor_side = (__pyx_v_neighbor_side + 4);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_WriteUnraisable("_soya._SimpleShape._compute_face_neighbors");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_v1);
  Py_DECREF((PyObject *)__pyx_v_v2);
  Py_DECREF((PyObject *)__pyx_v_v1_neighbor);
  Py_DECREF((PyObject *)__pyx_v_v2_neighbor);
  Py_DECREF((PyObject *)__pyx_v_face);
  Py_DECREF(__pyx_v_face2index);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_faces);
  Py_DECREF(__pyx_v_vertex2ivertex);
  Py_DECREF(__pyx_v_ivertex2vertices);
}

static int __pyx_f_5_soya_12_SimpleShape___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_12_SimpleShape___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_world = 0;
  float __pyx_v_angle;
  int __pyx_v_option;
  PyObject *__pyx_v_lights = 0;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst;
  PyObject *__pyx_v_faces;
  struct __pyx_obj_5_soya__Face *__pyx_v_face;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_vertex;
  struct __pyx_obj_5_soya__Vertex *__pyx_v_ivertex;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int __pyx_v_i;
  PyObject *__pyx_v_vertex2ivertex;
  PyObject *__pyx_v_ivertex2vertices;
  PyObject *__pyx_v_ivertices;
  PyObject *__pyx_v_ivertex2index;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  int __pyx_6;
  static char *__pyx_argnames[] = {"world","angle","option","lights",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OfiO", __pyx_argnames, &__pyx_v_world, &__pyx_v_angle, &__pyx_v_option, &__pyx_v_lights)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);
  Py_INCREF(__pyx_v_lights);
  __pyx_v_coordsyst = Py_None; Py_INCREF((PyObject *) __pyx_v_coordsyst);
  __pyx_v_faces = Py_None; Py_INCREF(__pyx_v_faces);
  __pyx_v_face = Py_None; Py_INCREF((PyObject *) __pyx_v_face);
  __pyx_v_vertex = Py_None; Py_INCREF((PyObject *) __pyx_v_vertex);
  __pyx_v_ivertex = Py_None; Py_INCREF((PyObject *) __pyx_v_ivertex);
  __pyx_v_vertex2ivertex = Py_None; Py_INCREF(__pyx_v_vertex2ivertex);
  __pyx_v_ivertex2vertices = Py_None; Py_INCREF(__pyx_v_ivertex2vertices);
  __pyx_v_ivertices = Py_None; Py_INCREF(__pyx_v_ivertices);
  __pyx_v_ivertex2index = Py_None; Py_INCREF(__pyx_v_ivertex2index);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_world), __pyx_ptype_5_soya__World, 1, "world")) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 624; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shape.pyx":631 */
  __pyx_v_chunk = chunk_new();

  /* "/home/jiba/src/soya/model/shape.pyx":633 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 633; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":637 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 637; goto __pyx_L1;}
  Py_DECREF(__pyx_v_faces);
  __pyx_v_faces = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":638 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_world), __pyx_n_recursive); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":639 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_coordsyst));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Face));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__Face));
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    if (__pyx_5) {
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_3 = PyInt_FromLong((!(__pyx_v_coordsyst->_option & __pyx_e_5_soya_HIDDEN))); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    }
    __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_5) {
      __pyx_2 = PyObject_GetAttr(__pyx_v_faces, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
      PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_coordsyst));
      __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":642 */
  ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option | __pyx_v_option);

  /* "/home/jiba/src/soya/model/shape.pyx":643 */
  __pyx_5 = PyObject_IsTrue(__pyx_v_lights); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 643; goto __pyx_L1;}
  if (__pyx_5) {
    ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option | (__pyx_e_5_soya_SHAPE_STATIC_LIT + __pyx_e_5_soya_SHAPE_EMISSIVES));
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":645 */
  __pyx_2 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 645; goto __pyx_L1;}
  for (;;) {
    __pyx_L6:;
    __pyx_4 = PyIter_Next(__pyx_2);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 645; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 645; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":646 */
    __pyx_3 = PyObject_GetIter(__pyx_v_face->_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 646; goto __pyx_L1;}
    for (;;) {
      __pyx_L8:;
      __pyx_1 = PyIter_Next(__pyx_3);
      if (!__pyx_1) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 646; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 646; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":647 */
      __pyx_6 = ((PyObject *)__pyx_v_face->_material->_texture) == Py_None;
      __pyx_5 = (!__pyx_6);
      if (__pyx_5) {
        __pyx_5 = (__pyx_v_vertex->_tex_x != 0.0);
        if (!__pyx_5) {
          __pyx_5 = (__pyx_v_vertex->_tex_y != 0.0);
        }
      }
      if (__pyx_5) {
        ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option | __pyx_e_5_soya_SHAPE_TEXCOORDS);
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/model/shape.pyx":648 */
      __pyx_6 = __pyx_v_vertex->_diffuse == Py_None;
      __pyx_5 = (!__pyx_6);
      if (__pyx_5) {
        ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option | __pyx_e_5_soya_SHAPE_DIFFUSES);
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/model/shape.pyx":649 */
      __pyx_6 = __pyx_v_vertex->_emissive == Py_None;
      __pyx_5 = (!__pyx_6);
      if (__pyx_5) {
        ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option | __pyx_e_5_soya_SHAPE_EMISSIVES);
        goto __pyx_L12;
      }
      __pyx_L12:;
    }
    __pyx_L9:;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  __pyx_L7:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":651 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_face_normals(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_faces);

  /* "/home/jiba/src/soya/model/shape.pyx":652 */
  __pyx_4 = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_identify_vertices(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_faces,__pyx_v_angle); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 652; goto __pyx_L1;}
  __pyx_1 = __Pyx_UnpackItem(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 652; goto __pyx_L1;}
  Py_DECREF(__pyx_v_vertex2ivertex);
  __pyx_v_vertex2ivertex = __pyx_1;
  __pyx_1 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_4, 1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 652; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2vertices);
  __pyx_v_ivertex2vertices = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_4, 2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 652; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":653 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_vertex_normals(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_faces,__pyx_v_vertex2ivertex,__pyx_v_ivertex2vertices);

  /* "/home/jiba/src/soya/model/shape.pyx":656 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":657 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 657; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertices);
  __pyx_v_ivertices = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":658 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 658; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2index);
  __pyx_v_ivertex2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":659 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_keys); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  for (;;) {
    __pyx_L13:;
    __pyx_3 = PyIter_Next(__pyx_1);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":660 */
    __pyx_6 = ((PyObject *)__pyx_v_ivertex->_normal) == Py_None;
    __pyx_5 = (!__pyx_6);
    if (__pyx_5) {

      /* "/home/jiba/src/soya/model/shape.pyx":661 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_ivertices, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 661; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 661; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_ivertex));
      PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_ivertex));
      __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 661; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":662 */
      __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 662; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_ivertex2index, ((PyObject *)__pyx_v_ivertex), __pyx_4) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 662; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":663 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L15;
    }
    __pyx_L15:;
  }
  __pyx_L14:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":664 */
  __pyx_6 = PyObject_Length(__pyx_v_ivertices); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 664; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vnormals = ((float (*))malloc(((__pyx_6 * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":665 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_keys); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 665; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 665; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 665; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyObject_GetIter(__pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 665; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  for (;;) {
    __pyx_L16:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 665; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 665; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":666 */
    __pyx_5 = ((PyObject *)__pyx_v_ivertex->_normal) == Py_None;
    if (__pyx_5) {

      /* "/home/jiba/src/soya/model/shape.pyx":667 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_ivertices, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 667; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 667; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_ivertex));
      PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_ivertex));
      __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 667; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":668 */
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 668; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_ivertex2index, ((PyObject *)__pyx_v_ivertex), __pyx_3) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 668; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":669 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L18;
    }
    __pyx_L18:;
  }
  __pyx_L17:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":670 */
  __pyx_6 = PyObject_Length(__pyx_v_ivertices); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 670; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_coords = ((float (*))malloc(((__pyx_6 * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/shape.pyx":671 */
  __pyx_4 = PyObject_GetIter(__pyx_v_ivertices); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 671; goto __pyx_L1;}
  for (;;) {
    __pyx_L19:;
    __pyx_2 = PyIter_Next(__pyx_4);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 671; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 671; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_2;
    __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_add_coord(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_ivertex);
  }
  __pyx_L20:;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":674 */
  __pyx_5 = PyObject_Length(__pyx_v_faces); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 674; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_faces = ((__pyx_t_5_soya_ShapeFace (*))malloc((__pyx_5 * (sizeof(__pyx_t_5_soya_ShapeFace )))));

  /* "/home/jiba/src/soya/model/shape.pyx":675 */
  __pyx_3 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 675; goto __pyx_L1;}
  for (;;) {
    __pyx_L21:;
    __pyx_1 = PyIter_Next(__pyx_3);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 675; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 675; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_1;
    __pyx_1 = 0;
    ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_add_face(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_face,__pyx_v_vertex2ivertex,__pyx_v_ivertex2index,__pyx_v_lights,(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_STATIC_SHADOW));
  }
  __pyx_L22:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":678 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 678; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 678; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials);
  PyTuple_SET_ITEM(__pyx_4, 0, ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials);
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 678; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":681 */
  __pyx_6 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_NEIGHBORS);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/model/shape.pyx":682 */
    ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_neighbors = ((int (*))malloc(((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":683 */
    ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_neighbors_side = ((char (*))malloc(((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/shape.pyx":684 */
    ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_face_neighbors(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_faces,__pyx_v_vertex2ivertex,__pyx_v_ivertex2vertices,((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_neighbors,((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_neighbors_side);
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "/home/jiba/src/soya/model/shape.pyx":687 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/shape.pyx":689 */
    __pyx_3 = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_identify_vertices(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_faces,360.0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 689; goto __pyx_L1;}
    __pyx_2 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 689; goto __pyx_L1;}
    Py_DECREF(__pyx_v_vertex2ivertex);
    __pyx_v_vertex2ivertex = __pyx_2;
    __pyx_2 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 689; goto __pyx_L1;}
    Py_DECREF(__pyx_v_ivertex2vertices);
    __pyx_v_ivertex2vertices = __pyx_4;
    __pyx_4 = 0;
    if (__Pyx_EndUnpack(__pyx_3, 2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 689; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":690 */
    ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_simple_neighbors = ((int (*))malloc(((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/shape.pyx":691 */
    ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_simple_neighbors_side = ((char (*))malloc(((((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/shape.pyx":692 */
    ((struct __pyx_vtabstruct_5_soya__SimpleShape *)((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_face_neighbors(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_faces,__pyx_v_vertex2ivertex,__pyx_v_ivertex2vertices,((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_simple_neighbors,((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_simple_neighbors_side);
    goto __pyx_L24;
  }
  __pyx_L24:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._SimpleShape.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_faces);
  Py_DECREF((PyObject *)__pyx_v_face);
  Py_DECREF((PyObject *)__pyx_v_vertex);
  Py_DECREF((PyObject *)__pyx_v_ivertex);
  Py_DECREF(__pyx_v_vertex2ivertex);
  Py_DECREF(__pyx_v_ivertex2vertices);
  Py_DECREF(__pyx_v_ivertices);
  Py_DECREF(__pyx_v_ivertex2index);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  Py_DECREF(__pyx_v_lights);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape__build_sphere(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":698 */
  __pyx_1 = (__pyx_v_self->_nb_coords > 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":699 */
    __pyx_v_self->_sphere = ((float (*))malloc((4 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/shape.pyx":700 */
    sphere_from_points(__pyx_v_self->_sphere,__pyx_v_self->_coords,__pyx_v_self->_nb_coords);

    /* "/home/jiba/src/soya/model/shape.pyx":701 */
    __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_SHAPE_HAS_SPHERE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._build_sphere");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleShape__build_display_list(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self) {
  __pyx_t_5_soya_DisplayLists (*__pyx_v_display_lists);
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  int __pyx_v_nb;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":711 */
  __pyx_v_display_lists = ((__pyx_t_5_soya_DisplayLists (*))malloc((sizeof(__pyx_t_5_soya_DisplayLists ))));

  /* "/home/jiba/src/soya/model/shape.pyx":712 */
  __pyx_v_display_lists->nb_opaque_list = 0;
  __pyx_v_display_lists->nb_alpha_list = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":713 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":714 */
  __pyx_v_display_lists->display_lists = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":715 */
  for (__pyx_v_k = 0; __pyx_v_k < 2; ++__pyx_v_k) {

    /* "/home/jiba/src/soya/model/shape.pyx":716 */
    __pyx_1 = __pyx_v_self->_nb_faces;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/shape.pyx":717 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_j);

      /* "/home/jiba/src/soya/model/shape.pyx":718 */
      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_ALPHA);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_k == 1);
      }
      if (!__pyx_2) {
        __pyx_2 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_ALPHA));
        if (__pyx_2) {
          __pyx_2 = (__pyx_v_k == 0);
        }
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":719 */
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

          /* "/home/jiba/src/soya/model/shape.pyx":720 */
          __pyx_v_display_list = (__pyx_v_display_lists->display_lists + __pyx_v_i);

          /* "/home/jiba/src/soya/model/shape.pyx":721 */
          __pyx_2 = (__pyx_v_display_list->material_id == __pyx_v_face->pack->material_id);
          if (__pyx_2) {
            __pyx_2 = (__pyx_v_display_list->option == (__pyx_v_face->option & __pyx_e_5_soya_DISPLAY_LIST_OPTIONS));
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/model/shape.pyx":722 */
            chunk_add_int(__pyx_v_display_list->chunk,__pyx_v_j);

            /* "/home/jiba/src/soya/model/shape.pyx":723 */
            goto __pyx_L8;
            goto __pyx_L9;
          }
          __pyx_L9:;
          __pyx_L7:;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/shape.pyx":725 */
          __pyx_v_display_lists->display_lists = ((__pyx_t_5_soya_DisplayList (*))realloc(__pyx_v_display_lists->display_lists,((__pyx_v_nb + 1) * (sizeof(__pyx_t_5_soya_DisplayList )))));

          /* "/home/jiba/src/soya/model/shape.pyx":726 */
          __pyx_v_display_list = (__pyx_v_display_lists->display_lists + __pyx_v_nb);

          /* "/home/jiba/src/soya/model/shape.pyx":727 */
          __pyx_v_display_list->material_id = __pyx_v_face->pack->material_id;

          /* "/home/jiba/src/soya/model/shape.pyx":728 */
          __pyx_v_display_list->option = (__pyx_v_face->option & __pyx_e_5_soya_DISPLAY_LIST_OPTIONS);

          /* "/home/jiba/src/soya/model/shape.pyx":729 */
          __pyx_v_display_list->chunk = chunk_new();

          /* "/home/jiba/src/soya/model/shape.pyx":730 */
          chunk_add_int(__pyx_v_display_list->chunk,__pyx_v_j);

          /* "/home/jiba/src/soya/model/shape.pyx":731 */
          __pyx_2 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_ALPHA);
          if (__pyx_2) {
            __pyx_v_display_lists->nb_alpha_list = (__pyx_v_display_lists->nb_alpha_list + 1);
            goto __pyx_L10;
          }
          /*else*/ {
            __pyx_v_display_lists->nb_opaque_list = (__pyx_v_display_lists->nb_opaque_list + 1);
          }
          __pyx_L10:;

          /* "/home/jiba/src/soya/model/shape.pyx":733 */
          __pyx_v_nb = (__pyx_v_nb + 1);
        }
        __pyx_L8:;
        goto __pyx_L6;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":735 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":736 */
    __pyx_v_display_list = (__pyx_v_display_lists->display_lists + __pyx_v_i);

    /* "/home/jiba/src/soya/model/shape.pyx":737 */
    chunk_add_int(__pyx_v_display_list->chunk,(-1));

    /* "/home/jiba/src/soya/model/shape.pyx":738 */
    __pyx_v_display_list->faces_id = ((int (*))__pyx_v_display_list->chunk->content);

    /* "/home/jiba/src/soya/model/shape.pyx":739 */
    free(__pyx_v_display_list->chunk);
    __pyx_L11:;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/model/shape.pyx":743 */
  __pyx_v_self->_display_lists = __pyx_v_display_lists;

  /* "/home/jiba/src/soya/model/shape.pyx":744 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_SHAPE_DISPLAY_LISTS);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._build_display_list");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k260p;
static PyObject *__pyx_k261p;

static char (__pyx_k260[]) = "Shape supports only triangle or quad faces !";
static char (__pyx_k261[]) = "Shape supports only triangle or quad faces !";

static void __pyx_f_5_soya_12_SimpleShape__init_display_list(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self) {
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_v_j;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":751 */
  __pyx_v_nb = (__pyx_v_self->_display_lists->nb_opaque_list + __pyx_v_self->_display_lists->nb_alpha_list);

  /* "/home/jiba/src/soya/model/shape.pyx":752 */
  __pyx_v_display_list = __pyx_v_self->_display_lists->display_lists;

  /* "/home/jiba/src/soya/model/shape.pyx":754 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":755 */
    __pyx_v_display_list = (__pyx_v_self->_display_lists->display_lists + __pyx_v_i);

    /* "/home/jiba/src/soya/model/shape.pyx":756 */
    __pyx_v_display_list->id = glGenLists(1);

    /* "/home/jiba/src/soya/model/shape.pyx":757 */
    __pyx_1 = (PyObject *)__pyx_v_display_list->material_id;
    Py_INCREF((PyObject *)__pyx_1);
    ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_display_list->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_display_list->material_id));
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":758 */
    __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

    /* "/home/jiba/src/soya/model/shape.pyx":759 */
    glNewList(__pyx_v_display_list->id,GL_COMPILE);

    /* "/home/jiba/src/soya/model/shape.pyx":761 */
    __pyx_2 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_TRIANGLE);
    if (__pyx_2) {
      glBegin(GL_TRIANGLES);
      goto __pyx_L4;
    }
    __pyx_2 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_QUAD);
    if (__pyx_2) {
      glBegin(GL_QUADS);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/shape.pyx":764 */
      if (__Pyx_PrintItem(__pyx_k260p) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 764; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 764; goto __pyx_L1;}

      /* "/home/jiba/src/soya/model/shape.pyx":765 */
      __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; goto __pyx_L1;}
      Py_INCREF(__pyx_k261p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k261p);
      __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[17]; __pyx_lineno = 765; goto __pyx_L1;}
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/shape.pyx":767 */
    __pyx_2 = __pyx_v_self->_nb_faces;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/shape.pyx":768 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_j);

      /* "/home/jiba/src/soya/model/shape.pyx":769 */
      __pyx_5 = ((__pyx_v_face->option & __pyx_e_5_soya_DISPLAY_LIST_OPTIONS) == __pyx_v_display_list->option);
      if (__pyx_5) {
        __pyx_5 = (__pyx_v_face->pack->material_id == __pyx_v_display_list->material_id);
      }
      if (__pyx_5) {

        /* "/home/jiba/src/soya/model/shape.pyx":770 */
        __pyx_5 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
        if (__pyx_5) {
          ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_quad(__pyx_v_self,__pyx_v_face);
          goto __pyx_L8;
        }
        /*else*/ {
          ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle(__pyx_v_self,__pyx_v_face);
        }
        __pyx_L8:;
        goto __pyx_L7;
      }
      __pyx_L7:;
      __pyx_L5:;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/shape.pyx":773 */
    glEnd();

    /* "/home/jiba/src/soya/model/shape.pyx":774 */
    glEndList();

    /* "/home/jiba/src/soya/model/shape.pyx":775 */
    __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":777 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_SHAPE_INITED);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleShape._init_display_list");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleShape___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_12_SimpleShape___dealloc__(PyObject *__pyx_v_self) {
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":782 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_DISPLAY_LISTS);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_INITED);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":783 */
    __pyx_v_nb = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_display_lists->nb_opaque_list + ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_display_lists->nb_alpha_list);

    /* "/home/jiba/src/soya/model/shape.pyx":784 */
    __pyx_v_display_list = ((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_display_lists->display_lists;

    /* "/home/jiba/src/soya/model/shape.pyx":785 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":786 */
      __pyx_v_display_list = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/shape.pyx":787 */
      glDeleteLists(__pyx_v_display_list->id,1);
      __pyx_L3:;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":789 */
  free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_faces);

  /* "/home/jiba/src/soya/model/shape.pyx":790 */
  free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_coords);

  /* "/home/jiba/src/soya/model/shape.pyx":791 */
  free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vnormals);

  /* "/home/jiba/src/soya/model/shape.pyx":792 */
  free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_colors);

  /* "/home/jiba/src/soya/model/shape.pyx":793 */
  free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_values);

  /* "/home/jiba/src/soya/model/shape.pyx":794 */
  free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_coords);

  /* "/home/jiba/src/soya/model/shape.pyx":795 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_options);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":796 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_texcoords);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/shape.pyx":797 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_diffuses);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/shape.pyx":798 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_vertex_emissives);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/shape.pyx":799 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self)->_sphere);
    goto __pyx_L9;
  }
  __pyx_L9:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SimpleShape.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleShape__batch(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/shape.pyx":803 */
  __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/shape.pyx":804 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_1) {
    __pyx_1 = (sphere_in_frustum(__pyx_v_frustum,__pyx_v_self->_sphere) == 0);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":806 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DISPLAY_LISTS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":807 */
    __pyx_1 = (__pyx_v_self->_display_lists->nb_opaque_list != 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/shape.pyx":808 */
    __pyx_1 = (__pyx_v_self->_display_lists->nb_alpha_list != 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_n_P3_VERTEX_ALPHA;

static void __pyx_f_5_soya_12_SimpleShape__batch_face(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face)) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":815 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":816 */
    __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[0])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[1])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
      if (__pyx_1) {
        __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[2])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_TRIANGLE);
          if (!__pyx_1) {
            __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[3])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
          }
        }
      }
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/shape.pyx":820 */
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/shape.pyx":822 */
    __pyx_3 = PyInt_FromLong((__pyx_v_self->_vertex_options[(__pyx_v_face->v[0])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 822; goto __pyx_L1;}
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_P3_VERTEX_ALPHA); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 822; goto __pyx_L1;}
    __pyx_2 = PyNumber_And(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 822; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 822; goto __pyx_L1;}
    if (!__pyx_1) {
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_3 = PyInt_FromLong((__pyx_v_self->_vertex_options[(__pyx_v_face->v[1])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 823; goto __pyx_L1;}
      __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_P3_VERTEX_ALPHA); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 823; goto __pyx_L1;}
      __pyx_2 = PyNumber_And(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 823; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 823; goto __pyx_L1;}
      if (!__pyx_1) {
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_3 = PyInt_FromLong((__pyx_v_self->_vertex_options[(__pyx_v_face->v[2])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 824; goto __pyx_L1;}
        __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_P3_VERTEX_ALPHA); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 824; goto __pyx_L1;}
        __pyx_2 = PyNumber_And(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 824; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 824; goto __pyx_L1;}
        if (!__pyx_1) {
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
          if (__pyx_1) {
            __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[3])]) & __pyx_e_5_soya_VERTEX_ALPHA);
          }
          __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 825; goto __pyx_L1;}
        }
      }
    }
    __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 822; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/shape.pyx":827 */
      __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_alpha(__pyx_v_face->pack),__pyx_v_face);

      /* "/home/jiba/src/soya/model/shape.pyx":828 */
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":830 */
  __pyx_f_5_soya_pack_batch_face(__pyx_v_face->pack,__pyx_v_face);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleShape._batch_face");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleShape__render(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_instance) {
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  int __pyx_v_i;
  int __pyx_v_start;
  int __pyx_v_end;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_instance);

  /* "/home/jiba/src/soya/model/shape.pyx":851 */
  __pyx_f_5_soya_shape_option_activate(__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/shape.pyx":853 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DISPLAY_LISTS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":854 */
    __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_INITED));
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_init_display_list(__pyx_v_self);
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/shape.pyx":855 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/shape.pyx":856 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":857 */
      __pyx_v_end = __pyx_v_self->_display_lists->nb_opaque_list;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/shape.pyx":859 */
      __pyx_v_start = __pyx_v_self->_display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/shape.pyx":860 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->_display_lists->nb_alpha_list);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/shape.pyx":861 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":862 */
      __pyx_v_display_list = (__pyx_v_self->_display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/shape.pyx":863 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/shape.pyx":864 */
      __pyx_2 = (PyObject *)__pyx_v_display_list->material_id;
      Py_INCREF((PyObject *)__pyx_2);
      ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_display_list->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_display_list->material_id));
      Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/shape.pyx":865 */
      glCallList(__pyx_v_display_list->id);

      /* "/home/jiba/src/soya/model/shape.pyx":866 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L5:;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":867 */
  __pyx_f_5_soya_shape_option_inactivate(__pyx_v_self->_option);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._SimpleShape._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_instance);
}

static void __pyx_f_5_soya_12_SimpleShape__raypick(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_raydata);
  int __pyx_v_i;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/shape.pyx":872 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/model/shape.pyx":873 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_1) {
    __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_self->_sphere) == 0);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":874 */
  __pyx_1 = __pyx_v_self->_nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":875 */
    ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_face_raypick(__pyx_v_self,(__pyx_v_self->_faces + __pyx_v_i),__pyx_v_raydata,__pyx_v_data,__pyx_v_parent);
    __pyx_L3:;
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static int __pyx_f_5_soya_12_SimpleShape__raypick_b(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_raydata);
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/shape.pyx":880 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/model/shape.pyx":881 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_1) {
    __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_self->_sphere) == 0);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":882 */
  __pyx_1 = __pyx_v_self->_nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/shape.pyx":883 */
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_face_raypick_b(__pyx_v_self,(__pyx_v_self->_faces + __pyx_v_i),__pyx_v_raydata,__pyx_v_data);
    if (__pyx_2) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":884 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape__face_raypick(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face),float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float __pyx_v_z;
  float __pyx_v_root_z;
  int __pyx_v_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/shape.pyx":891 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":892 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_data->option & __pyx_e_5_soya_RAYPICK_CULL_FACE);
  }
  if (__pyx_1) {
    __pyx_v_data->option = (__pyx_v_data->option - __pyx_e_5_soya_RAYPICK_CULL_FACE);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":893 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":894 */
    __pyx_v_r = quad_raypick(__pyx_v_raydata,(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[0])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[1])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[2])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[3])])),(__pyx_v_self->_values + __pyx_v_face->normal),__pyx_v_data->option,(&__pyx_v_z));
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/shape.pyx":896 */
    __pyx_v_r = triangle_raypick(__pyx_v_raydata,(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[0])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[1])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[2])])),(__pyx_v_self->_values + __pyx_v_face->normal),__pyx_v_data->option,(&__pyx_v_z));
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":898 */
  __pyx_1 = (__pyx_v_r != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":899 */
    __pyx_v_root_z = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_distance_out(__pyx_v_parent,__pyx_v_z);

    /* "/home/jiba/src/soya/model/shape.pyx":900 */
    __pyx_1 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
    if (!__pyx_1) {
      __pyx_1 = (fabs(__pyx_v_root_z) < fabs(__pyx_v_data->root_result));
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/shape.pyx":901 */
      __pyx_v_data->result = __pyx_v_z;

      /* "/home/jiba/src/soya/model/shape.pyx":902 */
      __pyx_v_data->root_result = __pyx_v_root_z;

      /* "/home/jiba/src/soya/model/shape.pyx":903 */
      Py_INCREF(((PyObject *)__pyx_v_parent));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
      __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_parent);

      /* "/home/jiba/src/soya/model/shape.pyx":904 */
      __pyx_1 = (__pyx_v_r == __pyx_e_5_soya_RAYPICK_DIRECT);
      if (__pyx_1) {
        memcpy(__pyx_v_data->normal,(__pyx_v_self->_values + __pyx_v_face->normal),(3 * (sizeof(float ))));
        goto __pyx_L7;
      }
      __pyx_1 = (__pyx_v_r == __pyx_e_5_soya_RAYPICK_INDIRECT);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/shape.pyx":906 */
        __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/shape.pyx":907 */
          (__pyx_v_data->normal[0]) = (-((__pyx_v_self->_values + __pyx_v_face->normal)[0]));

          /* "/home/jiba/src/soya/model/shape.pyx":908 */
          (__pyx_v_data->normal[1]) = (-((__pyx_v_self->_values + __pyx_v_face->normal)[1]));

          /* "/home/jiba/src/soya/model/shape.pyx":909 */
          (__pyx_v_data->normal[2]) = (-((__pyx_v_self->_values + __pyx_v_face->normal)[2]));
          goto __pyx_L8;
        }
        /*else*/ {
          memcpy(__pyx_v_data->normal,(__pyx_v_self->_values + __pyx_v_face->normal),(3 * (sizeof(float ))));
        }
        __pyx_L8:;
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._face_raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static int __pyx_f_5_soya_12_SimpleShape__face_raypick_b(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face),float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data) {
  float __pyx_v_z;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/model/shape.pyx":916 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_NON_SOLID);
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":917 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_data->option & __pyx_e_5_soya_RAYPICK_CULL_FACE);
  }
  if (__pyx_1) {
    __pyx_v_data->option = (__pyx_v_data->option - __pyx_e_5_soya_RAYPICK_CULL_FACE);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":918 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":919 */
    __pyx_1 = (quad_raypick(__pyx_v_raydata,(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[0])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[1])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[2])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[3])])),(__pyx_v_self->_values + __pyx_v_face->normal),__pyx_v_data->option,(&__pyx_v_z)) != 0);
    if (__pyx_1) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/shape.pyx":921 */
    __pyx_1 = (triangle_raypick(__pyx_v_raydata,(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[0])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[1])])),(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[2])])),(__pyx_v_self->_values + __pyx_v_face->normal),__pyx_v_data->option,(&__pyx_v_z)) != 0);
    if (__pyx_1) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":922 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._face_raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleShape__collect_raypickables(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere),struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/shape.pyx":925 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_HAS_SPHERE));
  if (!__pyx_1) {
    __pyx_1 = (sphere_distance_sphere(__pyx_v_sphere,__pyx_v_self->_sphere) < 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":926 */
    chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_parent)));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static void __pyx_f_5_soya_12_SimpleShape__render_triangle(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":930 */
  __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT));
  if (__pyx_1) {
    glNormal3fv((__pyx_v_self->_values + __pyx_v_face->normal));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":931 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[0]),__pyx_v_face->option);

  /* "/home/jiba/src/soya/model/shape.pyx":932 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[1]),__pyx_v_face->option);

  /* "/home/jiba/src/soya/model/shape.pyx":933 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[2]),__pyx_v_face->option);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._render_triangle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleShape__render_quad(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":937 */
  __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT));
  if (__pyx_1) {
    glNormal3fv((__pyx_v_self->_values + __pyx_v_face->normal));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":938 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[0]),__pyx_v_face->option);

  /* "/home/jiba/src/soya/model/shape.pyx":939 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[1]),__pyx_v_face->option);

  /* "/home/jiba/src/soya/model/shape.pyx":940 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[2]),__pyx_v_face->option);

  /* "/home/jiba/src/soya/model/shape.pyx":941 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex(__pyx_v_self,(__pyx_v_face->v[3]),__pyx_v_face->option);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._render_quad");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleShape__render_vertex(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,int __pyx_v_index,int __pyx_v_face_option) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shape.pyx":947 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_1) {
    glColor4fv((__pyx_v_self->_colors + (__pyx_v_self->_vertex_diffuses[__pyx_v_index])));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":948 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_1) {
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,(__pyx_v_self->_colors + (__pyx_v_self->_vertex_emissives[__pyx_v_index])));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":949 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_1) {
    glTexCoord2fv((__pyx_v_self->_values + (__pyx_v_self->_vertex_texcoords[__pyx_v_index])));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":950 */
  __pyx_1 = (__pyx_v_face_option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
  if (__pyx_1) {
    glNormal3fv((__pyx_v_self->_vnormals + (__pyx_v_self->_vertex_coords[__pyx_v_index])));
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/shape.pyx":951 */
  glVertex3fv((__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[__pyx_v_index])));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleShape._render_vertex");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_has_key;

static PyObject *__pyx_k262p;

static char (__pyx_k262[]) = "* Soya * warning : drawing shadow for non-closed shape (can't join segments)!";

static int __pyx_f_5_soya_12_SimpleShape__shadow(struct __pyx_obj_5_soya__SimpleShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_neighbor_face);
  float (*__pyx_v_coord_ptr);
  float (*__pyx_v_normal);
  double (*__pyx_v_coord_ptrd);
  float (__pyx_v_coord[4]);
  float (__pyx_v_cone[9]);
  float __pyx_v_b;
  int __pyx_v_nbv;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  int __pyx_v_p1;
  int __pyx_v_p2;
  int __pyx_v_nb_inter;
  int __pyx_v_nb_segment;
  int (*__pyx_v_neighbors);
  char (*__pyx_v_neighbors_side);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk2);
  float (__pyx_v_fp1[3]);
  float (__pyx_v_fp2[3]);
  float (__pyx_v_inter1[3]);
  float (__pyx_v_inter2[3]);
  float (__pyx_v_face_data[15]);
  float (__pyx_v_plane[4]);
  float (__pyx_v_v1[3]);
  float (__pyx_v_v2[3]);
  int (__pyx_v_nb_points[3]);
  PyObject *__pyx_v_joined;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  double __pyx_3;
  double __pyx_4;
  double __pyx_5;
  double __pyx_6;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);
  Py_INCREF((PyObject *)__pyx_v_light);
  __pyx_v_joined = Py_None; Py_INCREF(__pyx_v_joined);

  /* "/home/jiba/src/soya/model/shape.pyx":962 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_SHADOW));
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":981 */
  __pyx_v_b = __pyx_v_5_soya_renderer->current_camera->_back;

  /* "/home/jiba/src/soya/model/shape.pyx":985 */
  ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_cast_into(__pyx_v_light,__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/shape.pyx":986 */
  __pyx_1 = (__pyx_v_light->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":987 */
    cone_from_sphere_and_vector(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b);

    /* "/home/jiba/src/soya/model/shape.pyx":988 */
    __pyx_1 = __pyx_v_self->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":989 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/shape.pyx":990 */
      __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":991 */
        __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[0])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
        if (__pyx_2) {
          __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[1])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
          if (__pyx_2) {
            __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[2])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
            if (__pyx_2) {
              __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_TRIANGLE);
              if (!__pyx_2) {
                __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[3])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
              }
            }
          }
        }
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/shape.pyx":995 */
          goto __pyx_L4;
          goto __pyx_L7;
        }
        __pyx_L7:;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/shape.pyx":997 */
      __pyx_2 = (vector_dot_product(__pyx_v_light->_data,(__pyx_v_self->_values + __pyx_v_face->normal)) >= 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":998 */
        __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_LIGHT_FRONT)) | __pyx_e_5_soya_FACE_LIGHT_BACK);
        goto __pyx_L8;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/shape.pyx":1000 */
        __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_LIGHT_BACK)) | __pyx_e_5_soya_FACE_LIGHT_FRONT);
      }
      __pyx_L8:;
      __pyx_L4:;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/shape.pyx":1003 */
    __pyx_2 = (cone_from_sphere_and_origin(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b) == 0);
    if (__pyx_2) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/model/shape.pyx":1004 */
    __pyx_1 = __pyx_v_self->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":1005 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/shape.pyx":1006 */
      __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_SHAPE_VERTEX_OPTIONS);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":1007 */
        __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[0])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
        if (__pyx_2) {
          __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[1])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
          if (__pyx_2) {
            __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[2])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
            if (__pyx_2) {
              __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_TRIANGLE);
              if (!__pyx_2) {
                __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_face->v[3])]) & __pyx_e_5_soya_VERTEX_INVISIBLE);
              }
            }
          }
        }
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/shape.pyx":1011 */
          goto __pyx_L10;
          goto __pyx_L13;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/home/jiba/src/soya/model/shape.pyx":1013 */
      __pyx_v_normal = (__pyx_v_self->_values + __pyx_v_face->normal);

      /* "/home/jiba/src/soya/model/shape.pyx":1014 */
      __pyx_2 = ((((((__pyx_v_light->_data[0]) * (__pyx_v_normal[0])) + ((__pyx_v_light->_data[1]) * (__pyx_v_normal[1]))) + ((__pyx_v_light->_data[2]) * (__pyx_v_normal[2]))) + (__pyx_v_normal[3])) > 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":1015 */
        __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_LIGHT_BACK)) | __pyx_e_5_soya_FACE_LIGHT_FRONT);
        goto __pyx_L14;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/shape.pyx":1017 */
        __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_LIGHT_FRONT)) | __pyx_e_5_soya_FACE_LIGHT_BACK);
      }
      __pyx_L14:;
      __pyx_L10:;
    }
    __pyx_L11:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/shape.pyx":1020 */
  glStencilFunc(GL_ALWAYS,1,4294967295);

  /* "/home/jiba/src/soya/model/shape.pyx":1021 */
  glFrontFace(GL_CW);

  /* "/home/jiba/src/soya/model/shape.pyx":1022 */
  glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);

  /* "/home/jiba/src/soya/model/shape.pyx":1023 */
  glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

  /* "/home/jiba/src/soya/model/shape.pyx":1024 */
  glNewList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST,GL_COMPILE_AND_EXECUTE);

  /* "/home/jiba/src/soya/model/shape.pyx":1027 */
  __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/shape.pyx":1028 */
  (__pyx_v_coord[0]) = (0.5 * ((__pyx_v_frustum->points[0]) + (__pyx_v_frustum->points[6])));

  /* "/home/jiba/src/soya/model/shape.pyx":1029 */
  (__pyx_v_coord[1]) = (0.5 * ((__pyx_v_frustum->points[1]) + (__pyx_v_frustum->points[7])));

  /* "/home/jiba/src/soya/model/shape.pyx":1030 */
  (__pyx_v_coord[2]) = (0.5 * ((__pyx_v_frustum->points[2]) + (__pyx_v_frustum->points[8])));

  /* "/home/jiba/src/soya/model/shape.pyx":1031 */
  (__pyx_v_coord[3]) = point_distance_to(__pyx_v_coord,__pyx_v_frustum->points);

  /* "/home/jiba/src/soya/model/shape.pyx":1032 */
  __pyx_2 = sphere_is_in_cone(__pyx_v_coord,__pyx_v_cone);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1036 */
    __pyx_3 = 0.0;
    __pyx_4 = 0.0;
    __pyx_5 = (-1.0);
    __pyx_6 = ((-0.1) - __pyx_v_5_soya_renderer->current_camera->_front);
    (__pyx_v_plane[0]) = __pyx_3;
    (__pyx_v_plane[1]) = __pyx_4;
    (__pyx_v_plane[2]) = __pyx_5;
    (__pyx_v_plane[3]) = __pyx_6;

    /* "/home/jiba/src/soya/model/shape.pyx":1038 */
    __pyx_v_chunk = get_chunk();

    /* "/home/jiba/src/soya/model/shape.pyx":1039 */
    __pyx_v_chunk2 = get_chunk();

    /* "/home/jiba/src/soya/model/shape.pyx":1040 */
    __pyx_v_nb_inter = 0;
    __pyx_v_nb_segment = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":1043 */
    __pyx_1 = __pyx_v_self->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":1044 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/shape.pyx":1046 */
      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
      if (!__pyx_2) {
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":1048 */
        __pyx_v_neighbors = (__pyx_v_self->_simple_neighbors + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/shape.pyx":1049 */
        __pyx_v_neighbors_side = (__pyx_v_self->_simple_neighbors_side + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/shape.pyx":1050 */
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
        if (__pyx_2) {
          __pyx_v_nbv = 4;
          goto __pyx_L19;
        }
        /*else*/ {
          __pyx_v_nbv = 3;
        }
        __pyx_L19:;

        /* "/home/jiba/src/soya/model/shape.pyx":1053 */
        for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nbv; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/model/shape.pyx":1054 */
          __pyx_v_neighbor_face = (__pyx_v_self->_faces + (__pyx_v_neighbors[__pyx_v_k]));

          /* "/home/jiba/src/soya/model/shape.pyx":1056 */
          __pyx_2 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED));
          if (__pyx_2) {
            __pyx_2 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
            if (!__pyx_2) {
              __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
            }
          }
          if (!__pyx_2) {
            __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
            if (__pyx_2) {
              __pyx_2 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
              if (!__pyx_2) {
                __pyx_2 = ((__pyx_v_neighbors_side[__pyx_v_k]) == (-1));
                if (__pyx_2) {
                  __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                  if (__pyx_2) {
                    __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                  }
                  if (!__pyx_2) {
                    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                    if (__pyx_2) {
                      __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                  }
                }
                if (!__pyx_2) {
                  __pyx_2 = ((__pyx_v_neighbors_side[__pyx_v_k]) == 1);
                  if (__pyx_2) {
                    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    if (__pyx_2) {
                      __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                    if (!__pyx_2) {
                      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      if (__pyx_2) {
                        __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      }
                    }
                  }
                }
              }
            }
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/model/shape.pyx":1065 */
            __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/model/shape.pyx":1066 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/model/shape.pyx":1067 */
              __pyx_2 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_2) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L24;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L24:;
              goto __pyx_L23;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/shape.pyx":1070 */
              __pyx_2 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_2) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L25;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L25:;

              /* "/home/jiba/src/soya/model/shape.pyx":1072 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L23:;

            /* "/home/jiba/src/soya/model/shape.pyx":1074 */
            __pyx_v_nb_segment = (__pyx_v_nb_segment + 1);

            /* "/home/jiba/src/soya/model/shape.pyx":1075 */
            chunk_add(__pyx_v_chunk,(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[__pyx_v_p1])])),(3 * (sizeof(float ))));

            /* "/home/jiba/src/soya/model/shape.pyx":1076 */
            chunk_add(__pyx_v_chunk,(__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[__pyx_v_p2])])),(3 * (sizeof(float ))));

            /* "/home/jiba/src/soya/model/shape.pyx":1077 */
            chunk_add_int(__pyx_v_chunk,(-1));
            goto __pyx_L22;
          }
          __pyx_L22:;
          __pyx_L20:;
        }
        __pyx_L21:;
        goto __pyx_L18;
      }
      __pyx_L18:;
      __pyx_L16:;
    }
    __pyx_L17:;

    /* "/home/jiba/src/soya/model/shape.pyx":1080 */
    __pyx_7 = PyDict_New(); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1080; goto __pyx_L1;}
    Py_DECREF(__pyx_v_joined);
    __pyx_v_joined = __pyx_7;
    __pyx_7 = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":1081 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_segment; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":1082 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_segment; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/shape.pyx":1083 */
        __pyx_2 = (__pyx_v_i == __pyx_v_j);
        if (__pyx_2) {
          goto __pyx_L28;
          goto __pyx_L30;
        }
        __pyx_L30:;

        /* "/home/jiba/src/soya/model/shape.pyx":1084 */
        __pyx_7 = PyObject_GetAttr(__pyx_v_joined, __pyx_n_has_key); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1084; goto __pyx_L1;}
        __pyx_8 = PyInt_FromLong(__pyx_v_j); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1084; goto __pyx_L1;}
        __pyx_9 = PyTuple_New(1); if (!__pyx_9) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1084; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_9, 0, __pyx_8);
        __pyx_8 = 0;
        __pyx_8 = PyObject_CallObject(__pyx_7, __pyx_9); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1084; goto __pyx_L1;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(__pyx_9); __pyx_9 = 0;
        __pyx_1 = PyObject_IsTrue(__pyx_8); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1084; goto __pyx_L1;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        if (__pyx_1) {
          goto __pyx_L28;
          goto __pyx_L31;
        }
        __pyx_L31:;

        /* "/home/jiba/src/soya/model/shape.pyx":1086 */
        __pyx_2 = (memcmp(((__pyx_v_chunk->content + (__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int ))))) + (3 * (sizeof(float )))),(__pyx_v_chunk->content + (__pyx_v_j * ((6 * (sizeof(float ))) + (sizeof(int ))))),(3 * (sizeof(float )))) == 0);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/shape.pyx":1087 */
          (((int (*))(__pyx_v_chunk->content + ((__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int )))) + (6 * (sizeof(float ))))))[0]) = __pyx_v_j;

          /* "/home/jiba/src/soya/model/shape.pyx":1089 */
          __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1089; goto __pyx_L1;}
          __pyx_9 = PyInt_FromLong(__pyx_v_j); if (!__pyx_9) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1089; goto __pyx_L1;}
          if (PyObject_SetItem(__pyx_v_joined, __pyx_9, __pyx_7) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1089; goto __pyx_L1;}
          Py_DECREF(__pyx_9); __pyx_9 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;

          /* "/home/jiba/src/soya/model/shape.pyx":1091 */
          goto __pyx_L29;
          goto __pyx_L32;
        }
        __pyx_L32:;
        __pyx_L28:;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/shape.pyx":1093 */
        if (__Pyx_PrintItem(__pyx_k262p) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1093; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1093; goto __pyx_L1;}
      }
      __pyx_L29:;
      __pyx_L26:;
    }
    __pyx_L27:;

    /* "/home/jiba/src/soya/model/shape.pyx":1095 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/model/shape.pyx":1096 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":1097 */
    for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nb_segment; ++__pyx_v_k) {

      /* "/home/jiba/src/soya/model/shape.pyx":1098 */
      __pyx_1 = (__pyx_v_i == (-1));
      if (__pyx_1) {
        goto __pyx_L34;
        goto __pyx_L35;
      }
      __pyx_L35:;

      /* "/home/jiba/src/soya/model/shape.pyx":1099 */
      __pyx_v_coord_ptr = ((float (*))(__pyx_v_chunk->content + (__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int ))))));

      /* "/home/jiba/src/soya/model/shape.pyx":1101 */
      __pyx_v_i = (((int (*))(__pyx_v_chunk->content + ((__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int )))) + (6 * (sizeof(float ))))))[0]);

      /* "/home/jiba/src/soya/model/shape.pyx":1103 */
      memcpy(__pyx_v_fp1,__pyx_v_coord_ptr,(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/model/shape.pyx":1104 */
      memcpy(__pyx_v_fp2,(__pyx_v_coord_ptr + 3),(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/model/shape.pyx":1106 */
      __pyx_2 = (__pyx_v_light->_w == 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":1107 */
        memcpy(__pyx_v_v1,__pyx_v_light->_data,(3 * (sizeof(float ))));

        /* "/home/jiba/src/soya/model/shape.pyx":1108 */
        memcpy(__pyx_v_v2,__pyx_v_light->_data,(3 * (sizeof(float ))));
        goto __pyx_L36;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/shape.pyx":1110 */
        (__pyx_v_v1[0]) = ((__pyx_v_fp1[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/model/shape.pyx":1111 */
        (__pyx_v_v1[1]) = ((__pyx_v_fp1[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/model/shape.pyx":1112 */
        (__pyx_v_v1[2]) = ((__pyx_v_fp1[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/model/shape.pyx":1113 */
        vector_normalize(__pyx_v_v1);

        /* "/home/jiba/src/soya/model/shape.pyx":1115 */
        (__pyx_v_v2[0]) = ((__pyx_v_fp2[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/model/shape.pyx":1116 */
        (__pyx_v_v2[1]) = ((__pyx_v_fp2[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/model/shape.pyx":1117 */
        (__pyx_v_v2[2]) = ((__pyx_v_fp2[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/model/shape.pyx":1118 */
        vector_normalize(__pyx_v_v2);
      }
      __pyx_L36:;

      /* "/home/jiba/src/soya/model/shape.pyx":1121 */
      point_by_matrix(__pyx_v_fp1,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coord_syst->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_coord_syst));

      /* "/home/jiba/src/soya/model/shape.pyx":1122 */
      point_by_matrix(__pyx_v_fp1,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/model/shape.pyx":1124 */
      point_by_matrix(__pyx_v_fp2,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coord_syst->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_coord_syst));

      /* "/home/jiba/src/soya/model/shape.pyx":1125 */
      point_by_matrix(__pyx_v_fp2,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/model/shape.pyx":1127 */
      vector_by_matrix(__pyx_v_v1,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coord_syst->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_coord_syst));

      /* "/home/jiba/src/soya/model/shape.pyx":1128 */
      vector_by_matrix(__pyx_v_v1,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/model/shape.pyx":1130 */
      vector_by_matrix(__pyx_v_v2,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_coord_syst->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_coord_syst));

      /* "/home/jiba/src/soya/model/shape.pyx":1131 */
      vector_by_matrix(__pyx_v_v2,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/model/shape.pyx":1133 */
      __pyx_f_5_soya_segment_projection_intersect_plane(__pyx_v_fp1,__pyx_v_v1,__pyx_v_fp2,__pyx_v_v2,__pyx_v_b,__pyx_v_plane,__pyx_v_inter1,__pyx_v_inter2,__pyx_v_face_data,__pyx_v_nb_points);

      /* "/home/jiba/src/soya/model/shape.pyx":1135 */
      glBegin(GL_POLYGON);

      /* "/home/jiba/src/soya/model/shape.pyx":1136 */
      __pyx_1 = (__pyx_v_nb_points[0]);
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/shape.pyx":1137 */
        glVertex3fv((__pyx_v_face_data + (__pyx_v_j * 3)));
        __pyx_L37:;
      }
      __pyx_L38:;

      /* "/home/jiba/src/soya/model/shape.pyx":1138 */
      glEnd();

      /* "/home/jiba/src/soya/model/shape.pyx":1140 */
      __pyx_2 = (__pyx_v_nb_points[1]);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":1141 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[0])));

        /* "/home/jiba/src/soya/model/shape.pyx":1142 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[1])));

        /* "/home/jiba/src/soya/model/shape.pyx":1143 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[2])));

        /* "/home/jiba/src/soya/model/shape.pyx":1144 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L39;
      }
      __pyx_L39:;

      /* "/home/jiba/src/soya/model/shape.pyx":1146 */
      __pyx_1 = (__pyx_v_nb_points[2]);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/shape.pyx":1147 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[0])));

        /* "/home/jiba/src/soya/model/shape.pyx":1148 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[1])));

        /* "/home/jiba/src/soya/model/shape.pyx":1149 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[2])));

        /* "/home/jiba/src/soya/model/shape.pyx":1150 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L40;
      }
      __pyx_L40:;
      __pyx_L33:;
    }
    __pyx_L34:;

    /* "/home/jiba/src/soya/model/shape.pyx":1154 */
    glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

    /* "/home/jiba/src/soya/model/shape.pyx":1156 */
    glEndList();

    /* "/home/jiba/src/soya/model/shape.pyx":1160 */
    glDisable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/model/shape.pyx":1161 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/model/shape.pyx":1162 */
    gluTessBeginPolygon(__pyx_v_5_soya_SHADOW_TESS,0);

    /* "/home/jiba/src/soya/model/shape.pyx":1163 */
    gluTessBeginContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/model/shape.pyx":1164 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_inter; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":1165 */
      gluTessVertex(__pyx_v_5_soya_SHADOW_TESS,(((double (*))__pyx_v_chunk2->content) + (__pyx_v_i * 3)),(((double (*))__pyx_v_chunk2->content) + (__pyx_v_i * 3)));
      __pyx_L41:;
    }
    __pyx_L42:;

    /* "/home/jiba/src/soya/model/shape.pyx":1166 */
    gluTessEndContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/model/shape.pyx":1167 */
    gluTessEndPolygon(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/model/shape.pyx":1168 */
    glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

    /* "/home/jiba/src/soya/model/shape.pyx":1169 */
    glEnable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/model/shape.pyx":1173 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/model/shape.pyx":1174 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/model/shape.pyx":1175 */
    glCallList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST);

    /* "/home/jiba/src/soya/model/shape.pyx":1181 */
    __pyx_v_i = __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb;

    /* "/home/jiba/src/soya/model/shape.pyx":1182 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":1183 */
    while (1) {
      __pyx_L43:;
      __pyx_2 = (__pyx_v_5_soya_SHADOW_TESS_CHUNK->nb < __pyx_v_i);
      if (!__pyx_2) break;
      free(chunk_get_ptr(__pyx_v_5_soya_SHADOW_TESS_CHUNK));
    }
    __pyx_L44:;

    /* "/home/jiba/src/soya/model/shape.pyx":1185 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/model/shape.pyx":1187 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/model/shape.pyx":1188 */
    drop_chunk(__pyx_v_chunk2);
    goto __pyx_L15;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/shape.pyx":1194 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/model/shape.pyx":1195 */
    __pyx_1 = __pyx_v_self->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/shape.pyx":1196 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/shape.pyx":1198 */
      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
      if (!__pyx_2) {
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/shape.pyx":1199 */
        __pyx_v_neighbors = (__pyx_v_self->_simple_neighbors + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/shape.pyx":1200 */
        __pyx_v_neighbors_side = (__pyx_v_self->_simple_neighbors_side + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/shape.pyx":1201 */
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
        if (__pyx_2) {
          __pyx_v_nbv = 4;
          goto __pyx_L48;
        }
        /*else*/ {
          __pyx_v_nbv = 3;
        }
        __pyx_L48:;

        /* "/home/jiba/src/soya/model/shape.pyx":1204 */
        for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nbv; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/model/shape.pyx":1205 */
          __pyx_v_neighbor_face = (__pyx_v_self->_faces + (__pyx_v_neighbors[__pyx_v_k]));

          /* "/home/jiba/src/soya/model/shape.pyx":1207 */
          __pyx_2 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED));
          if (__pyx_2) {
            __pyx_2 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
            if (!__pyx_2) {
              __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
            }
          }
          if (!__pyx_2) {
            __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
            if (__pyx_2) {
              __pyx_2 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
              if (!__pyx_2) {
                __pyx_2 = ((__pyx_v_neighbors_side[__pyx_v_k]) == (-1));
                if (__pyx_2) {
                  __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                  if (__pyx_2) {
                    __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                  }
                  if (!__pyx_2) {
                    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                    if (__pyx_2) {
                      __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                  }
                }
                if (!__pyx_2) {
                  __pyx_2 = ((__pyx_v_neighbors_side[__pyx_v_k]) == 1);
                  if (__pyx_2) {
                    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    if (__pyx_2) {
                      __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                    if (!__pyx_2) {
                      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      if (__pyx_2) {
                        __pyx_2 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      }
                    }
                  }
                }
              }
            }
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/model/shape.pyx":1216 */
            __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/model/shape.pyx":1217 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/model/shape.pyx":1218 */
              __pyx_2 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_2) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L53;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L53:;
              goto __pyx_L52;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/shape.pyx":1221 */
              __pyx_2 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_2) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L54;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L54:;

              /* "/home/jiba/src/soya/model/shape.pyx":1223 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L52:;

            /* "/home/jiba/src/soya/model/shape.pyx":1225 */
            __pyx_v_coord_ptr = (__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[__pyx_v_p1])]));

            /* "/home/jiba/src/soya/model/shape.pyx":1226 */
            glVertex3fv(__pyx_v_coord_ptr);

            /* "/home/jiba/src/soya/model/shape.pyx":1229 */
            __pyx_2 = (__pyx_v_light->_w == 0.0);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/model/shape.pyx":1230 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_light->_data[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_light->_data[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_light->_data[2]))));
              goto __pyx_L55;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/shape.pyx":1232 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/model/shape.pyx":1233 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/model/shape.pyx":1234 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/model/shape.pyx":1235 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/model/shape.pyx":1236 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_coord[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_coord[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_coord[2]))));
            }
            __pyx_L55:;

            /* "/home/jiba/src/soya/model/shape.pyx":1238 */
            __pyx_v_coord_ptr = (__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_face->v[__pyx_v_p2])]));

            /* "/home/jiba/src/soya/model/shape.pyx":1241 */
            __pyx_2 = (__pyx_v_light->_w == 0.0);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/model/shape.pyx":1242 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_light->_data[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_light->_data[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_light->_data[2]))));
              goto __pyx_L56;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/shape.pyx":1244 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/model/shape.pyx":1245 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/model/shape.pyx":1246 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/model/shape.pyx":1247 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/model/shape.pyx":1248 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_coord[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_coord[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_coord[2]))));
            }
            __pyx_L56:;

            /* "/home/jiba/src/soya/model/shape.pyx":1250 */
            glVertex3fv(__pyx_v_coord_ptr);
            goto __pyx_L51;
          }
          __pyx_L51:;
          __pyx_L49:;
        }
        __pyx_L50:;
        goto __pyx_L47;
      }
      __pyx_L47:;
      __pyx_L45:;
    }
    __pyx_L46:;

    /* "/home/jiba/src/soya/model/shape.pyx":1253 */
    glEnd();

    /* "/home/jiba/src/soya/model/shape.pyx":1254 */
    glEndList();

    /* "/home/jiba/src/soya/model/shape.pyx":1257 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/model/shape.pyx":1258 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/model/shape.pyx":1259 */
    glCallList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST);
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/model/shape.pyx":1264 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_WriteUnraisable("_soya._SimpleShape._shadow");
  __pyx_L0:;
  Py_DECREF(__pyx_v_joined);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_shape_option_activate(int __pyx_v_option) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":1275 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_SHAPE_STATIC_LIT);
  if (__pyx_1) {
    __pyx_f_5_soya_disable_static_lights();
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.shape_option_activate");
  __pyx_L0:;
}

static void __pyx_f_5_soya_shape_option_inactivate(int __pyx_v_option) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":1278 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_SHAPE_STATIC_LIT);
  if (__pyx_1) {
    __pyx_f_5_soya_enable_static_lights();
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.shape_option_inactivate");
  __pyx_L0:;
}

static void __pyx_f_5_soya_face_option_activate(int __pyx_v_option) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":1281 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1282 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/shape.pyx":1283 */
    glDisable(GL_CULL_FACE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":1284 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_FACE_NON_LIT);
  if (__pyx_1) {
    glDisable(GL_LIGHTING);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.face_option_activate");
  __pyx_L0:;
}

static void __pyx_f_5_soya_face_option_inactivate(int __pyx_v_option) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":1287 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1288 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);

    /* "/home/jiba/src/soya/model/shape.pyx":1289 */
    glEnable(GL_CULL_FACE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":1290 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_FACE_NON_LIT);
  if (__pyx_1) {
    glEnable(GL_LIGHTING);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.face_option_inactivate");
  __pyx_L0:;
}

static void __pyx_f_5_soya_shape_shadow_tess_combine(double (*__pyx_v_coords),void (*(*__pyx_v_vertex_data)),float (*__pyx_v_weight),void (*(*__pyx_v_out_data))) {
  double (*__pyx_v_d);
  double (*__pyx_1);

  /* "/home/jiba/src/soya/model/shape.pyx":1295 */
  __pyx_1 = ((double (*))malloc((3 * (sizeof(double )))));
  __pyx_v_d = __pyx_1;
  (__pyx_v_out_data[0]) = __pyx_1;

  /* "/home/jiba/src/soya/model/shape.pyx":1296 */
  memcpy(__pyx_v_d,__pyx_v_coords,(3 * (sizeof(double ))));

  /* "/home/jiba/src/soya/model/shape.pyx":1298 */
  chunk_add_ptr(__pyx_v_5_soya_SHADOW_TESS_CHUNK,__pyx_v_d);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.shape_shadow_tess_combine");
  __pyx_L0:;
}

static void __pyx_f_5_soya_segment_projection_intersect_plane(float (*__pyx_v_p1),float (*__pyx_v_v1),float (*__pyx_v_p2),float (*__pyx_v_v2),float __pyx_v_infinity,float (*__pyx_v_plane),float (*__pyx_v_inter1),float (*__pyx_v_inter2),float (*__pyx_v_face),int (*__pyx_v_nb)) {
  int __pyx_v_nb_face;
  int __pyx_v_has_i1;
  int __pyx_v_has_i2;
  int __pyx_v_has_i3;
  int __pyx_v_has_i4;
  float __pyx_v_p1d;
  float __pyx_v_p2d;
  float __pyx_v_pv1d;
  float __pyx_v_pv2d;
  float __pyx_v_f;
  float __pyx_v_fdiv;
  float (__pyx_v_v[3]);
  float (__pyx_v_pv1[3]);
  float (__pyx_v_pv2[3]);
  float (__pyx_v_i1[3]);
  float (__pyx_v_i2[3]);
  float (__pyx_v_i3[3]);
  float (__pyx_v_i4[3]);
  int __pyx_1;
  int __pyx_2;

  /* "/home/jiba/src/soya/model/shape.pyx":1309 */
  __pyx_v_nb_face = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":1310 */
  __pyx_v_has_i1 = 0;
  __pyx_v_has_i2 = 0;
  __pyx_v_has_i3 = 0;
  __pyx_v_has_i4 = 0;

  /* "/home/jiba/src/soya/model/shape.pyx":1312 */
  (__pyx_v_pv1[0]) = ((__pyx_v_p1[0]) + (__pyx_v_infinity * (__pyx_v_v1[0])));

  /* "/home/jiba/src/soya/model/shape.pyx":1313 */
  (__pyx_v_pv1[1]) = ((__pyx_v_p1[1]) + (__pyx_v_infinity * (__pyx_v_v1[1])));

  /* "/home/jiba/src/soya/model/shape.pyx":1314 */
  (__pyx_v_pv1[2]) = ((__pyx_v_p1[2]) + (__pyx_v_infinity * (__pyx_v_v1[2])));

  /* "/home/jiba/src/soya/model/shape.pyx":1316 */
  (__pyx_v_pv2[0]) = ((__pyx_v_p2[0]) + (__pyx_v_infinity * (__pyx_v_v2[0])));

  /* "/home/jiba/src/soya/model/shape.pyx":1317 */
  (__pyx_v_pv2[1]) = ((__pyx_v_p2[1]) + (__pyx_v_infinity * (__pyx_v_v2[1])));

  /* "/home/jiba/src/soya/model/shape.pyx":1318 */
  (__pyx_v_pv2[2]) = ((__pyx_v_p2[2]) + (__pyx_v_infinity * (__pyx_v_v2[2])));

  /* "/home/jiba/src/soya/model/shape.pyx":1321 */
  __pyx_v_p1d = (((((__pyx_v_plane[0]) * (__pyx_v_p1[0])) + ((__pyx_v_plane[1]) * (__pyx_v_p1[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_p1[2]))) + (__pyx_v_plane[3]));

  /* "/home/jiba/src/soya/model/shape.pyx":1322 */
  __pyx_v_p2d = (((((__pyx_v_plane[0]) * (__pyx_v_p2[0])) + ((__pyx_v_plane[1]) * (__pyx_v_p2[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_p2[2]))) + (__pyx_v_plane[3]));

  /* "/home/jiba/src/soya/model/shape.pyx":1323 */
  __pyx_v_pv1d = (((((__pyx_v_plane[0]) * (__pyx_v_pv1[0])) + ((__pyx_v_plane[1]) * (__pyx_v_pv1[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_pv1[2]))) + (__pyx_v_plane[3]));

  /* "/home/jiba/src/soya/model/shape.pyx":1324 */
  __pyx_v_pv2d = (((((__pyx_v_plane[0]) * (__pyx_v_pv2[0])) + ((__pyx_v_plane[1]) * (__pyx_v_pv2[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_pv2[2]))) + (__pyx_v_plane[3]));

  /* "/home/jiba/src/soya/model/shape.pyx":1326 */
  __pyx_v_fdiv = ((((__pyx_v_plane[0]) * (__pyx_v_v1[0])) + ((__pyx_v_plane[1]) * (__pyx_v_v1[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_v1[2])));

  /* "/home/jiba/src/soya/model/shape.pyx":1327 */
  __pyx_1 = (__pyx_v_fdiv != 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1328 */
    __pyx_v_f = ((-(((((__pyx_v_plane[0]) * (__pyx_v_p1[0])) + ((__pyx_v_plane[1]) * (__pyx_v_p1[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_p1[2]))) + (__pyx_v_plane[3]))) / __pyx_v_fdiv);

    /* "/home/jiba/src/soya/model/shape.pyx":1329 */
    __pyx_1 = (__pyx_v_f > 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/shape.pyx":1330 */
      __pyx_v_has_i1 = 1;

      /* "/home/jiba/src/soya/model/shape.pyx":1331 */
      (__pyx_v_i1[0]) = ((__pyx_v_p1[0]) + (__pyx_v_f * (__pyx_v_v1[0])));

      /* "/home/jiba/src/soya/model/shape.pyx":1332 */
      (__pyx_v_i1[1]) = ((__pyx_v_p1[1]) + (__pyx_v_f * (__pyx_v_v1[1])));

      /* "/home/jiba/src/soya/model/shape.pyx":1333 */
      (__pyx_v_i1[2]) = ((__pyx_v_p1[2]) + (__pyx_v_f * (__pyx_v_v1[2])));
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shape.pyx":1335 */
  __pyx_v_fdiv = ((((__pyx_v_plane[0]) * (__pyx_v_v2[0])) + ((__pyx_v_plane[1]) * (__pyx_v_v2[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_v2[2])));

  /* "/home/jiba/src/soya/model/shape.pyx":1336 */
  __pyx_1 = (__pyx_v_fdiv != 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1337 */
    __pyx_v_f = ((-(((((__pyx_v_plane[0]) * (__pyx_v_p2[0])) + ((__pyx_v_plane[1]) * (__pyx_v_p2[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_p2[2]))) + (__pyx_v_plane[3]))) / __pyx_v_fdiv);

    /* "/home/jiba/src/soya/model/shape.pyx":1338 */
    __pyx_1 = (__pyx_v_f > 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/shape.pyx":1339 */
      __pyx_v_has_i2 = 1;

      /* "/home/jiba/src/soya/model/shape.pyx":1340 */
      (__pyx_v_i2[0]) = ((__pyx_v_p2[0]) + (__pyx_v_f * (__pyx_v_v2[0])));

      /* "/home/jiba/src/soya/model/shape.pyx":1341 */
      (__pyx_v_i2[1]) = ((__pyx_v_p2[1]) + (__pyx_v_f * (__pyx_v_v2[1])));

      /* "/home/jiba/src/soya/model/shape.pyx":1342 */
      (__pyx_v_i2[2]) = ((__pyx_v_p2[2]) + (__pyx_v_f * (__pyx_v_v2[2])));
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/shape.pyx":1344 */
  __pyx_1 = ((__pyx_v_p1d * __pyx_v_p2d) < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1345 */
    (__pyx_v_v[0]) = ((__pyx_v_p1[0]) - (__pyx_v_p2[0]));

    /* "/home/jiba/src/soya/model/shape.pyx":1346 */
    (__pyx_v_v[1]) = ((__pyx_v_p1[1]) - (__pyx_v_p2[1]));

    /* "/home/jiba/src/soya/model/shape.pyx":1347 */
    (__pyx_v_v[2]) = ((__pyx_v_p1[2]) - (__pyx_v_p2[2]));

    /* "/home/jiba/src/soya/model/shape.pyx":1348 */
    __pyx_v_fdiv = ((((__pyx_v_plane[0]) * (__pyx_v_v[0])) + ((__pyx_v_plane[1]) * (__pyx_v_v[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_v[2])));

    /* "/home/jiba/src/soya/model/shape.pyx":1349 */
    __pyx_v_f = ((-(((((__pyx_v_plane[0]) * (__pyx_v_p1[0])) + ((__pyx_v_plane[1]) * (__pyx_v_p1[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_p1[2]))) + (__pyx_v_plane[3]))) / __pyx_v_fdiv);

    /* "/home/jiba/src/soya/model/shape.pyx":1350 */
    __pyx_v_has_i3 = 1;

    /* "/home/jiba/src/soya/model/shape.pyx":1351 */
    (__pyx_v_i3[0]) = ((__pyx_v_p1[0]) + (__pyx_v_f * (__pyx_v_v[0])));

    /* "/home/jiba/src/soya/model/shape.pyx":1352 */
    (__pyx_v_i3[1]) = ((__pyx_v_p1[1]) + (__pyx_v_f * (__pyx_v_v[1])));

    /* "/home/jiba/src/soya/model/shape.pyx":1353 */
    (__pyx_v_i3[2]) = ((__pyx_v_p1[2]) + (__pyx_v_f * (__pyx_v_v[2])));
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/shape.pyx":1355 */
  __pyx_1 = ((__pyx_v_pv1d * __pyx_v_pv2d) < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1356 */
    (__pyx_v_v[0]) = ((__pyx_v_pv1[0]) - (__pyx_v_pv2[0]));

    /* "/home/jiba/src/soya/model/shape.pyx":1357 */
    (__pyx_v_v[1]) = ((__pyx_v_pv1[1]) - (__pyx_v_pv2[1]));

    /* "/home/jiba/src/soya/model/shape.pyx":1358 */
    (__pyx_v_v[2]) = ((__pyx_v_pv1[2]) - (__pyx_v_pv2[2]));

    /* "/home/jiba/src/soya/model/shape.pyx":1359 */
    __pyx_v_fdiv = ((((__pyx_v_plane[0]) * (__pyx_v_v[0])) + ((__pyx_v_plane[1]) * (__pyx_v_v[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_v[2])));

    /* "/home/jiba/src/soya/model/shape.pyx":1360 */
    __pyx_v_f = ((-(((((__pyx_v_plane[0]) * (__pyx_v_pv1[0])) + ((__pyx_v_plane[1]) * (__pyx_v_pv1[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_pv1[2]))) + (__pyx_v_plane[3]))) / __pyx_v_fdiv);

    /* "/home/jiba/src/soya/model/shape.pyx":1361 */
    __pyx_v_has_i4 = 1;

    /* "/home/jiba/src/soya/model/shape.pyx":1362 */
    (__pyx_v_i4[0]) = ((__pyx_v_pv1[0]) + (__pyx_v_f * (__pyx_v_v[0])));

    /* "/home/jiba/src/soya/model/shape.pyx":1363 */
    (__pyx_v_i4[1]) = ((__pyx_v_pv1[1]) + (__pyx_v_f * (__pyx_v_v[1])));

    /* "/home/jiba/src/soya/model/shape.pyx":1364 */
    (__pyx_v_i4[2]) = ((__pyx_v_pv1[2]) + (__pyx_v_f * (__pyx_v_v[2])));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/shape.pyx":1366 */
  __pyx_1 = __pyx_v_has_i1;
  if (!__pyx_1) {
    __pyx_1 = __pyx_v_has_i2;
  }
  if (__pyx_1) {
    __pyx_v_has_i4 = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/shape.pyx":1369 */
  __pyx_1 = (__pyx_v_p1d > 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1370 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_p1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1371 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/shape.pyx":1373 */
  __pyx_1 = __pyx_v_has_i1;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1374 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1375 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/shape.pyx":1377 */
  __pyx_1 = (__pyx_v_pv1d > 0.0);
  if (__pyx_1) {
    __pyx_2 = __pyx_v_has_i1;
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_p1d > 0.0);
    }
    __pyx_1 = (!__pyx_2);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1378 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_pv1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1379 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/shape.pyx":1382 */
  __pyx_2 = __pyx_v_has_i4;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1383 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i4,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1384 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/model/shape.pyx":1387 */
  __pyx_1 = (__pyx_v_pv2d > 0.0);
  if (__pyx_1) {
    __pyx_2 = __pyx_v_has_i2;
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_p2d > 0.0);
    }
    __pyx_1 = (!__pyx_2);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1388 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_pv2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1389 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/model/shape.pyx":1391 */
  __pyx_2 = __pyx_v_has_i2;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1392 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1393 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/jiba/src/soya/model/shape.pyx":1395 */
  __pyx_1 = (__pyx_v_p2d > 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1396 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_p2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1397 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/model/shape.pyx":1400 */
  __pyx_2 = __pyx_v_has_i3;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1401 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i3,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1402 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/jiba/src/soya/model/shape.pyx":1405 */
  __pyx_1 = __pyx_v_has_i1;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1405 */
    memcpy(__pyx_v_inter1,__pyx_v_i1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1405 */
    (__pyx_v_nb[1]) = 1;
    goto __pyx_L17;
  }
  __pyx_2 = __pyx_v_has_i3;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1406 */
    memcpy(__pyx_v_inter1,__pyx_v_i3,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1406 */
    (__pyx_v_nb[1]) = 1;
    goto __pyx_L17;
  }
  __pyx_1 = __pyx_v_has_i4;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1407 */
    memcpy(__pyx_v_inter1,__pyx_v_i4,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1407 */
    (__pyx_v_nb[1]) = 1;
    goto __pyx_L17;
  }
  /*else*/ {
    (__pyx_v_nb[1]) = 0;
  }
  __pyx_L17:;

  /* "/home/jiba/src/soya/model/shape.pyx":1410 */
  __pyx_2 = __pyx_v_has_i2;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1410 */
    memcpy(__pyx_v_inter2,__pyx_v_i2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1410 */
    (__pyx_v_nb[2]) = 1;
    goto __pyx_L18;
  }
  __pyx_1 = __pyx_v_has_i4;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/shape.pyx":1411 */
    memcpy(__pyx_v_inter2,__pyx_v_i4,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1411 */
    (__pyx_v_nb[2]) = 1;
    goto __pyx_L18;
  }
  __pyx_2 = __pyx_v_has_i3;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/shape.pyx":1412 */
    memcpy(__pyx_v_inter2,__pyx_v_i3,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/shape.pyx":1412 */
    (__pyx_v_nb[2]) = 1;
    goto __pyx_L18;
  }
  /*else*/ {
    (__pyx_v_nb[2]) = 0;
  }
  __pyx_L18:;

  /* "/home/jiba/src/soya/model/shape.pyx":1415 */
  (__pyx_v_nb[0]) = (__pyx_v_nb_face / 3);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.segment_projection_intersect_plane");
  __pyx_L0:;
}

static void __pyx_f_5_soya_11_SolidShape__render(struct __pyx_obj_5_soya__SolidShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst) {
  float (__pyx_v_pos[3]);
  int (__pyx_v_v2[3]);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_start;
  int __pyx_v_end;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/solid_shape.pyx":26 */
  point_by_matrix_copy(__pyx_v_pos,__pyx_v_self->__pyx_base._sphere,__pyx_v_coord_syst->_render_matrix);

  /* "/home/jiba/src/soya/model/solid_shape.pyx":29 */
  __pyx_1 = (((__pyx_v_pos[2]) + (__pyx_v_self->__pyx_base._sphere[3])) < (-__pyx_v_5_soya_renderer->current_camera->_front));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/solid_shape.pyx":33 */
    __pyx_vtabptr_5_soya__SimpleShape->__pyx_base._render(((struct __pyx_obj_5_soya__Shape *)__pyx_v_self),__pyx_v_coord_syst);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/solid_shape.pyx":39 */
    __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_INITED));
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._init_display_list(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self));
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":41 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/model/solid_shape.pyx":43 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":44 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":45 */
      __pyx_v_end = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":47 */
      __pyx_v_start = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":48 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->__pyx_base._display_lists->nb_alpha_list);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":50 */
    __pyx_v_display_list = __pyx_v_self->__pyx_base._display_lists->display_lists;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":52 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":53 */
      __pyx_v_display_list = (__pyx_v_self->__pyx_base._display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":54 */
      __pyx_2 = (PyObject *)__pyx_v_display_list->material_id;
      Py_INCREF((PyObject *)__pyx_2);
      ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_display_list->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_display_list->material_id));
      Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":55 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":57 */
      __pyx_1 = __pyx_v_self->__pyx_base._nb_faces;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/solid_shape.pyx":58 */
        __pyx_v_face = (__pyx_v_self->__pyx_base._faces + __pyx_v_j);

        /* "/home/jiba/src/soya/model/solid_shape.pyx":59 */
        __pyx_3 = ((__pyx_v_face->option & __pyx_e_5_soya_DISPLAY_LIST_OPTIONS) == __pyx_v_display_list->option);
        if (__pyx_3) {
          __pyx_3 = (__pyx_v_face->pack->material_id == __pyx_v_display_list->material_id);
        }
        if (__pyx_3) {

          /* "/home/jiba/src/soya/model/solid_shape.pyx":60 */
          __pyx_3 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
          if (__pyx_3) {

            /* "/home/jiba/src/soya/model/solid_shape.pyx":61 */
            ((struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_solid(__pyx_v_self,__pyx_v_face,__pyx_v_coord_syst,__pyx_v_face->v);

            /* "/home/jiba/src/soya/model/solid_shape.pyx":62 */
            (__pyx_v_v2[0]) = (__pyx_v_face->v[0]);

            /* "/home/jiba/src/soya/model/solid_shape.pyx":63 */
            (__pyx_v_v2[1]) = (__pyx_v_face->v[2]);

            /* "/home/jiba/src/soya/model/solid_shape.pyx":64 */
            (__pyx_v_v2[2]) = (__pyx_v_face->v[3]);

            /* "/home/jiba/src/soya/model/solid_shape.pyx":65 */
            ((struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_solid(__pyx_v_self,__pyx_v_face,__pyx_v_coord_syst,__pyx_v_v2);
            goto __pyx_L10;
          }
          /*else*/ {

            /* "/home/jiba/src/soya/model/solid_shape.pyx":67 */
            ((struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_solid(__pyx_v_self,__pyx_v_face,__pyx_v_coord_syst,__pyx_v_face->v);
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;
        __pyx_L7:;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":69 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L5:;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":70 */
    __pyx_f_5_soya_shape_option_inactivate(__pyx_v_self->__pyx_base._option);
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._SolidShape._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static void __pyx_f_5_soya_11_SolidShape__render_triangle_solid(struct __pyx_obj_5_soya__SolidShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face),struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst,int (*__pyx_v_vertex_indices)) {
  int __pyx_v_i;
  int __pyx_v_i3;
  int __pyx_v_j;
  int __pyx_v_j3;
  int __pyx_v_cur_inter3;
  int __pyx_v_nb_inter;
  float __pyx_v_f;
  float __pyx_v_f1;
  float (__pyx_v_n[3]);
  float (__pyx_v_p[9]);
  float (__pyx_v_inter[(4 * (((3 + 2) + 4) + 4))]);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);

  /* "/home/jiba/src/soya/model/solid_shape.pyx":75 */
  __pyx_v_cur_inter3 = 0;

  /* "/home/jiba/src/soya/model/solid_shape.pyx":76 */
  __pyx_v_nb_inter = 0;

  /* "/home/jiba/src/soya/model/solid_shape.pyx":78 */
  __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT));
  if (__pyx_1) {
    glNormal3fv((__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/solid_shape.pyx":80 */
  glBegin(GL_TRIANGLES);

  /* "/home/jiba/src/soya/model/solid_shape.pyx":81 */
  for (__pyx_v_i = 0; __pyx_v_i < 3; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/solid_shape.pyx":82 */
    point_by_matrix_copy((__pyx_v_p + (3 * __pyx_v_i)),(__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_vertex_indices[__pyx_v_i])])),__pyx_v_coord_syst->_render_matrix);

    /* "/home/jiba/src/soya/model/solid_shape.pyx":84 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_DIFFUSES);
    if (__pyx_1) {
      glColor4fv((__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_i])])));
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":85 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_EMISSIVES);
    if (__pyx_1) {
      glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,(__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_i])])));
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":86 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
    if (__pyx_1) {
      glTexCoord2fv((__pyx_v_self->__pyx_base._values + (__pyx_v_self->__pyx_base._vertex_texcoords[(__pyx_v_vertex_indices[__pyx_v_i])])));
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":87 */
    __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":88 */
      vector_by_matrix_copy(__pyx_v_n,(__pyx_v_self->__pyx_base._vnormals + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_vertex_indices[__pyx_v_i])])),__pyx_v_coord_syst->_render_matrix);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":89 */
      glNormal3fv(__pyx_v_n);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":90 */
    glVertex3fv((__pyx_v_p + (3 * __pyx_v_i)));
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/solid_shape.pyx":91 */
  glEnd();

  /* "/home/jiba/src/soya/model/solid_shape.pyx":93 */
  for (__pyx_v_i = 0; __pyx_v_i < 3; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/solid_shape.pyx":94 */
    __pyx_v_i3 = (3 * __pyx_v_i);

    /* "/home/jiba/src/soya/model/solid_shape.pyx":95 */
    __pyx_1 = (__pyx_v_i == 2);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":95 */
      __pyx_v_j = 0;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":95 */
      __pyx_v_j3 = 0;
      goto __pyx_L11;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":96 */
      __pyx_v_j = (__pyx_v_i + 1);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":96 */
      __pyx_v_j3 = (3 * __pyx_v_j);
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":98 */
    __pyx_1 = ((__pyx_v_p[(__pyx_v_i3 + 2)]) > (-__pyx_v_5_soya_renderer->current_camera->_front));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":99 */
      (__pyx_v_inter[__pyx_v_cur_inter3]) = (__pyx_v_p[__pyx_v_i3]);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":100 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 1)]) = (__pyx_v_p[(__pyx_v_i3 + 1)]);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":101 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 2)]) = ((-__pyx_v_5_soya_renderer->current_camera->_front) - 0.0001);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":103 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_DIFFUSES);
      if (__pyx_1) {
        memcpy((__pyx_v_inter + (__pyx_v_cur_inter3 + 3)),(__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_i])])),(4 * (sizeof(float ))));
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":104 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_EMISSIVES);
      if (__pyx_1) {
        memcpy((__pyx_v_inter + (__pyx_v_cur_inter3 + 7)),(__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_i])])),(4 * (sizeof(float ))));
        goto __pyx_L14;
      }
      __pyx_L14:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":105 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
      if (__pyx_1) {
        memcpy((__pyx_v_inter + (__pyx_v_cur_inter3 + 11)),(__pyx_v_self->__pyx_base._values + (__pyx_v_self->__pyx_base._vertex_texcoords[(__pyx_v_vertex_indices[__pyx_v_i])])),(2 * (sizeof(float ))));
        goto __pyx_L15;
      }
      __pyx_L15:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":107 */
      __pyx_v_cur_inter3 = (__pyx_v_cur_inter3 + 13);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":108 */
      __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":111 */
    __pyx_1 = ((((__pyx_v_p[(__pyx_v_i3 + 2)]) + __pyx_v_5_soya_renderer->current_camera->_front) * ((__pyx_v_p[(__pyx_v_j3 + 2)]) + __pyx_v_5_soya_renderer->current_camera->_front)) < 0.0);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_nb_inter < 4);
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":112 */
      (__pyx_v_n[0]) = ((__pyx_v_p[__pyx_v_i3]) - (__pyx_v_p[__pyx_v_j3]));

      /* "/home/jiba/src/soya/model/solid_shape.pyx":113 */
      (__pyx_v_n[1]) = ((__pyx_v_p[(__pyx_v_i3 + 1)]) - (__pyx_v_p[(__pyx_v_j3 + 1)]));

      /* "/home/jiba/src/soya/model/solid_shape.pyx":114 */
      (__pyx_v_n[2]) = ((__pyx_v_p[(__pyx_v_i3 + 2)]) - (__pyx_v_p[(__pyx_v_j3 + 2)]));

      /* "/home/jiba/src/soya/model/solid_shape.pyx":116 */
      __pyx_v_f = ((-((__pyx_v_p[(__pyx_v_i3 + 2)]) + __pyx_v_5_soya_renderer->current_camera->_front)) / (__pyx_v_n[2]));

      /* "/home/jiba/src/soya/model/solid_shape.pyx":117 */
      __pyx_v_f1 = (1.0 - __pyx_v_f);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":118 */
      (__pyx_v_inter[__pyx_v_cur_inter3]) = ((__pyx_v_p[__pyx_v_i3]) + (__pyx_v_f * (__pyx_v_n[0])));

      /* "/home/jiba/src/soya/model/solid_shape.pyx":119 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 1)]) = ((__pyx_v_p[(__pyx_v_i3 + 1)]) + (__pyx_v_f * (__pyx_v_n[1])));

      /* "/home/jiba/src/soya/model/solid_shape.pyx":120 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 2)]) = ((-__pyx_v_5_soya_renderer->current_camera->_front) - 0.0001);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":122 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_DIFFUSES);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/solid_shape.pyx":123 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 3)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[(__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_i])])])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[(__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_j])])])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":124 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 4)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_i])]) + 1)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_j])]) + 1)])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":125 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 5)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_i])]) + 2)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_j])]) + 2)])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":126 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 6)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_i])]) + 3)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_diffuses[(__pyx_v_vertex_indices[__pyx_v_j])]) + 3)])));
        goto __pyx_L17;
      }
      __pyx_L17:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":128 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_EMISSIVES);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/solid_shape.pyx":129 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 3)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[(__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_i])])])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[(__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_j])])])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":130 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 4)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_i])]) + 1)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_j])]) + 1)])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":131 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 5)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_i])]) + 2)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_j])]) + 2)])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":132 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 6)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_i])]) + 3)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._colors[((__pyx_v_self->__pyx_base._vertex_emissives[(__pyx_v_vertex_indices[__pyx_v_j])]) + 3)])));
        goto __pyx_L18;
      }
      __pyx_L18:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":134 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/solid_shape.pyx":135 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 11)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._values[(__pyx_v_self->__pyx_base._vertex_texcoords[(__pyx_v_vertex_indices[__pyx_v_i])])])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._values[(__pyx_v_self->__pyx_base._vertex_texcoords[(__pyx_v_vertex_indices[__pyx_v_j])])])));

        /* "/home/jiba/src/soya/model/solid_shape.pyx":136 */
        (__pyx_v_inter[(__pyx_v_cur_inter3 + 12)]) = ((__pyx_v_f * (__pyx_v_self->__pyx_base._values[((__pyx_v_self->__pyx_base._vertex_texcoords[(__pyx_v_vertex_indices[__pyx_v_i])]) + 1)])) + (__pyx_v_f1 * (__pyx_v_self->__pyx_base._values[((__pyx_v_self->__pyx_base._vertex_texcoords[(__pyx_v_vertex_indices[__pyx_v_j])]) + 1)])));
        goto __pyx_L19;
      }
      __pyx_L19:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":138 */
      __pyx_v_cur_inter3 = (__pyx_v_cur_inter3 + 13);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":139 */
      __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
      goto __pyx_L16;
    }
    __pyx_L16:;
    __pyx_L9:;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/solid_shape.pyx":141 */
  __pyx_1 = (__pyx_v_cur_inter3 != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/solid_shape.pyx":142 */
    __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED));
    if (__pyx_1) {
      glDisable(GL_CULL_FACE);
      goto __pyx_L21;
    }
    __pyx_L21:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":144 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/model/solid_shape.pyx":145 */
    glNormal3f(0.0,0.0,1.0);

    /* "/home/jiba/src/soya/model/solid_shape.pyx":146 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_inter; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/solid_shape.pyx":147 */
      __pyx_v_cur_inter3 = (__pyx_v_i * 13);

      /* "/home/jiba/src/soya/model/solid_shape.pyx":148 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_DIFFUSES);
      if (__pyx_1) {
        glColor4fv((__pyx_v_inter + (__pyx_v_cur_inter3 + 3)));
        goto __pyx_L24;
      }
      __pyx_L24:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":149 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_EMISSIVES);
      if (__pyx_1) {
        glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,(__pyx_v_inter + (__pyx_v_cur_inter3 + 7)));
        goto __pyx_L25;
      }
      __pyx_L25:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":150 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
      if (__pyx_1) {
        glTexCoord2fv((__pyx_v_inter + (__pyx_v_cur_inter3 + 11)));
        goto __pyx_L26;
      }
      __pyx_L26:;

      /* "/home/jiba/src/soya/model/solid_shape.pyx":151 */
      glVertex3fv((__pyx_v_inter + __pyx_v_cur_inter3));
      __pyx_L22:;
    }
    __pyx_L23:;

    /* "/home/jiba/src/soya/model/solid_shape.pyx":152 */
    glEnd();

    /* "/home/jiba/src/soya/model/solid_shape.pyx":154 */
    __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED));
    if (__pyx_1) {
      glEnable(GL_CULL_FACE);
      goto __pyx_L27;
    }
    __pyx_L27:;
    goto __pyx_L20;
  }
  __pyx_L20:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SolidShape._render_triangle_solid");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coord_syst);
}

static PyObject *__pyx_f_5_soya_17_CellShadingShape___getcstate__(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":26 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/cellshading.pyx":27 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_width);

  /* "/home/jiba/src/soya/model/cellshading.pyx":28 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/model/cellshading.pyx":29 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_color,4);

  /* "/home/jiba/src/soya/model/cellshading.pyx":30 */
  __pyx_1 = __pyx_vtabptr_5_soya__SimpleShape->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 30; goto __pyx_L1;}
  __pyx_2 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 30; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 30; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_shader));
  PyTuple_SET_ITEM(__pyx_3, 2, ((PyObject *)__pyx_v_self->_shader));
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._CellShadingShape.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_17_CellShadingShape___setcstate__(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/cellshading.pyx":33 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 33; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 33; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya__SimpleShape->__setcstate_data__(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":36 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":37 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_outline_width));

  /* "/home/jiba/src/soya/model/cellshading.pyx":38 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_outline_attenuation));

  /* "/home/jiba/src/soya/model/cellshading.pyx":39 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_color,4);

  /* "/home/jiba/src/soya/model/cellshading.pyx":40 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/cellshading.pyx":41 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 41; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 41; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 41; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_shader));
  __pyx_v_self->_shader = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":44 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_display_list(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingShape.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_17_CellShadingShape__build_cellshading(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,struct __pyx_obj_5_soya__Material *__pyx_v_shader,PyObject *__pyx_v_outline_color,float __pyx_v_outline_width,float __pyx_v_outline_attenuation) {
  int __pyx_v_i;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  float __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shader);
  Py_INCREF(__pyx_v_outline_color);

  /* "/home/jiba/src/soya/model/cellshading.pyx":48 */
  Py_INCREF(((PyObject *)__pyx_v_shader));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_shader));
  __pyx_v_self->_shader = ((PyObject *)__pyx_v_shader);

  /* "/home/jiba/src/soya/model/cellshading.pyx":49 */
  __pyx_v_self->_outline_width = __pyx_v_outline_width;

  /* "/home/jiba/src/soya/model/cellshading.pyx":50 */
  __pyx_v_self->_outline_attenuation = __pyx_v_outline_attenuation;

  /* "/home/jiba/src/soya/model/cellshading.pyx":51 */
  for (__pyx_v_i = 0; __pyx_v_i < 4; ++__pyx_v_i) {
    __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 51; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_outline_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 51; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 51; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    (__pyx_v_self->_outline_color[__pyx_v_i]) = __pyx_3;
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingShape._build_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shader);
  Py_DECREF(__pyx_v_outline_color);
}

static void __pyx_f_5_soya_17_CellShadingShape__batch(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_v_i;
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/cellshading.pyx":54 */
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_LOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":55 */
    __pyx_vtabptr_5_soya__SimpleShape->__pyx_base._batch(((struct __pyx_obj_5_soya__Shape *)__pyx_v_self),__pyx_v_coordsyst);

    /* "/home/jiba/src/soya/model/cellshading.pyx":56 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":61 */
  __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/cellshading.pyx":62 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_HAS_SPHERE);
  if (__pyx_1) {
    __pyx_1 = (sphere_in_frustum(__pyx_v_frustum,__pyx_v_self->__pyx_base._sphere) == 0);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":64 */
  __pyx_1 = (__pyx_v_self->__pyx_base._display_lists->nb_opaque_list != 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":65 */
  __pyx_1 = (__pyx_v_self->__pyx_base._display_lists->nb_alpha_list != 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":72 */
  __pyx_1 = (__pyx_v_self->_outline_width > 0.0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->secondpass,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,0);
    goto __pyx_L6;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingShape._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_17_CellShadingShape__render(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_v_i;
  int __pyx_v_start;
  int __pyx_v_end;
  int (*__pyx_v_face_id);
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  float (*__pyx_v_shades);
  struct __pyx_obj_5_soya__Material *__pyx_v_material;
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_material = Py_None; Py_INCREF((PyObject *) __pyx_v_material);

  /* "/home/jiba/src/soya/model/cellshading.pyx":142 */
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_LOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":143 */
    __pyx_vtabptr_5_soya__SimpleShape->__pyx_base._render(((struct __pyx_obj_5_soya__Shape *)__pyx_v_self),__pyx_v_coordsyst);

    /* "/home/jiba/src/soya/model/cellshading.pyx":144 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":154 */
  __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_SECONDPASS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":155 */
    __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst);

    /* "/home/jiba/src/soya/model/cellshading.pyx":156 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_outline(__pyx_v_self,__pyx_v_frustum);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":158 */
    __pyx_f_5_soya_shape_option_activate(__pyx_v_self->__pyx_base._option);

    /* "/home/jiba/src/soya/model/cellshading.pyx":160 */
    __pyx_v_chunk = get_chunk();

    /* "/home/jiba/src/soya/model/cellshading.pyx":161 */
    chunk_register(__pyx_v_chunk,(__pyx_v_self->__pyx_base._nb_vnormals * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/cellshading.pyx":162 */
    __pyx_v_shades = ((float (*))__pyx_v_chunk->content);

    /* "/home/jiba/src/soya/model/cellshading.pyx":163 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading(__pyx_v_self,__pyx_v_coordsyst,__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":165 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":166 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/cellshading.pyx":167 */
      __pyx_v_end = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":169 */
      __pyx_v_start = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/cellshading.pyx":170 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->__pyx_base._display_lists->nb_alpha_list);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":173 */
    glActiveTextureARB(GL_TEXTURE1);

    /* "/home/jiba/src/soya/model/cellshading.pyx":174 */
    __pyx_1 = (__pyx_v_self->_shader->_id == 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_shader->__pyx_base.__pyx_vtab)->_init_texture(__pyx_v_self->_shader);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":175 */
    glEnable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/model/cellshading.pyx":176 */
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);

    /* "/home/jiba/src/soya/model/cellshading.pyx":177 */
    glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_shader->_id);

    /* "/home/jiba/src/soya/model/cellshading.pyx":178 */
    glActiveTextureARB(GL_TEXTURE0);

    /* "/home/jiba/src/soya/model/cellshading.pyx":180 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":181 */
      __pyx_v_display_list = (__pyx_v_self->__pyx_base._display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/cellshading.pyx":183 */
      __pyx_2 = (PyObject *)__pyx_v_display_list->material_id;
      Py_INCREF((PyObject *)__pyx_2);
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_material));
      __pyx_v_material = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/cellshading.pyx":184 */
      ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_material);

      /* "/home/jiba/src/soya/model/cellshading.pyx":186 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/cellshading.pyx":188 */
      __pyx_v_face_id = __pyx_v_display_list->faces_id;

      /* "/home/jiba/src/soya/model/cellshading.pyx":189 */
      __pyx_1 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_TRIANGLE);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":190 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/model/cellshading.pyx":191 */
        while (1) {
          __pyx_L9:;
          __pyx_1 = ((__pyx_v_face_id[0]) != (-1));
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/cellshading.pyx":192 */
          ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_cellshading(__pyx_v_self,(__pyx_v_self->__pyx_base._faces + (__pyx_v_face_id[0])),__pyx_v_shades);

          /* "/home/jiba/src/soya/model/cellshading.pyx":193 */
          __pyx_v_face_id = (__pyx_v_face_id + 1);
        }
        __pyx_L10:;
        goto __pyx_L8;
      }
      __pyx_1 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_QUAD);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":196 */
        glBegin(GL_QUADS);

        /* "/home/jiba/src/soya/model/cellshading.pyx":197 */
        while (1) {
          __pyx_L11:;
          __pyx_1 = ((__pyx_v_face_id[0]) != (-1));
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/cellshading.pyx":198 */
          ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_quad_cellshading(__pyx_v_self,(__pyx_v_self->__pyx_base._faces + (__pyx_v_face_id[0])),__pyx_v_shades);

          /* "/home/jiba/src/soya/model/cellshading.pyx":199 */
          __pyx_v_face_id = (__pyx_v_face_id + 1);
        }
        __pyx_L12:;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/model/cellshading.pyx":201 */
      glEnd();

      /* "/home/jiba/src/soya/model/cellshading.pyx":203 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L6:;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":206 */
    glActiveTextureARB(GL_TEXTURE1);

    /* "/home/jiba/src/soya/model/cellshading.pyx":207 */
    glDisable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/model/cellshading.pyx":208 */
    glActiveTextureARB(GL_TEXTURE0);

    /* "/home/jiba/src/soya/model/cellshading.pyx":211 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/model/cellshading.pyx":212 */
    __pyx_f_5_soya_shape_option_inactivate(__pyx_v_self->__pyx_base._option);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingShape._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_17_CellShadingShape__render_outline(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,__pyx_t_5_soya_Frustum (*__pyx_v_frustum)) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  int __pyx_v_ns;
  int __pyx_v_nb;
  float __pyx_v_d;
  float (*__pyx_v_plane);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  __pyx_t_5_soya_ShapeFace __pyx_v_neighbor_face;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int (*__pyx_v_vertex_used);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":222 */
  __pyx_v_d = (sphere_distance_point(__pyx_v_self->__pyx_base._sphere,__pyx_v_frustum->position) * __pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/model/cellshading.pyx":223 */
  __pyx_1 = (__pyx_v_d < 1.0);
  if (__pyx_1) {
    __pyx_v_d = __pyx_v_self->_outline_width;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":225 */
    __pyx_v_d = (__pyx_v_self->_outline_width / __pyx_v_d);

    /* "/home/jiba/src/soya/model/cellshading.pyx":226 */
    __pyx_1 = (__pyx_v_d < 2.0);
    if (__pyx_1) {
      __pyx_v_d = 2.0;
      goto __pyx_L3;
    }
    __pyx_L3:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":228 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya__DEFAULT_MATERIAL->__pyx_base.__pyx_vtab)->_activate(__pyx_v_5_soya__DEFAULT_MATERIAL);

  /* "/home/jiba/src/soya/model/cellshading.pyx":229 */
  glLineWidth(__pyx_v_d);

  /* "/home/jiba/src/soya/model/cellshading.pyx":230 */
  glColor4fv(__pyx_v_self->_outline_color);

  /* "/home/jiba/src/soya/model/cellshading.pyx":231 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/cellshading.pyx":232 */
  glDepthFunc(GL_LEQUAL);

  /* "/home/jiba/src/soya/model/cellshading.pyx":235 */
  __pyx_1 = __pyx_v_self->__pyx_base._nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":236 */
    __pyx_v_face = (__pyx_v_self->__pyx_base._faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/cellshading.pyx":237 */
    __pyx_v_plane = (__pyx_v_self->__pyx_base._values + __pyx_v_face->normal);

    /* "/home/jiba/src/soya/model/cellshading.pyx":238 */
    __pyx_2 = ((((((__pyx_v_plane[0]) * (__pyx_v_frustum->position[0])) + ((__pyx_v_plane[1]) * (__pyx_v_frustum->position[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_frustum->position[2]))) + (__pyx_v_plane[3])) > 0.0);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":239 */
      __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_BACK)) | __pyx_e_5_soya_FACE_FRONT);
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":241 */
      __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_FRONT)) | __pyx_e_5_soya_FACE_BACK);
    }
    __pyx_L6:;
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":314 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/cellshading.pyx":315 */
  chunk_register(__pyx_v_chunk,(__pyx_v_self->__pyx_base._nb_coords * (sizeof(int ))));

  /* "/home/jiba/src/soya/model/cellshading.pyx":317 */
  __pyx_v_vertex_used = ((int (*))__pyx_v_chunk->content);

  /* "/home/jiba/src/soya/model/cellshading.pyx":318 */
  __pyx_2 = __pyx_v_self->__pyx_base._nb_coords;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {
    (__pyx_v_vertex_used[__pyx_v_i]) = (-1);
    __pyx_L7:;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":322 */
  glBegin(GL_LINES);

  /* "/home/jiba/src/soya/model/cellshading.pyx":323 */
  __pyx_1 = __pyx_v_self->__pyx_base._nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":324 */
    __pyx_v_face = (__pyx_v_self->__pyx_base._faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/cellshading.pyx":325 */
    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_ALPHA);
    if (__pyx_2) {
      goto __pyx_L9;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":327 */
    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
    if (__pyx_2) {
      __pyx_v_nb = 4;
      goto __pyx_L12;
    }
    /*else*/ {
      __pyx_v_nb = 3;
    }
    __pyx_L12:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":330 */
    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":331 */
      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":332 */
        for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/cellshading.pyx":333 */
          __pyx_v_k = (__pyx_v_self->__pyx_base._neighbors[((4 * __pyx_v_i) + __pyx_v_j)]);

          /* "/home/jiba/src/soya/model/cellshading.pyx":334 */
          __pyx_2 = (__pyx_v_k == (-1));
          if (__pyx_2) {

            /* "/home/jiba/src/soya/model/cellshading.pyx":335 */
            (__pyx_v_vertex_used[((__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])]) / 3)]) = 1;

            /* "/home/jiba/src/soya/model/cellshading.pyx":338 */
            glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])])));

            /* "/home/jiba/src/soya/model/cellshading.pyx":339 */
            __pyx_2 = (__pyx_v_j < (__pyx_v_nb - 1));
            if (__pyx_2) {
              glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[(__pyx_v_j + 1)])])));
              goto __pyx_L18;
            }
            /*else*/ {
              glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[0])])));
            }
            __pyx_L18:;
            goto __pyx_L17;
          }
          /*else*/ {

            /* "/home/jiba/src/soya/model/cellshading.pyx":343 */
            __pyx_v_ns = (__pyx_v_self->__pyx_base._neighbors_side[((4 * __pyx_v_i) + __pyx_v_j)]);

            /* "/home/jiba/src/soya/model/cellshading.pyx":344 */
            __pyx_v_neighbor_face = (__pyx_v_self->__pyx_base._faces[__pyx_v_k]);

            /* "/home/jiba/src/soya/model/cellshading.pyx":345 */
            __pyx_2 = (__pyx_v_ns == (-1));
            if (__pyx_2) {
              __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_FRONT);
              if (__pyx_2) {
                __pyx_2 = (__pyx_v_neighbor_face.option & __pyx_e_5_soya_FACE_BACK);
              }
              if (!__pyx_2) {
                __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_BACK);
                if (__pyx_2) {
                  __pyx_2 = (__pyx_v_neighbor_face.option & __pyx_e_5_soya_FACE_FRONT);
                }
              }
            }
            if (!__pyx_2) {
              __pyx_2 = (__pyx_v_ns == 1);
              if (__pyx_2) {
                __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_FRONT);
                if (__pyx_2) {
                  __pyx_2 = (__pyx_v_neighbor_face.option & __pyx_e_5_soya_FACE_FRONT);
                }
                if (!__pyx_2) {
                  __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_BACK);
                  if (__pyx_2) {
                    __pyx_2 = (__pyx_v_neighbor_face.option & __pyx_e_5_soya_FACE_BACK);
                  }
                }
              }
            }
            if (__pyx_2) {

              /* "/home/jiba/src/soya/model/cellshading.pyx":350 */
              (__pyx_v_vertex_used[((__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])]) / 3)]) = 1;

              /* "/home/jiba/src/soya/model/cellshading.pyx":353 */
              glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])])));

              /* "/home/jiba/src/soya/model/cellshading.pyx":354 */
              __pyx_2 = (__pyx_v_j < (__pyx_v_nb - 1));
              if (__pyx_2) {
                glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[(__pyx_v_j + 1)])])));
                goto __pyx_L20;
              }
              /*else*/ {
                glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[0])])));
              }
              __pyx_L20:;
              goto __pyx_L19;
            }
            __pyx_L19:;
          }
          __pyx_L17:;
          __pyx_L15:;
        }
        __pyx_L16:;
        goto __pyx_L14;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/cellshading.pyx":358 */
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_FRONT);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/cellshading.pyx":360 */
          for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb; ++__pyx_v_j) {

            /* "/home/jiba/src/soya/model/cellshading.pyx":361 */
            __pyx_v_k = (__pyx_v_self->__pyx_base._neighbors[((4 * __pyx_v_i) + __pyx_v_j)]);

            /* "/home/jiba/src/soya/model/cellshading.pyx":362 */
            __pyx_2 = (__pyx_v_k == (-1));
            if (!__pyx_2) {
              __pyx_2 = ((__pyx_v_self->__pyx_base._faces[__pyx_v_k]).option & __pyx_e_5_soya_FACE_BACK);
            }
            if (__pyx_2) {

              /* "/home/jiba/src/soya/model/cellshading.pyx":363 */
              (__pyx_v_vertex_used[((__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])]) / 3)]) = 1;

              /* "/home/jiba/src/soya/model/cellshading.pyx":366 */
              glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])])));

              /* "/home/jiba/src/soya/model/cellshading.pyx":367 */
              __pyx_2 = (__pyx_v_j < (__pyx_v_nb - 1));
              if (__pyx_2) {
                glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[(__pyx_v_j + 1)])])));
                goto __pyx_L25;
              }
              /*else*/ {
                glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[0])])));
              }
              __pyx_L25:;
              goto __pyx_L24;
            }
            __pyx_L24:;
            __pyx_L22:;
          }
          __pyx_L23:;
          goto __pyx_L21;
        }
        __pyx_L21:;
      }
      __pyx_L14:;
      goto __pyx_L13;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":371 */
      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_FRONT);
      if (!__pyx_2) {
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":372 */
        for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/cellshading.pyx":374 */
          glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[__pyx_v_j])])));

          /* "/home/jiba/src/soya/model/cellshading.pyx":375 */
          __pyx_2 = (__pyx_v_j < (__pyx_v_nb - 1));
          if (__pyx_2) {
            glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[(__pyx_v_j + 1)])])));
            goto __pyx_L29;
          }
          /*else*/ {
            glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[0])])));
          }
          __pyx_L29:;
          __pyx_L27:;
        }
        __pyx_L28:;
        goto __pyx_L26;
      }
      __pyx_L26:;
    }
    __pyx_L13:;
    __pyx_L9:;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":378 */
  glEnd();

  /* "/home/jiba/src/soya/model/cellshading.pyx":380 */
  glPointSize((__pyx_v_d / 2));

  /* "/home/jiba/src/soya/model/cellshading.pyx":382 */
  glBegin(GL_POINTS);

  /* "/home/jiba/src/soya/model/cellshading.pyx":383 */
  __pyx_2 = __pyx_v_self->__pyx_base._nb_coords;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":384 */
    __pyx_1 = ((__pyx_v_vertex_used[__pyx_v_i]) == 1);
    if (__pyx_1) {
      glVertex3fv((__pyx_v_self->__pyx_base._coords + (__pyx_v_i * 3)));
      goto __pyx_L32;
    }
    __pyx_L32:;
    __pyx_L30:;
  }
  __pyx_L31:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":385 */
  glEnd();

  /* "/home/jiba/src/soya/model/cellshading.pyx":388 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/cellshading.pyx":390 */
  glLineWidth(1.0);

  /* "/home/jiba/src/soya/model/cellshading.pyx":391 */
  glPointSize(1.0);

  /* "/home/jiba/src/soya/model/cellshading.pyx":392 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/cellshading.pyx":393 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/model/cellshading.pyx":394 */
  glColor4fv(__pyx_v_5_soya_white);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingShape._render_outline");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static float __pyx_f_5_soya_17_CellShadingShape__vertex_compute_cellshading(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,float (*__pyx_v_coord),float (*__pyx_v_normal),PyObject *__pyx_v_lights,float __pyx_v_shade) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  float (__pyx_v_ptr[3]);
  float __pyx_v_tmp;
  int __pyx_v_i;
  float __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_lights);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/model/cellshading.pyx":403 */
  __pyx_1 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 403; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 403; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 403; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/cellshading.pyx":404 */
    __pyx_3 = (__pyx_v_light->_w == 0.0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":405 */
      __pyx_v_tmp = (-vector_dot_product(__pyx_v_normal,__pyx_v_light->_data));
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":407 */
      (__pyx_v_ptr[0]) = ((__pyx_v_light->_data[0]) - (__pyx_v_coord[0]));

      /* "/home/jiba/src/soya/model/cellshading.pyx":408 */
      (__pyx_v_ptr[1]) = ((__pyx_v_light->_data[1]) - (__pyx_v_coord[1]));

      /* "/home/jiba/src/soya/model/cellshading.pyx":409 */
      (__pyx_v_ptr[2]) = ((__pyx_v_light->_data[2]) - (__pyx_v_coord[2]));

      /* "/home/jiba/src/soya/model/cellshading.pyx":410 */
      vector_normalize(__pyx_v_ptr);

      /* "/home/jiba/src/soya/model/cellshading.pyx":411 */
      __pyx_v_tmp = vector_dot_product(__pyx_v_normal,__pyx_v_ptr);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":413 */
    __pyx_v_shade = (__pyx_v_shade + __pyx_v_tmp);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":415 */
  __pyx_r = __pyx_v_shade;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingShape._vertex_compute_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_lights);
  return __pyx_r;
}

static void __pyx_f_5_soya_17_CellShadingShape__prepare_cellshading_shades(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,float (*__pyx_v_shades),PyObject *__pyx_v_lights) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  float (*__pyx_v_ptr1);
  float (*__pyx_v_ptr2);
  float (__pyx_v_v[3]);
  float __pyx_v_tmp;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_lights);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/model/cellshading.pyx":424 */
  __pyx_1 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 424; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 424; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 424; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/cellshading.pyx":425 */
    __pyx_v_ptr1 = __pyx_v_self->__pyx_base._vnormals;

    /* "/home/jiba/src/soya/model/cellshading.pyx":426 */
    __pyx_3 = (__pyx_v_light->_w == 0.0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":427 */
      __pyx_3 = __pyx_v_self->__pyx_base._nb_vnormals;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":428 */
        __pyx_v_tmp = (-vector_dot_product(__pyx_v_ptr1,__pyx_v_light->_data));

        /* "/home/jiba/src/soya/model/cellshading.pyx":429 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/model/cellshading.pyx":430 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);
        __pyx_L5:;
      }
      __pyx_L6:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":433 */
      __pyx_v_ptr2 = __pyx_v_self->__pyx_base._coords;

      /* "/home/jiba/src/soya/model/cellshading.pyx":434 */
      __pyx_3 = __pyx_v_self->__pyx_base._nb_vnormals;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":435 */
        (__pyx_v_v[0]) = ((__pyx_v_light->_data[0]) - (__pyx_v_ptr2[0]));

        /* "/home/jiba/src/soya/model/cellshading.pyx":436 */
        (__pyx_v_v[1]) = ((__pyx_v_light->_data[1]) - (__pyx_v_ptr2[1]));

        /* "/home/jiba/src/soya/model/cellshading.pyx":437 */
        (__pyx_v_v[2]) = ((__pyx_v_light->_data[2]) - (__pyx_v_ptr2[2]));

        /* "/home/jiba/src/soya/model/cellshading.pyx":438 */
        vector_normalize(__pyx_v_v);

        /* "/home/jiba/src/soya/model/cellshading.pyx":439 */
        __pyx_v_tmp = vector_dot_product(__pyx_v_ptr1,__pyx_v_v);

        /* "/home/jiba/src/soya/model/cellshading.pyx":440 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/model/cellshading.pyx":441 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);

        /* "/home/jiba/src/soya/model/cellshading.pyx":442 */
        __pyx_v_ptr2 = (__pyx_v_ptr2 + 3);
        __pyx_L7:;
      }
      __pyx_L8:;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingShape._prepare_cellshading_shades");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_lights);
}

static void __pyx_f_5_soya_17_CellShadingShape__prepare_cellshading(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,float (*__pyx_v_shades)) {
  int __pyx_v_n;
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/model/cellshading.pyx":447 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_renderer->top_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 447; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 447; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 447; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_cast_into(__pyx_v_light,__pyx_v_coordsyst);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":448 */
  __pyx_2 = PyObject_GetIter(__pyx_v_5_soya_renderer->current_context->lights); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 448; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 448; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 448; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_1;
    __pyx_1 = 0;
    ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_cast_into(__pyx_v_light,__pyx_v_coordsyst);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":450 */
  __pyx_3 = (__pyx_v_self->__pyx_base._nb_vnormals > 0);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":451 */
    __pyx_3 = __pyx_v_self->__pyx_base._nb_vnormals;
    for (__pyx_v_n = 0; __pyx_v_n < __pyx_3; ++__pyx_v_n) {
      (__pyx_v_shades[__pyx_v_n]) = 0.5;
      __pyx_L7:;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":452 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading_shades(__pyx_v_self,__pyx_v_shades,__pyx_v_5_soya_renderer->top_lights);

    /* "/home/jiba/src/soya/model/cellshading.pyx":453 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading_shades(__pyx_v_self,__pyx_v_shades,__pyx_v_5_soya_renderer->current_context->lights);

    /* "/home/jiba/src/soya/model/cellshading.pyx":456 */
    __pyx_3 = __pyx_v_self->__pyx_base._nb_vnormals;
    for (__pyx_v_n = 0; __pyx_v_n < __pyx_3; ++__pyx_v_n) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":459 */
      __pyx_4 = ((__pyx_v_shades[__pyx_v_n]) > 0.95);
      if (__pyx_4) {
        (__pyx_v_shades[__pyx_v_n]) = 0.95;
        goto __pyx_L11;
      }
      __pyx_4 = ((__pyx_v_shades[__pyx_v_n]) < 0.05);
      if (__pyx_4) {
        (__pyx_v_shades[__pyx_v_n]) = 0.05;
        goto __pyx_L11;
      }
      __pyx_L11:;
      __pyx_L9:;
    }
    __pyx_L10:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingShape._prepare_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_17_CellShadingShape__render_triangle_cellshading(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face),float (*__pyx_v_shades)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":464 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":465 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[0]),__pyx_v_face->option,__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":466 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[1]),__pyx_v_face->option,__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":467 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[2]),__pyx_v_face->option,__pyx_v_shades);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":469 */
    glNormal3fv((__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":470 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[0]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":471 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[1]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":472 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[2]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingShape._render_triangle_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_17_CellShadingShape__render_quad_cellshading(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face),float (*__pyx_v_shades)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":475 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":476 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[0]),__pyx_v_face->option,__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":477 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[1]),__pyx_v_face->option,__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":478 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[2]),__pyx_v_face->option,__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":479 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading_smoothlit(__pyx_v_self,(__pyx_v_face->v[3]),__pyx_v_face->option,__pyx_v_shades);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":481 */
    glNormal3fv((__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":482 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[0]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":483 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[1]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":484 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[2]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":485 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_vertex_cellshading(__pyx_v_self,(__pyx_v_face->v[3]),__pyx_v_face->option,(__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingShape._render_quad_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_17_CellShadingShape__render_vertex_cellshading_smoothlit(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,int __pyx_v_index,int __pyx_v_face_option,float (*__pyx_v_shades)) {
  int __pyx_v_n;
  float (*__pyx_v_coord);
  float __pyx_v_shade;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":493 */
  __pyx_v_n = (__pyx_v_self->__pyx_base._vertex_coords[__pyx_v_index]);

  /* "/home/jiba/src/soya/model/cellshading.pyx":494 */
  __pyx_v_coord = (__pyx_v_self->__pyx_base._coords + __pyx_v_n);

  /* "/home/jiba/src/soya/model/cellshading.pyx":496 */
  __pyx_1 = (__pyx_v_face_option & __pyx_e_5_soya_FACE_NON_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":497 */
    __pyx_v_shade = 0.5;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":499 */
    __pyx_v_shade = (__pyx_v_shades[(__pyx_v_n / 3)]);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":501 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_1) {
    glColor4fv((__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_diffuses[__pyx_v_index])));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":502 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_1) {
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,(__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_emissives[__pyx_v_index])));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":503 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":504 */
    glMultiTexCoord2fvARB(GL_TEXTURE0,(__pyx_v_self->__pyx_base._values + (__pyx_v_self->__pyx_base._vertex_texcoords[__pyx_v_index])));

    /* "/home/jiba/src/soya/model/cellshading.pyx":505 */
    glMultiTexCoord2fARB(GL_TEXTURE1,__pyx_v_shade,__pyx_v_shade);
    goto __pyx_L5;
  }
  /*else*/ {
    glTexCoord2f(__pyx_v_shade,__pyx_v_shade);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":508 */
  glNormal3fv((__pyx_v_self->__pyx_base._vnormals + __pyx_v_n));

  /* "/home/jiba/src/soya/model/cellshading.pyx":509 */
  glVertex3fv(__pyx_v_coord);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingShape._render_vertex_cellshading_smoothlit");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_17_CellShadingShape__render_vertex_cellshading(struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_self,int __pyx_v_index,int __pyx_v_face_option,float (*__pyx_v_fnormal)) {
  float (*__pyx_v_coord);
  float __pyx_v_shade;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":515 */
  __pyx_v_coord = (__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[__pyx_v_index]));

  /* "/home/jiba/src/soya/model/cellshading.pyx":517 */
  __pyx_1 = (__pyx_v_face_option & __pyx_e_5_soya_FACE_NON_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":518 */
    __pyx_v_shade = 0.5;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":520 */
    __pyx_v_shade = ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_vertex_compute_cellshading(__pyx_v_self,__pyx_v_coord,__pyx_v_fnormal,__pyx_v_5_soya_renderer->top_lights,0.5);

    /* "/home/jiba/src/soya/model/cellshading.pyx":521 */
    __pyx_v_shade = ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_vertex_compute_cellshading(__pyx_v_self,__pyx_v_coord,__pyx_v_fnormal,__pyx_v_5_soya_renderer->current_context->lights,__pyx_v_shade);

    /* "/home/jiba/src/soya/model/cellshading.pyx":522 */
    __pyx_1 = (__pyx_v_shade < 0.05);
    if (__pyx_1) {
      __pyx_v_shade = 0.05;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_shade > 0.95);
    if (__pyx_1) {
      __pyx_v_shade = 0.95;
      goto __pyx_L3;
    }
    __pyx_L3:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":525 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_DIFFUSES);
  if (__pyx_1) {
    glColor4fv((__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_diffuses[__pyx_v_index])));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":526 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_EMISSIVES);
  if (__pyx_1) {
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,(__pyx_v_self->__pyx_base._colors + (__pyx_v_self->__pyx_base._vertex_emissives[__pyx_v_index])));
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":527 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SHAPE_TEXCOORDS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":528 */
    glMultiTexCoord2fvARB(GL_TEXTURE0,(__pyx_v_self->__pyx_base._values + (__pyx_v_self->__pyx_base._vertex_texcoords[__pyx_v_index])));

    /* "/home/jiba/src/soya/model/cellshading.pyx":529 */
    glMultiTexCoord2fARB(GL_TEXTURE1,__pyx_v_shade,__pyx_v_shade);
    goto __pyx_L6;
  }
  /*else*/ {
    glTexCoord2f(__pyx_v_shade,__pyx_v_shade);
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":532 */
  glVertex3fv(__pyx_v_coord);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingShape._render_vertex_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static struct __pyx_t_5_soya__Node (*__pyx_f_5_soya_node_new(int __pyx_v_face_index,GLfloat (*__pyx_v_sphere))) {
  struct __pyx_t_5_soya__Node (*__pyx_v_node);
  struct __pyx_t_5_soya__Node (*__pyx_r);

  /* "/home/jiba/src/soya/model/tree.pyx":27 */
  __pyx_v_node = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

  /* "/home/jiba/src/soya/model/tree.pyx":28 */
  __pyx_v_node->nb_faces = 1;

  /* "/home/jiba/src/soya/model/tree.pyx":29 */
  __pyx_v_node->faces = ((int (*))malloc((sizeof(int ))));

  /* "/home/jiba/src/soya/model/tree.pyx":30 */
  (__pyx_v_node->faces[0]) = __pyx_v_face_index;

  /* "/home/jiba/src/soya/model/tree.pyx":31 */
  __pyx_v_node->nb_children = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":32 */
  __pyx_v_node->children = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":33 */
  memcpy(__pyx_v_node->sphere,__pyx_v_sphere,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":34 */
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_new");
  __pyx_L0:;
  return __pyx_r;
}

static struct __pyx_t_5_soya__Node (*__pyx_f_5_soya_node_register_face(struct __pyx_t_5_soya__Node (*__pyx_v_node),struct __pyx_t_5_soya__Node (*__pyx_v_parent),int __pyx_v_face_index,float (*__pyx_v_sphere))) {
  float __pyx_v_d;
  struct __pyx_t_5_soya__Node (*__pyx_v_n);
  struct __pyx_t_5_soya__Node (*__pyx_r);
  int __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":39 */
  __pyx_v_d = point_distance_to(__pyx_v_node->sphere,__pyx_v_sphere);

  /* "/home/jiba/src/soya/model/tree.pyx":40 */
  __pyx_1 = ((__pyx_v_d + (__pyx_v_sphere[3])) <= (__pyx_v_node->sphere[3]));
  if (__pyx_1) {
    __pyx_f_5_soya_node_register_inside_face(__pyx_v_node,__pyx_v_face_index,__pyx_v_sphere);
    goto __pyx_L2;
  }
  __pyx_1 = ((__pyx_v_d + (__pyx_v_node->sphere[3])) <= (__pyx_v_sphere[3]));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":42 */
    __pyx_v_n = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

    /* "/home/jiba/src/soya/model/tree.pyx":43 */
    __pyx_v_n->nb_faces = 1;

    /* "/home/jiba/src/soya/model/tree.pyx":44 */
    __pyx_v_n->faces = ((int (*))malloc((sizeof(int ))));

    /* "/home/jiba/src/soya/model/tree.pyx":45 */
    (__pyx_v_n->faces[0]) = __pyx_v_face_index;

    /* "/home/jiba/src/soya/model/tree.pyx":46 */
    __pyx_v_n->nb_children = 1;

    /* "/home/jiba/src/soya/model/tree.pyx":47 */
    __pyx_v_n->children = ((struct __pyx_t_5_soya__Node (*(*)))malloc((sizeof(struct __pyx_t_5_soya__Node (*)))));

    /* "/home/jiba/src/soya/model/tree.pyx":48 */
    (__pyx_v_n->children[0]) = __pyx_v_node;

    /* "/home/jiba/src/soya/model/tree.pyx":49 */
    memcpy(__pyx_v_n->sphere,__pyx_v_sphere,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/tree.pyx":50 */
    __pyx_r = __pyx_v_n;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/tree.pyx":52 */
    __pyx_1 = (__pyx_v_parent == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":53 */
      __pyx_v_n = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

      /* "/home/jiba/src/soya/model/tree.pyx":54 */
      __pyx_v_n->nb_faces = 0;

      /* "/home/jiba/src/soya/model/tree.pyx":55 */
      __pyx_v_n->faces = 0;

      /* "/home/jiba/src/soya/model/tree.pyx":56 */
      __pyx_v_n->nb_children = 2;

      /* "/home/jiba/src/soya/model/tree.pyx":57 */
      __pyx_v_n->children = ((struct __pyx_t_5_soya__Node (*(*)))malloc((2 * (sizeof(struct __pyx_t_5_soya__Node (*))))));

      /* "/home/jiba/src/soya/model/tree.pyx":58 */
      (__pyx_v_n->children[0]) = __pyx_v_node;

      /* "/home/jiba/src/soya/model/tree.pyx":59 */
      (__pyx_v_n->children[1]) = __pyx_f_5_soya_node_new(__pyx_v_face_index,__pyx_v_sphere);

      /* "/home/jiba/src/soya/model/tree.pyx":60 */
      sphere_from_2_spheres(__pyx_v_n->sphere,__pyx_v_node->sphere,__pyx_v_sphere);

      /* "/home/jiba/src/soya/model/tree.pyx":61 */
      __pyx_r = __pyx_v_n;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    /*else*/ {
      __pyx_f_5_soya_node_add_face(__pyx_v_parent,__pyx_v_face_index,__pyx_v_sphere);
    }
    __pyx_L3:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/tree.pyx":63 */
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_register_face");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_node_register_inside_face(struct __pyx_t_5_soya__Node (*__pyx_v_node),int __pyx_v_face_index,GLfloat (*__pyx_v_sphere)) {
  float __pyx_v_d;
  int __pyx_v_i;
  int __pyx_1;
  int __pyx_2;

  /* "/home/jiba/src/soya/model/tree.pyx":68 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/tree.pyx":69 */
    __pyx_v_d = point_distance_to((__pyx_v_node->children[__pyx_v_i])->sphere,__pyx_v_sphere);

    /* "/home/jiba/src/soya/model/tree.pyx":70 */
    __pyx_2 = ((__pyx_v_d + (__pyx_v_sphere[3])) <= ((__pyx_v_node->children[__pyx_v_i])->sphere[3]));
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/tree.pyx":71 */
      __pyx_f_5_soya_node_register_inside_face((__pyx_v_node->children[__pyx_v_i]),__pyx_v_face_index,__pyx_v_sphere);

      /* "/home/jiba/src/soya/model/tree.pyx":72 */
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":73 */
  __pyx_f_5_soya_node_add_face(__pyx_v_node,__pyx_v_face_index,__pyx_v_sphere);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_register_inside_face");
  __pyx_L0:;
}

static void __pyx_f_5_soya_node_register_node(struct __pyx_t_5_soya__Node (*__pyx_v_node),struct __pyx_t_5_soya__Node (*__pyx_v_add)) {
  float __pyx_v_d;
  int __pyx_v_i;
  int __pyx_v_added;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":78 */
  __pyx_v_i = 0;
  __pyx_v_added = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":80 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_node->nb_children);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/tree.pyx":81 */
    __pyx_1 = ((__pyx_v_node->children[__pyx_v_i]) == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":82 */
      __pyx_1 = (__pyx_v_added == 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/tree.pyx":83 */
        (__pyx_v_node->children[__pyx_v_i]) = __pyx_v_add;

        /* "/home/jiba/src/soya/model/tree.pyx":84 */
        __pyx_v_added = 1;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/model/tree.pyx":85 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/tree.pyx":87 */
      __pyx_v_d = point_distance_to(__pyx_v_add->sphere,(__pyx_v_node->children[__pyx_v_i])->sphere);

      /* "/home/jiba/src/soya/model/tree.pyx":88 */
      __pyx_1 = ((__pyx_v_d + ((__pyx_v_node->children[__pyx_v_i])->sphere[3])) <= (__pyx_v_add->sphere[3]));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/tree.pyx":90 */
        __pyx_f_5_soya_node_add_node(__pyx_v_add,(__pyx_v_node->children[__pyx_v_i]));

        /* "/home/jiba/src/soya/model/tree.pyx":91 */
        __pyx_1 = (__pyx_v_added == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/tree.pyx":92 */
          (__pyx_v_node->children[__pyx_v_i]) = __pyx_v_add;

          /* "/home/jiba/src/soya/model/tree.pyx":93 */
          __pyx_v_added = 1;

          /* "/home/jiba/src/soya/model/tree.pyx":94 */
          __pyx_v_i = (__pyx_v_i + 1);
          goto __pyx_L7;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/tree.pyx":96 */
          __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

          /* "/home/jiba/src/soya/model/tree.pyx":97 */
          (__pyx_v_node->children[__pyx_v_i]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);

          /* "/home/jiba/src/soya/model/tree.pyx":98 */
          (__pyx_v_node->children[__pyx_v_node->nb_children]) = 0;
        }
        __pyx_L7:;
        goto __pyx_L6;
      }
      /*else*/ {
        __pyx_v_i = (__pyx_v_i + 1);
      }
      __pyx_L6:;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":100 */
  __pyx_1 = (__pyx_v_added == 0);
  if (__pyx_1) {
    __pyx_f_5_soya_node_add_node(__pyx_v_node,__pyx_v_add);
    goto __pyx_L8;
  }
  __pyx_L8:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_register_node");
  __pyx_L0:;
}

static void __pyx_f_5_soya_node_add_face(struct __pyx_t_5_soya__Node (*__pyx_v_node),int __pyx_v_face_index,float (*__pyx_v_sphere)) {
  struct __pyx_t_5_soya__Node (*__pyx_v_new);

  /* "/home/jiba/src/soya/model/tree.pyx":105 */
  __pyx_v_new = __pyx_f_5_soya_node_new(__pyx_v_face_index,__pyx_v_sphere);

  /* "/home/jiba/src/soya/model/tree.pyx":106 */
  __pyx_f_5_soya_node_register_node(__pyx_v_node,__pyx_v_new);

  /* "/home/jiba/src/soya/model/tree.pyx":107 */
  __pyx_v_node->children = ((struct __pyx_t_5_soya__Node (*(*)))realloc(__pyx_v_node->children,(__pyx_v_node->nb_children * (sizeof(struct __pyx_t_5_soya__Node (*))))));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_add_face");
  __pyx_L0:;
}

static int __pyx_f_5_soya_node_gather(struct __pyx_t_5_soya__Node (*__pyx_v_node),int __pyx_v_mode,float __pyx_v_param) {
  int __pyx_v_best1;
  int __pyx_v_best2;
  int __pyx_v_i;
  int __pyx_v_j;
  float __pyx_v_min_radius;
  float __pyx_v_radius;
  float (__pyx_v_sphere[4]);
  float (__pyx_v_best_sphere[4]);
  struct __pyx_t_5_soya__Node (*__pyx_v_n);
  int __pyx_r;
  long __pyx_1;
  int __pyx_2;
  int __pyx_3;
  int __pyx_4;

  /* "/home/jiba/src/soya/model/tree.pyx":114 */
  __pyx_1 = (-1);
  __pyx_v_best1 = __pyx_1;
  __pyx_v_best2 = __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":117 */
  __pyx_2 = (__pyx_v_mode == 0);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/tree.pyx":118 */
    __pyx_v_min_radius = 100000.0;

    /* "/home/jiba/src/soya/model/tree.pyx":119 */
    __pyx_v_radius = (__pyx_v_param * (__pyx_v_node->sphere[3]));

    /* "/home/jiba/src/soya/model/tree.pyx":120 */
    __pyx_v_n = 0;

    /* "/home/jiba/src/soya/model/tree.pyx":121 */
    __pyx_2 = __pyx_v_node->nb_children;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/tree.pyx":122 */
      __pyx_3 = (__pyx_v_n == 0);
      if (!__pyx_3) {
        __pyx_3 = (((__pyx_v_node->children[__pyx_v_i])->sphere[3]) < __pyx_v_min_radius);
      }
      if (__pyx_3) {

        /* "/home/jiba/src/soya/model/tree.pyx":123 */
        __pyx_v_best1 = __pyx_v_i;

        /* "/home/jiba/src/soya/model/tree.pyx":124 */
        __pyx_v_n = (__pyx_v_node->children[__pyx_v_i]);

        /* "/home/jiba/src/soya/model/tree.pyx":125 */
        __pyx_v_min_radius = (__pyx_v_n->sphere[3]);
        goto __pyx_L5;
      }
      __pyx_L5:;
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":126 */
    __pyx_3 = (__pyx_v_min_radius >= __pyx_v_radius);
    if (__pyx_3) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/tree.pyx":128 */
      __pyx_2 = __pyx_v_node->nb_children;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

        /* "/home/jiba/src/soya/model/tree.pyx":129 */
        __pyx_3 = (__pyx_v_i != __pyx_v_best1);
        if (__pyx_3) {

          /* "/home/jiba/src/soya/model/tree.pyx":130 */
          sphere_from_2_spheres(__pyx_v_best_sphere,__pyx_v_n->sphere,(__pyx_v_node->children[__pyx_v_i])->sphere);

          /* "/home/jiba/src/soya/model/tree.pyx":131 */
          __pyx_3 = ((__pyx_v_best_sphere[3]) <= __pyx_v_radius);
          if (__pyx_3) {

            /* "/home/jiba/src/soya/model/tree.pyx":132 */
            __pyx_v_best2 = __pyx_v_i;

            /* "/home/jiba/src/soya/model/tree.pyx":133 */
            goto __pyx_L8;
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;
        __pyx_L7:;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/model/tree.pyx":134 */
      __pyx_r = 0;
      goto __pyx_L0;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/tree.pyx":138 */
    __pyx_3 = __pyx_v_node->nb_children;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_3; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/tree.pyx":139 */
      __pyx_v_n = (__pyx_v_node->children[__pyx_v_i]);

      /* "/home/jiba/src/soya/model/tree.pyx":140 */
      __pyx_2 = (__pyx_v_n != 0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/tree.pyx":141 */
        __pyx_2 = __pyx_v_node->nb_children;
        for (__pyx_v_j = (__pyx_v_i + 1); __pyx_v_j < __pyx_2; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/tree.pyx":142 */
          __pyx_4 = ((__pyx_v_node->children[__pyx_v_j]) != 0);
          if (__pyx_4) {

            /* "/home/jiba/src/soya/model/tree.pyx":143 */
            sphere_from_2_spheres(__pyx_v_sphere,__pyx_v_n->sphere,(__pyx_v_node->children[__pyx_v_j])->sphere);

            /* "/home/jiba/src/soya/model/tree.pyx":144 */
            __pyx_4 = (__pyx_v_best1 < 0);
            if (!__pyx_4) {
              __pyx_4 = ((__pyx_v_sphere[3]) < (__pyx_v_best_sphere[3]));
            }
            if (__pyx_4) {

              /* "/home/jiba/src/soya/model/tree.pyx":145 */
              memcpy(__pyx_v_best_sphere,__pyx_v_sphere,(4 * (sizeof(float ))));

              /* "/home/jiba/src/soya/model/tree.pyx":146 */
              __pyx_v_best1 = __pyx_v_i;

              /* "/home/jiba/src/soya/model/tree.pyx":147 */
              __pyx_v_best2 = __pyx_v_j;
              goto __pyx_L17;
            }
            __pyx_L17:;
            goto __pyx_L16;
          }
          __pyx_L16:;
          __pyx_L14:;
        }
        __pyx_L15:;
        goto __pyx_L13;
      }
      __pyx_L13:;
      __pyx_L11:;
    }
    __pyx_L12:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/tree.pyx":148 */
  __pyx_4 = ((__pyx_v_best_sphere[3]) >= (__pyx_v_node->sphere[3]));
  if (__pyx_4) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L18;
  }
  __pyx_L18:;

  /* "/home/jiba/src/soya/model/tree.pyx":150 */
  __pyx_v_n = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

  /* "/home/jiba/src/soya/model/tree.pyx":151 */
  __pyx_v_n->nb_faces = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":152 */
  __pyx_v_n->faces = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":153 */
  __pyx_v_n->nb_children = 2;

  /* "/home/jiba/src/soya/model/tree.pyx":154 */
  __pyx_v_n->children = ((struct __pyx_t_5_soya__Node (*(*)))malloc((2 * (sizeof(struct __pyx_t_5_soya__Node (*))))));

  /* "/home/jiba/src/soya/model/tree.pyx":155 */
  (__pyx_v_n->children[0]) = (__pyx_v_node->children[__pyx_v_best1]);

  /* "/home/jiba/src/soya/model/tree.pyx":156 */
  (__pyx_v_n->children[1]) = (__pyx_v_node->children[__pyx_v_best2]);

  /* "/home/jiba/src/soya/model/tree.pyx":157 */
  memcpy(__pyx_v_n->sphere,__pyx_v_best_sphere,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":158 */
  __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

  /* "/home/jiba/src/soya/model/tree.pyx":159 */
  (__pyx_v_node->children[__pyx_v_best1]) = __pyx_v_n;

  /* "/home/jiba/src/soya/model/tree.pyx":160 */
  (__pyx_v_node->children[__pyx_v_best2]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);

  /* "/home/jiba/src/soya/model/tree.pyx":161 */
  __pyx_f_5_soya_node_added(__pyx_v_node,__pyx_v_n);

  /* "/home/jiba/src/soya/model/tree.pyx":162 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_gather");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_node_added(struct __pyx_t_5_soya__Node (*__pyx_v_node),struct __pyx_t_5_soya__Node (*__pyx_v_new)) {
  float __pyx_v_d;
  int __pyx_v_i;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":168 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":169 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_node->nb_children);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/tree.pyx":170 */
    __pyx_1 = ((__pyx_v_node->children[__pyx_v_i]) != 0);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_new != (__pyx_v_node->children[__pyx_v_i]));
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":171 */
      __pyx_v_d = point_distance_to(__pyx_v_new->sphere,(__pyx_v_node->children[__pyx_v_i])->sphere);

      /* "/home/jiba/src/soya/model/tree.pyx":172 */
      __pyx_1 = ((__pyx_v_d + ((__pyx_v_node->children[__pyx_v_i])->sphere[3])) <= (__pyx_v_new->sphere[3]));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/tree.pyx":174 */
        __pyx_f_5_soya_node_add_node(__pyx_v_new,(__pyx_v_node->children[__pyx_v_i]));

        /* "/home/jiba/src/soya/model/tree.pyx":175 */
        __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

        /* "/home/jiba/src/soya/model/tree.pyx":176 */
        (__pyx_v_node->children[__pyx_v_i]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);

        /* "/home/jiba/src/soya/model/tree.pyx":177 */
        (__pyx_v_node->children[__pyx_v_node->nb_children]) = 0;
        goto __pyx_L5;
      }
      /*else*/ {
        __pyx_v_i = (__pyx_v_i + 1);
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    /*else*/ {
      __pyx_v_i = (__pyx_v_i + 1);
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_added");
  __pyx_L0:;
}

static void __pyx_f_5_soya_node_add_node(struct __pyx_t_5_soya__Node (*__pyx_v_node),struct __pyx_t_5_soya__Node (*__pyx_v_add)) {

  /* "/home/jiba/src/soya/model/tree.pyx":182 */
  __pyx_v_node->children = ((struct __pyx_t_5_soya__Node (*(*)))realloc(__pyx_v_node->children,((__pyx_v_node->nb_children + 1) * (sizeof(struct __pyx_t_5_soya__Node (*))))));

  /* "/home/jiba/src/soya/model/tree.pyx":183 */
  (__pyx_v_node->children[__pyx_v_node->nb_children]) = __pyx_v_add;

  /* "/home/jiba/src/soya/model/tree.pyx":184 */
  __pyx_v_node->nb_children = (__pyx_v_node->nb_children + 1);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_add_node");
  __pyx_L0:;
}

static void __pyx_f_5_soya_node_collapse_with_child(struct __pyx_t_5_soya__Node (*__pyx_v_node),float __pyx_v_collapse) {
  int __pyx_v_i;
  int __pyx_1;
  int __pyx_2;

  /* "/home/jiba/src/soya/model/tree.pyx":188 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/tree.pyx":189 */
    __pyx_2 = (((__pyx_v_node->children[__pyx_v_i])->sphere[3]) > (__pyx_v_collapse * (__pyx_v_node->sphere[3])));
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/tree.pyx":190 */
      __pyx_f_5_soya_node_join(__pyx_v_node,(__pyx_v_node->children[__pyx_v_i]));

      /* "/home/jiba/src/soya/model/tree.pyx":191 */
      __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

      /* "/home/jiba/src/soya/model/tree.pyx":192 */
      (__pyx_v_node->children[__pyx_v_i]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_collapse_with_child");
  __pyx_L0:;
}

static void __pyx_f_5_soya_node_join(struct __pyx_t_5_soya__Node (*__pyx_v_n1),struct __pyx_t_5_soya__Node (*__pyx_v_n2)) {
  int __pyx_v_i;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":196 */
  __pyx_v_n1->faces = ((int (*))realloc(__pyx_v_n1->faces,((__pyx_v_n1->nb_faces + __pyx_v_n2->nb_faces) * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/tree.pyx":197 */
  __pyx_1 = __pyx_v_n2->nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
    (__pyx_v_n1->faces[(__pyx_v_n1->nb_faces + __pyx_v_i)]) = (__pyx_v_n2->faces[__pyx_v_i]);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":198 */
  __pyx_v_n1->nb_faces = (__pyx_v_n1->nb_faces + __pyx_v_n2->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":200 */
  __pyx_v_n1->children = ((struct __pyx_t_5_soya__Node (*(*)))realloc(__pyx_v_n1->children,((__pyx_v_n1->nb_children + __pyx_v_n2->nb_children) * (sizeof(struct __pyx_t_5_soya__Node (*))))));

  /* "/home/jiba/src/soya/model/tree.pyx":201 */
  __pyx_1 = __pyx_v_n2->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
    (__pyx_v_n1->children[(__pyx_v_n1->nb_children + __pyx_v_i)]) = (__pyx_v_n2->children[__pyx_v_i]);
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/tree.pyx":202 */
  __pyx_v_n1->nb_children = (__pyx_v_n1->nb_children + __pyx_v_n2->nb_children);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_join");
  __pyx_L0:;
}

static void __pyx_f_5_soya_node_optimize(struct __pyx_t_5_soya__Node (*__pyx_v_node),float __pyx_v_collapse,int __pyx_v_mode,float __pyx_v_param) {
  int __pyx_v_i;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":206 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_node->nb_children > 2);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/tree.pyx":207 */
    __pyx_1 = (__pyx_f_5_soya_node_gather(__pyx_v_node,__pyx_v_mode,__pyx_v_param) == 0);
    if (__pyx_1) {
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":208 */
  __pyx_f_5_soya_node_collapse_with_child(__pyx_v_node,__pyx_v_collapse);

  /* "/home/jiba/src/soya/model/tree.pyx":209 */
  __pyx_v_node->children = ((struct __pyx_t_5_soya__Node (*(*)))realloc(__pyx_v_node->children,(__pyx_v_node->nb_children * (sizeof(struct __pyx_t_5_soya__Node (*))))));

  /* "/home/jiba/src/soya/model/tree.pyx":210 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
    __pyx_f_5_soya_node_optimize((__pyx_v_node->children[__pyx_v_i]),__pyx_v_collapse,__pyx_v_mode,__pyx_v_param);
    __pyx_L5:;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_optimize");
  __pyx_L0:;
}

static int __pyx_f_5_soya_node_get_nb_level(struct __pyx_t_5_soya__Node (*__pyx_v_node)) {
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_v_n;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;

  /* "/home/jiba/src/soya/model/tree.pyx":214 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":215 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/tree.pyx":216 */
    __pyx_v_n = __pyx_f_5_soya_node_get_nb_level((__pyx_v_node->children[__pyx_v_i]));

    /* "/home/jiba/src/soya/model/tree.pyx":217 */
    __pyx_2 = (__pyx_v_n > __pyx_v_nb);
    if (__pyx_2) {
      __pyx_v_nb = __pyx_v_n;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":218 */
  __pyx_r = (__pyx_v_nb + 1);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_get_nb_level");
  __pyx_L0:;
  return __pyx_r;
}

static int __pyx_f_5_soya_node_get_memory_size(struct __pyx_t_5_soya__Node (*__pyx_v_node)) {
  int __pyx_v_size;
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":222 */
  __pyx_v_size = (((2 * (sizeof(int ))) + (4 * (sizeof(float )))) + (((2 + __pyx_v_node->nb_children) + __pyx_v_node->nb_faces) * (sizeof(void (*)))));

  /* "/home/jiba/src/soya/model/tree.pyx":223 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
    __pyx_v_size = (__pyx_v_size + __pyx_f_5_soya_node_get_memory_size((__pyx_v_node->children[__pyx_v_i])));
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":224 */
  __pyx_r = __pyx_v_size;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.node_get_memory_size");
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_node_collect_raypickables(struct __pyx_t_5_soya__Node (*__pyx_v_node),__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_sphere)) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":229 */
  __pyx_1 = (sphere_distance_sphere(__pyx_v_sphere,__pyx_v_node->sphere) < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":231 */
    chunk_add(__pyx_v_items,__pyx_v_node->faces,(__pyx_v_node->nb_faces * (sizeof(int ))));

    /* "/home/jiba/src/soya/model/tree.pyx":232 */
    __pyx_1 = __pyx_v_node->nb_children;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
      __pyx_2 = __pyx_f_5_soya_node_collect_raypickables((__pyx_v_node->children[__pyx_v_i]),__pyx_v_items,__pyx_v_sphere); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 232; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_L3:;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.node_collect_raypickables");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_TreeShape___getcstate__(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":239 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/tree.pyx":240 */
  __pyx_1 = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_node2chunk(__pyx_v_self,__pyx_v_self->_tree,__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 240; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":241 */
  __pyx_1 = __pyx_vtabptr_5_soya__SimpleShape->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 241; goto __pyx_L1;}
  __pyx_2 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 241; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 241; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._TreeShape.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_TreeShape___setcstate__(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/tree.pyx":244 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya__SimpleShape->__setcstate_data__(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":247 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 247; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":248 */
  __pyx_v_self->_tree = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_chunk2node(__pyx_v_self,__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/tree.pyx":249 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._TreeShape.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_10_TreeShape__node2chunk(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_t_5_soya__Node (*__pyx_v_node),__pyx_t_5_soya_Chunk (*__pyx_v_chunk)) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":253 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_node->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":254 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_node->nb_children);

  /* "/home/jiba/src/soya/model/tree.pyx":255 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_node->sphere,4);

  /* "/home/jiba/src/soya/model/tree.pyx":256 */
  chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_node->faces,__pyx_v_node->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":257 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_node2chunk(__pyx_v_self,(__pyx_v_node->children[__pyx_v_i]),__pyx_v_chunk); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 257; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._TreeShape._node2chunk");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static struct __pyx_t_5_soya__Node (*__pyx_f_5_soya_10_TreeShape__chunk2node(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_chunk))) {
  int __pyx_v_i;
  struct __pyx_t_5_soya__Node (*__pyx_v_node);
  struct __pyx_t_5_soya__Node (*__pyx_r);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":262 */
  __pyx_v_node = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

  /* "/home/jiba/src/soya/model/tree.pyx":263 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_node->nb_faces));

  /* "/home/jiba/src/soya/model/tree.pyx":264 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_node->nb_children));

  /* "/home/jiba/src/soya/model/tree.pyx":265 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_node->sphere,4);

  /* "/home/jiba/src/soya/model/tree.pyx":266 */
  __pyx_v_node->faces = ((int (*))malloc((__pyx_v_node->nb_faces * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/tree.pyx":267 */
  __pyx_v_node->children = ((struct __pyx_t_5_soya__Node (*(*)))malloc((__pyx_v_node->nb_children * (sizeof(struct __pyx_t_5_soya__Node (*))))));

  /* "/home/jiba/src/soya/model/tree.pyx":268 */
  chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_node->faces,__pyx_v_node->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":269 */
  __pyx_1 = __pyx_v_node->nb_children;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
    (__pyx_v_node->children[__pyx_v_i]) = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_chunk2node(__pyx_v_self,__pyx_v_chunk);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":270 */
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._chunk2node");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k263p;

static char (__pyx_k263[]) = "* Soya * Tree built,     %s levels, memory : %s bytes";

static void __pyx_f_5_soya_10_TreeShape__build_tree(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self) {
  int __pyx_v_i;
  float (__pyx_v_sphere[4]);
  struct __pyx_t_5_soya__Node (*__pyx_v_tree);
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":276 */
  __pyx_v_tree = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":278 */
  __pyx_1 = __pyx_v_self->__pyx_base._nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/tree.pyx":279 */
    ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->compute_sphere(__pyx_v_self,(__pyx_v_self->__pyx_base._faces + __pyx_v_i),__pyx_v_sphere);

    /* "/home/jiba/src/soya/model/tree.pyx":280 */
    __pyx_2 = (__pyx_v_tree == 0);
    if (__pyx_2) {
      __pyx_v_tree = __pyx_f_5_soya_node_new(__pyx_v_i,__pyx_v_sphere);
      goto __pyx_L4;
    }
    /*else*/ {
      __pyx_v_tree = __pyx_f_5_soya_node_register_face(__pyx_v_tree,0,__pyx_v_i,__pyx_v_sphere);
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":283 */
  __pyx_v_self->_tree = __pyx_v_tree;

  /* "/home/jiba/src/soya/model/tree.pyx":285 */
  __pyx_3 = PyInt_FromLong(__pyx_f_5_soya_node_get_nb_level(__pyx_v_self->_tree)); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 285; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_f_5_soya_node_get_memory_size(__pyx_v_self->_tree)); if (!__pyx_4) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 285; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 285; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_3 = PyNumber_Remainder(__pyx_k263p, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 285; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 285; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 285; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._TreeShape._build_tree");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k264p;

static char (__pyx_k264[]) = "* Soya * Tree optimized, %s levels, memory : %s bytes";

static void __pyx_f_5_soya_10_TreeShape__optimize_tree(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,float __pyx_v_collapse,int __pyx_v_mode,float __pyx_v_max_children_radius) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":288 */
  __pyx_f_5_soya_node_optimize(__pyx_v_self->_tree,__pyx_v_collapse,__pyx_v_mode,__pyx_v_max_children_radius);

  /* "/home/jiba/src/soya/model/tree.pyx":290 */
  __pyx_1 = PyInt_FromLong(__pyx_f_5_soya_node_get_nb_level(__pyx_v_self->_tree)); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_f_5_soya_node_get_memory_size(__pyx_v_self->_tree)); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 290; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k264p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 290; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 290; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._TreeShape._optimize_tree");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_TreeShape_compute_sphere(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,__pyx_t_5_soya_ShapeFace (*__pyx_v_face),float (*__pyx_v_sphere)) {
  float (__pyx_v_p[12]);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":294 */
  memcpy(__pyx_v_p,(__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[0])])),(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":295 */
  memcpy((__pyx_v_p + 3),(__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[1])])),(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":296 */
  memcpy((__pyx_v_p + 6),(__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[2])])),(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":297 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_TRIANGLE);
  if (__pyx_1) {
    sphere_from_points(__pyx_v_sphere,__pyx_v_p,3);
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":299 */
    memcpy((__pyx_v_p + 9),(__pyx_v_self->__pyx_base._coords + (__pyx_v_self->__pyx_base._vertex_coords[(__pyx_v_face->v[3])])),(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/tree.pyx":300 */
    sphere_from_points(__pyx_v_sphere,__pyx_v_p,4);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape.compute_sphere");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_TreeShape__batch(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/tree.pyx":305 */
  __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/tree.pyx":309 */
  ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_batch_node(__pyx_v_self,__pyx_v_self->_tree,__pyx_v_frustum);

  /* "/home/jiba/src/soya/model/tree.pyx":310 */
  __pyx_f_5_soya_pack_batch_end(((PyObject *)__pyx_v_self),__pyx_v_coordsyst);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_10_TreeShape__batch_node(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_t_5_soya__Node (*__pyx_v_node),__pyx_t_5_soya_Frustum (*__pyx_v_frustum)) {
  int __pyx_v_i;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/tree.pyx":317 */
  __pyx_1 = (sphere_in_frustum(__pyx_v_frustum,__pyx_v_node->sphere) == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":318 */
    __pyx_1 = __pyx_v_node->nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
      ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._batch_face(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),(__pyx_v_self->__pyx_base._faces + (__pyx_v_node->faces[__pyx_v_i])));
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":319 */
    __pyx_1 = __pyx_v_node->nb_children;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
      ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_batch_node(__pyx_v_self,(__pyx_v_node->children[__pyx_v_i]),__pyx_v_frustum);
      __pyx_L5:;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._batch_node");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_TreeShape__render(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_instance) {
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  __pyx_t_5_soya_ShapeFace (*__pyx_v_face);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_instance);

  /* "/home/jiba/src/soya/model/tree.pyx":325 */
  __pyx_f_5_soya_shape_option_activate(__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/tree.pyx":327 */
  __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

  /* "/home/jiba/src/soya/model/tree.pyx":328 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_pack != 0);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/tree.pyx":329 */
    __pyx_2 = (PyObject *)__pyx_v_pack->material_id;
    Py_INCREF((PyObject *)__pyx_2);
    ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id));
    Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/tree.pyx":330 */
    __pyx_f_5_soya_face_option_activate(__pyx_v_pack->option);

    /* "/home/jiba/src/soya/model/tree.pyx":332 */
    __pyx_v_face = ((__pyx_t_5_soya_ShapeFace (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

    /* "/home/jiba/src/soya/model/tree.pyx":333 */
    __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_FACE_TRIANGLE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":334 */
      glBegin(GL_TRIANGLES);

      /* "/home/jiba/src/soya/model/tree.pyx":335 */
      while (1) {
        __pyx_L5:;
        __pyx_1 = (__pyx_v_face != 0);
        if (!__pyx_1) break;

        /* "/home/jiba/src/soya/model/tree.pyx":336 */
        ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._render_triangle(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_face);

        /* "/home/jiba/src/soya/model/tree.pyx":337 */
        __pyx_v_face = ((__pyx_t_5_soya_ShapeFace (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
      }
      __pyx_L6:;
      goto __pyx_L4;
    }
    __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_FACE_QUAD);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":340 */
      glBegin(GL_QUADS);

      /* "/home/jiba/src/soya/model/tree.pyx":341 */
      while (1) {
        __pyx_L7:;
        __pyx_1 = (__pyx_v_face != 0);
        if (!__pyx_1) break;

        /* "/home/jiba/src/soya/model/tree.pyx":342 */
        ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._render_quad(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),__pyx_v_face);

        /* "/home/jiba/src/soya/model/tree.pyx":343 */
        __pyx_v_face = ((__pyx_t_5_soya_ShapeFace (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
      }
      __pyx_L8:;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":345 */
    glEnd();

    /* "/home/jiba/src/soya/model/tree.pyx":346 */
    __pyx_f_5_soya_face_option_inactivate(__pyx_v_pack->option);

    /* "/home/jiba/src/soya/model/tree.pyx":347 */
    __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":349 */
  __pyx_f_5_soya_shape_option_inactivate(__pyx_v_self->__pyx_base._option);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._TreeShape._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_instance);
}

static void __pyx_f_5_soya_10_TreeShape__raypick(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_raydata);
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/tree.pyx":353 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/model/tree.pyx":354 */
  ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_node_raypick(__pyx_v_self,__pyx_v_self->_tree,__pyx_v_raydata,__pyx_v_data,__pyx_v_parent);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static int __pyx_f_5_soya_10_TreeShape__raypick_b(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_raydata);
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/tree.pyx":358 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/model/tree.pyx":359 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_node_raypick_b(__pyx_v_self,__pyx_v_self->_tree,__pyx_v_raydata,__pyx_v_data);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_TreeShape__node_raypick(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_t_5_soya__Node (*__pyx_v_node),float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  int __pyx_v_i;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/tree.pyx":363 */
  __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_node->sphere) == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":364 */
    __pyx_1 = __pyx_v_node->nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
      ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),(__pyx_v_self->__pyx_base._faces + (__pyx_v_node->faces[__pyx_v_i])),__pyx_v_raydata,__pyx_v_data,__pyx_v_parent);
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":365 */
    __pyx_1 = __pyx_v_node->nb_children;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {
      ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_node_raypick(__pyx_v_self,(__pyx_v_node->children[__pyx_v_i]),__pyx_v_raydata,__pyx_v_data,__pyx_v_parent);
      __pyx_L5:;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._node_raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static int __pyx_f_5_soya_10_TreeShape__node_raypick_b(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_t_5_soya__Node (*__pyx_v_node),float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data) {
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/model/tree.pyx":369 */
  __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_node->sphere) == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":370 */
    __pyx_1 = __pyx_v_node->nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/tree.pyx":371 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick_b(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),(__pyx_v_self->__pyx_base._faces + (__pyx_v_node->faces[__pyx_v_i])),__pyx_v_raydata,__pyx_v_data);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L5;
      }
      __pyx_L5:;
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":372 */
    __pyx_2 = __pyx_v_node->nb_children;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/tree.pyx":373 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_node_raypick_b(__pyx_v_self,(__pyx_v_node->children[__pyx_v_i]),__pyx_v_raydata,__pyx_v_data);
      if (__pyx_1) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L8;
      }
      __pyx_L8:;
      __pyx_L6:;
    }
    __pyx_L7:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/tree.pyx":374 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeShape._node_raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_TreeShape__collect_raypickables(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere),struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);

  /* "/home/jiba/src/soya/model/tree.pyx":377 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_self)));

  /* "/home/jiba/src/soya/model/tree.pyx":378 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_parent)));

  /* "/home/jiba/src/soya/model/tree.pyx":379 */
  __pyx_1 = __pyx_f_5_soya_node_collect_raypickables(__pyx_v_self->_tree,__pyx_v_items,__pyx_v_sphere); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 379; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":380 */
  chunk_add_int(__pyx_v_items,(-1));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._TreeShape._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static void __pyx_f_5_soya_10_TreeShape__raypick_from_context(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,__pyx_t_5_soya_Chunk (*__pyx_v_items)) {
  float (*__pyx_v_raydata);
  int __pyx_v_face_index;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  __pyx_v_parent = Py_None; Py_INCREF((PyObject *) __pyx_v_parent);

  /* "/home/jiba/src/soya/model/tree.pyx":386 */
  __pyx_1 = (PyObject *)chunk_get_ptr(__pyx_v_items);
  Py_INCREF((PyObject *)__pyx_1);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_parent));
  __pyx_v_parent = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":387 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/model/tree.pyx":388 */
  __pyx_v_face_index = chunk_get_int(__pyx_v_items);

  /* "/home/jiba/src/soya/model/tree.pyx":389 */
  while (1) {
    __pyx_L2:;
    __pyx_2 = (__pyx_v_face_index != (-1));
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/model/tree.pyx":390 */
    ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),(__pyx_v_self->__pyx_base._faces + __pyx_v_face_index),__pyx_v_raydata,__pyx_v_data,__pyx_v_parent);

    /* "/home/jiba/src/soya/model/tree.pyx":391 */
    __pyx_v_face_index = chunk_get_int(__pyx_v_items);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._TreeShape._raypick_from_context");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static int __pyx_f_5_soya_10_TreeShape__raypick_from_context_b(struct __pyx_obj_5_soya__TreeShape *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,__pyx_t_5_soya_Chunk (*__pyx_v_items)) {
  float (*__pyx_v_raydata);
  int __pyx_v_face_index;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  __pyx_v_parent = Py_None; Py_INCREF((PyObject *) __pyx_v_parent);

  /* "/home/jiba/src/soya/model/tree.pyx":397 */
  __pyx_1 = (PyObject *)chunk_get_ptr(__pyx_v_items);
  Py_INCREF((PyObject *)__pyx_1);
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_parent));
  __pyx_v_parent = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":398 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/model/tree.pyx":399 */
  __pyx_v_face_index = chunk_get_int(__pyx_v_items);

  /* "/home/jiba/src/soya/model/tree.pyx":400 */
  while (1) {
    __pyx_L2:;
    __pyx_2 = (__pyx_v_face_index != (-1));
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/model/tree.pyx":401 */
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick_b(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_self),(__pyx_v_self->__pyx_base._faces + __pyx_v_face_index),__pyx_v_raydata,__pyx_v_data);
    if (__pyx_2) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":402 */
    __pyx_v_face_index = chunk_get_int(__pyx_v_items);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":403 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._TreeShape._raypick_from_context_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Sprite_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Sprite_5width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":32 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_width); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 32; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Sprite.width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Sprite_5width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Sprite_5width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 33; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":34 */
  ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_width = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Sprite.width.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Sprite_6height___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Sprite_6height___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":38 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_height); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Sprite.height.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Sprite_6height___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Sprite_6height___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 39; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":40 */
  ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_height = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Sprite.height.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Sprite_5color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Sprite_5color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":44 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 44; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 44; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 44; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 44; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 44; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Sprite.color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Sprite_5color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_7_Sprite_5color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/sprite.pyx":46 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Sprite.color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Sprite_8material___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Sprite_8material___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":50 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_material));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_material);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Sprite.material.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Sprite_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_7_Sprite_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 0, "x")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 51; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":52 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_material = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Sprite.material.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Sprite_3lit___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Sprite_3lit___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":56 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT))); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 56; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Sprite.lit.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Sprite_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Sprite_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 57; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":58 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_SPRITE_NEVER_LIT));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SPRITE_NEVER_LIT);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Sprite.lit.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Sprite___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7_Sprite___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"parent","material",0};
  __pyx_v_parent = __pyx_k80;
  __pyx_v_material = __pyx_k81;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 61; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 61; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":62 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 62; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/sprite.pyx":63 */
  __pyx_1 = ((PyObject *)__pyx_v_material);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_4 = PyObject_IsTrue(__pyx_1); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 63; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_1 = ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_1);
  }
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 63; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_material = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/sprite.pyx":64 */
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[0]) = 1.0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[1]) = 1.0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[2]) = 1.0;
  (((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_color[3]) = 1.0;

  /* "/home/jiba/src/soya/model/sprite.pyx":65 */
  ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_width = 0.5;
  ((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_height = 0.5;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Sprite.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_7_Sprite___getcstate__(struct __pyx_obj_5_soya__Sprite *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":71 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/sprite.pyx":72 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/sprite.pyx":73 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":74 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_width);

  /* "/home/jiba/src/soya/model/sprite.pyx":75 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_height);

  /* "/home/jiba/src/soya/model/sprite.pyx":76 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":77 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 77; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 77; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_material));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Sprite.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Sprite___setcstate__(struct __pyx_obj_5_soya__Sprite *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":80 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/sprite.pyx":85 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 85; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 85; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 85; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  __pyx_v_self->_material = __pyx_2;
  __pyx_2 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 2) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 85; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":86 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":87 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/sprite.pyx":88 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":89 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_width));

  /* "/home/jiba/src/soya/model/sprite.pyx":90 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_height));

  /* "/home/jiba/src/soya/model/sprite.pyx":91 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":92 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Sprite.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_n_option;

static void __pyx_f_5_soya_7_Sprite__batch(struct __pyx_obj_5_soya__Sprite *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/sprite.pyx":95 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":96 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_RECEIVE_SHADOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":97 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_option); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 97; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_e_5_soya_SPRITE_ALPHA); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 97; goto __pyx_L1;}
    __pyx_4 = PyNumber_And(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 97; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 97; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {
      if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 97; goto __pyx_L1;}
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)Py_None),(-1));
      goto __pyx_L4;
    }
    /*else*/ {
      if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 98; goto __pyx_L1;}
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,((PyObject *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)Py_None),(-1));
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  /*else*/ {
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 99; goto __pyx_L1;}
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->specials,((PyObject *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)Py_None),(-1));
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Sprite._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_7_Sprite__render(struct __pyx_obj_5_soya__Sprite *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  float (*__pyx_v_a);
  float (*__pyx_v_b);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/sprite.pyx":104 */
  __pyx_v_b = __pyx_v_self->__pyx_base.__pyx_base._parent->_render_matrix;

  /* "/home/jiba/src/soya/model/sprite.pyx":105 */
  __pyx_v_a = (&(__pyx_v_self->__pyx_base._matrix[12]));

  /* "/home/jiba/src/soya/model/sprite.pyx":106 */
  (__pyx_v_5_soya__SPRITE_MATRIX[12]) = (((((__pyx_v_a[0]) * (__pyx_v_b[0])) + ((__pyx_v_a[1]) * (__pyx_v_b[4]))) + ((__pyx_v_a[2]) * (__pyx_v_b[8]))) + (__pyx_v_b[12]));

  /* "/home/jiba/src/soya/model/sprite.pyx":107 */
  (__pyx_v_5_soya__SPRITE_MATRIX[13]) = (((((__pyx_v_a[0]) * (__pyx_v_b[1])) + ((__pyx_v_a[1]) * (__pyx_v_b[5]))) + ((__pyx_v_a[2]) * (__pyx_v_b[9]))) + (__pyx_v_b[13]));

  /* "/home/jiba/src/soya/model/sprite.pyx":108 */
  (__pyx_v_5_soya__SPRITE_MATRIX[14]) = (((((__pyx_v_a[0]) * (__pyx_v_b[2])) + ((__pyx_v_a[1]) * (__pyx_v_b[6]))) + ((__pyx_v_a[2]) * (__pyx_v_b[10]))) + (__pyx_v_b[14]));

  /* "/home/jiba/src/soya/model/sprite.pyx":109 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_self->_material);

  /* "/home/jiba/src/soya/model/sprite.pyx":110 */
  glLoadMatrixf(__pyx_v_5_soya__SPRITE_MATRIX);

  /* "/home/jiba/src/soya/model/sprite.pyx":111 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":112 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glDisable(GL_LIGHTING);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/sprite.pyx":114 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/sprite.pyx":115 */
    glNormal3f(0.0,0.0,(-1.0));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":116 */
  glColor4fv(__pyx_v_self->_color);

  /* "/home/jiba/src/soya/model/sprite.pyx":118 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":119 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":119 */
  glVertex3f((-__pyx_v_self->_width),(-__pyx_v_self->_height),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":120 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":120 */
  glVertex3f(__pyx_v_self->_width,(-__pyx_v_self->_height),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":121 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":121 */
  glVertex3f(__pyx_v_self->_width,__pyx_v_self->_height,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":122 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":122 */
  glVertex3f((-__pyx_v_self->_width),__pyx_v_self->_height,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":123 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":124 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":125 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glEnable(GL_LIGHTING);
    goto __pyx_L3;
  }
  /*else*/ {
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Sprite._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_7_Sprite__compute_alpha(struct __pyx_obj_5_soya__Sprite *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":129 */
  __pyx_1 = (__pyx_v_self->_material->_option & (__pyx_e_5_soya_MATERIAL_ALPHA | __pyx_e_5_soya_MATERIAL_MASK));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":130 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_SPRITE_ALPHA);

    /* "/home/jiba/src/soya/model/sprite.pyx":131 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":132 */
  __pyx_1 = ((__pyx_v_self->_color[3]) < 1.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":133 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_SPRITE_ALPHA);

    /* "/home/jiba/src/soya/model/sprite.pyx":134 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/sprite.pyx":135 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_SPRITE_ALPHA));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Sprite._compute_alpha");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_15_CylinderSprite___getcstate__(struct __pyx_obj_5_soya__CylinderSprite *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":143 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/sprite.pyx":144 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base.__pyx_base._option);

  /* "/home/jiba/src/soya/model/sprite.pyx":145 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base.__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":146 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._width);

  /* "/home/jiba/src/soya/model/sprite.pyx":147 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._height);

  /* "/home/jiba/src/soya/model/sprite.pyx":148 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":149 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 149; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base._material));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->__pyx_base._material));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._CylinderSprite.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_15_CylinderSprite___setcstate__(struct __pyx_obj_5_soya__CylinderSprite *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":152 */
  __pyx_v_self->__pyx_base.__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/sprite.pyx":157 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 157; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 157; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 157; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base._material));
  __pyx_v_self->__pyx_base._material = __pyx_2;
  __pyx_2 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 2) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 157; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":158 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":159 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base.__pyx_base._option));

  /* "/home/jiba/src/soya/model/sprite.pyx":160 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base.__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":161 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._width));

  /* "/home/jiba/src/soya/model/sprite.pyx":162 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._height));

  /* "/home/jiba/src/soya/model/sprite.pyx":163 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":164 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CylinderSprite.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_15_CylinderSprite__render(struct __pyx_obj_5_soya__CylinderSprite *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_f;
  float (*__pyx_v_a);
  float (*__pyx_v_m);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/sprite.pyx":170 */
  __pyx_v_m = __pyx_v_self->__pyx_base.__pyx_base.__pyx_base._parent->_render_matrix;

  /* "/home/jiba/src/soya/model/sprite.pyx":171 */
  __pyx_v_a = (&(__pyx_v_self->__pyx_base.__pyx_base._matrix[8]));

  /* "/home/jiba/src/soya/model/sprite.pyx":172 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8]) = ((((__pyx_v_a[0]) * (__pyx_v_m[0])) + ((__pyx_v_a[1]) * (__pyx_v_m[4]))) + ((__pyx_v_a[2]) * (__pyx_v_m[8])));

  /* "/home/jiba/src/soya/model/sprite.pyx":173 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9]) = ((((__pyx_v_a[0]) * (__pyx_v_m[1])) + ((__pyx_v_a[1]) * (__pyx_v_m[5]))) + ((__pyx_v_a[2]) * (__pyx_v_m[9])));

  /* "/home/jiba/src/soya/model/sprite.pyx":174 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10]) = ((((__pyx_v_a[0]) * (__pyx_v_m[2])) + ((__pyx_v_a[1]) * (__pyx_v_m[6]))) + ((__pyx_v_a[2]) * (__pyx_v_m[10])));

  /* "/home/jiba/src/soya/model/sprite.pyx":175 */
  __pyx_v_a = (&(__pyx_v_self->__pyx_base.__pyx_base._matrix[12]));

  /* "/home/jiba/src/soya/model/sprite.pyx":176 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[12]) = (((((__pyx_v_a[0]) * (__pyx_v_m[0])) + ((__pyx_v_a[1]) * (__pyx_v_m[4]))) + ((__pyx_v_a[2]) * (__pyx_v_m[8]))) + (__pyx_v_m[12]));

  /* "/home/jiba/src/soya/model/sprite.pyx":177 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[13]) = (((((__pyx_v_a[0]) * (__pyx_v_m[1])) + ((__pyx_v_a[1]) * (__pyx_v_m[5]))) + ((__pyx_v_a[2]) * (__pyx_v_m[9]))) + (__pyx_v_m[13]));

  /* "/home/jiba/src/soya/model/sprite.pyx":178 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[14]) = (((((__pyx_v_a[0]) * (__pyx_v_m[2])) + ((__pyx_v_a[1]) * (__pyx_v_m[6]))) + ((__pyx_v_a[2]) * (__pyx_v_m[10]))) + (__pyx_v_m[14]));

  /* "/home/jiba/src/soya/model/sprite.pyx":179 */
  __pyx_1 = ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10]) == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":180 */
    __pyx_v_x = (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8]);

    /* "/home/jiba/src/soya/model/sprite.pyx":181 */
    __pyx_v_y = (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9]);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/sprite.pyx":183 */
    __pyx_v_f = ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[14]) / (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10]));

    /* "/home/jiba/src/soya/model/sprite.pyx":184 */
    __pyx_v_x = ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[12]) - (__pyx_v_f * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8])));

    /* "/home/jiba/src/soya/model/sprite.pyx":185 */
    __pyx_v_y = ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[13]) - (__pyx_v_f * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9])));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":187 */
  __pyx_1 = (__pyx_v_x == 0.0);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_y == 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":188 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4]) = 0.0;

    /* "/home/jiba/src/soya/model/sprite.pyx":189 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) = 1.0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/sprite.pyx":191 */
    __pyx_v_f = ((float )(1.0 / sqrt(((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)))));

    /* "/home/jiba/src/soya/model/sprite.pyx":192 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) = ((-__pyx_v_x) * __pyx_v_f);

    /* "/home/jiba/src/soya/model/sprite.pyx":193 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4]) = (__pyx_v_y * __pyx_v_f);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/sprite.pyx":194 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[0]) = (((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10])) - ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[6]) * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9])));

  /* "/home/jiba/src/soya/model/sprite.pyx":195 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[1]) = (((-(__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4])) * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10])) + ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[6]) * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8])));

  /* "/home/jiba/src/soya/model/sprite.pyx":196 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[2]) = (((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4]) * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9])) - ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) * (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8])));

  /* "/home/jiba/src/soya/model/sprite.pyx":198 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->__pyx_base._material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_self->__pyx_base._material);

  /* "/home/jiba/src/soya/model/sprite.pyx":199 */
  glLoadMatrixf(__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX);

  /* "/home/jiba/src/soya/model/sprite.pyx":200 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":201 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glDisable(GL_LIGHTING);
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/sprite.pyx":203 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/sprite.pyx":204 */
    glNormal3f(1.0,0.0,0.0);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/sprite.pyx":205 */
  glColor4fv(__pyx_v_self->__pyx_base._color);

  /* "/home/jiba/src/soya/model/sprite.pyx":206 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":207 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":207 */
  glVertex3f(0.0,(-__pyx_v_self->__pyx_base._height),(-__pyx_v_self->__pyx_base._width));

  /* "/home/jiba/src/soya/model/sprite.pyx":208 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":208 */
  glVertex3f(0.0,__pyx_v_self->__pyx_base._height,(-__pyx_v_self->__pyx_base._width));

  /* "/home/jiba/src/soya/model/sprite.pyx":209 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":209 */
  glVertex3f(0.0,__pyx_v_self->__pyx_base._height,__pyx_v_self->__pyx_base._width);

  /* "/home/jiba/src/soya/model/sprite.pyx":210 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":210 */
  glVertex3f(0.0,(-__pyx_v_self->__pyx_base._height),__pyx_v_self->__pyx_base._width);

  /* "/home/jiba/src/soya/model/sprite.pyx":211 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":212 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":213 */
  __pyx_1 = (__pyx_v_self->__pyx_base.__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glEnable(GL_LIGHTING);
    goto __pyx_L5;
  }
  /*else*/ {
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CylinderSprite._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_f_5_soya_6_Bonus___getcstate__(struct __pyx_obj_5_soya__Bonus *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":226 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/sprite.pyx":227 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/sprite.pyx":228 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":229 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":230 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 230; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 230; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_material));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_halo));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_self->_halo));
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Bonus.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Bonus___setcstate__(struct __pyx_obj_5_soya__Bonus *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":233 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/sprite.pyx":238 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 238; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 238; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 238; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  __pyx_v_self->_material = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 238; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 238; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_halo));
  __pyx_v_self->_halo = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 3) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 238; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":239 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":240 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/sprite.pyx":241 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":242 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":243 */
  drop_chunk(__pyx_v_chunk);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Bonus.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_6_Bonus_5color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Bonus_5color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":247 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 247; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Bonus.color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Bonus_5color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_6_Bonus_5color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/sprite.pyx":249 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_x, 4) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Bonus.color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Bonus_8material___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Bonus_8material___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":253 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_material));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_material);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Bonus.material.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Bonus_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_6_Bonus_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 0, "x")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 254; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":255 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_material = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Bonus.material.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Bonus_4halo___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Bonus_4halo___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":259 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_halo));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_halo);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Bonus.halo.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Bonus_4halo___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_6_Bonus_4halo___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 0, "x")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 260; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":261 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_halo));
  ((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_halo = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Bonus.halo.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Bonus_3lit___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Bonus_3lit___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/sprite.pyx":265 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT))); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 265; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Bonus.lit.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Bonus_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Bonus_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 266; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":267 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_SPRITE_NEVER_LIT));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SPRITE_NEVER_LIT);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Bonus.lit.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Bonus___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_6_Bonus___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_halo = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"parent","material","halo",0};
  __pyx_v_parent = __pyx_k82;
  __pyx_v_material = __pyx_k83;
  __pyx_v_halo = __pyx_k84;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material, &__pyx_v_halo)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  Py_INCREF((PyObject *)__pyx_v_halo);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 270; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 270; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_halo), __pyx_ptype_5_soya__Material, 1, "halo")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 270; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":271 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 271; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 271; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 271; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/sprite.pyx":272 */
  __pyx_1 = ((PyObject *)__pyx_v_material);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_4 = PyObject_IsTrue(__pyx_1); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_1 = ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_1);
  }
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_material = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/sprite.pyx":273 */
  __pyx_2 = ((PyObject *)__pyx_v_halo);
  Py_INCREF((PyObject *)__pyx_2);
  __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 273; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;
    __pyx_2 = ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_2);
  }
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 273; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_halo));
  ((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_halo = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/sprite.pyx":274 */
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[0]) = 1.0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[1]) = 1.0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[2]) = 1.0;
  (((struct __pyx_obj_5_soya__Bonus *)__pyx_v_self)->_color[3]) = 1.0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Bonus.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF((PyObject *)__pyx_v_halo);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Bonus__batch(struct __pyx_obj_5_soya__Bonus *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/sprite.pyx":277 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":278 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_BONUS_BATCHED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":280 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_BONUS_BATCHED);

    /* "/home/jiba/src/soya/model/sprite.pyx":281 */
    __pyx_v_self->_angle = (__pyx_v_self->_angle + 4.0);

    /* "/home/jiba/src/soya/model/sprite.pyx":282 */
    __pyx_1 = (__pyx_v_self->_angle >= 360.0);
    if (__pyx_1) {
      __pyx_v_self->_angle = (__pyx_v_self->_angle - 360.0);
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/sprite.pyx":283 */
  multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base._matrix);

  /* "/home/jiba/src/soya/model/sprite.pyx":284 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/model/sprite.pyx":285 */
  ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),(-1));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Bonus._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_6_Bonus__render(struct __pyx_obj_5_soya__Bonus *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  float (*__pyx_v_m);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/sprite.pyx":289 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_BONUS_BATCHED));

  /* "/home/jiba/src/soya/model/sprite.pyx":290 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":291 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glDisable(GL_LIGHTING);
    goto __pyx_L2;
  }
  /*else*/ {
    glNormal3f(0.0,0.0,(-1.0));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":299 */
  __pyx_v_m = __pyx_v_self->__pyx_base._render_matrix;

  /* "/home/jiba/src/soya/model/sprite.pyx":300 */
  (__pyx_v_5_soya__SPRITE_MATRIX[12]) = (__pyx_v_m[12]);

  /* "/home/jiba/src/soya/model/sprite.pyx":301 */
  (__pyx_v_5_soya__SPRITE_MATRIX[13]) = ((__pyx_v_m[13]) + 1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":302 */
  (__pyx_v_5_soya__SPRITE_MATRIX[14]) = (__pyx_v_m[14]);

  /* "/home/jiba/src/soya/model/sprite.pyx":303 */
  glLoadMatrixf(__pyx_v_5_soya__SPRITE_MATRIX);

  /* "/home/jiba/src/soya/model/sprite.pyx":305 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_halo->__pyx_base.__pyx_vtab)->_activate(__pyx_v_self->_halo);

  /* "/home/jiba/src/soya/model/sprite.pyx":306 */
  glColor4fv(__pyx_v_self->_color);

  /* "/home/jiba/src/soya/model/sprite.pyx":307 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/sprite.pyx":308 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":309 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":309 */
  glVertex3f((-1.0),(-1.0),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":310 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":310 */
  glVertex3f((-1.0),1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":311 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":311 */
  glVertex3f(1.0,1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":312 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":312 */
  glVertex3f(1.0,(-1.0),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":313 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":314 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/sprite.pyx":316 */
  glRotatef(__pyx_v_self->_angle,0.0,1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":317 */
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

  /* "/home/jiba/src/soya/model/sprite.pyx":318 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_self->_material);

  /* "/home/jiba/src/soya/model/sprite.pyx":319 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":320 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":320 */
  glVertex3f((-0.5),(-0.5),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":321 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":321 */
  glVertex3f(0.5,(-0.5),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":322 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":322 */
  glVertex3f(0.5,0.5,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":323 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":323 */
  glVertex3f((-0.5),0.5,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":324 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":325 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":326 */
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);

  /* "/home/jiba/src/soya/model/sprite.pyx":327 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glEnable(GL_LIGHTING);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Bonus._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_f_5_soya__set_particle_default_material(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__set_particle_default_material(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"material",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_material)) return 0;
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 19; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":21 */
  Py_INCREF(((PyObject *)__pyx_v_material));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__PARTICLE_DEFAULT_MATERIAL));
  __pyx_v_5_soya__PARTICLE_DEFAULT_MATERIAL = ((PyObject *)__pyx_v_material);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._set_particle_default_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles___getcstate__(struct __pyx_obj_5_soya__Particles *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":37 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/particle.pyx":38 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/particle.pyx":39 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/particle.pyx":40 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_particles);

  /* "/home/jiba/src/soya/model/particle.pyx":41 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_max_particles);

  /* "/home/jiba/src/soya/model/particle.pyx":42 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_particle_size);

  /* "/home/jiba/src/soya/model/particle.pyx":43 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_colors);

  /* "/home/jiba/src/soya/model/particle.pyx":44 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_sizes);

  /* "/home/jiba/src/soya/model/particle.pyx":45 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_max_particles_per_round);

  /* "/home/jiba/src/soya/model/particle.pyx":46 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_particles,(__pyx_v_self->_nb_particles * __pyx_v_self->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":47 */
  __pyx_1 = __pyx_v_self->_nb_colors;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":48 */
    chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_fading_colors,(4 * __pyx_v_self->_nb_colors));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":49 */
  __pyx_1 = __pyx_v_self->_nb_sizes;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":50 */
    chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sizes,(2 * __pyx_v_self->_nb_sizes));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":52 */
  __pyx_2 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 52; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 52; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject *)__pyx_v_self->_material));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_particle_coordsyst));
  PyTuple_SET_ITEM(__pyx_3, 2, ((PyObject *)__pyx_v_self->_particle_coordsyst));
  __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Particles.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_Particles___setcstate__(struct __pyx_obj_5_soya__Particles *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_cstate2;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_cstate2 = Py_None; Py_INCREF(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/particle.pyx":56 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF(__pyx_v_cstate2);
  __pyx_v_cstate2 = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 56; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  __pyx_v_self->_material = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 56; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_particle_coordsyst));
  __pyx_v_self->_particle_coordsyst = __pyx_3;
  __pyx_3 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 3) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 56; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":57 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/particle.pyx":58 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/particle.pyx":59 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/particle.pyx":60 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_particles));

  /* "/home/jiba/src/soya/model/particle.pyx":61 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_max_particles));

  /* "/home/jiba/src/soya/model/particle.pyx":62 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":63 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/particle.pyx":64 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_sizes));

  /* "/home/jiba/src/soya/model/particle.pyx":65 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_max_particles_per_round));

  /* "/home/jiba/src/soya/model/particle.pyx":67 */
  __pyx_v_self->_particles = ((float (*))malloc(((__pyx_v_self->_nb_max_particles * __pyx_v_self->_particle_size) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/particle.pyx":68 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_particles,(__pyx_v_self->_nb_particles * __pyx_v_self->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":69 */
  __pyx_4 = __pyx_v_self->_nb_colors;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/particle.pyx":70 */
    __pyx_v_self->_fading_colors = ((float (*))malloc(((4 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":71 */
    chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_fading_colors,(4 * __pyx_v_self->_nb_colors));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":72 */
  __pyx_4 = __pyx_v_self->_nb_sizes;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/particle.pyx":73 */
    __pyx_v_self->_sizes = ((float (*))malloc(((2 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":74 */
    chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sizes,(2 * __pyx_v_self->_nb_sizes));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":76 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/particle.pyx":77 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Particles.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_cstate2);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_10_Particles_8material___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_8material___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":81 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_material));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_material);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.material.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_8material___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 0, "x")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 82; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":83 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_material = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":84 */
  ((struct __pyx_vtabstruct_5_soya__Particles *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_alpha(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.material.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_18particle_coordsyst___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_18particle_coordsyst___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":88 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_coordsyst));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_coordsyst);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.particle_coordsyst.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_18particle_coordsyst___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_18particle_coordsyst___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya_CoordSyst, 1, "x")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 89; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":90 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_coordsyst));
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_coordsyst = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.particle_coordsyst.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_12nb_particles___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_12nb_particles___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":94 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_particles); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 94; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Particles.nb_particles.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_12nb_particles___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_12nb_particles___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 95; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":96 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_particles = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.nb_particles.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_16nb_max_particles___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_16nb_max_particles___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":100 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 100; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Particles.nb_max_particles.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_16nb_max_particles___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_16nb_max_particles___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 101; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":102 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":103 */
  ((struct __pyx_vtabstruct_5_soya__Particles *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_reinit(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.nb_max_particles.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_3lit___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_3lit___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":107 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT))); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 107; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Particles.lit.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_3lit___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 108; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":109 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_SPRITE_NEVER_LIT));
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SPRITE_NEVER_LIT);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.lit.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_22auto_generate_particle___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_22auto_generate_particle___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":114 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_AUTO_GENERATE)); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 114; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Particles.auto_generate_particle.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_22auto_generate_particle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_22auto_generate_particle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 115; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":116 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":117 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PARTICLES_AUTO_GENERATE);

    /* "/home/jiba/src/soya/model/particle.pyx":118 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":120 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PARTICLES_AUTO_GENERATE));

    /* "/home/jiba/src/soya/model/particle.pyx":121 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles = 0;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.auto_generate_particle.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_REMOVABLE;

static PyObject *__pyx_f_5_soya_10_Particles_9removable___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_9removable___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":125 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 125; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_REMOVABLE); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 125; goto __pyx_L1;}
  __pyx_3 = PyNumber_And(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 125; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Particles.removable.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_9removable___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_9removable___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 126; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":127 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PARTICLES_REMOVABLE);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PARTICLES_REMOVABLE));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.removable.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_23max_particles_per_round___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_23max_particles_per_round___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":132 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Particles.max_particles_per_round.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles_23max_particles_per_round___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_10_Particles_23max_particles_per_round___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 133; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":134 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":135 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_AUTO_GENERATE);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles = __pyx_v_x;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.max_particles_per_round.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_10_Particles___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_10_Particles___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  int __pyx_v_nb_max_particles;
  int __pyx_v_removable;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"parent","material","nb_max_particles","removable",0};
  __pyx_v_parent = __pyx_k85;
  __pyx_v_material = __pyx_k86;
  __pyx_v_nb_max_particles = __pyx_k87;
  __pyx_v_removable = __pyx_k88;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOii", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material, &__pyx_v_nb_max_particles, &__pyx_v_removable)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 137; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 137; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":138 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 138; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 138; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":139 */
  __pyx_1 = ((PyObject *)__pyx_v_material);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_4 = PyObject_IsTrue(__pyx_1); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 139; goto __pyx_L1;}
  if (!__pyx_4) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_1 = ((PyObject *)__pyx_v_5_soya__PARTICLE_DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_1);
  }
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 139; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_material));
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_material = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":140 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_size = 11;

  /* "/home/jiba/src/soya/model/particle.pyx":141 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes = 1;

  /* "/home/jiba/src/soya/model/particle.pyx":142 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes = ((float (*))malloc((2 * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/particle.pyx":143 */
  (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes[0]) = 1.0;
  (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes[1]) = 1.0;

  /* "/home/jiba/src/soya/model/particle.pyx":144 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round = 1000000;

  /* "/home/jiba/src/soya/model/particle.pyx":145 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles = __pyx_v_nb_max_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":146 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles = __pyx_v_nb_max_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":147 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":148 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particles = ((float (*))malloc(((((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles * ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_size) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/particle.pyx":150 */
  __pyx_4 = (__pyx_v_removable != 0);
  if (__pyx_4) {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PARTICLES_REMOVABLE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Particles.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_Particles__reinit(struct __pyx_obj_5_soya__Particles *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":153 */
  __pyx_v_self->_particle_size = 11;

  /* "/home/jiba/src/soya/model/particle.pyx":154 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
  if (__pyx_1) {
    __pyx_v_self->_particle_size = (__pyx_v_self->_particle_size + 4);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":155 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
  if (__pyx_1) {
    __pyx_v_self->_particle_size = (__pyx_v_self->_particle_size + 2);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":156 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_CYLINDER);
  if (__pyx_1) {
    __pyx_v_self->_particle_size = (__pyx_v_self->_particle_size + 3);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/particle.pyx":157 */
  __pyx_v_self->_particles = ((float (*))realloc(__pyx_v_self->_particles,((__pyx_v_self->_nb_max_particles * __pyx_v_self->_particle_size) * (sizeof(float )))));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Particles._reinit");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_Particles___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_10_Particles___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":160 */
  free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particles);

  /* "/home/jiba/src/soya/model/particle.pyx":161 */
  free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes);

  /* "/home/jiba/src/soya/model/particle.pyx":162 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_generate;

static PyObject *__pyx_f_5_soya_10_Particles_regenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_regenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_nb_particle;
  int __pyx_v_i;
  int __pyx_v_max;
  int __pyx_v_nb;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"nb_particle",0};
  __pyx_v_nb_particle = __pyx_k89;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|i", __pyx_argnames, &__pyx_v_nb_particle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":166 */
  __pyx_1 = (__pyx_v_nb_particle == (-1));
  if (__pyx_1) {
    __pyx_v_nb_particle = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":167 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":168 */
  __pyx_v_max = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_particles + __pyx_v_nb_particle);

  /* "/home/jiba/src/soya/model/particle.pyx":169 */
  __pyx_1 = (__pyx_v_max > ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles);
  if (__pyx_1) {
    __pyx_v_max = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":170 */
  for (__pyx_v_i = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_particles; __pyx_v_i < __pyx_v_max; ++__pyx_v_i) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_generate); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 170; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 170; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 170; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 170; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_L4:;
  }
  __pyx_L5:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Particles.regenerate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":173 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_AUTO_GENERATE);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles < ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":174 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":177 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_delta_time = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_delta_time + __pyx_v_proportion);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_regenerate;
static PyObject *__pyx_n_next_round_tasks;


static void __pyx_f_5_soya_10_Particles__advance(struct __pyx_obj_5_soya__Particles *__pyx_v_self,float __pyx_v_proportion) {
  float (*__pyx_v_particle);
  float __pyx_v_decay;
  int __pyx_v_i;
  PyObject *__pyx_v_IDLER;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_IDLER = Py_None; Py_INCREF(__pyx_v_IDLER);

  /* "/home/jiba/src/soya/model/particle.pyx":183 */
  __pyx_v_decay = ((-0.05) * __pyx_v_proportion);

  /* "/home/jiba/src/soya/model/particle.pyx":184 */
  __pyx_v_particle = __pyx_v_self->_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":185 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":186 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_self->_nb_particles);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/particle.pyx":187 */
    (__pyx_v_particle[0]) = ((__pyx_v_particle[0]) + __pyx_v_decay);

    /* "/home/jiba/src/soya/model/particle.pyx":188 */
    __pyx_1 = ((__pyx_v_particle[0]) < 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/particle.pyx":190 */
      __pyx_1 = (__pyx_v_self->_nb_creatable_particles != 0);
      if (__pyx_1) {
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_generate); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 190; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 190; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 190; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
        __pyx_3 = 0;
        __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 190; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 190; goto __pyx_L1;}
        if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 190; goto __pyx_L1;}
        __pyx_1 = __pyx_1 != 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/particle.pyx":191 */
        __pyx_v_self->_nb_creatable_particles = (__pyx_v_self->_nb_creatable_particles - 1);
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/particle.pyx":193 */
        __pyx_v_self->_nb_particles = (__pyx_v_self->_nb_particles - 1);

        /* "/home/jiba/src/soya/model/particle.pyx":195 */
        memcpy((__pyx_v_self->_particles + (__pyx_v_i * __pyx_v_self->_particle_size)),(__pyx_v_self->_particles + (__pyx_v_self->_nb_particles * __pyx_v_self->_particle_size)),(__pyx_v_self->_particle_size * (sizeof(float ))));

        /* "/home/jiba/src/soya/model/particle.pyx":198 */
        goto __pyx_L2;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/particle.pyx":201 */
      (__pyx_v_particle[5]) = ((__pyx_v_particle[5]) + ((__pyx_v_particle[8]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":202 */
      (__pyx_v_particle[6]) = ((__pyx_v_particle[6]) + ((__pyx_v_particle[9]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":203 */
      (__pyx_v_particle[7]) = ((__pyx_v_particle[7]) + ((__pyx_v_particle[10]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":204 */
      (__pyx_v_particle[2]) = ((__pyx_v_particle[2]) + ((__pyx_v_particle[5]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":205 */
      (__pyx_v_particle[3]) = ((__pyx_v_particle[3]) + ((__pyx_v_particle[6]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":206 */
      (__pyx_v_particle[4]) = ((__pyx_v_particle[4]) + ((__pyx_v_particle[7]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":208 */
      __pyx_1 = (__pyx_v_self->_nb_colors > 0);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/particle.pyx":209 */
        ((struct __pyx_vtabstruct_5_soya__Particles *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_fading_color(__pyx_v_self,(__pyx_v_particle[0]),(__pyx_v_particle[1]),(__pyx_v_particle + 11));
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/particle.pyx":212 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/particle.pyx":213 */
        __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
        if (__pyx_1) {
          ((struct __pyx_vtabstruct_5_soya__Particles *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_size(__pyx_v_self,(__pyx_v_particle[0]),(__pyx_v_particle[1]),(__pyx_v_particle + 15));
          goto __pyx_L8;
        }
        /*else*/ {
          ((struct __pyx_vtabstruct_5_soya__Particles *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_size(__pyx_v_self,(__pyx_v_particle[0]),(__pyx_v_particle[1]),(__pyx_v_particle + 11));
        }
        __pyx_L8:;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/model/particle.pyx":217 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_CYLINDER);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/particle.pyx":218 */
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/particle.pyx":220 */
    __pyx_v_particle = (__pyx_v_particle + __pyx_v_self->_particle_size);

    /* "/home/jiba/src/soya/model/particle.pyx":221 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":223 */
  __pyx_1 = (__pyx_v_self->_nb_particles < __pyx_v_self->_nb_max_particles);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_nb_creatable_particles > 0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":224 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_regenerate); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 224; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_self->_nb_creatable_particles); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 224; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 224; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 224; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/particle.pyx":225 */
    __pyx_v_self->_nb_creatable_particles = 0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/particle.pyx":227 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_REMOVABLE);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_nb_particles == 0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":229 */
    __pyx_4 = PyList_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_INCREF(__pyx_n_IDLER);
    PyList_SET_ITEM(__pyx_4, 0, __pyx_n_IDLER);
    __pyx_2 = __Pyx_Import(__pyx_n_soya, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_IDLER); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 229; goto __pyx_L1;}
    Py_DECREF(__pyx_v_IDLER);
    __pyx_v_IDLER = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/particle.pyx":230 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_IDLER, __pyx_n_next_round_tasks); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 230; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 230; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_remove); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 230; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 230; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 230; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Particles._advance");
  __pyx_L0:;
  Py_DECREF(__pyx_v_IDLER);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_10_Particles_remove(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_remove(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":233 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base._parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 233; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base._parent), __pyx_n_remove); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 233; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 233; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 233; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Particles.remove");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_Particles__batch(struct __pyx_obj_5_soya__Particles *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/particle.pyx":236 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":240 */
  ((struct __pyx_vtabstruct_5_soya__Particles *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_advance(__pyx_v_self,__pyx_v_self->_delta_time);

  /* "/home/jiba/src/soya/model/particle.pyx":241 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/particle.pyx":242 */
    ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self),__pyx_v_coordsyst,(-1));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":243 */
  __pyx_v_self->_delta_time = 0.0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Particles._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_10_Particles__render(struct __pyx_obj_5_soya__Particles *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  float (*__pyx_v_particle);
  float (*__pyx_v_m);
  float (__pyx_v_posi[3]);
  float __pyx_v_w;
  float __pyx_v_h;
  int __pyx_v_i;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/particle.pyx":254 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_self->_material);

  /* "/home/jiba/src/soya/model/particle.pyx":256 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/particle.pyx":257 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_1) {
    glDisable(GL_LIGHTING);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":258 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_COLORED);
  if (__pyx_1) {
    glColor4fv(__pyx_v_self->_fading_colors);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":259 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
  if (__pyx_1) {
    __pyx_v_w = 1.0;
    __pyx_v_h = 1.0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":261 */
    __pyx_v_w = (__pyx_v_self->_sizes[0]);

    /* "/home/jiba/src/soya/model/particle.pyx":262 */
    __pyx_v_h = (__pyx_v_self->_sizes[1]);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/particle.pyx":264 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/model/particle.pyx":266 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_particle_coordsyst) == Py_None;
  if (__pyx_1) {
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Particles *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self))); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_v_m = ((struct __pyx_vtabstruct_5_soya__Particles *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_root(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self))->__pyx_base.__pyx_base._render_matrix;
    Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {
    __pyx_v_m = __pyx_v_self->_particle_coordsyst->_render_matrix;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/particle.pyx":268 */
  __pyx_v_particle = __pyx_v_self->_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":270 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/particle.pyx":271 */
  __pyx_1 = __pyx_v_self->_nb_particles;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/particle.pyx":272 */
    __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/model/particle.pyx":273 */
      glColor4fv((__pyx_v_particle + 11));

      /* "/home/jiba/src/soya/model/particle.pyx":275 */
      __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
      if (__pyx_3) {

        /* "/home/jiba/src/soya/model/particle.pyx":276 */
        __pyx_v_w = (__pyx_v_particle[15]);

        /* "/home/jiba/src/soya/model/particle.pyx":277 */
        __pyx_v_h = (__pyx_v_particle[16]);
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/model/particle.pyx":279 */
      __pyx_v_w = (__pyx_v_particle[11]);

      /* "/home/jiba/src/soya/model/particle.pyx":280 */
      __pyx_v_h = (__pyx_v_particle[12]);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/particle.pyx":282 */
    (__pyx_v_posi[0]) = (((((__pyx_v_particle[2]) * (__pyx_v_m[0])) + ((__pyx_v_particle[3]) * (__pyx_v_m[4]))) + ((__pyx_v_particle[4]) * (__pyx_v_m[8]))) + (__pyx_v_m[12]));

    /* "/home/jiba/src/soya/model/particle.pyx":283 */
    (__pyx_v_posi[1]) = (((((__pyx_v_particle[2]) * (__pyx_v_m[1])) + ((__pyx_v_particle[3]) * (__pyx_v_m[5]))) + ((__pyx_v_particle[4]) * (__pyx_v_m[9]))) + (__pyx_v_m[13]));

    /* "/home/jiba/src/soya/model/particle.pyx":284 */
    (__pyx_v_posi[2]) = (((((__pyx_v_particle[2]) * (__pyx_v_m[2])) + ((__pyx_v_particle[3]) * (__pyx_v_m[6]))) + ((__pyx_v_particle[4]) * (__pyx_v_m[10]))) + (__pyx_v_m[14]));

    /* "/home/jiba/src/soya/model/particle.pyx":285 */
    glTexCoord2f(0.0,0.0);

    /* "/home/jiba/src/soya/model/particle.pyx":285 */
    glVertex3f(((__pyx_v_posi[0]) - __pyx_v_w),((__pyx_v_posi[1]) - __pyx_v_h),(__pyx_v_posi[2]));

    /* "/home/jiba/src/soya/model/particle.pyx":286 */
    glTexCoord2f(1.0,0.0);

    /* "/home/jiba/src/soya/model/particle.pyx":286 */
    glVertex3f(((__pyx_v_posi[0]) + __pyx_v_w),((__pyx_v_posi[1]) - __pyx_v_h),(__pyx_v_posi[2]));

    /* "/home/jiba/src/soya/model/particle.pyx":287 */
    glTexCoord2f(1.0,1.0);

    /* "/home/jiba/src/soya/model/particle.pyx":287 */
    glVertex3f(((__pyx_v_posi[0]) + __pyx_v_w),((__pyx_v_posi[1]) + __pyx_v_h),(__pyx_v_posi[2]));

    /* "/home/jiba/src/soya/model/particle.pyx":288 */
    glTexCoord2f(0.0,1.0);

    /* "/home/jiba/src/soya/model/particle.pyx":288 */
    glVertex3f(((__pyx_v_posi[0]) - __pyx_v_w),((__pyx_v_posi[1]) + __pyx_v_h),(__pyx_v_posi[2]));

    /* "/home/jiba/src/soya/model/particle.pyx":289 */
    __pyx_v_particle = (__pyx_v_particle + __pyx_v_self->_particle_size);
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/particle.pyx":291 */
  glEnd();

  /* "/home/jiba/src/soya/model/particle.pyx":292 */
  __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_NEVER_LIT);
  if (__pyx_3) {
    glEnable(GL_LIGHTING);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/particle.pyx":293 */
  glEnable(GL_CULL_FACE);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Particles._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_10_Particles__compute_alpha(struct __pyx_obj_5_soya__Particles *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":297 */
  __pyx_1 = (__pyx_v_self->_material->_option & (__pyx_e_5_soya_MATERIAL_ALPHA | __pyx_e_5_soya_MATERIAL_MASK));
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SPRITE_COLORED);
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->_fading_colors[3]) < 1.0);
    }
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":298 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_SPRITE_ALPHA);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":300 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_SPRITE_ALPHA));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Particles._compute_alpha");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_Particles__get_fading_color(struct __pyx_obj_5_soya__Particles *__pyx_v_self,float __pyx_v_life,float __pyx_v_max_life,float (*__pyx_v_returned_color)) {
  int __pyx_v_i;
  float __pyx_v_f1;
  float __pyx_v_f2;
  float (*__pyx_v_c1);
  float (*__pyx_v_c2);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":306 */
  __pyx_1 = (__pyx_v_life <= 0.0);
  if (__pyx_1) {
    memcpy(__pyx_v_returned_color,(__pyx_v_self->_fading_colors + (4 * (__pyx_v_self->_nb_colors - 1))),(4 * (sizeof(float ))));
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_life >= __pyx_v_max_life);
  if (__pyx_1) {
    memcpy(__pyx_v_returned_color,__pyx_v_self->_fading_colors,(4 * (sizeof(float ))));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":309 */
    __pyx_v_life = ((1.0 - (__pyx_v_life / __pyx_v_max_life)) * (__pyx_v_self->_nb_colors - 1));

    /* "/home/jiba/src/soya/model/particle.pyx":310 */
    __pyx_v_i = ((int )__pyx_v_life);

    /* "/home/jiba/src/soya/model/particle.pyx":311 */
    __pyx_v_c1 = (__pyx_v_self->_fading_colors + (4 * __pyx_v_i));

    /* "/home/jiba/src/soya/model/particle.pyx":312 */
    __pyx_v_c2 = (__pyx_v_self->_fading_colors + (4 * (__pyx_v_i + 1)));

    /* "/home/jiba/src/soya/model/particle.pyx":313 */
    __pyx_v_f2 = (__pyx_v_life - __pyx_v_i);

    /* "/home/jiba/src/soya/model/particle.pyx":314 */
    __pyx_v_f1 = (1.0 - __pyx_v_f2);

    /* "/home/jiba/src/soya/model/particle.pyx":315 */
    (__pyx_v_returned_color[0]) = (((__pyx_v_c1[0]) * __pyx_v_f1) + ((__pyx_v_c2[0]) * __pyx_v_f2));

    /* "/home/jiba/src/soya/model/particle.pyx":316 */
    (__pyx_v_returned_color[1]) = (((__pyx_v_c1[1]) * __pyx_v_f1) + ((__pyx_v_c2[1]) * __pyx_v_f2));

    /* "/home/jiba/src/soya/model/particle.pyx":317 */
    (__pyx_v_returned_color[2]) = (((__pyx_v_c1[2]) * __pyx_v_f1) + ((__pyx_v_c2[2]) * __pyx_v_f2));

    /* "/home/jiba/src/soya/model/particle.pyx":318 */
    (__pyx_v_returned_color[3]) = (((__pyx_v_c1[3]) * __pyx_v_f1) + ((__pyx_v_c2[3]) * __pyx_v_f2));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Particles._get_fading_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_Particles__get_size(struct __pyx_obj_5_soya__Particles *__pyx_v_self,float __pyx_v_life,float __pyx_v_max_life,float (*__pyx_v_returned_size)) {
  int __pyx_v_i;
  float __pyx_v_f1;
  float __pyx_v_f2;
  float (*__pyx_v_c1);
  float (*__pyx_v_c2);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":324 */
  __pyx_1 = (__pyx_v_life <= 0.0);
  if (__pyx_1) {
    memcpy(__pyx_v_returned_size,(__pyx_v_self->_sizes + (2 * (__pyx_v_self->_nb_sizes - 1))),(2 * (sizeof(float ))));
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_life >= __pyx_v_max_life);
  if (__pyx_1) {
    memcpy(__pyx_v_returned_size,__pyx_v_self->_sizes,(2 * (sizeof(float ))));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":327 */
    __pyx_v_life = ((1.0 - (__pyx_v_life / __pyx_v_max_life)) * (__pyx_v_self->_nb_sizes - 1));

    /* "/home/jiba/src/soya/model/particle.pyx":328 */
    __pyx_v_i = ((int )__pyx_v_life);

    /* "/home/jiba/src/soya/model/particle.pyx":329 */
    __pyx_v_c1 = (__pyx_v_self->_sizes + (2 * __pyx_v_i));

    /* "/home/jiba/src/soya/model/particle.pyx":330 */
    __pyx_v_c2 = (__pyx_v_self->_sizes + (2 * (__pyx_v_i + 1)));

    /* "/home/jiba/src/soya/model/particle.pyx":331 */
    __pyx_v_f2 = (__pyx_v_life - __pyx_v_i);

    /* "/home/jiba/src/soya/model/particle.pyx":332 */
    __pyx_v_f1 = (1.0 - __pyx_v_f2);

    /* "/home/jiba/src/soya/model/particle.pyx":333 */
    (__pyx_v_returned_size[0]) = (((__pyx_v_c1[0]) * __pyx_v_f1) + ((__pyx_v_c2[0]) * __pyx_v_f2));

    /* "/home/jiba/src/soya/model/particle.pyx":334 */
    (__pyx_v_returned_size[1]) = (((__pyx_v_c1[1]) * __pyx_v_f1) + ((__pyx_v_c2[1]) * __pyx_v_f2));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Particles._get_size");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static float (*__pyx_f_5_soya_10_Particles__generate(struct __pyx_obj_5_soya__Particles *__pyx_v_self,int __pyx_v_index,float __pyx_v_life)) {
  float (*__pyx_v_particle);
  float (*__pyx_r);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":338 */
  __pyx_v_particle = (__pyx_v_self->_particles + (__pyx_v_index * __pyx_v_self->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":339 */
  (__pyx_v_particle[0]) = __pyx_v_life;
  (__pyx_v_particle[1]) = __pyx_v_life;

  /* "/home/jiba/src/soya/model/particle.pyx":340 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == Py_None;
  if (__pyx_1) {
    memcpy((__pyx_v_particle + 2),(__pyx_v_self->__pyx_base._matrix + 12),(3 * (sizeof(float ))));
    goto __pyx_L2;
  }
  /*else*/ {
    point_by_matrix_copy((__pyx_v_particle + 2),(__pyx_v_self->__pyx_base._matrix + 12),((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base._parent->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_self->__pyx_base.__pyx_base._parent));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":342 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_particle_coordsyst) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    point_by_matrix((__pyx_v_particle + 2),((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->_particle_coordsyst->__pyx_base.__pyx_base.__pyx_vtab)->_inverted_root_matrix(__pyx_v_self->_particle_coordsyst));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":344 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":345 */
    memcpy((__pyx_v_particle + 11),__pyx_v_self->_fading_colors,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/particle.pyx":346 */
    __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
    if (__pyx_2) {
      memcpy((__pyx_v_particle + 15),__pyx_v_self->_sizes,(2 * (sizeof(float ))));
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
  if (__pyx_1) {
    memcpy((__pyx_v_particle + 11),__pyx_v_self->_sizes,(2 * (sizeof(float ))));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/particle.pyx":349 */
  __pyx_2 = (__pyx_v_self->_nb_particles <= __pyx_v_index);
  if (__pyx_2) {
    __pyx_v_self->_nb_particles = (__pyx_v_index + 1);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/particle.pyx":350 */
  __pyx_r = (__pyx_v_self->_particles + (__pyx_v_self->_particle_size * __pyx_v_index));
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Particles._generate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"i",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_i)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":353 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.generate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_set_particle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_set_particle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_life;
  float __pyx_v_speed_x;
  float __pyx_v_speed_y;
  float __pyx_v_speed_z;
  float __pyx_v_accel_x;
  float __pyx_v_accel_y;
  float __pyx_v_accel_z;
  float __pyx_v_dir_x;
  float __pyx_v_dir_y;
  float __pyx_v_dir_z;
  int __pyx_v_i;
  float (*__pyx_v_particle);
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"index","life","speed_x","speed_y","speed_z","accel_x","accel_y","accel_z","dir_x","dir_y","dir_z",0};
  __pyx_v_dir_x = __pyx_k90;
  __pyx_v_dir_y = __pyx_k91;
  __pyx_v_dir_z = __pyx_k92;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ifffffff|fff", __pyx_argnames, &__pyx_v_index, &__pyx_v_life, &__pyx_v_speed_x, &__pyx_v_speed_y, &__pyx_v_speed_z, &__pyx_v_accel_x, &__pyx_v_accel_y, &__pyx_v_accel_z, &__pyx_v_dir_x, &__pyx_v_dir_y, &__pyx_v_dir_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":359 */
  __pyx_v_particle = ((struct __pyx_vtabstruct_5_soya__Particles *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_generate(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self),__pyx_v_index,__pyx_v_life);

  /* "/home/jiba/src/soya/model/particle.pyx":360 */
  (__pyx_v_particle[5]) = __pyx_v_speed_x;

  /* "/home/jiba/src/soya/model/particle.pyx":361 */
  (__pyx_v_particle[6]) = __pyx_v_speed_y;

  /* "/home/jiba/src/soya/model/particle.pyx":362 */
  (__pyx_v_particle[7]) = __pyx_v_speed_z;

  /* "/home/jiba/src/soya/model/particle.pyx":363 */
  (__pyx_v_particle[8]) = __pyx_v_accel_x;

  /* "/home/jiba/src/soya/model/particle.pyx":364 */
  (__pyx_v_particle[9]) = __pyx_v_accel_y;

  /* "/home/jiba/src/soya/model/particle.pyx":365 */
  (__pyx_v_particle[10]) = __pyx_v_accel_z;

  /* "/home/jiba/src/soya/model/particle.pyx":366 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_CYLINDER);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":367 */
    __pyx_v_i = 11;

    /* "/home/jiba/src/soya/model/particle.pyx":368 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
    if (__pyx_1) {
      __pyx_v_i = (__pyx_v_i + 4);
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/particle.pyx":369 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
    if (__pyx_1) {
      __pyx_v_i = (__pyx_v_i + 2);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/particle.pyx":370 */
    (__pyx_v_particle[__pyx_v_i]) = __pyx_v_dir_x;

    /* "/home/jiba/src/soya/model/particle.pyx":371 */
    (__pyx_v_particle[(__pyx_v_i + 1)]) = __pyx_v_dir_y;

    /* "/home/jiba/src/soya/model/particle.pyx":372 */
    (__pyx_v_particle[(__pyx_v_i + 2)]) = __pyx_v_dir_z;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.set_particle");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_set_particle2(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_set_particle2(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_life;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float __pyx_v_speed_x;
  float __pyx_v_speed_y;
  float __pyx_v_speed_z;
  float __pyx_v_accel_x;
  float __pyx_v_accel_y;
  float __pyx_v_accel_z;
  float __pyx_v_dir_x;
  float __pyx_v_dir_y;
  float __pyx_v_dir_z;
  int __pyx_v_i;
  float (*__pyx_v_particle);
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"index","life","x","y","z","speed_x","speed_y","speed_z","accel_x","accel_y","accel_z","dir_x","dir_y","dir_z",0};
  __pyx_v_dir_x = __pyx_k93;
  __pyx_v_dir_y = __pyx_k94;
  __pyx_v_dir_z = __pyx_k95;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iffffffffff|fff", __pyx_argnames, &__pyx_v_index, &__pyx_v_life, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_speed_x, &__pyx_v_speed_y, &__pyx_v_speed_z, &__pyx_v_accel_x, &__pyx_v_accel_y, &__pyx_v_accel_z, &__pyx_v_dir_x, &__pyx_v_dir_y, &__pyx_v_dir_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":378 */
  __pyx_v_particle = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particles + (__pyx_v_index * ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":379 */
  (__pyx_v_particle[0]) = __pyx_v_life;

  /* "/home/jiba/src/soya/model/particle.pyx":380 */
  (__pyx_v_particle[1]) = (__pyx_v_particle[0]);

  /* "/home/jiba/src/soya/model/particle.pyx":381 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":382 */
    memcpy((__pyx_v_particle + 11),((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/particle.pyx":383 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
    if (__pyx_1) {
      memcpy((__pyx_v_particle + 15),((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes,(2 * (sizeof(float ))));
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":384 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
  if (__pyx_1) {
    memcpy((__pyx_v_particle + 11),((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes,(2 * (sizeof(float ))));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/particle.pyx":385 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_particles <= __pyx_v_index);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_particles = (__pyx_v_index + 1);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/particle.pyx":387 */
  (__pyx_v_particle[2]) = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":388 */
  (__pyx_v_particle[3]) = __pyx_v_y;

  /* "/home/jiba/src/soya/model/particle.pyx":389 */
  (__pyx_v_particle[4]) = __pyx_v_z;

  /* "/home/jiba/src/soya/model/particle.pyx":390 */
  (__pyx_v_particle[5]) = __pyx_v_speed_x;

  /* "/home/jiba/src/soya/model/particle.pyx":391 */
  (__pyx_v_particle[6]) = __pyx_v_speed_y;

  /* "/home/jiba/src/soya/model/particle.pyx":392 */
  (__pyx_v_particle[7]) = __pyx_v_speed_z;

  /* "/home/jiba/src/soya/model/particle.pyx":393 */
  (__pyx_v_particle[8]) = __pyx_v_accel_x;

  /* "/home/jiba/src/soya/model/particle.pyx":394 */
  (__pyx_v_particle[9]) = __pyx_v_accel_y;

  /* "/home/jiba/src/soya/model/particle.pyx":395 */
  (__pyx_v_particle[10]) = __pyx_v_accel_z;

  /* "/home/jiba/src/soya/model/particle.pyx":396 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_CYLINDER);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":397 */
    __pyx_v_i = 11;

    /* "/home/jiba/src/soya/model/particle.pyx":398 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
    if (__pyx_1) {
      __pyx_v_i = (__pyx_v_i + 4);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/particle.pyx":399 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
    if (__pyx_1) {
      __pyx_v_i = (__pyx_v_i + 2);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/particle.pyx":400 */
    (__pyx_v_particle[__pyx_v_i]) = __pyx_v_dir_x;

    /* "/home/jiba/src/soya/model/particle.pyx":401 */
    (__pyx_v_particle[(__pyx_v_i + 1)]) = __pyx_v_dir_y;

    /* "/home/jiba/src/soya/model/particle.pyx":402 */
    (__pyx_v_particle[(__pyx_v_i + 2)]) = __pyx_v_dir_z;
    goto __pyx_L6;
  }
  __pyx_L6:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.set_particle2");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_get_particle_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_get_particle_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float (*__pyx_v_particle);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":406 */
  __pyx_v_particle = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particles + (__pyx_v_index * ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":407 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_particle[2])); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_particle[3])); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_particle[4])); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 407; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Particles.get_particle_position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_set_particle_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_set_particle_position(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float (*__pyx_v_particle);
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"index","x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ifff", __pyx_argnames, &__pyx_v_index, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":411 */
  __pyx_v_particle = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particles + (__pyx_v_index * ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":412 */
  (__pyx_v_particle[2]) = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":413 */
  (__pyx_v_particle[3]) = __pyx_v_y;

  /* "/home/jiba/src/soya/model/particle.pyx":414 */
  (__pyx_v_particle[4]) = __pyx_v_z;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Particles.set_particle_position");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_set_colors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_set_colors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_colors = 0;
  int __pyx_v_i;
  int __pyx_v_j;
  PyObject *__pyx_v_color;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_colors, 0) < 0) return 0;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_colors);
    return 0;
  }
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_color = Py_None; Py_INCREF(__pyx_v_color);

  /* "/home/jiba/src/soya/model/particle.pyx":419 */
  __pyx_1 = PyObject_Length(__pyx_v_colors); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 419; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors = __pyx_1;

  /* "/home/jiba/src/soya/model/particle.pyx":420 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":421 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors = ((float (*))realloc(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors,((((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors * 4) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":422 */
    __pyx_1 = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/particle.pyx":423 */
      __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 423; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_colors, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 423; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_color);
      __pyx_v_color = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/particle.pyx":424 */
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 424; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 424; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 424; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors[(__pyx_v_i * 4)]) = __pyx_4;

      /* "/home/jiba/src/soya/model/particle.pyx":425 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 425; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 425; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 425; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors[((__pyx_v_i * 4) + 1)]) = __pyx_4;

      /* "/home/jiba/src/soya/model/particle.pyx":426 */
      __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 426; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 426; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 426; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors[((__pyx_v_i * 4) + 2)]) = __pyx_4;

      /* "/home/jiba/src/soya/model/particle.pyx":427 */
      __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 427; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 427; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 427; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors[((__pyx_v_i * 4) + 3)]) = __pyx_4;
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/particle.pyx":428 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SPRITE_COLORED);

    /* "/home/jiba/src/soya/model/particle.pyx":429 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors == 1);
    if (__pyx_1) {
      ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PARTICLES_MULTI_COLOR));
      goto __pyx_L5;
    }
    /*else*/ {
      ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PARTICLES_MULTI_COLOR);
    }
    __pyx_L5:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":432 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors != 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/particle.pyx":433 */
      free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors);

      /* "/home/jiba/src/soya/model/particle.pyx":434 */
      ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/particle.pyx":435 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & ((~__pyx_e_5_soya_SPRITE_COLORED) | (~__pyx_e_5_soya_PARTICLES_MULTI_COLOR)));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":436 */
  ((struct __pyx_vtabstruct_5_soya__Particles *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_alpha(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/particle.pyx":437 */
  ((struct __pyx_vtabstruct_5_soya__Particles *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_reinit(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Particles.set_colors");
  __pyx_r = 0;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_colors);
  Py_DECREF(__pyx_v_color);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_10_Particles_set_sizes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_10_Particles_set_sizes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sizes = 0;
  int __pyx_v_i;
  PyObject *__pyx_v_size;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_sizes, 0) < 0) return 0;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_sizes);
    return 0;
  }
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_size = Py_None; Py_INCREF(__pyx_v_size);

  /* "/home/jiba/src/soya/model/particle.pyx":441 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_sizes); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 441; goto __pyx_L1;}
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":442 */
    __pyx_1 = PyObject_Length(__pyx_v_sizes); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 442; goto __pyx_L1;}
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes = __pyx_1;

    /* "/home/jiba/src/soya/model/particle.pyx":443 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes = ((float (*))realloc(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes,((((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes * 2) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":444 */
    __pyx_1 = ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/particle.pyx":445 */
      __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 445; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_sizes, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 445; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_v_size);
      __pyx_v_size = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/particle.pyx":446 */
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 446; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 446; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 446; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes[(__pyx_v_i * 2)]) = __pyx_4;

      /* "/home/jiba/src/soya/model/particle.pyx":447 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 447; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 447; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 447; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes[((__pyx_v_i * 2) + 1)]) = __pyx_4;
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/particle.pyx":448 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes == 1);
    if (__pyx_1) {
      ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PARTICLES_MULTI_SIZE));
      goto __pyx_L5;
    }
    /*else*/ {
      ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_PARTICLES_MULTI_SIZE);
    }
    __pyx_L5:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/particle.pyx":451 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes = 1;

    /* "/home/jiba/src/soya/model/particle.pyx":452 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes = ((float (*))realloc(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes,(2 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":453 */
    (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes[0]) = 1.0;
    (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes[1]) = 1.0;

    /* "/home/jiba/src/soya/model/particle.pyx":454 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_PARTICLES_MULTI_SIZE));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":455 */
  ((struct __pyx_vtabstruct_5_soya__Particles *)((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_reinit(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Particles.set_sizes");
  __pyx_r = 0;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_sizes);
  Py_DECREF(__pyx_v_size);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_n_set_colors;
static PyObject *__pyx_n_set_sizes;

static int __pyx_f_5_soya_8Fountain___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_8Fountain___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  int __pyx_v_nb_particles;
  int __pyx_v_removable;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"parent","material","nb_particles","removable",0};
  __pyx_v_parent = __pyx_k97;
  __pyx_v_material = __pyx_k98;
  __pyx_v_nb_particles = __pyx_k99;
  __pyx_v_removable = __pyx_k100;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOii", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material, &__pyx_v_nb_particles, &__pyx_v_removable)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 471; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 471; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":472 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 472; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 472; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 472; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 472; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_v_parent));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 2, ((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 3, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 4, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 472; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":475 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.3); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_7, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_7, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.3); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_8, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_8, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_8, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_8, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_9, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_9, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_9, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_9, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyTuple_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_6);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_7);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_8);
  PyTuple_SET_ITEM(__pyx_1, 3, __pyx_9);
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 475; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":476 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.25); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.25); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_8 = PyFloat_FromDouble(1.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(1.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_8);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_9);
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3);
  __pyx_7 = 0;
  __pyx_3 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 476; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.Fountain.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_n_set_particle;

static PyObject *__pyx_f_5_soya_8Fountain_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8Fountain_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_sx;
  float __pyx_v_sy;
  float __pyx_v_sz;
  float __pyx_v_l;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":480 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 480; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":481 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  __pyx_1 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 481; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":482 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":483 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_5 = PyNumber_Add(__pyx_2, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_2 = PyFloat_FromDouble(sqrt((((__pyx_v_sx * __pyx_v_sx) + (__pyx_v_sy * __pyx_v_sy)) + (__pyx_v_sz * __pyx_v_sz)))); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = PyFloat_FromDouble(0.4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_Fountain *)__pyx_v_self)->__pyx_base.__pyx_base._matrix[16])); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_2 = PyNumber_Multiply(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":484 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_index); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyNumber_Add(__pyx_5, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_1 = PyFloat_FromDouble((__pyx_v_sx * __pyx_v_l)); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(0.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble(0.0); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_11 = PyTuple_New(8); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_11, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_11, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_11, 2, __pyx_1);
  PyTuple_SET_ITEM(__pyx_11, 3, __pyx_5);
  PyTuple_SET_ITEM(__pyx_11, 4, __pyx_7);
  PyTuple_SET_ITEM(__pyx_11, 5, __pyx_8);
  PyTuple_SET_ITEM(__pyx_11, 6, __pyx_9);
  PyTuple_SET_ITEM(__pyx_11, 7, __pyx_10);
  __pyx_3 = 0;
  __pyx_2 = 0;
  __pyx_1 = 0;
  __pyx_5 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_6, __pyx_11); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_11); __pyx_11 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  __Pyx_AddTraceback("_soya.Fountain.generate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5Smoke___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_5Smoke___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  int __pyx_v_nb_particles;
  int __pyx_v_removable;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"parent","material","nb_particles","removable",0};
  __pyx_v_parent = __pyx_k101;
  __pyx_v_material = __pyx_k102;
  __pyx_v_nb_particles = __pyx_k103;
  __pyx_v_removable = __pyx_k104;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOii", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material, &__pyx_v_nb_particles, &__pyx_v_removable)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 487; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 487; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":488 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 488; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 488; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 488; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 488; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_v_parent));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 2, ((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 3, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 4, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 488; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":491 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.3); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_7, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_7, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.3); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_8, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_8, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_8, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_8, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_9, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_9, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_9, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_9, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyTuple_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_6);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_7);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_8);
  PyTuple_SET_ITEM(__pyx_1, 3, __pyx_9);
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 491; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":492 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.25); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.25); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_8 = PyFloat_FromDouble(1.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(1.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_8);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_9);
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3);
  __pyx_7 = 0;
  __pyx_3 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 492; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.Smoke.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5Smoke_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5Smoke_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_sx;
  float __pyx_v_sy;
  float __pyx_v_sz;
  float __pyx_v_l;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":496 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 496; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":497 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 497; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":498 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":499 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_5 = PyNumber_Add(__pyx_2, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_2 = PyFloat_FromDouble(sqrt((((__pyx_v_sx * __pyx_v_sx) + (__pyx_v_sy * __pyx_v_sy)) + (__pyx_v_sz * __pyx_v_sz)))); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = PyFloat_FromDouble(0.4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_Smoke *)__pyx_v_self)->__pyx_base.__pyx_base._matrix[16])); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_2 = PyNumber_Multiply(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":500 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_index); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyNumber_Add(__pyx_5, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_1 = PyFloat_FromDouble((__pyx_v_sx * __pyx_v_l)); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(0.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble(0.0); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_11 = PyTuple_New(8); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_11, 0, __pyx_3);
  PyTuple_SET_ITEM(__pyx_11, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_11, 2, __pyx_1);
  PyTuple_SET_ITEM(__pyx_11, 3, __pyx_5);
  PyTuple_SET_ITEM(__pyx_11, 4, __pyx_7);
  PyTuple_SET_ITEM(__pyx_11, 5, __pyx_8);
  PyTuple_SET_ITEM(__pyx_11, 6, __pyx_9);
  PyTuple_SET_ITEM(__pyx_11, 7, __pyx_10);
  __pyx_3 = 0;
  __pyx_2 = 0;
  __pyx_1 = 0;
  __pyx_5 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_6, __pyx_11); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_11); __pyx_11 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  __Pyx_AddTraceback("_soya.Smoke.generate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11FlagSubFire___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_11FlagSubFire___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  int __pyx_v_nb_particles;
  int __pyx_v_removable;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  static char *__pyx_argnames[] = {"parent","material","nb_particles","removable",0};
  __pyx_v_parent = __pyx_k105;
  __pyx_v_material = __pyx_k106;
  __pyx_v_nb_particles = __pyx_k107;
  __pyx_v_removable = __pyx_k108;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOii", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material, &__pyx_v_nb_particles, &__pyx_v_removable)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 504; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 504; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":505 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 505; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 505; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 505; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 505; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_v_parent));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 2, ((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 3, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 4, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 505; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":506 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.7); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.8); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.8); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_7, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_7, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyFloat_FromDouble(0.2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.4); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.8); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.2); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_8, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_8, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_8, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_8, 3, __pyx_5);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_6);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_7);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_8);
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":507 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.25); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.25); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_5);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_8 = PyFloat_FromDouble(1.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_8);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3);
  __pyx_8 = 0;
  __pyx_3 = 0;
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_7);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
  __pyx_7 = 0;
  __pyx_1 = 0;
  __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("_soya.FlagSubFire.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_n_set_particle2;

static PyObject *__pyx_f_5_soya_11FlagSubFire_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11FlagSubFire_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float __pyx_v_sx;
  float __pyx_v_sy;
  float __pyx_v_sz;
  float __pyx_v_l;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  PyObject *__pyx_12 = 0;
  PyObject *__pyx_13 = 0;
  PyObject *__pyx_14 = 0;
  static char *__pyx_argnames[] = {"index","x","y","z",0};
  __pyx_v_x = __pyx_k109;
  __pyx_v_y = __pyx_k110;
  __pyx_v_z = __pyx_k111;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i|fff", __pyx_argnames, &__pyx_v_index, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":515 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 515; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":516 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  __pyx_1 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 516; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":517 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":518 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_5 = PyNumber_Add(__pyx_2, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_2 = PyFloat_FromDouble(sqrt((((__pyx_v_sx * __pyx_v_sx) + (__pyx_v_sy * __pyx_v_sy)) + (__pyx_v_sz * __pyx_v_sz)))); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_FlagSubFire *)__pyx_v_self)->__pyx_base.__pyx_base._matrix[16])); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":519 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.5); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = PyNumber_Add(__pyx_6, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_3 = PyFloat_FromDouble(__pyx_v_x); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(__pyx_v_y); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((__pyx_v_sx * __pyx_v_l)); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble(0.0); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((-0.03)); if (!__pyx_12) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble(0.0); if (!__pyx_13) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_14 = PyTuple_New(11); if (!__pyx_14) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_14, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_14, 1, __pyx_5);
  PyTuple_SET_ITEM(__pyx_14, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_14, 3, __pyx_6);
  PyTuple_SET_ITEM(__pyx_14, 4, __pyx_7);
  PyTuple_SET_ITEM(__pyx_14, 5, __pyx_8);
  PyTuple_SET_ITEM(__pyx_14, 6, __pyx_9);
  PyTuple_SET_ITEM(__pyx_14, 7, __pyx_10);
  PyTuple_SET_ITEM(__pyx_14, 8, __pyx_11);
  PyTuple_SET_ITEM(__pyx_14, 9, __pyx_12);
  PyTuple_SET_ITEM(__pyx_14, 10, __pyx_13);
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_3 = 0;
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_11 = 0;
  __pyx_12 = 0;
  __pyx_13 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_14); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_14); __pyx_14 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  Py_XDECREF(__pyx_12);
  Py_XDECREF(__pyx_13);
  Py_XDECREF(__pyx_14);
  __Pyx_AddTraceback("_soya.FlagSubFire.generate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_nb_particles;


static int __pyx_f_5_soya_12FlagFirework___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_12FlagFirework___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  int __pyx_v_nb_particles;
  int __pyx_v_removable;
  PyObject *__pyx_v_subgenerator = 0;
  int __pyx_v_nb_sub_particles;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"parent","material","nb_particles","removable","subgenerator","nb_sub_particles",0};
  __pyx_v_parent = __pyx_k112;
  __pyx_v_material = __pyx_k113;
  __pyx_v_nb_particles = __pyx_k114;
  __pyx_v_removable = __pyx_k115;
  __pyx_v_subgenerator = __pyx_k116;
  __pyx_v_nb_sub_particles = __pyx_k117;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOiiOi", __pyx_argnames, &__pyx_v_parent, &__pyx_v_material, &__pyx_v_nb_particles, &__pyx_v_removable, &__pyx_v_subgenerator, &__pyx_v_nb_sub_particles)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_material);
  Py_INCREF(__pyx_v_subgenerator);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 531; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 531; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":532 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 532; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 532; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 532; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 532; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject *)__pyx_v_parent));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 2, ((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_4, 3, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 4, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 532; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":533 */
  __pyx_3 = __pyx_v_subgenerator;
  Py_INCREF(__pyx_3);
  __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
  if (!__pyx_5) {
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_parent));
    __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((__pyx_v_nb_particles * __pyx_v_nb_sub_particles)); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
    if (PyDict_SetItem(__pyx_4, __pyx_n_nb_particles, __pyx_2) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_3 = PyEval_CallObjectWithKeywords(((PyObject*)__pyx_ptype_5_soya_FlagSubFire), __pyx_1, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Particles)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_subgenerator));
  ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_subgenerator = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":534 */
  ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_nb_sub_particles = __pyx_v_nb_sub_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":535 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.9); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.7); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_7, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_7, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_3 = 0;
  __pyx_6 = 0;
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_8, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_8, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_8, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_8, 3, __pyx_6);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_3 = 0;
  __pyx_6 = 0;
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_9, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_9, 1, __pyx_4);
  PyTuple_SET_ITEM(__pyx_9, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_9, 3, __pyx_6);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_3 = 0;
  __pyx_6 = 0;
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_8);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_9);
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":536 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.0); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(0.0); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(2); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_8, 0, __pyx_6);
  PyTuple_SET_ITEM(__pyx_8, 1, __pyx_7);
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_9 = PyFloat_FromDouble(0.25); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.25); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_9);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2);
  __pyx_9 = 0;
  __pyx_2 = 0;
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_8);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
  __pyx_8 = 0;
  __pyx_1 = 0;
  __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 536; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":537 */
  ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->__pyx_base.__pyx_base._option = (((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->__pyx_base.__pyx_base._option | __pyx_e_5_soya_PARTICLES_AUTO_GENERATE);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.FlagFirework.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF(__pyx_v_subgenerator);
  return __pyx_r;
}

static PyObject *__pyx_n_removable;

static PyObject *__pyx_f_5_soya_12FlagFirework_remove(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12FlagFirework_remove(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":540 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n_remove); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 540; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 540; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 540; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":541 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 541; goto __pyx_L1;}
  if (PyObject_SetAttr(((PyObject *)((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_subgenerator), __pyx_n_removable, __pyx_1) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 541; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.FlagFirework.remove");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_mygenerate;

static PyObject *__pyx_f_5_soya_12FlagFirework_regenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12FlagFirework_regenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_nb_particle;
  int __pyx_v_i;
  int __pyx_v_nb;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"nb_particle",0};
  __pyx_v_nb_particle = __pyx_k118;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|i", __pyx_argnames, &__pyx_v_nb_particle)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":545 */
  __pyx_1 = (__pyx_v_nb_particle == (-1));
  if (__pyx_1) {
    __pyx_v_nb_particle = ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->__pyx_base._max_particles_per_round;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/particle.pyx":546 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":547 */
  __pyx_v_i = ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->__pyx_base._nb_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":548 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = (__pyx_v_i < ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->__pyx_base._nb_max_particles);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/particle.pyx":549 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_mygenerate); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 549; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 549; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 549; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 549; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/particle.pyx":550 */
    __pyx_v_i = (__pyx_v_nb + 1);

    /* "/home/jiba/src/soya/model/particle.pyx":551 */
    __pyx_v_nb = (__pyx_v_i + 1);

    /* "/home/jiba/src/soya/model/particle.pyx":552 */
    __pyx_1 = (__pyx_v_nb >= __pyx_v_nb_particle);
    if (__pyx_1) {
      goto __pyx_L4;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L4:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.FlagFirework.regenerate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_nb_max_particles;
static PyObject *__pyx_n_get_particle_position;

static PyObject *__pyx_f_5_soya_12FlagFirework_subgenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12FlagFirework_subgenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  int __pyx_v_i;
  struct __pyx_obj_5_soya__Particles *__pyx_v_subg;
  PyObject *__pyx_v_p;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_subg = Py_None; Py_INCREF((PyObject *) __pyx_v_subg);
  __pyx_v_p = Py_None; Py_INCREF(__pyx_v_p);

  /* "/home/jiba/src/soya/model/particle.pyx":558 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_subgenerator));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_subg));
  __pyx_v_subg = ((PyObject *)((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_subgenerator);

  /* "/home/jiba/src/soya/model/particle.pyx":559 */
  __pyx_1 = ((PyObject *)__pyx_v_subg) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/particle.pyx":560 */
    __pyx_1 = ((__pyx_v_subg->_nb_particles + ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_nb_sub_particles) > __pyx_v_subg->_nb_max_particles);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/particle.pyx":564 */
      __pyx_3 = PyInt_FromLong((__pyx_v_subg->_nb_particles + ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_nb_sub_particles)); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 564; goto __pyx_L1;}
      if (PyObject_SetAttr(((PyObject *)__pyx_v_subg), __pyx_n_nb_max_particles, __pyx_3) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 564; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/particle.pyx":565 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_particle_position); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 565; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_index); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 565; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 565; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 565; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_v_p);
    __pyx_v_p = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/particle.pyx":567 */
    __pyx_2 = (__pyx_v_subg->_nb_particles + ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_nb_sub_particles);
    for (__pyx_v_i = __pyx_v_subg->_nb_particles; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/particle.pyx":568 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_subg), __pyx_n_generate); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(__pyx_v_i); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      __pyx_6 = PyObject_GetItem(__pyx_v_p, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      __pyx_7 = PyObject_GetItem(__pyx_v_p, __pyx_4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      __pyx_8 = PyObject_GetItem(__pyx_v_p, __pyx_4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_4 = PyTuple_New(4); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_6);
      PyTuple_SET_ITEM(__pyx_4, 2, __pyx_7);
      PyTuple_SET_ITEM(__pyx_4, 3, __pyx_8);
      __pyx_5 = 0;
      __pyx_6 = 0;
      __pyx_7 = 0;
      __pyx_8 = 0;
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 568; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_L4:;
    }
    __pyx_L5:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("_soya.FlagFirework.subgenerate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_subg);
  Py_DECREF(__pyx_v_p);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12FlagFirework_mygenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12FlagFirework_mygenerate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  float __pyx_v_sx;
  float __pyx_v_sy;
  float __pyx_v_sz;
  float __pyx_v_l;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  PyObject *__pyx_11 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":573 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 573; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":574 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  __pyx_1 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 574; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":575 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":576 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.8); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_5 = PyNumber_Add(__pyx_2, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_1 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_2 = PyFloat_FromDouble(sqrt((((__pyx_v_sx * __pyx_v_sx) + (__pyx_v_sy * __pyx_v_sy)) + (__pyx_v_sz * __pyx_v_sz)))); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_6); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":577 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_index); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_6 = PyObject_GetAttr(__pyx_2, __pyx_n_random); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_6, __pyx_2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_6 = PyNumber_Add(__pyx_1, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_2 = PyFloat_FromDouble((__pyx_v_sx * __pyx_v_l)); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(0.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((-0.03)); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble(0.0); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_11 = PyTuple_New(8); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_11, 0, __pyx_5);
  PyTuple_SET_ITEM(__pyx_11, 1, __pyx_6);
  PyTuple_SET_ITEM(__pyx_11, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_11, 3, __pyx_1);
  PyTuple_SET_ITEM(__pyx_11, 4, __pyx_7);
  PyTuple_SET_ITEM(__pyx_11, 5, __pyx_8);
  PyTuple_SET_ITEM(__pyx_11, 6, __pyx_9);
  PyTuple_SET_ITEM(__pyx_11, 7, __pyx_10);
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_2 = 0;
  __pyx_1 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_10 = 0;
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_11); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_11); __pyx_11 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  Py_XDECREF(__pyx_11);
  __Pyx_AddTraceback("_soya.FlagFirework.mygenerate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_subgenerate;

static PyObject *__pyx_f_5_soya_12FlagFirework_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12FlagFirework_generate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"index",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_index)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/particle.pyx":580 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_subgenerate); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 580; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 580; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 580; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 580; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":581 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_mygenerate); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 581; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_index); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 581; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 581; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 581; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.FlagFirework.generate");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_land_tri_dealloc(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":54 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":55 */
    __pyx_f_5_soya_land_tri_dealloc(__pyx_v_tri->left_child);

    /* "/home/jiba/src/soya/model/land.pyx":56 */
    __pyx_f_5_soya_land_tri_dealloc(__pyx_v_tri->right_child);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":57 */
  free(__pyx_v_tri);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_dealloc");
  __pyx_L0:;
}

static int __pyx_f_5_soya_land_tri_has_child(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  int __pyx_r;

  /* "/home/jiba/src/soya/model/land.pyx":60 */
  __pyx_r = (__pyx_v_tri->left_child != 0);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_has_child");
  __pyx_L0:;
  return __pyx_r;
}

static int __pyx_f_5_soya_land_tri_diamond(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":63 */
  __pyx_1 = (__pyx_v_tri->base_neighbor == 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_tri->v2 == __pyx_v_tri->base_neighbor->v3);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_tri->v3 == __pyx_v_tri->base_neighbor->v2);
    }
  }
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_diamond");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_land_tri_sphere(float (*__pyx_v_r),float (*__pyx_v_p1),float (*__pyx_v_p2),float (*__pyx_v_p3)) {
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float __pyx_v_f;
  float __pyx_v_d;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":69 */
  __pyx_v_f = (1.0 / 3.0);

  /* "/home/jiba/src/soya/model/land.pyx":70 */
  (__pyx_v_r[0]) = ((((__pyx_v_p1[0]) + (__pyx_v_p2[0])) + (__pyx_v_p3[0])) * __pyx_v_f);

  /* "/home/jiba/src/soya/model/land.pyx":71 */
  (__pyx_v_r[1]) = ((((__pyx_v_p1[1]) + (__pyx_v_p2[1])) + (__pyx_v_p3[1])) * __pyx_v_f);

  /* "/home/jiba/src/soya/model/land.pyx":72 */
  (__pyx_v_r[2]) = ((((__pyx_v_p1[2]) + (__pyx_v_p2[2])) + (__pyx_v_p3[2])) * __pyx_v_f);

  /* "/home/jiba/src/soya/model/land.pyx":73 */
  __pyx_v_x = ((__pyx_v_p1[0]) - (__pyx_v_r[0]));

  /* "/home/jiba/src/soya/model/land.pyx":74 */
  __pyx_v_y = ((__pyx_v_p1[1]) - (__pyx_v_r[1]));

  /* "/home/jiba/src/soya/model/land.pyx":75 */
  __pyx_v_z = ((__pyx_v_p1[2]) - (__pyx_v_r[2]));

  /* "/home/jiba/src/soya/model/land.pyx":76 */
  __pyx_v_d = (((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) + (__pyx_v_z * __pyx_v_z));

  /* "/home/jiba/src/soya/model/land.pyx":77 */
  __pyx_v_x = ((__pyx_v_p2[0]) - (__pyx_v_r[0]));

  /* "/home/jiba/src/soya/model/land.pyx":78 */
  __pyx_v_y = ((__pyx_v_p2[1]) - (__pyx_v_r[1]));

  /* "/home/jiba/src/soya/model/land.pyx":79 */
  __pyx_v_z = ((__pyx_v_p2[2]) - (__pyx_v_r[2]));

  /* "/home/jiba/src/soya/model/land.pyx":80 */
  __pyx_v_f = (((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) + (__pyx_v_z * __pyx_v_z));

  /* "/home/jiba/src/soya/model/land.pyx":81 */
  __pyx_1 = (__pyx_v_f > __pyx_v_d);
  if (__pyx_1) {
    __pyx_v_d = __pyx_v_f;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":82 */
  __pyx_v_x = ((__pyx_v_p3[0]) - (__pyx_v_r[0]));

  /* "/home/jiba/src/soya/model/land.pyx":83 */
  __pyx_v_y = ((__pyx_v_p3[1]) - (__pyx_v_r[1]));

  /* "/home/jiba/src/soya/model/land.pyx":84 */
  __pyx_v_z = ((__pyx_v_p3[2]) - (__pyx_v_r[2]));

  /* "/home/jiba/src/soya/model/land.pyx":85 */
  __pyx_v_f = (((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) + (__pyx_v_z * __pyx_v_z));

  /* "/home/jiba/src/soya/model/land.pyx":86 */
  __pyx_1 = (__pyx_v_f > __pyx_v_d);
  if (__pyx_1) {
    __pyx_v_d = __pyx_v_f;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":87 */
  (__pyx_v_r[3]) = sqrt(__pyx_v_d);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_sphere");
  __pyx_L0:;
}

static struct __pyx_t_5_soya__LandTri (*__pyx_f_5_soya_land_get_tri(void)) {
  struct __pyx_t_5_soya__LandTri (*__pyx_r);

  /* "/home/jiba/src/soya/model/land.pyx":92 */
  __pyx_r = ((struct __pyx_t_5_soya__LandTri (*))malloc((sizeof(struct __pyx_t_5_soya__LandTri ))));
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_get_tri");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_land_tri_drop(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {

  /* "/home/jiba/src/soya/model/land.pyx":96 */
  free(__pyx_v_tri);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_drop");
  __pyx_L0:;
}

static struct __pyx_t_5_soya__LandTri (*__pyx_f_5_soya_land_create_tri(__pyx_t_5_soya_LandVertex (*__pyx_v_v1),__pyx_t_5_soya_LandVertex (*__pyx_v_v2),__pyx_t_5_soya_LandVertex (*__pyx_v_v3),struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch))) {
  struct __pyx_t_5_soya__LandTri (*__pyx_v_tri);
  struct __pyx_t_5_soya__LandTri (*__pyx_r);

  /* "/home/jiba/src/soya/model/land.pyx":100 */
  __pyx_v_tri = __pyx_f_5_soya_land_get_tri();

  /* "/home/jiba/src/soya/model/land.pyx":101 */
  __pyx_v_tri->v1 = __pyx_v_v1;

  /* "/home/jiba/src/soya/model/land.pyx":102 */
  __pyx_v_tri->v2 = __pyx_v_v2;

  /* "/home/jiba/src/soya/model/land.pyx":103 */
  __pyx_v_tri->v3 = __pyx_v_v3;

  /* "/home/jiba/src/soya/model/land.pyx":104 */
  __pyx_v_tri->patch = __pyx_v_patch;

  /* "/home/jiba/src/soya/model/land.pyx":105 */
  __pyx_v_tri->level = 0;

  /* "/home/jiba/src/soya/model/land.pyx":106 */
  __pyx_v_tri->parent = 0;

  /* "/home/jiba/src/soya/model/land.pyx":107 */
  __pyx_v_tri->left_child = 0;

  /* "/home/jiba/src/soya/model/land.pyx":108 */
  __pyx_v_tri->right_child = 0;

  /* "/home/jiba/src/soya/model/land.pyx":109 */
  __pyx_v_tri->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/land.pyx":110 */
  __pyx_f_5_soya_land_tri_sphere(__pyx_v_tri->sphere,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/land.pyx":111 */
  face_normal(__pyx_v_tri->normal,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/land.pyx":112 */
  vector_normalize(__pyx_v_tri->normal);

  /* "/home/jiba/src/soya/model/land.pyx":113 */
  __pyx_r = __pyx_v_tri;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_create_tri");
  __pyx_L0:;
  return __pyx_r;
}

static struct __pyx_t_5_soya__LandTri (*__pyx_f_5_soya_land_create_child_tri(__pyx_t_5_soya_LandVertex (*__pyx_v_v1),__pyx_t_5_soya_LandVertex (*__pyx_v_v2),__pyx_t_5_soya_LandVertex (*__pyx_v_v3),struct __pyx_t_5_soya__LandTri (*__pyx_v_parent))) {
  struct __pyx_t_5_soya__LandTri (*__pyx_v_tri);
  struct __pyx_t_5_soya__LandTri (*__pyx_r);

  /* "/home/jiba/src/soya/model/land.pyx":117 */
  __pyx_v_tri = __pyx_f_5_soya_land_get_tri();

  /* "/home/jiba/src/soya/model/land.pyx":118 */
  __pyx_v_tri->v1 = __pyx_v_v1;

  /* "/home/jiba/src/soya/model/land.pyx":119 */
  __pyx_v_tri->v2 = __pyx_v_v2;

  /* "/home/jiba/src/soya/model/land.pyx":120 */
  __pyx_v_tri->v3 = __pyx_v_v3;

  /* "/home/jiba/src/soya/model/land.pyx":121 */
  __pyx_v_tri->parent = __pyx_v_parent;

  /* "/home/jiba/src/soya/model/land.pyx":122 */
  __pyx_v_tri->level = (__pyx_v_parent->level + 1);

  /* "/home/jiba/src/soya/model/land.pyx":123 */
  __pyx_v_tri->patch = __pyx_v_parent->patch;

  /* "/home/jiba/src/soya/model/land.pyx":124 */
  __pyx_v_tri->left_child = 0;

  /* "/home/jiba/src/soya/model/land.pyx":125 */
  __pyx_v_tri->right_child = 0;

  /* "/home/jiba/src/soya/model/land.pyx":126 */
  __pyx_f_5_soya_land_tri_sphere(__pyx_v_tri->sphere,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/land.pyx":127 */
  face_normal(__pyx_v_tri->normal,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/land.pyx":128 */
  vector_normalize(__pyx_v_tri->normal);

  /* "/home/jiba/src/soya/model/land.pyx":129 */
  __pyx_r = __pyx_v_tri;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_create_child_tri");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_land_tri_update_neighbor_after_split(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":132 */
  __pyx_v_tri->left_child->left_neighbor = __pyx_v_tri->right_child;

  /* "/home/jiba/src/soya/model/land.pyx":133 */
  __pyx_1 = (__pyx_v_tri->left_neighbor != 0);
  if (__pyx_1) {
    __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri->left_neighbor);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":134 */
    __pyx_v_tri->left_child->base_neighbor = __pyx_v_tri->left_neighbor->right_child;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":136 */
    __pyx_v_tri->left_child->base_neighbor = __pyx_v_tri->left_neighbor;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":138 */
  __pyx_v_tri->right_child->right_neighbor = __pyx_v_tri->left_child;

  /* "/home/jiba/src/soya/model/land.pyx":139 */
  __pyx_1 = (__pyx_v_tri->right_neighbor != 0);
  if (__pyx_1) {
    __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri->right_neighbor);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":140 */
    __pyx_v_tri->right_child->base_neighbor = __pyx_v_tri->right_neighbor->left_child;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":142 */
    __pyx_v_tri->right_child->base_neighbor = __pyx_v_tri->right_neighbor;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":144 */
  __pyx_1 = (__pyx_v_tri->base_neighbor == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":145 */
    __pyx_v_tri->left_child->right_neighbor = 0;

    /* "/home/jiba/src/soya/model/land.pyx":146 */
    __pyx_v_tri->right_child->left_neighbor = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":148 */
    __pyx_v_tri->left_child->right_neighbor = __pyx_v_tri->base_neighbor->right_child;

    /* "/home/jiba/src/soya/model/land.pyx":149 */
    __pyx_v_tri->right_child->left_neighbor = __pyx_v_tri->base_neighbor->left_child;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":151 */
  __pyx_1 = (__pyx_v_tri->left_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":152 */
    __pyx_1 = (__pyx_v_tri->v1 == __pyx_v_tri->left_neighbor->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":153 */
      __pyx_v_tri->left_neighbor->right_neighbor = __pyx_v_tri->left_child;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":155 */
      __pyx_v_tri->left_neighbor->base_neighbor = __pyx_v_tri->left_child;

      /* "/home/jiba/src/soya/model/land.pyx":156 */
      __pyx_1 = (__pyx_v_tri->left_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":157 */
        __pyx_v_tri->left_neighbor->parent->right_neighbor = __pyx_v_tri->left_child;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":159 */
  __pyx_1 = (__pyx_v_tri->right_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":160 */
    __pyx_1 = (__pyx_v_tri->v1 == __pyx_v_tri->right_neighbor->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":161 */
      __pyx_v_tri->right_neighbor->left_neighbor = __pyx_v_tri->right_child;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":163 */
      __pyx_v_tri->right_neighbor->base_neighbor = __pyx_v_tri->right_child;

      /* "/home/jiba/src/soya/model/land.pyx":164 */
      __pyx_1 = (__pyx_v_tri->right_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":165 */
        __pyx_v_tri->right_neighbor->parent->left_neighbor = __pyx_v_tri->right_child;
        goto __pyx_L10;
      }
      __pyx_L10:;
    }
    __pyx_L9:;
    goto __pyx_L8;
  }
  __pyx_L8:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_update_neighbor_after_split");
  __pyx_L0:;
}

static void __pyx_f_5_soya_land_tri_force_split(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri),__pyx_t_5_soya_LandVertex (*__pyx_v_apex)) {

  /* "/home/jiba/src/soya/model/land.pyx":168 */
  __pyx_v_tri->left_child = __pyx_f_5_soya_land_create_child_tri(__pyx_v_apex,__pyx_v_tri->v1,__pyx_v_tri->v2,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/land.pyx":169 */
  __pyx_v_tri->right_child = __pyx_f_5_soya_land_create_child_tri(__pyx_v_apex,__pyx_v_tri->v3,__pyx_v_tri->v1,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/land.pyx":170 */
  __pyx_f_5_soya_land_tri_update_neighbor_after_split(__pyx_v_tri);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_force_split");
  __pyx_L0:;
}

static void __pyx_f_5_soya_land_tri_update_neighbor_after_merge(struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":173 */
  __pyx_1 = (__pyx_v_tri->left_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":174 */
    __pyx_1 = (__pyx_v_tri->left_neighbor->v1 == __pyx_v_tri->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":175 */
      __pyx_v_tri->left_neighbor->right_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/land.pyx":176 */
      __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri->left_neighbor);
      if (__pyx_1) {
        __pyx_v_tri->left_neighbor->right_child->base_neighbor = __pyx_v_tri;
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":178 */
      __pyx_v_tri->left_neighbor->base_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/land.pyx":179 */
      __pyx_1 = (__pyx_v_tri->left_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":180 */
        __pyx_v_tri->left_neighbor->parent->right_neighbor = __pyx_v_tri;
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":181 */
  __pyx_1 = (__pyx_v_tri->right_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":182 */
    __pyx_1 = (__pyx_v_tri->right_neighbor->v1 == __pyx_v_tri->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":183 */
      __pyx_v_tri->right_neighbor->left_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/land.pyx":184 */
      __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri->right_neighbor);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":185 */
        __pyx_v_tri->right_neighbor->left_child->base_neighbor = __pyx_v_tri;
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":187 */
      __pyx_v_tri->right_neighbor->base_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/land.pyx":188 */
      __pyx_1 = (__pyx_v_tri->right_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":189 */
        __pyx_v_tri->right_neighbor->parent->left_neighbor = __pyx_v_tri;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_tri_update_neighbor_after_merge");
  __pyx_L0:;
}

static void __pyx_f_5_soya_land_get_height_at_factors(__pyx_t_5_soya_LandVertex (*__pyx_v_v1),__pyx_t_5_soya_LandVertex (*__pyx_v_v2),__pyx_t_5_soya_LandVertex (*__pyx_v_v3),float __pyx_v_x,float __pyx_v_z,float (*__pyx_v_k),float (*__pyx_v_t)) {
  float (__pyx_v_u[2]);
  float (__pyx_v_w[2]);
  float __pyx_v_q;
  float (*__pyx_v_ptr);

  /* "/home/jiba/src/soya/model/land.pyx":194 */
  __pyx_v_ptr = __pyx_v_v1->coord;

  /* "/home/jiba/src/soya/model/land.pyx":195 */
  (__pyx_v_u[0]) = ((__pyx_v_v2->coord[0]) - (__pyx_v_ptr[0]));

  /* "/home/jiba/src/soya/model/land.pyx":196 */
  (__pyx_v_u[1]) = ((__pyx_v_v2->coord[2]) - (__pyx_v_ptr[2]));

  /* "/home/jiba/src/soya/model/land.pyx":197 */
  (__pyx_v_w[0]) = ((__pyx_v_v3->coord[0]) - (__pyx_v_ptr[0]));

  /* "/home/jiba/src/soya/model/land.pyx":198 */
  (__pyx_v_w[1]) = ((__pyx_v_v3->coord[2]) - (__pyx_v_ptr[2]));

  /* "/home/jiba/src/soya/model/land.pyx":199 */
  __pyx_v_q = (1.0 / (((__pyx_v_w[0]) * (__pyx_v_u[1])) - ((__pyx_v_w[1]) * (__pyx_v_u[0]))));

  /* "/home/jiba/src/soya/model/land.pyx":200 */
  (__pyx_v_t[0]) = ((((__pyx_v_x - (__pyx_v_ptr[0])) * (__pyx_v_u[1])) - ((__pyx_v_z - (__pyx_v_ptr[2])) * (__pyx_v_u[0]))) * __pyx_v_q);

  /* "/home/jiba/src/soya/model/land.pyx":201 */
  (__pyx_v_k[0]) = ((((-(__pyx_v_x - (__pyx_v_ptr[0]))) * (__pyx_v_w[1])) + ((__pyx_v_z - (__pyx_v_ptr[2])) * (__pyx_v_w[0]))) * __pyx_v_q);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_get_height_at_factors");
  __pyx_L0:;
}

static void __pyx_f_5_soya_land_drawColor_radeon(float (*__pyx_v_vect)) {

  /* "/home/jiba/src/soya/model/land.pyx":205 */
  glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,__pyx_v_vect);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_drawColor_radeon");
  __pyx_L0:;
}

static void __pyx_f_5_soya_noop(void) {

  /* "/home/jiba/src/soya/model/land.pyx":208 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.noop");
  __pyx_L0:;
}

static void __pyx_f_5_soya_land_disableColor_radeon(void) {

  /* "/home/jiba/src/soya/model/land.pyx":212 */
  glDisable(GL_COLOR_MATERIAL);

  /* "/home/jiba/src/soya/model/land.pyx":213 */
  glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,__pyx_v_5_soya_white);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_disableColor_radeon");
  __pyx_L0:;
}

static void __pyx_f_5_soya_land_enableColor_radeon(void) {

  /* "/home/jiba/src/soya/model/land.pyx":216 */
  glEnable(GL_COLOR_MATERIAL);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.land_enableColor_radeon");
  __pyx_L0:;
}

static void __pyx_f_5_soya_SET_COLOR_OPAQUE(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_index) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":233 */
  __pyx_1 = (__pyx_v_self->_colors == 0);
  if (__pyx_1) {
    __pyx_v_5_soya_land_drawColor(__pyx_v_5_soya_renderer->current_material->_diffuse);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_5_soya_land_drawColor((__pyx_v_self->_colors + __pyx_v_index));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.SET_COLOR_OPAQUE");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_SET_COLOR_ALPHA(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_index) {
  float (__pyx_v_ccc[4]);
  float (*__pyx_v_color);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":240 */
  __pyx_1 = (__pyx_v_self->_colors == 0);
  if (__pyx_1) {
    __pyx_v_color = __pyx_v_5_soya_renderer->current_material->_diffuse;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_color = (__pyx_v_self->_colors + __pyx_v_index);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":242 */
  (__pyx_v_ccc[0]) = (__pyx_v_color[0]);

  /* "/home/jiba/src/soya/model/land.pyx":243 */
  (__pyx_v_ccc[1]) = (__pyx_v_color[1]);

  /* "/home/jiba/src/soya/model/land.pyx":244 */
  (__pyx_v_ccc[2]) = (__pyx_v_color[2]);

  /* "/home/jiba/src/soya/model/land.pyx":245 */
  (__pyx_v_ccc[3]) = 0.0;

  /* "/home/jiba/src/soya/model/land.pyx":246 */
  __pyx_v_5_soya_land_drawColor(__pyx_v_ccc);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.SET_COLOR_ALPHA");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_5_Land_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_5width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":271 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 271; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_5depth___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_5depth___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":274 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.depth.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_10patch_size___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_10patch_size___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":278 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_patch_size); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 278; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.patch_size.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land_10patch_size___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_5_Land_10patch_size___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/land.pyx":280 */
  __pyx_1 = PyInt_AsLong(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 280; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_patch_size = __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":281 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_INITED);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option - __pyx_e_5_soya_LAND_INITED);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.patch_size.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_18has_vertex_options___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_18has_vertex_options___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":285 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 285; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.has_vertex_options.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_12split_factor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_12split_factor___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":289 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_split_factor); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 289; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.split_factor.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land_12split_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_5_Land_12split_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  float __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/land.pyx":291 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 291; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_split_factor = __pyx_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.split_factor.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_12scale_factor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_12scale_factor___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":295 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_scale_factor); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.scale_factor.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land_12scale_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_5_Land_12scale_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  float __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/land.pyx":297 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 297; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_scale_factor = __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":298 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LAND_INITED));

  /* "/home/jiba/src/soya/model/land.pyx":299 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.scale_factor.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_14texture_factor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_14texture_factor___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":303 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_texture_factor); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 303; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.texture_factor.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land_14texture_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_5_Land_14texture_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  float __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/land.pyx":305 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 305; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_texture_factor = __pyx_1;

  /* "/home/jiba/src/soya/model/land.pyx":306 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.texture_factor.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_16raypick_with_LOD___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_16raypick_with_LOD___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":310 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_REAL_LOD_RAYPICK)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 310; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.raypick_with_LOD.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land_16raypick_with_LOD___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_5_Land_16raypick_with_LOD___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/land.pyx":312 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_x); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 312; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_LAND_REAL_LOD_RAYPICK);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LAND_REAL_LOD_RAYPICK));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.raypick_with_LOD.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static __pyx_t_5_soya_LandVertex (*__pyx_f_5_soya_5_Land__get_vertex(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_x,int __pyx_v_z)) {
  __pyx_t_5_soya_LandVertex (*__pyx_r);
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":317 */
  __pyx_r = (__pyx_v_self->_vertices + (__pyx_v_x + (__pyx_v_z * __pyx_v_self->_nb_vertex_width)));
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._get_vertex");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k268p;
static PyObject *__pyx_k269p;

static char (__pyx_k268[]) = "WARNING Land size width must be (2^n) + 1";
static char (__pyx_k269[]) = "WARNING Land size depth must be (2^n) + 1";

static void __pyx_f_5_soya_5_Land__check_size(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_d;
  long __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":321 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/land.pyx":322 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/land.pyx":323 */
    __pyx_v_d = ((1 << __pyx_v_i) + 1);

    /* "/home/jiba/src/soya/model/land.pyx":324 */
    __pyx_2 = (__pyx_v_self->_nb_vertex_width <= __pyx_v_d);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/land.pyx":325 */
      __pyx_2 = (__pyx_v_self->_nb_vertex_width < __pyx_v_d);
      if (__pyx_2) {
        if (__Pyx_PrintItem(__pyx_k268p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 325; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 325; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/model/land.pyx":326 */
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/land.pyx":327 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":329 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/land.pyx":330 */
  while (1) {
    __pyx_L6:;
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/land.pyx":331 */
    __pyx_v_d = ((1 << __pyx_v_i) + 1);

    /* "/home/jiba/src/soya/model/land.pyx":332 */
    __pyx_2 = (__pyx_v_self->_nb_vertex_depth <= __pyx_v_d);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/land.pyx":333 */
      __pyx_2 = (__pyx_v_self->_nb_vertex_depth < __pyx_v_d);
      if (__pyx_2) {
        if (__Pyx_PrintItem(__pyx_k269p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 333; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 333; goto __pyx_L1;}
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/model/land.pyx":334 */
      goto __pyx_L7;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/land.pyx":335 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L7:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._check_size");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_5_Land___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_5_Land___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  int __pyx_v_width;
  int __pyx_v_depth;
  float __pyx_v_scale_factor;
  __pyx_t_5_soya_LandVertex (*__pyx_v_v);
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"parent","width","depth","scale_factor",0};
  __pyx_v_parent = __pyx_k119;
  __pyx_v_width = __pyx_k120;
  __pyx_v_depth = __pyx_k121;
  __pyx_v_scale_factor = __pyx_k122;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|Oiif", __pyx_argnames, &__pyx_v_parent, &__pyx_v_width, &__pyx_v_depth, &__pyx_v_scale_factor)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 339; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/land.pyx":344 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 344; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 344; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 344; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":345 */
  __pyx_4 = (__pyx_v_depth == 0);
  if (__pyx_4) {
    __pyx_v_depth = __pyx_v_width;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":347 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width = __pyx_v_width;

  /* "/home/jiba/src/soya/model/land.pyx":348 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth = __pyx_v_depth;

  /* "/home/jiba/src/soya/model/land.pyx":349 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_patch_size = 8;

  /* "/home/jiba/src/soya/model/land.pyx":350 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_texture_factor = 1.0;

  /* "/home/jiba/src/soya/model/land.pyx":351 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_scale_factor = __pyx_v_scale_factor;

  /* "/home/jiba/src/soya/model/land.pyx":352 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_split_factor = 2.0;

  /* "/home/jiba/src/soya/model/land.pyx":353 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 353; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL));
  PyList_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL));
  Py_DECREF(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":354 */
  __pyx_4 = (__pyx_v_width != 0);
  if (__pyx_4) {
    __pyx_4 = (__pyx_v_depth != 0);
  }
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/land.pyx":355 */
    __pyx_v_nb = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width * ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth);

    /* "/home/jiba/src/soya/model/land.pyx":356 */
    ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_size(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

    /* "/home/jiba/src/soya/model/land.pyx":357 */
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices = ((__pyx_t_5_soya_LandVertex (*))malloc((__pyx_v_nb * (sizeof(__pyx_t_5_soya_LandVertex )))));

    /* "/home/jiba/src/soya/model/land.pyx":358 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":359 */
      __pyx_v_v = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices + __pyx_v_i);

      /* "/home/jiba/src/soya/model/land.pyx":360 */
      (__pyx_v_v->coord[1]) = 0;

      /* "/home/jiba/src/soya/model/land.pyx":361 */
      __pyx_v_v->pack = ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya__DEFAULT_MATERIAL->__pyx_base.__pyx_vtab)->_pack(__pyx_v_5_soya__DEFAULT_MATERIAL,__pyx_e_5_soya_FACE_TRIANGLE);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/land.pyx":362 */
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_normals = ((float (*))malloc(((((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width - 1) * (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth - 1)) * 6) * (sizeof(float )))));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":363 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Land.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__free_patchs(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch);
  int __pyx_v_i;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":369 */
  __pyx_1 = __pyx_v_self->_nb_patchs;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":370 */
    __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

    /* "/home/jiba/src/soya/model/land.pyx":371 */
    __pyx_f_5_soya_land_tri_dealloc(__pyx_v_patch->tri_top);

    /* "/home/jiba/src/soya/model/land.pyx":372 */
    __pyx_f_5_soya_land_tri_dealloc(__pyx_v_patch->tri_left);

    /* "/home/jiba/src/soya/model/land.pyx":373 */
    __pyx_f_5_soya_land_tri_dealloc(__pyx_v_patch->tri_right);

    /* "/home/jiba/src/soya/model/land.pyx":374 */
    __pyx_f_5_soya_land_tri_dealloc(__pyx_v_patch->tri_bottom);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":375 */
  free(__pyx_v_self->_patchs);

  /* "/home/jiba/src/soya/model/land.pyx":376 */
  __pyx_v_self->_patchs = 0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._free_patchs");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land___del__(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":380 */
  ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_free_patchs(__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":381 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n___imul__); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 381; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 381; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 381; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 381; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":382 */
  free(__pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/land.pyx":383 */
  free(__pyx_v_self->_colors);

  /* "/home/jiba/src/soya/model/land.pyx":384 */
  free(__pyx_v_self->_normals);

  /* "/home/jiba/src/soya/model/land.pyx":385 */
  free(__pyx_v_self->_vertex_options);

  /* "/home/jiba/src/soya/model/land.pyx":386 */
  free(__pyx_v_self->_vertex_colors);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Land.__del__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_5_Land_from_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_from_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Image *__pyx_v_image = 0;
  GLubyte (*__pyx_v_ptr);
  int __pyx_v_nb;
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"image",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_image)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_image);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image), __pyx_ptype_5_soya__Image, 1, "image")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 388; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/land.pyx":391 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width = __pyx_v_image->width;

  /* "/home/jiba/src/soya/model/land.pyx":392 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth = __pyx_v_image->height;

  /* "/home/jiba/src/soya/model/land.pyx":393 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_size(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/land.pyx":394 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":395 */
  __pyx_v_nb = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width * ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/land.pyx":396 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices = ((__pyx_t_5_soya_LandVertex (*))malloc((__pyx_v_nb * (sizeof(__pyx_t_5_soya_LandVertex )))));

  /* "/home/jiba/src/soya/model/land.pyx":397 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {
    (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices + __pyx_v_i)->pack = ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya__DEFAULT_MATERIAL->__pyx_base.__pyx_vtab)->_pack(__pyx_v_5_soya__DEFAULT_MATERIAL,__pyx_e_5_soya_FACE_TRIANGLE);
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":398 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_normals = ((float (*))malloc(((((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width - 1) * (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth - 1)) * 6) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/land.pyx":399 */
  __pyx_1 = (__pyx_v_image->nb_color == 3);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":400 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":401 */
      __pyx_v_ptr = (__pyx_v_image->_pixels + (__pyx_v_i * 3));

      /* "/home/jiba/src/soya/model/land.pyx":402 */
      ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices + __pyx_v_i)->coord[1]) = ((((__pyx_v_ptr[0]) + (__pyx_v_ptr[1])) + (__pyx_v_ptr[2])) / (3.0 * 255.0));
      __pyx_L6:;
    }
    __pyx_L7:;
    goto __pyx_L5;
  }
  __pyx_1 = (__pyx_v_image->nb_color == 4);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":404 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":405 */
      __pyx_v_ptr = (__pyx_v_image->_pixels + (__pyx_v_i * 4));

      /* "/home/jiba/src/soya/model/land.pyx":406 */
      ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices + __pyx_v_i)->coord[1]) = (((((__pyx_v_ptr[0]) + (__pyx_v_ptr[1])) + (__pyx_v_ptr[2])) + (__pyx_v_ptr[3])) / (4.0 * 255.0));
      __pyx_L8:;
    }
    __pyx_L9:;
    goto __pyx_L5;
  }
  __pyx_1 = (__pyx_v_image->nb_color == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":408 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":409 */
      ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices + __pyx_v_i)->coord[1]) = ((__pyx_v_image->_pixels[__pyx_v_i]) / 255.0);
      __pyx_L10:;
    }
    __pyx_L11:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":411 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LAND_INITED));

  /* "/home/jiba/src/soya/model/land.pyx":412 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.from_image");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_image);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__add_material(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_obj_5_soya__Material *__pyx_v_material) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_material);

  /* "/home/jiba/src/soya/model/land.pyx":415 */
  __pyx_1 = PySequence_Contains(__pyx_v_self->_materials, ((PyObject *)__pyx_v_material)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 415; goto __pyx_L1;}
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":416 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 416; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 416; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_material));
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 416; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":417 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_LAND_INITED));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Land._add_material");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
}

static PyObject *__pyx_f_5_soya_5_Land_set_material_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_set_material_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  float __pyx_v_start;
  float __pyx_v_end;
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  int __pyx_3;
  static char *__pyx_argnames[] = {"material","start","end",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Off", __pyx_argnames, &__pyx_v_material, &__pyx_v_start, &__pyx_v_end)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 419; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/land.pyx":423 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_material);

  /* "/home/jiba/src/soya/model/land.pyx":424 */
  __pyx_v_pack = ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_material->__pyx_base.__pyx_vtab)->_pack(__pyx_v_material,__pyx_e_5_soya_FACE_TRIANGLE);

  /* "/home/jiba/src/soya/model/land.pyx":425 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":426 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":427 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":428 */
      __pyx_3 = ((__pyx_v_vertex->coord[1]) >= __pyx_v_start);
      if (__pyx_3) {
        __pyx_3 = ((__pyx_v_vertex->coord[1]) <= __pyx_v_end);
      }
      if (__pyx_3) {
        __pyx_v_vertex->pack = __pyx_v_pack;
        goto __pyx_L6;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":429 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LAND_INITED));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.set_material_layer");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_set_material_layer_angle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_set_material_layer_angle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  float __pyx_v_start;
  float __pyx_v_end;
  float __pyx_v_angle_min;
  float __pyx_v_angle_max;
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  float __pyx_v_f;
  float (__pyx_v_v[3]);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  int __pyx_3;
  static char *__pyx_argnames[] = {"material","start","end","angle_min","angle_max",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Offff", __pyx_argnames, &__pyx_v_material, &__pyx_v_start, &__pyx_v_end, &__pyx_v_angle_min, &__pyx_v_angle_max)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 431; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/land.pyx":436 */
  (__pyx_v_v[0]) = 0.0;

  /* "/home/jiba/src/soya/model/land.pyx":436 */
  (__pyx_v_v[1]) = 1.0;

  /* "/home/jiba/src/soya/model/land.pyx":436 */
  (__pyx_v_v[2]) = 0.0;

  /* "/home/jiba/src/soya/model/land.pyx":438 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":440 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_material);

  /* "/home/jiba/src/soya/model/land.pyx":441 */
  __pyx_v_pack = ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_material->__pyx_base.__pyx_vtab)->_pack(__pyx_v_material,__pyx_e_5_soya_FACE_TRIANGLE);

  /* "/home/jiba/src/soya/model/land.pyx":442 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":443 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":444 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":445 */
      __pyx_v_f = fabs(to_degrees(vector_angle(__pyx_v_vertex->normal,__pyx_v_v)));

      /* "/home/jiba/src/soya/model/land.pyx":446 */
      __pyx_3 = ((__pyx_v_vertex->coord[1]) >= __pyx_v_start);
      if (__pyx_3) {
        __pyx_3 = ((__pyx_v_vertex->coord[1]) <= __pyx_v_end);
        if (__pyx_3) {
          __pyx_3 = __pyx_v_angle_min <= __pyx_v_f;
          if (__pyx_3) {
            __pyx_3 = __pyx_v_f <= __pyx_v_angle_max;
          }
        }
      }
      if (__pyx_3) {
        __pyx_v_vertex->pack = __pyx_v_pack;
        goto __pyx_L7;
      }
      __pyx_L7:;
      __pyx_L5:;
    }
    __pyx_L6:;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":447 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LAND_INITED));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.set_material_layer_angle");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_get_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_get_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"x","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii", __pyx_argnames, &__pyx_v_x, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":452 */
  __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_x,__pyx_v_z);

  /* "/home/jiba/src/soya/model/land.pyx":453 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_vertex->normal[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 453; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_vertex->normal[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 453; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_vertex->normal[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 453; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 453; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Land.get_normal");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_get_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_get_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"x","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii", __pyx_argnames, &__pyx_v_x, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":456 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_x,__pyx_v_z)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 456; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Land.get_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static float __pyx_f_5_soya_5_Land__get_height(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_x,int __pyx_v_z) {
  float __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":459 */
  __pyx_1 = (__pyx_v_x < 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_z < 0);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_x >= __pyx_v_self->_nb_vertex_width);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_z >= __pyx_v_self->_nb_vertex_depth);
      }
    }
  }
  if (__pyx_1) {
    __pyx_r = 0.0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":460 */
  __pyx_r = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_x,__pyx_v_z)->coord[1]);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._get_height");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_get_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_get_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"x","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii", __pyx_argnames, &__pyx_v_x, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":463 */
  __pyx_1 = (__pyx_v_x < 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_z < 0);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_x >= ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_z >= ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth);
      }
    }
  }
  if (__pyx_1) {
    Py_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":464 */
  __pyx_2 = (PyObject *)((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_x,__pyx_v_z)->pack->material_id;
  Py_INCREF((PyObject *)__pyx_2);
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Land.get_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__set_height(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_x,int __pyx_v_z,float __pyx_v_height) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":467 */
  __pyx_1 = (__pyx_v_x < 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_z < 0);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_x >= __pyx_v_self->_nb_vertex_width);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_z >= __pyx_v_self->_nb_vertex_depth);
      }
    }
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":468 */
  (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_x,__pyx_v_z)->coord[1]) = __pyx_v_height;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._set_height");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_5_Land_set_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_set_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  float __pyx_v_height;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"x","z","height",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iif", __pyx_argnames, &__pyx_v_x, &__pyx_v_z, &__pyx_v_height)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":471 */
  __pyx_1 = (__pyx_v_x < 0);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_z < 0);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_x >= ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_z >= ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth);
      }
    }
  }
  if (__pyx_1) {
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":472 */
  (((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_x,__pyx_v_z)->coord[1]) = __pyx_v_height;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.set_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_multiply_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_multiply_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_factor;
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  static char *__pyx_argnames[] = {"factor",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_factor)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":477 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":478 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":479 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":480 */
      (__pyx_v_vertex->coord[1]) = ((__pyx_v_vertex->coord[1]) * __pyx_v_factor);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.multiply_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_add_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_add_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_height;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  int __pyx_v_i;
  int __pyx_v_j;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  static char *__pyx_argnames[] = {"height",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_height)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":485 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":486 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":487 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":488 */
      (__pyx_v_vertex->coord[1]) = ((__pyx_v_vertex->coord[1]) + __pyx_v_height);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.add_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_set_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_set_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  struct __pyx_obj_5_soya__Material *__pyx_v_material = 0;
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"x","z","material",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iiO", __pyx_argnames, &__pyx_v_x, &__pyx_v_z, &__pyx_v_material)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_material);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 490; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/land.pyx":492 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_material);

  /* "/home/jiba/src/soya/model/land.pyx":493 */
  __pyx_v_pack = ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_material->__pyx_base.__pyx_vtab)->_pack(__pyx_v_material,__pyx_e_5_soya_FACE_TRIANGLE);

  /* "/home/jiba/src/soya/model/land.pyx":494 */
  __pyx_1 = 0 <= __pyx_v_x;
  if (__pyx_1) {
    __pyx_1 = __pyx_v_x < ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width;
  }
  if (__pyx_1) {
    __pyx_1 = 0 <= __pyx_v_z;
    if (__pyx_1) {
      __pyx_1 = __pyx_v_z < ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth;
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":495 */
    ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_x,__pyx_v_z)->pack = __pyx_v_pack;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.set_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_remove_colors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Land_remove_colors[] = "Land.remove_colors()\n\nRemoves all colors, from all vertices that have colors.";
static PyObject *__pyx_f_5_soya_5_Land_remove_colors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":501 */
  free(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors);

  /* "/home/jiba/src/soya/model/land.pyx":502 */
  free(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors);

  /* "/home/jiba/src/soya/model/land.pyx":503 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_colors = 0;

  /* "/home/jiba/src/soya/model/land.pyx":504 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors = 0;

  /* "/home/jiba/src/soya/model/land.pyx":505 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors = 0;

  /* "/home/jiba/src/soya/model/land.pyx":506 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_LAND_COLORED));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.remove_colors");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_get_vertex_option(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Land_get_vertex_option[] = "Land.get_vertex_option(X, Z) => (HIDDEN, NON_SOLID, FORCE_PRESENCE)\n\nReturns the vertex options associated with the vertex of coordinates X, Z, as a 4-int tuple.\nSee Land.set_vertex_option for the available options.";
static PyObject *__pyx_f_5_soya_5_Land_get_vertex_option(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  int __pyx_v_option;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"x","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii", __pyx_argnames, &__pyx_v_x, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":514 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_vertex_options(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/land.pyx":515 */
  __pyx_v_option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[(__pyx_v_x + (__pyx_v_z * ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width))]);

  /* "/home/jiba/src/soya/model/land.pyx":516 */
  __pyx_1 = PyInt_FromLong((__pyx_v_option & __pyx_e_5_soya_LAND_VERTEX_HIDDEN)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 516; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong((__pyx_v_option & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID)); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 516; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_option & __pyx_e_5_soya_LAND_VERTEX_FORCE_PRESENCE)); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 516; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 516; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Land.get_vertex_option");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_set_vertex_option(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Land_set_vertex_option[] = "Land.set_vertex_option(X, Z, HIDDEN, NON_SOLID, FORCE_PRESENCE)\n\nSets the vertex options associated with the vertex of coordinates X, Z.\nThese options are usefull to create hole in the landscape, or non-rectangular landscape.\n\nOptions are (all option are boolean, and default is 0 for all):\n  - Hidden : hide the vertex (a triangle whose 3 vertices hidden is not drawn)\n  - Non-solid : the vertex is non-solid (raypicking is disabled on a triangle whose 3 vertices are non-solid).\n  - ForcePresence : the vertex is ALWAYS present (else, the LOD system may remove some vertex temporarily).\n";
static PyObject *__pyx_f_5_soya_5_Land_set_vertex_option(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  int __pyx_v_hidden;
  int __pyx_v_non_solid;
  int __pyx_v_force_presence;
  int __pyx_v_index;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"x","z","hidden","non_solid","force_presence",0};
  __pyx_v_hidden = __pyx_k123;
  __pyx_v_non_solid = __pyx_k124;
  __pyx_v_force_presence = __pyx_k125;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ii|iii", __pyx_argnames, &__pyx_v_x, &__pyx_v_z, &__pyx_v_hidden, &__pyx_v_non_solid, &__pyx_v_force_presence)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":530 */
  __pyx_v_index = (__pyx_v_x + (__pyx_v_z * ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/land.pyx":531 */
  ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_vertex_options(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/land.pyx":532 */
  (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_index]) = (((((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_index]) & (~((__pyx_e_5_soya_LAND_VERTEX_HIDDEN | __pyx_e_5_soya_LAND_VERTEX_NON_SOLID) | __pyx_e_5_soya_LAND_VERTEX_FORCE_PRESENCE))) | (__pyx_v_hidden * __pyx_e_5_soya_LAND_VERTEX_HIDDEN)) | (__pyx_v_non_solid * __pyx_e_5_soya_LAND_VERTEX_NON_SOLID)) | (__pyx_v_force_presence * __pyx_e_5_soya_LAND_VERTEX_FORCE_PRESENCE));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.set_vertex_option");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_set_vertex_color(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_set_vertex_color(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  PyObject *__pyx_v_color = 0;
  float (__pyx_v_ccolor[4]);
  int __pyx_v_n;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  float __pyx_3;
  int __pyx_4;
  static char *__pyx_argnames[] = {"x","z","color",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "iiO", __pyx_argnames, &__pyx_v_x, &__pyx_v_z, &__pyx_v_color)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_color);

  /* "/home/jiba/src/soya/model/land.pyx":537 */
  __pyx_v_n = (__pyx_v_x + (__pyx_v_z * ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/land.pyx":538 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 538; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 538; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 538; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[0]) = __pyx_3;

  /* "/home/jiba/src/soya/model/land.pyx":539 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 539; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 539; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 539; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[1]) = __pyx_3;

  /* "/home/jiba/src/soya/model/land.pyx":540 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 540; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 540; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 540; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[2]) = __pyx_3;

  /* "/home/jiba/src/soya/model/land.pyx":541 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 541; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 541; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 541; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[3]) = __pyx_3;

  /* "/home/jiba/src/soya/model/land.pyx":542 */
  (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_n]) = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_color(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ccolor);

  /* "/home/jiba/src/soya/model/land.pyx":543 */
  __pyx_4 = ((1.0 - (__pyx_v_ccolor[3])) > EPSILON);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) | __pyx_e_5_soya_LAND_VERTEX_ALPHA);
    goto __pyx_L2;
  }
  __pyx_4 = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) & (~__pyx_e_5_soya_LAND_VERTEX_ALPHA));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":545 */
  __pyx_4 = ((__pyx_v_ccolor[3]) < EPSILON);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) | __pyx_e_5_soya_LAND_VERTEX_HIDDEN);
    goto __pyx_L3;
  }
  __pyx_4 = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_options[__pyx_v_n]) & (~__pyx_e_5_soya_LAND_VERTEX_HIDDEN));
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Land.set_vertex_color");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_color);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_reinit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Land_reinit[] = "Land.reinit()\n\nRe-inits the landscape.\nYou MUST call this method after the landscape have been modified manually\n(e.g. with Land.set_height).";
static PyObject *__pyx_f_5_soya_5_Land_reinit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":554 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_INITED);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option - __pyx_e_5_soya_LAND_INITED);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Land.reinit");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__init(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":558 */
  __pyx_1 = (__pyx_v_self->_patchs != 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_free_patchs(__pyx_v_self);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":559 */
  ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normals(__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":560 */
  ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_create_patchs(__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":561 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_force_presence(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":562 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_LAND_INITED);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._init");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__compute_normal(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_x,int __pyx_v_y) {
  float __pyx_v_y00;
  float __pyx_v_y01;
  float __pyx_v_y10;
  float __pyx_v_y11;
  float __pyx_v_y12;
  float __pyx_v_y21;
  float __pyx_v_y22;
  float __pyx_v_y02;
  float __pyx_v_y20;
  float __pyx_v_a;
  float __pyx_v_b;
  float __pyx_v_c;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":567 */
  __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_x,__pyx_v_y);

  /* "/home/jiba/src/soya/model/land.pyx":568 */
  __pyx_v_y11 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,__pyx_v_x,__pyx_v_y);

  /* "/home/jiba/src/soya/model/land.pyx":570 */
  __pyx_v_y00 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,(__pyx_v_x - 1),(__pyx_v_y - 1)) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":571 */
  __pyx_v_y01 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,(__pyx_v_x - 1),__pyx_v_y) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":572 */
  __pyx_v_y10 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,__pyx_v_x,(__pyx_v_y - 1)) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":573 */
  __pyx_v_y12 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,__pyx_v_x,(__pyx_v_y + 1)) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":574 */
  __pyx_v_y21 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,(__pyx_v_x + 1),__pyx_v_y) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":575 */
  __pyx_v_y22 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,(__pyx_v_x + 1),(__pyx_v_y + 1)) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":576 */
  __pyx_v_y02 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,(__pyx_v_x - 1),(__pyx_v_y + 1)) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":577 */
  __pyx_v_y20 = (((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(__pyx_v_self,(__pyx_v_x + 1),(__pyx_v_y - 1)) - __pyx_v_y11);

  /* "/home/jiba/src/soya/model/land.pyx":579 */
  __pyx_v_a = (((((((-__pyx_v_y00) - (2.0 * __pyx_v_y01)) - __pyx_v_y02) + __pyx_v_y20) + (2.0 * __pyx_v_y21)) + __pyx_v_y22) / __pyx_v_self->_scale_factor);

  /* "/home/jiba/src/soya/model/land.pyx":580 */
  __pyx_v_b = (((((((-__pyx_v_y00) - (2.0 * __pyx_v_y10)) - __pyx_v_y20) + __pyx_v_y02) + (2.0 * __pyx_v_y12)) + __pyx_v_y22) / __pyx_v_self->_scale_factor);

  /* "/home/jiba/src/soya/model/land.pyx":581 */
  __pyx_v_c = 8.0;

  /* "/home/jiba/src/soya/model/land.pyx":582 */
  (__pyx_v_vertex->normal[0]) = (-__pyx_v_a);

  /* "/home/jiba/src/soya/model/land.pyx":583 */
  (__pyx_v_vertex->normal[1]) = __pyx_v_c;

  /* "/home/jiba/src/soya/model/land.pyx":584 */
  (__pyx_v_vertex->normal[2]) = (-__pyx_v_b);

  /* "/home/jiba/src/soya/model/land.pyx":585 */
  vector_normalize(__pyx_v_vertex->normal);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._compute_normal");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__compute_normals(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  float (*__pyx_v_ptr);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v1);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v2);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v3);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v4);
  int __pyx_1;
  int __pyx_2;
  long __pyx_3;
  long __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":592 */
  __pyx_1 = __pyx_v_self->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":593 */
    __pyx_2 = __pyx_v_self->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":594 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normal(__pyx_v_self,__pyx_v_i,__pyx_v_j);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":596 */
  __pyx_v_ptr = __pyx_v_self->_normals;

  /* "/home/jiba/src/soya/model/land.pyx":597 */
  __pyx_3 = (__pyx_v_self->_nb_vertex_depth - 1);
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_3; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":598 */
    __pyx_4 = (__pyx_v_self->_nb_vertex_width - 1);
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_4; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":599 */
      __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":600 */
      __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,(__pyx_v_i + 1),__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":601 */
      __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,(__pyx_v_i + 1),(__pyx_v_j + 1));

      /* "/home/jiba/src/soya/model/land.pyx":602 */
      __pyx_v_v4 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_i,(__pyx_v_j + 1));

      /* "/home/jiba/src/soya/model/land.pyx":603 */
      __pyx_2 = (__pyx_v_i & 1);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_j & 1);
      }
      if (!__pyx_2) {
        __pyx_2 = (!(__pyx_v_i & 1));
        if (__pyx_2) {
          __pyx_2 = (!(__pyx_v_j & 1));
        }
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/land.pyx":604 */
        face_normal(__pyx_v_ptr,__pyx_v_v4->coord,__pyx_v_v3->coord,__pyx_v_v1->coord);

        /* "/home/jiba/src/soya/model/land.pyx":604 */
        vector_normalize(__pyx_v_ptr);

        /* "/home/jiba/src/soya/model/land.pyx":605 */
        face_normal((__pyx_v_ptr + 3),__pyx_v_v2->coord,__pyx_v_v1->coord,__pyx_v_v3->coord);

        /* "/home/jiba/src/soya/model/land.pyx":605 */
        vector_normalize((__pyx_v_ptr + 3));
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":607 */
        face_normal(__pyx_v_ptr,__pyx_v_v1->coord,__pyx_v_v4->coord,__pyx_v_v2->coord);

        /* "/home/jiba/src/soya/model/land.pyx":607 */
        vector_normalize(__pyx_v_ptr);

        /* "/home/jiba/src/soya/model/land.pyx":608 */
        face_normal((__pyx_v_ptr + 3),__pyx_v_v3->coord,__pyx_v_v2->coord,__pyx_v_v4->coord);

        /* "/home/jiba/src/soya/model/land.pyx":608 */
        vector_normalize((__pyx_v_ptr + 3));
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/model/land.pyx":609 */
      __pyx_v_ptr = (__pyx_v_ptr + 6);
      __pyx_L8:;
    }
    __pyx_L9:;
    __pyx_L6:;
  }
  __pyx_L7:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._compute_normals");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__compute_coords(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":614 */
  __pyx_v_k = 0;

  /* "/home/jiba/src/soya/model/land.pyx":615 */
  __pyx_1 = __pyx_v_self->_nb_vertex_depth;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":616 */
    __pyx_2 = __pyx_v_self->_nb_vertex_width;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/land.pyx":617 */
      __pyx_v_vertex = (__pyx_v_self->_vertices + __pyx_v_k);

      /* "/home/jiba/src/soya/model/land.pyx":618 */
      (__pyx_v_vertex->coord[0]) = (((float )__pyx_v_j) * __pyx_v_self->_scale_factor);

      /* "/home/jiba/src/soya/model/land.pyx":619 */
      (__pyx_v_vertex->coord[2]) = (((float )__pyx_v_i) * __pyx_v_self->_scale_factor);

      /* "/home/jiba/src/soya/model/land.pyx":620 */
      (__pyx_v_vertex->texcoord[0]) = (((float )__pyx_v_j) * __pyx_v_self->_texture_factor);

      /* "/home/jiba/src/soya/model/land.pyx":621 */
      (__pyx_v_vertex->texcoord[1]) = (((float )__pyx_v_i) * __pyx_v_self->_texture_factor);

      /* "/home/jiba/src/soya/model/land.pyx":622 */
      __pyx_v_k = (__pyx_v_k + 1);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._compute_coords");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__create_patch(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch),int __pyx_v_x,int __pyx_v_z,int __pyx_v_patch_size) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_m;
  int __pyx_v_nb;
  int __pyx_v_x1;
  int __pyx_v_z1;
  int __pyx_v_x2;
  int __pyx_v_z2;
  float (*__pyx_v_coords);
  __pyx_t_5_soya_LandVertex (*__pyx_v_vertex);
  __pyx_t_5_soya_LandVertex (*__pyx_v_center);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v0);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v1);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v2);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v3);
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":628 */
  __pyx_v_patch->level = 0;

  /* "/home/jiba/src/soya/model/land.pyx":629 */
  __pyx_v_x1 = (__pyx_v_x * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":630 */
  __pyx_v_x2 = ((__pyx_v_x + 1) * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":631 */
  __pyx_v_z1 = (__pyx_v_z * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":632 */
  __pyx_v_z2 = ((__pyx_v_z + 1) * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":635 */
  __pyx_v_nb = ((__pyx_v_patch_size + 1) * (__pyx_v_patch_size + 1));

  /* "/home/jiba/src/soya/model/land.pyx":636 */
  __pyx_v_coords = ((float (*))malloc(((__pyx_v_nb * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/land.pyx":637 */
  __pyx_v_m = 0;

  /* "/home/jiba/src/soya/model/land.pyx":638 */
  for (__pyx_v_i = __pyx_v_x1; __pyx_v_i <= __pyx_v_x2; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":639 */
    for (__pyx_v_j = __pyx_v_z1; __pyx_v_j <= __pyx_v_z2; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/land.pyx":640 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/land.pyx":641 */
      memcpy((__pyx_v_coords + __pyx_v_m),__pyx_v_vertex->coord,(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/model/land.pyx":642 */
      __pyx_v_m = (__pyx_v_m + 3);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":643 */
  sphere_from_points(__pyx_v_patch->sphere,__pyx_v_coords,__pyx_v_nb);

  /* "/home/jiba/src/soya/model/land.pyx":644 */
  free(__pyx_v_coords);

  /* "/home/jiba/src/soya/model/land.pyx":647 */
  __pyx_v_v0 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_x1,__pyx_v_z1);

  /* "/home/jiba/src/soya/model/land.pyx":648 */
  __pyx_v_v1 = (__pyx_v_v0 + __pyx_v_self->_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":649 */
  __pyx_v_v2 = (__pyx_v_v0 + (__pyx_v_self->_patch_size * __pyx_v_self->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/land.pyx":650 */
  __pyx_v_v3 = (__pyx_v_v2 + __pyx_v_self->_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":651 */
  __pyx_v_center = (__pyx_v_v0 + ((__pyx_v_v3 - __pyx_v_v0) >> 1));

  /* "/home/jiba/src/soya/model/land.pyx":652 */
  __pyx_v_patch->tri_top = __pyx_f_5_soya_land_create_tri(__pyx_v_center,__pyx_v_v1,__pyx_v_v0,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/land.pyx":653 */
  __pyx_v_patch->tri_left = __pyx_f_5_soya_land_create_tri(__pyx_v_center,__pyx_v_v0,__pyx_v_v2,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/land.pyx":654 */
  __pyx_v_patch->tri_right = __pyx_f_5_soya_land_create_tri(__pyx_v_center,__pyx_v_v3,__pyx_v_v1,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/land.pyx":655 */
  __pyx_v_patch->tri_bottom = __pyx_f_5_soya_land_create_tri(__pyx_v_center,__pyx_v_v2,__pyx_v_v3,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/land.pyx":656 */
  __pyx_v_patch->tri_top->left_neighbor = __pyx_v_patch->tri_right;

  /* "/home/jiba/src/soya/model/land.pyx":657 */
  __pyx_v_patch->tri_top->right_neighbor = __pyx_v_patch->tri_left;

  /* "/home/jiba/src/soya/model/land.pyx":658 */
  __pyx_v_patch->tri_top->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/land.pyx":659 */
  __pyx_v_patch->tri_left->left_neighbor = __pyx_v_patch->tri_top;

  /* "/home/jiba/src/soya/model/land.pyx":660 */
  __pyx_v_patch->tri_left->right_neighbor = __pyx_v_patch->tri_bottom;

  /* "/home/jiba/src/soya/model/land.pyx":661 */
  __pyx_v_patch->tri_left->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/land.pyx":662 */
  __pyx_v_patch->tri_right->left_neighbor = __pyx_v_patch->tri_bottom;

  /* "/home/jiba/src/soya/model/land.pyx":663 */
  __pyx_v_patch->tri_right->right_neighbor = __pyx_v_patch->tri_top;

  /* "/home/jiba/src/soya/model/land.pyx":664 */
  __pyx_v_patch->tri_right->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/land.pyx":665 */
  __pyx_v_patch->tri_bottom->left_neighbor = __pyx_v_patch->tri_left;

  /* "/home/jiba/src/soya/model/land.pyx":666 */
  __pyx_v_patch->tri_bottom->right_neighbor = __pyx_v_patch->tri_right;

  /* "/home/jiba/src/soya/model/land.pyx":667 */
  __pyx_v_patch->tri_bottom->base_neighbor = 0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._create_patch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_land_free_patchs;
static PyObject *__pyx_n_land;

static void __pyx_f_5_soya_5_Land__create_patchs(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_m);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  int __pyx_6;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":672 */
  __pyx_v_self->_max_level = ((exp_of_2(__pyx_v_self->_patch_size) * 2) - 1);

  /* "/home/jiba/src/soya/model/land.pyx":674 */
  __pyx_v_self->_nb_patch_width = ((int )((__pyx_v_self->_nb_vertex_width - 1) / __pyx_v_self->_patch_size));

  /* "/home/jiba/src/soya/model/land.pyx":675 */
  __pyx_v_self->_nb_patch_depth = ((int )((__pyx_v_self->_nb_vertex_depth - 1) / __pyx_v_self->_patch_size));

  /* "/home/jiba/src/soya/model/land.pyx":676 */
  __pyx_v_self->_nb_patchs = (__pyx_v_self->_nb_patch_width * __pyx_v_self->_nb_patch_depth);

  /* "/home/jiba/src/soya/model/land.pyx":677 */
  __pyx_1 = (__pyx_v_self->_patchs != 0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_land_free_patchs); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 677; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_land); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 677; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 677; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 677; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":678 */
  __pyx_v_self->_patchs = ((struct __pyx_t_5_soya__LandPatch (*))malloc((__pyx_v_self->_nb_patchs * (sizeof(struct __pyx_t_5_soya__LandPatch )))));

  /* "/home/jiba/src/soya/model/land.pyx":679 */
  __pyx_v_k = 0;

  /* "/home/jiba/src/soya/model/land.pyx":680 */
  __pyx_1 = __pyx_v_self->_nb_patch_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":681 */
    __pyx_5 = __pyx_v_self->_nb_patch_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":682 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_create_patch(__pyx_v_self,(__pyx_v_self->_patchs + __pyx_v_k),__pyx_v_i,__pyx_v_j,__pyx_v_self->_patch_size);

      /* "/home/jiba/src/soya/model/land.pyx":683 */
      __pyx_v_k = (__pyx_v_k + 1);
      __pyx_L5:;
    }
    __pyx_L6:;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":685 */
  __pyx_5 = __pyx_v_self->_nb_patch_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_5; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":686 */
    __pyx_1 = __pyx_v_self->_nb_patch_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":687 */
      __pyx_v_m = (__pyx_v_self->_patchs + (__pyx_v_i + (__pyx_v_j * __pyx_v_self->_nb_patch_width)));

      /* "/home/jiba/src/soya/model/land.pyx":688 */
      __pyx_6 = (__pyx_v_i > 0);
      if (__pyx_6) {
        __pyx_v_m->tri_left->base_neighbor = ((__pyx_v_self->_patchs + (__pyx_v_i - 1)) + (__pyx_v_j * __pyx_v_self->_nb_patch_width))->tri_right;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/model/land.pyx":689 */
      __pyx_6 = (__pyx_v_j > 0);
      if (__pyx_6) {
        __pyx_v_m->tri_top->base_neighbor = ((__pyx_v_self->_patchs + __pyx_v_i) + ((__pyx_v_j - 1) * __pyx_v_self->_nb_patch_width))->tri_bottom;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/home/jiba/src/soya/model/land.pyx":690 */
      __pyx_6 = (__pyx_v_i < (__pyx_v_self->_nb_patch_width - 1));
      if (__pyx_6) {
        __pyx_v_m->tri_right->base_neighbor = ((__pyx_v_self->_patchs + (__pyx_v_i + 1)) + (__pyx_v_j * __pyx_v_self->_nb_patch_width))->tri_left;
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "/home/jiba/src/soya/model/land.pyx":691 */
      __pyx_6 = (__pyx_v_j < (__pyx_v_self->_nb_patch_depth - 1));
      if (__pyx_6) {
        __pyx_v_m->tri_bottom->base_neighbor = ((__pyx_v_self->_patchs + __pyx_v_i) + ((__pyx_v_j + 1) * __pyx_v_self->_nb_patch_width))->tri_top;
        goto __pyx_L14;
      }
      __pyx_L14:;
      __pyx_L9:;
    }
    __pyx_L10:;
    __pyx_L7:;
  }
  __pyx_L8:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Land._create_patchs");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_5_Land__register_color(struct __pyx_obj_5_soya__Land *__pyx_v_self,float (*__pyx_v_color)) {
  float (*__pyx_v_c);
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":696 */
  __pyx_v_c = __pyx_v_self->_colors;

  /* "/home/jiba/src/soya/model/land.pyx":697 */
  __pyx_1 = __pyx_v_self->_nb_colors;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":698 */
    __pyx_2 = (fabs(((__pyx_v_color[0]) - (__pyx_v_c[0]))) < EPSILON);
    if (__pyx_2) {
      __pyx_2 = (fabs(((__pyx_v_color[1]) - (__pyx_v_c[1]))) < EPSILON);
      if (__pyx_2) {
        __pyx_2 = (fabs(((__pyx_v_color[2]) - (__pyx_v_c[2]))) < EPSILON);
        if (__pyx_2) {
          __pyx_2 = (fabs(((__pyx_v_color[3]) - (__pyx_v_c[3]))) < EPSILON);
        }
      }
    }
    if (__pyx_2) {
      __pyx_r = __pyx_v_i;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/land.pyx":702 */
    __pyx_v_c = (__pyx_v_c + 4);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":704 */
  __pyx_v_i = (__pyx_v_self->_nb_colors * 4);

  /* "/home/jiba/src/soya/model/land.pyx":705 */
  __pyx_v_self->_nb_colors = (__pyx_v_self->_nb_colors + 1);

  /* "/home/jiba/src/soya/model/land.pyx":706 */
  __pyx_v_self->_colors = ((float (*))realloc(__pyx_v_self->_colors,((__pyx_v_self->_nb_colors * 4) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/land.pyx":707 */
  memcpy((__pyx_v_self->_colors + __pyx_v_i),__pyx_v_color,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/land.pyx":708 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._register_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land_compute_shadow_color(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_compute_shadow_color(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light = 0;
  PyObject *__pyx_v_shadow_color = 0;
  int __pyx_v_i;
  int __pyx_v_nb;
  float (__pyx_v_color[4]);
  float (__pyx_v_cshadow_color[4]);
  float (*__pyx_v_ocolor);
  float (*__pyx_v_old_colors);
  int __pyx_v_scolor;
  int __pyx_v_wcolor;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  static char *__pyx_argnames[] = {"light","shadow_color",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_light, &__pyx_v_shadow_color)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_light);
  Py_INCREF(__pyx_v_shadow_color);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_light), __pyx_ptype_5_soya__Light, 1, "light")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 710; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/land.pyx":716 */
  __pyx_v_nb = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width * ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/land.pyx":717 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":719 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 719; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 719; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 719; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[0]) = __pyx_4;

  /* "/home/jiba/src/soya/model/land.pyx":720 */
  __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 720; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 720; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 720; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[1]) = __pyx_4;

  /* "/home/jiba/src/soya/model/land.pyx":721 */
  __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 721; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 721; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 721; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[2]) = __pyx_4;

  /* "/home/jiba/src/soya/model/land.pyx":722 */
  __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 722; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 722; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 722; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[3]) = __pyx_4;

  /* "/home/jiba/src/soya/model/land.pyx":725 */
  __pyx_v_old_colors = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors;

  /* "/home/jiba/src/soya/model/land.pyx":726 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors = 0;

  /* "/home/jiba/src/soya/model/land.pyx":727 */
  ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_colors = 0;

  /* "/home/jiba/src/soya/model/land.pyx":728 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_COLORED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":729 */
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_LAND_COLORED);

    /* "/home/jiba/src/soya/model/land.pyx":730 */
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors = ((int (*))malloc((__pyx_v_nb * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/land.pyx":731 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {
      (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = (-1);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/land.pyx":732 */
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_colors = 2;

    /* "/home/jiba/src/soya/model/land.pyx":733 */
    ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors = ((float (*))malloc((8 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/land.pyx":734 */
    __pyx_v_wcolor = 0;

    /* "/home/jiba/src/soya/model/land.pyx":735 */
    __pyx_v_scolor = 4;

    /* "/home/jiba/src/soya/model/land.pyx":736 */
    memcpy((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors + __pyx_v_wcolor),__pyx_v_5_soya_white,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/land.pyx":737 */
    memcpy((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors + __pyx_v_scolor),__pyx_v_cshadow_color,(4 * (sizeof(float ))));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":740 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":741 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_shadow_at(__pyx_v_light,(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertices + __pyx_v_i)->coord);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":742 */
      __pyx_1 = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) == (-1));
      if (__pyx_1) {
        (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = __pyx_v_scolor;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":744 */
        __pyx_v_ocolor = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors + (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]));

        /* "/home/jiba/src/soya/model/land.pyx":745 */
        (__pyx_v_color[0]) = ((__pyx_v_ocolor[0]) * (__pyx_v_cshadow_color[0]));

        /* "/home/jiba/src/soya/model/land.pyx":746 */
        (__pyx_v_color[1]) = ((__pyx_v_ocolor[1]) * (__pyx_v_cshadow_color[1]));

        /* "/home/jiba/src/soya/model/land.pyx":747 */
        (__pyx_v_color[2]) = ((__pyx_v_ocolor[2]) * (__pyx_v_cshadow_color[2]));

        /* "/home/jiba/src/soya/model/land.pyx":748 */
        (__pyx_v_color[3]) = ((__pyx_v_ocolor[3]) * (__pyx_v_cshadow_color[3]));

        /* "/home/jiba/src/soya/model/land.pyx":749 */
        (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_register_color(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_color);
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":751 */
      __pyx_1 = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) == (-1));
      if (__pyx_1) {
        (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = __pyx_v_wcolor;
        goto __pyx_L10;
      }
      /*else*/ {
        (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_register_color(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_colors + (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_vertex_colors[__pyx_v_i])));
      }
      __pyx_L10:;
    }
    __pyx_L8:;
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/land.pyx":753 */
  free(__pyx_v_old_colors);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Land.compute_shadow_color");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF(__pyx_v_shadow_color);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__tri_split(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  __pyx_t_5_soya_LandVertex (*__pyx_v_v);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":758 */
  __pyx_1 = (!__pyx_f_5_soya_land_tri_diamond(__pyx_v_tri));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_split(__pyx_v_self,__pyx_v_tri->base_neighbor);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":761 */
  __pyx_1 = (__pyx_v_tri->v2 < __pyx_v_tri->v3);
  if (__pyx_1) {
    __pyx_v_v = (__pyx_v_tri->v2 + ((__pyx_v_tri->v3 - __pyx_v_tri->v2) >> 1));
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_v_v = (__pyx_v_tri->v3 + ((__pyx_v_tri->v2 - __pyx_v_tri->v3) >> 1));
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":763 */
  __pyx_v_tri->left_child = __pyx_f_5_soya_land_create_child_tri(__pyx_v_v,__pyx_v_tri->v1,__pyx_v_tri->v2,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/land.pyx":764 */
  __pyx_v_tri->right_child = __pyx_f_5_soya_land_create_child_tri(__pyx_v_v,__pyx_v_tri->v3,__pyx_v_tri->v1,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/land.pyx":765 */
  __pyx_1 = (__pyx_v_tri->base_neighbor != 0);
  if (__pyx_1) {
    __pyx_f_5_soya_land_tri_force_split(__pyx_v_tri->base_neighbor,__pyx_v_v);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":766 */
  __pyx_f_5_soya_land_tri_update_neighbor_after_split(__pyx_v_tri);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_split");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_5_Land__tri_merge_child(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  struct __pyx_t_5_soya__LandTri (*__pyx_v_base);
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":771 */
  __pyx_v_base = __pyx_v_tri->base_neighbor;

  /* "/home/jiba/src/soya/model/land.pyx":772 */
  __pyx_1 = (__pyx_v_tri->left_child->level <= __pyx_v_tri->left_child->patch->level);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_base != 0);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_base->left_child->level <= __pyx_v_base->left_child->patch->level);
    }
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":775 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri->left_child);
  if (__pyx_1) {
    __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_merge_child(__pyx_v_self,__pyx_v_tri->left_child));
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":776 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri->right_child);
  if (__pyx_1) {
    __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_merge_child(__pyx_v_self,__pyx_v_tri->right_child));
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":777 */
  __pyx_1 = (__pyx_v_base != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":778 */
    __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_base->left_child);
    if (__pyx_1) {
      __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_merge_child(__pyx_v_self,__pyx_v_base->left_child));
    }
    if (__pyx_1) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/land.pyx":779 */
    __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_base->right_child);
    if (__pyx_1) {
      __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_merge_child(__pyx_v_self,__pyx_v_base->right_child));
    }
    if (__pyx_1) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":781 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->left_child->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_FORCE_PRESENCE);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":782 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/land.pyx":784 */
  __pyx_f_5_soya_land_tri_update_neighbor_after_merge(__pyx_v_tri);

  /* "/home/jiba/src/soya/model/land.pyx":785 */
  __pyx_1 = (__pyx_v_base != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":786 */
    __pyx_f_5_soya_land_tri_update_neighbor_after_merge(__pyx_v_base);

    /* "/home/jiba/src/soya/model/land.pyx":787 */
    __pyx_f_5_soya_land_tri_drop(__pyx_v_base->left_child);

    /* "/home/jiba/src/soya/model/land.pyx":788 */
    __pyx_f_5_soya_land_tri_drop(__pyx_v_base->right_child);

    /* "/home/jiba/src/soya/model/land.pyx":789 */
    __pyx_v_base->left_child = 0;
    __pyx_v_base->right_child = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/land.pyx":791 */
  __pyx_f_5_soya_land_tri_drop(__pyx_v_tri->left_child);

  /* "/home/jiba/src/soya/model/land.pyx":792 */
  __pyx_f_5_soya_land_tri_drop(__pyx_v_tri->right_child);

  /* "/home/jiba/src/soya/model/land.pyx":793 */
  __pyx_v_tri->left_child = 0;
  __pyx_v_tri->right_child = 0;

  /* "/home/jiba/src/soya/model/land.pyx":794 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_merge_child");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__tri_set_level(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri),char __pyx_v_level) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":797 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":798 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_level);

    /* "/home/jiba/src/soya/model/land.pyx":799 */
    __pyx_1 = (__pyx_v_tri->left_child == 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_tri,__pyx_v_level);
      goto __pyx_L3;
    }
    /*else*/ {
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_level);
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":802 */
    __pyx_1 = (__pyx_v_tri->level > __pyx_v_level);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_tri->parent != 0);
    }
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_merge_child(__pyx_v_self,__pyx_v_tri->parent);
      goto __pyx_L4;
    }
    __pyx_1 = (__pyx_v_tri->level < __pyx_v_level);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":804 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_split(__pyx_v_self,__pyx_v_tri);

      /* "/home/jiba/src/soya/model/land.pyx":805 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_level);

      /* "/home/jiba/src/soya/model/land.pyx":806 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_level);
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_set_level");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__patch_set_level(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch),char __pyx_v_level) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":809 */
  __pyx_1 = (__pyx_v_patch->level != __pyx_v_level);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":810 */
    __pyx_v_patch->level = __pyx_v_level;

    /* "/home/jiba/src/soya/model/land.pyx":811 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_patch->tri_top,__pyx_v_level);

    /* "/home/jiba/src/soya/model/land.pyx":812 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_patch->tri_left,__pyx_v_level);

    /* "/home/jiba/src/soya/model/land.pyx":813 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_patch->tri_right,__pyx_v_level);

    /* "/home/jiba/src/soya/model/land.pyx":814 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_set_level(__pyx_v_self,__pyx_v_patch->tri_bottom,__pyx_v_level);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._patch_set_level");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_5_Land__patch_update(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch),__pyx_t_5_soya_Frustum (*__pyx_v_frustum),float (*__pyx_v_frustum_box)) {
  char __pyx_v_level;
  float __pyx_v_d;
  float __pyx_v_r;
  float (*__pyx_v_v1);
  float (*__pyx_v_v2);
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":821 */
  __pyx_v_v1 = __pyx_v_patch->tri_top->v3->coord;

  /* "/home/jiba/src/soya/model/land.pyx":822 */
  __pyx_v_v2 = __pyx_v_patch->tri_bottom->v3->coord;

  /* "/home/jiba/src/soya/model/land.pyx":823 */
  __pyx_1 = ((__pyx_v_frustum_box[0]) > (__pyx_v_v2[0]));
  if (!__pyx_1) {
    __pyx_1 = ((__pyx_v_frustum_box[2]) < (__pyx_v_v1[0]));
    if (!__pyx_1) {
      __pyx_1 = ((__pyx_v_frustum_box[1]) > (__pyx_v_v2[2]));
      if (!__pyx_1) {
        __pyx_1 = ((__pyx_v_frustum_box[3]) < (__pyx_v_v1[2]));
        if (!__pyx_1) {
          __pyx_1 = (!sphere_in_frustum(__pyx_v_frustum,__pyx_v_patch->sphere));
        }
      }
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":824 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_patch_set_level(__pyx_v_self,__pyx_v_patch,0);

    /* "/home/jiba/src/soya/model/land.pyx":825 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":827 */
    __pyx_v_d = point_distance_to(__pyx_v_patch->sphere,__pyx_v_frustum->position);

    /* "/home/jiba/src/soya/model/land.pyx":828 */
    __pyx_v_r = ((__pyx_v_patch->sphere[3]) * __pyx_v_self->_split_factor);

    /* "/home/jiba/src/soya/model/land.pyx":829 */
    __pyx_1 = (__pyx_v_d <= __pyx_v_r);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_patch_set_level(__pyx_v_self,__pyx_v_patch,__pyx_v_self->_max_level);
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":831 */
      __pyx_v_level = ((char )((__pyx_v_self->_max_level + 1) - ((int )(__pyx_v_d / __pyx_v_r))));

      /* "/home/jiba/src/soya/model/land.pyx":832 */
      __pyx_1 = (__pyx_v_level < 0);
      if (__pyx_1) {
        __pyx_v_level = 0;
        goto __pyx_L4;
      }
      __pyx_L4:;

      /* "/home/jiba/src/soya/model/land.pyx":833 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_patch_set_level(__pyx_v_self,__pyx_v_patch,__pyx_v_level);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/land.pyx":834 */
    __pyx_r = 1;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._patch_update");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__tri_force_presence(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri),__pyx_t_5_soya_LandVertex (*__pyx_v_v)) {
  float (__pyx_v_u[2]);
  float (__pyx_v_w[2]);
  float __pyx_v_k;
  float __pyx_v_m;
  float __pyx_v_f;
  float __pyx_v_x;
  float __pyx_v_z;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":839 */
  __pyx_1 = (__pyx_v_v == __pyx_v_tri->v1);
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_v == __pyx_v_tri->v2);
    if (!__pyx_1) {
      __pyx_1 = (__pyx_v_v == __pyx_v_tri->v3);
    }
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":840 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":841 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_v);

    /* "/home/jiba/src/soya/model/land.pyx":842 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_v);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":844 */
    (__pyx_v_u[0]) = ((__pyx_v_tri->v2->coord[0]) - (__pyx_v_tri->v1->coord[0]));

    /* "/home/jiba/src/soya/model/land.pyx":845 */
    (__pyx_v_u[1]) = ((__pyx_v_tri->v2->coord[2]) - (__pyx_v_tri->v1->coord[2]));

    /* "/home/jiba/src/soya/model/land.pyx":846 */
    (__pyx_v_w[0]) = ((__pyx_v_tri->v3->coord[0]) - (__pyx_v_tri->v1->coord[0]));

    /* "/home/jiba/src/soya/model/land.pyx":847 */
    (__pyx_v_w[1]) = ((__pyx_v_tri->v3->coord[2]) - (__pyx_v_tri->v1->coord[2]));

    /* "/home/jiba/src/soya/model/land.pyx":848 */
    __pyx_v_x = ((__pyx_v_v->coord[0]) - (__pyx_v_tri->v1->coord[0]));

    /* "/home/jiba/src/soya/model/land.pyx":849 */
    __pyx_v_z = ((__pyx_v_v->coord[2]) - (__pyx_v_tri->v1->coord[2]));

    /* "/home/jiba/src/soya/model/land.pyx":850 */
    __pyx_v_f = (1.0 / (((__pyx_v_u[0]) * (__pyx_v_w[1])) - ((__pyx_v_u[1]) * (__pyx_v_w[0]))));

    /* "/home/jiba/src/soya/model/land.pyx":851 */
    __pyx_v_m = ((((__pyx_v_u[0]) * __pyx_v_z) - ((__pyx_v_u[1]) * __pyx_v_x)) * __pyx_v_f);

    /* "/home/jiba/src/soya/model/land.pyx":852 */
    __pyx_v_k = ((((__pyx_v_w[1]) * __pyx_v_x) - ((__pyx_v_w[0]) * __pyx_v_z)) * __pyx_v_f);

    /* "/home/jiba/src/soya/model/land.pyx":853 */
    __pyx_1 = (__pyx_v_m >= 0.0);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_m <= 1.0);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_k >= 0.0);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_k <= 1.0);
          if (__pyx_1) {
            __pyx_1 = ((__pyx_v_k + __pyx_v_m) <= 1.0);
          }
        }
      }
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":854 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_split(__pyx_v_self,__pyx_v_tri);

      /* "/home/jiba/src/soya/model/land.pyx":855 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_v);

      /* "/home/jiba/src/soya/model/land.pyx":856 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_v);
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_force_presence");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__force_presence(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  __pyx_t_5_soya_LandVertex (*__pyx_v_v);
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch);
  int __pyx_v_a;
  int __pyx_v_b;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_1;
  int __pyx_2;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":862 */
  __pyx_1 = __pyx_v_self->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":863 */
    __pyx_2 = __pyx_v_self->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":864 */
      __pyx_3 = ((__pyx_v_self->_vertex_options[(__pyx_v_i + (__pyx_v_j * __pyx_v_self->_nb_vertex_width))]) & __pyx_e_5_soya_LAND_VERTEX_FORCE_PRESENCE);
      if (__pyx_3) {

        /* "/home/jiba/src/soya/model/land.pyx":865 */
        __pyx_v_a = ((int )(((float )__pyx_v_i) / __pyx_v_self->_patch_size));

        /* "/home/jiba/src/soya/model/land.pyx":866 */
        __pyx_v_b = ((int )(((float )__pyx_v_j) / __pyx_v_self->_patch_size));

        /* "/home/jiba/src/soya/model/land.pyx":867 */
        __pyx_3 = (__pyx_v_a >= __pyx_v_self->_nb_patch_width);
        if (__pyx_3) {
          __pyx_v_a = (__pyx_v_self->_nb_patch_width - 1);
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/model/land.pyx":868 */
        __pyx_3 = (__pyx_v_b >= __pyx_v_self->_nb_patch_depth);
        if (__pyx_3) {
          __pyx_v_b = (__pyx_v_self->_nb_patch_depth - 1);
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/model/land.pyx":869 */
        __pyx_v_patch = ((__pyx_v_self->_patchs + __pyx_v_a) + (__pyx_v_b * __pyx_v_self->_nb_patch_width));

        /* "/home/jiba/src/soya/model/land.pyx":870 */
        __pyx_v_v = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_i,__pyx_v_j);

        /* "/home/jiba/src/soya/model/land.pyx":871 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_patch->tri_top,__pyx_v_v);

        /* "/home/jiba/src/soya/model/land.pyx":872 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_patch->tri_left,__pyx_v_v);

        /* "/home/jiba/src/soya/model/land.pyx":873 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_patch->tri_right,__pyx_v_v);

        /* "/home/jiba/src/soya/model/land.pyx":874 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_force_presence(__pyx_v_self,__pyx_v_patch->tri_bottom,__pyx_v_v);
        goto __pyx_L6;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._force_presence");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__tri_batch(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri),__pyx_t_5_soya_Frustum (*__pyx_v_frustum)) {
  struct __pyx_t_5_soya__Pack (*__pyx_v_p);
  struct __pyx_t_5_soya__Pack (*__pyx_v_p1);
  struct __pyx_t_5_soya__Pack (*__pyx_v_p2);
  struct __pyx_t_5_soya__Pack (*__pyx_v_p3);
  struct __pyx_t_5_soya__Pack (*__pyx_v_p4);
  int __pyx_v_o1;
  int __pyx_v_o2;
  int __pyx_v_o3;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":881 */
  __pyx_1 = sphere_in_frustum(__pyx_v_frustum,__pyx_v_tri->sphere);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":882 */
    __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":883 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_batch(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_frustum);

      /* "/home/jiba/src/soya/model/land.pyx":884 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_batch(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_frustum);
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":886 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":887 */
        __pyx_v_o1 = (__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]);

        /* "/home/jiba/src/soya/model/land.pyx":888 */
        __pyx_v_o2 = (__pyx_v_self->_vertex_options[(__pyx_v_tri->v2 - __pyx_v_self->_vertices)]);

        /* "/home/jiba/src/soya/model/land.pyx":889 */
        __pyx_v_o3 = (__pyx_v_self->_vertex_options[(__pyx_v_tri->v3 - __pyx_v_self->_vertices)]);

        /* "/home/jiba/src/soya/model/land.pyx":890 */
        __pyx_1 = (__pyx_v_o1 & __pyx_e_5_soya_LAND_VERTEX_HIDDEN);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_o2 & __pyx_e_5_soya_LAND_VERTEX_HIDDEN);
          if (__pyx_1) {
            __pyx_1 = (__pyx_v_o3 & __pyx_e_5_soya_LAND_VERTEX_HIDDEN);
          }
        }
        if (__pyx_1) {
          goto __pyx_L0;
          goto __pyx_L5;
        }
        __pyx_L5:;

        /* "/home/jiba/src/soya/model/land.pyx":893 */
        __pyx_1 = (__pyx_v_o1 & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
        if (!__pyx_1) {
          __pyx_1 = (__pyx_v_o2 & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
          if (!__pyx_1) {
            __pyx_1 = (__pyx_v_o3 & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
          }
        }
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/land.pyx":895 */
          __pyx_v_p1 = __pyx_f_5_soya_pack_get_secondpass(__pyx_v_tri->v1->pack);

          /* "/home/jiba/src/soya/model/land.pyx":896 */
          __pyx_v_p2 = __pyx_f_5_soya_pack_get_secondpass(__pyx_v_tri->v2->pack);

          /* "/home/jiba/src/soya/model/land.pyx":897 */
          __pyx_v_p3 = __pyx_f_5_soya_pack_get_secondpass(__pyx_v_tri->v3->pack);

          /* "/home/jiba/src/soya/model/land.pyx":898 */
          __pyx_1 = (__pyx_v_p1 < __pyx_v_p2);
          if (__pyx_1) {
            __pyx_v_p = __pyx_v_p1;
            goto __pyx_L7;
          }
          /*else*/ {
            __pyx_v_p = __pyx_v_p2;
          }
          __pyx_L7:;

          /* "/home/jiba/src/soya/model/land.pyx":900 */
          __pyx_1 = (__pyx_v_p3 < __pyx_v_p);
          if (__pyx_1) {
            __pyx_v_p = __pyx_v_p3;
            goto __pyx_L8;
          }
          __pyx_L8:;

          /* "/home/jiba/src/soya/model/land.pyx":901 */
          __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p),__pyx_v_tri);

          /* "/home/jiba/src/soya/model/land.pyx":902 */
          __pyx_1 = (__pyx_v_p1 != __pyx_v_p);
          if (__pyx_1) {
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);
            goto __pyx_L9;
          }
          __pyx_L9:;

          /* "/home/jiba/src/soya/model/land.pyx":903 */
          __pyx_1 = (__pyx_v_p2 != __pyx_v_p);
          if (__pyx_1) {
            __pyx_1 = (__pyx_v_p2 != __pyx_v_p1);
          }
          if (__pyx_1) {
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p2,__pyx_v_tri);
            goto __pyx_L10;
          }
          __pyx_L10:;

          /* "/home/jiba/src/soya/model/land.pyx":904 */
          __pyx_1 = (__pyx_v_p3 != __pyx_v_p);
          if (__pyx_1) {
            __pyx_1 = (__pyx_v_p3 != __pyx_v_p1);
            if (__pyx_1) {
              __pyx_1 = (__pyx_v_p3 != __pyx_v_p2);
            }
          }
          if (__pyx_1) {
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p3,__pyx_v_tri);
            goto __pyx_L11;
          }
          __pyx_L11:;

          /* "/home/jiba/src/soya/model/land.pyx":905 */
          goto __pyx_L0;
          goto __pyx_L6;
        }
        __pyx_L6:;
        goto __pyx_L4;
      }
      __pyx_L4:;

      /* "/home/jiba/src/soya/model/land.pyx":907 */
      __pyx_v_p1 = __pyx_v_tri->v1->pack;

      /* "/home/jiba/src/soya/model/land.pyx":908 */
      __pyx_v_p2 = __pyx_v_tri->v2->pack;

      /* "/home/jiba/src/soya/model/land.pyx":909 */
      __pyx_v_p3 = __pyx_v_tri->v3->pack;

      /* "/home/jiba/src/soya/model/land.pyx":912 */
      __pyx_1 = (__pyx_v_p1 == __pyx_v_p2);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":913 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/land.pyx":914 */
        __pyx_1 = (__pyx_v_p3 != __pyx_v_p1);
        if (__pyx_1) {
          __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p3),__pyx_v_tri);
          goto __pyx_L13;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }
      __pyx_1 = (__pyx_v_p1 == __pyx_v_p3);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":916 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/land.pyx":917 */
        __pyx_1 = (__pyx_v_p2 != __pyx_v_p1);
        if (__pyx_1) {
          __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p2),__pyx_v_tri);
          goto __pyx_L14;
        }
        __pyx_L14:;
        goto __pyx_L12;
      }
      __pyx_1 = (__pyx_v_p2 == __pyx_v_p3);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":919 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p2,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/land.pyx":920 */
        __pyx_1 = (__pyx_v_p1 != __pyx_v_p2);
        if (__pyx_1) {
          __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p1),__pyx_v_tri);
          goto __pyx_L15;
        }
        __pyx_L15:;
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":923 */
        __pyx_1 = (__pyx_v_tri->base_neighbor != 0);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_tri->v2 == __pyx_v_tri->base_neighbor->v3);
          if (__pyx_1) {
            __pyx_1 = (__pyx_v_tri->v3 == __pyx_v_tri->base_neighbor->v2);
          }
        }
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/land.pyx":924 */
          __pyx_v_p4 = __pyx_v_tri->base_neighbor->v1->pack;

          /* "/home/jiba/src/soya/model/land.pyx":925 */
          __pyx_1 = (__pyx_v_p2 == __pyx_v_p4);
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/land.pyx":926 */
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p2,__pyx_v_tri);

            /* "/home/jiba/src/soya/model/land.pyx":927 */
            __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p1),__pyx_v_tri);

            /* "/home/jiba/src/soya/model/land.pyx":928 */
            __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p3),__pyx_v_tri);

            /* "/home/jiba/src/soya/model/land.pyx":929 */
            goto __pyx_L0;
            goto __pyx_L17;
          }
          __pyx_1 = (__pyx_v_p3 == __pyx_v_p4);
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/land.pyx":931 */
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p3,__pyx_v_tri);

            /* "/home/jiba/src/soya/model/land.pyx":932 */
            __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p1),__pyx_v_tri);

            /* "/home/jiba/src/soya/model/land.pyx":933 */
            __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p2),__pyx_v_tri);

            /* "/home/jiba/src/soya/model/land.pyx":934 */
            goto __pyx_L0;
            goto __pyx_L17;
          }
          __pyx_L17:;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "/home/jiba/src/soya/model/land.pyx":935 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/land.pyx":936 */
        __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p2),__pyx_v_tri);

        /* "/home/jiba/src/soya/model/land.pyx":937 */
        __pyx_f_5_soya_pack_batch_face(__pyx_f_5_soya_pack_get_secondpass(__pyx_v_p3),__pyx_v_tri);
      }
      __pyx_L12:;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__patch_batch(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch),__pyx_t_5_soya_Frustum (*__pyx_v_frustum)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":940 */
  __pyx_1 = sphere_in_frustum(__pyx_v_frustum,__pyx_v_patch->sphere);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":941 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_batch(__pyx_v_self,__pyx_v_patch->tri_top,__pyx_v_frustum);

    /* "/home/jiba/src/soya/model/land.pyx":942 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_batch(__pyx_v_self,__pyx_v_patch->tri_left,__pyx_v_frustum);

    /* "/home/jiba/src/soya/model/land.pyx":943 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_batch(__pyx_v_self,__pyx_v_patch->tri_right,__pyx_v_frustum);

    /* "/home/jiba/src/soya/model/land.pyx":944 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_batch(__pyx_v_self,__pyx_v_patch->tri_bottom,__pyx_v_frustum);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._patch_batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__batch(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch);
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  float (*__pyx_v_ptr);
  float (__pyx_v_frustum_box[4]);
  int __pyx_v_i;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/land.pyx":947 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":949 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":951 */
  multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base._matrix);

  /* "/home/jiba/src/soya/model/land.pyx":952 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/model/land.pyx":962 */
  __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/land.pyx":963 */
  __pyx_v_ptr = __pyx_v_frustum->points;

  /* "/home/jiba/src/soya/model/land.pyx":964 */
  (__pyx_v_frustum_box[0]) = (__pyx_v_ptr[0]);

  /* "/home/jiba/src/soya/model/land.pyx":965 */
  (__pyx_v_frustum_box[1]) = (__pyx_v_ptr[2]);

  /* "/home/jiba/src/soya/model/land.pyx":966 */
  (__pyx_v_frustum_box[2]) = (__pyx_v_ptr[0]);

  /* "/home/jiba/src/soya/model/land.pyx":967 */
  (__pyx_v_frustum_box[3]) = (__pyx_v_ptr[2]);

  /* "/home/jiba/src/soya/model/land.pyx":968 */
  __pyx_v_i = 3;

  /* "/home/jiba/src/soya/model/land.pyx":969 */
  while (1) {
    __pyx_L4:;
    __pyx_1 = (__pyx_v_i < 24);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/land.pyx":970 */
    __pyx_1 = ((__pyx_v_ptr[__pyx_v_i]) < (__pyx_v_frustum_box[0]));
    if (__pyx_1) {
      (__pyx_v_frustum_box[0]) = (__pyx_v_ptr[__pyx_v_i]);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/land.pyx":971 */
    __pyx_1 = ((__pyx_v_ptr[__pyx_v_i]) > (__pyx_v_frustum_box[2]));
    if (__pyx_1) {
      (__pyx_v_frustum_box[2]) = (__pyx_v_ptr[__pyx_v_i]);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/land.pyx":972 */
    __pyx_v_i = (__pyx_v_i + 2);

    /* "/home/jiba/src/soya/model/land.pyx":973 */
    __pyx_1 = ((__pyx_v_ptr[__pyx_v_i]) < (__pyx_v_frustum_box[1]));
    if (__pyx_1) {
      (__pyx_v_frustum_box[1]) = (__pyx_v_ptr[__pyx_v_i]);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/land.pyx":974 */
    __pyx_1 = ((__pyx_v_ptr[__pyx_v_i]) > (__pyx_v_frustum_box[3]));
    if (__pyx_1) {
      (__pyx_v_frustum_box[3]) = (__pyx_v_ptr[__pyx_v_i]);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/model/land.pyx":975 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":977 */
  __pyx_v_patch = __pyx_v_self->_patchs;

  /* "/home/jiba/src/soya/model/land.pyx":978 */
  __pyx_1 = __pyx_v_self->_nb_patchs;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":979 */
    __pyx_v_patch->visible = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_patch_update(__pyx_v_self,__pyx_v_patch,__pyx_v_frustum,__pyx_v_frustum_box);

    /* "/home/jiba/src/soya/model/land.pyx":980 */
    __pyx_v_patch = (__pyx_v_patch + 1);
    __pyx_L10:;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/land.pyx":982 */
  __pyx_v_patch = __pyx_v_self->_patchs;

  /* "/home/jiba/src/soya/model/land.pyx":983 */
  __pyx_1 = __pyx_v_self->_nb_patchs;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":984 */
    __pyx_2 = __pyx_v_patch->visible;
    if (__pyx_2) {
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_patch_batch(__pyx_v_self,__pyx_v_patch,__pyx_v_frustum);
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/home/jiba/src/soya/model/land.pyx":985 */
    __pyx_v_patch = (__pyx_v_patch + 1);
    __pyx_L12:;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/model/land.pyx":987 */
  __pyx_f_5_soya_pack_batch_end(((PyObject *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_5_Land__vertex_render_special(struct __pyx_obj_5_soya__Land *__pyx_v_self,__pyx_t_5_soya_LandVertex (*__pyx_v_vertex)) {
  float (__pyx_v_ccc[4]);
  float (*__pyx_v_color);
  int __pyx_v_index;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":997 */
  __pyx_v_index = (__pyx_v_vertex - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/land.pyx":998 */
  __pyx_v_color = (__pyx_v_self->_colors + __pyx_v_index);

  /* "/home/jiba/src/soya/model/land.pyx":1000 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_self->_vertex_options[__pyx_v_index]) & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
    if (__pyx_1) {
      __pyx_2 = (PyObject *)__pyx_v_vertex->pack->material_id;
      Py_INCREF((PyObject *)__pyx_2);
      __pyx_3 = __pyx_2 == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
      Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;
      __pyx_1 = (!__pyx_3);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1001 */
    (__pyx_v_ccc[0]) = (__pyx_v_color[0]);

    /* "/home/jiba/src/soya/model/land.pyx":1002 */
    (__pyx_v_ccc[1]) = (__pyx_v_color[1]);

    /* "/home/jiba/src/soya/model/land.pyx":1003 */
    (__pyx_v_ccc[2]) = (__pyx_v_color[2]);

    /* "/home/jiba/src/soya/model/land.pyx":1004 */
    (__pyx_v_ccc[3]) = 0.0;

    /* "/home/jiba/src/soya/model/land.pyx":1005 */
    __pyx_v_5_soya_land_drawColor(__pyx_v_ccc);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_5_soya_land_drawColor(__pyx_v_color);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1008 */
  glTexCoord2fv(__pyx_v_vertex->texcoord);

  /* "/home/jiba/src/soya/model/land.pyx":1009 */
  glNormal3fv(__pyx_v_vertex->normal);

  /* "/home/jiba/src/soya/model/land.pyx":1010 */
  glVertex3fv(__pyx_v_vertex->coord);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Land._vertex_render_special");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__tri_render_middle(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  float (__pyx_v_ccc[4]);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v);
  float (*__pyx_v_color);
  float (*__pyx_v_color2);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1018 */
  __pyx_1 = (__pyx_v_self->_colors == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1019 */
    __pyx_v_color = __pyx_v_5_soya_renderer->current_material->_diffuse;

    /* "/home/jiba/src/soya/model/land.pyx":1020 */
    (__pyx_v_ccc[0]) = (__pyx_v_color[0]);

    /* "/home/jiba/src/soya/model/land.pyx":1021 */
    (__pyx_v_ccc[1]) = (__pyx_v_color[1]);

    /* "/home/jiba/src/soya/model/land.pyx":1022 */
    (__pyx_v_ccc[2]) = (__pyx_v_color[2]);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1024 */
    __pyx_v_color = (__pyx_v_self->_colors + (__pyx_v_tri->v2 - __pyx_v_self->_vertices));

    /* "/home/jiba/src/soya/model/land.pyx":1025 */
    __pyx_v_color2 = (__pyx_v_self->_colors + (__pyx_v_tri->v3 - __pyx_v_self->_vertices));

    /* "/home/jiba/src/soya/model/land.pyx":1026 */
    (__pyx_v_ccc[0]) = (((__pyx_v_color[0]) + (__pyx_v_color2[0])) * 0.5);

    /* "/home/jiba/src/soya/model/land.pyx":1027 */
    (__pyx_v_ccc[1]) = (((__pyx_v_color[1]) + (__pyx_v_color2[1])) * 0.5);

    /* "/home/jiba/src/soya/model/land.pyx":1028 */
    (__pyx_v_ccc[2]) = (((__pyx_v_color[2]) + (__pyx_v_color2[2])) * 0.5);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1029 */
  (__pyx_v_ccc[3]) = 0.0;

  /* "/home/jiba/src/soya/model/land.pyx":1030 */
  __pyx_v_5_soya_land_drawColor(__pyx_v_ccc);

  /* "/home/jiba/src/soya/model/land.pyx":1032 */
  __pyx_1 = (__pyx_v_tri->level == __pyx_v_self->_max_level);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1033 */
    glTexCoord2f((((__pyx_v_tri->v2->texcoord[0]) + (__pyx_v_tri->v3->texcoord[0])) * 0.5),(((__pyx_v_tri->v2->texcoord[1]) + (__pyx_v_tri->v3->texcoord[1])) * 0.5));

    /* "/home/jiba/src/soya/model/land.pyx":1035 */
    glNormal3f((((__pyx_v_tri->v2->normal[0]) + (__pyx_v_tri->v3->normal[0])) * 0.5),(((__pyx_v_tri->v2->normal[1]) + (__pyx_v_tri->v3->normal[1])) * 0.5),(((__pyx_v_tri->v2->normal[2]) + (__pyx_v_tri->v3->normal[2])) * 0.5));

    /* "/home/jiba/src/soya/model/land.pyx":1038 */
    glVertex3f((((__pyx_v_tri->v2->coord[0]) + (__pyx_v_tri->v3->coord[0])) * 0.5),(((__pyx_v_tri->v2->coord[1]) + (__pyx_v_tri->v3->coord[1])) * 0.5),(((__pyx_v_tri->v2->coord[2]) + (__pyx_v_tri->v3->coord[2])) * 0.5));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1042 */
    __pyx_1 = (__pyx_v_tri->v2 < __pyx_v_tri->v3);
    if (__pyx_1) {
      __pyx_v_v = (__pyx_v_tri->v2 + ((__pyx_v_tri->v3 - __pyx_v_tri->v2) >> 1));
      goto __pyx_L4;
    }
    /*else*/ {
      __pyx_v_v = (__pyx_v_tri->v3 + ((__pyx_v_tri->v2 - __pyx_v_tri->v3) >> 1));
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/land.pyx":1045 */
    glTexCoord2fv(__pyx_v_v->texcoord);

    /* "/home/jiba/src/soya/model/land.pyx":1046 */
    glNormal3fv(__pyx_v_v->normal);

    /* "/home/jiba/src/soya/model/land.pyx":1047 */
    glVertex3fv(__pyx_v_v->coord);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_render_middle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__tri_render_secondpass(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri)) {
  float (__pyx_v_ccc[4]);
  float (*__pyx_v_color);
  int __pyx_v_index;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1054 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS));
  if (!__pyx_1) {
    __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
    if (!__pyx_2) {
      __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
      if (!__pyx_2) {
        __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_ALPHA);
      }
    }
    __pyx_1 = (!__pyx_2);
  }
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_tri->base_neighbor != 0);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_tri->v2 == __pyx_v_tri->base_neighbor->v3);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_tri->v3 == __pyx_v_tri->base_neighbor->v2);
      }
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1060 */
    __pyx_3 = (PyObject *)__pyx_v_tri->v2->pack->material_id;
    Py_INCREF((PyObject *)__pyx_3);
    __pyx_2 = __pyx_3 == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
    Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
    if (__pyx_2) {
      __pyx_2 = (__pyx_v_tri->v2->pack != __pyx_v_tri->v1->pack);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_tri->v2->pack != __pyx_v_tri->v3->pack);
        if (__pyx_2) {
          __pyx_2 = (__pyx_v_tri->v2->pack != __pyx_v_tri->base_neighbor->v1->pack);
        }
      }
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/land.pyx":1064 */
      __pyx_v_index = (__pyx_v_tri->v1 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/land.pyx":1064 */
      __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/land.pyx":1064 */
      glTexCoord2fv(__pyx_v_tri->v1->texcoord);

      /* "/home/jiba/src/soya/model/land.pyx":1064 */
      glNormal3fv(__pyx_v_tri->v1->normal);

      /* "/home/jiba/src/soya/model/land.pyx":1064 */
      glVertex3fv(__pyx_v_tri->v1->coord);

      /* "/home/jiba/src/soya/model/land.pyx":1065 */
      __pyx_v_index = (__pyx_v_tri->v2 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/land.pyx":1065 */
      __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/land.pyx":1065 */
      glTexCoord2fv(__pyx_v_tri->v2->texcoord);

      /* "/home/jiba/src/soya/model/land.pyx":1065 */
      glNormal3fv(__pyx_v_tri->v2->normal);

      /* "/home/jiba/src/soya/model/land.pyx":1065 */
      glVertex3fv(__pyx_v_tri->v2->coord);

      /* "/home/jiba/src/soya/model/land.pyx":1066 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_render_middle(__pyx_v_self,__pyx_v_tri);

      /* "/home/jiba/src/soya/model/land.pyx":1067 */
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_3 = (PyObject *)__pyx_v_tri->v3->pack->material_id;
    Py_INCREF((PyObject *)__pyx_3);
    __pyx_1 = __pyx_3 == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
    Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_tri->v3->pack != __pyx_v_tri->v1->pack);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_tri->v3->pack != __pyx_v_tri->v2->pack);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_tri->v3->pack != __pyx_v_tri->base_neighbor->v1->pack);
        }
      }
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":1073 */
      __pyx_v_index = (__pyx_v_tri->v1 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/land.pyx":1073 */
      __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/land.pyx":1073 */
      glTexCoord2fv(__pyx_v_tri->v1->texcoord);

      /* "/home/jiba/src/soya/model/land.pyx":1073 */
      glNormal3fv(__pyx_v_tri->v1->normal);

      /* "/home/jiba/src/soya/model/land.pyx":1073 */
      glVertex3fv(__pyx_v_tri->v1->coord);

      /* "/home/jiba/src/soya/model/land.pyx":1074 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_render_middle(__pyx_v_self,__pyx_v_tri);

      /* "/home/jiba/src/soya/model/land.pyx":1075 */
      __pyx_v_index = (__pyx_v_tri->v3 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/land.pyx":1075 */
      __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/land.pyx":1075 */
      glTexCoord2fv(__pyx_v_tri->v3->texcoord);

      /* "/home/jiba/src/soya/model/land.pyx":1075 */
      glNormal3fv(__pyx_v_tri->v3->normal);

      /* "/home/jiba/src/soya/model/land.pyx":1075 */
      glVertex3fv(__pyx_v_tri->v3->coord);

      /* "/home/jiba/src/soya/model/land.pyx":1076 */
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1078 */
  __pyx_v_index = (__pyx_v_tri->v1 - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/land.pyx":1079 */
  __pyx_3 = (PyObject *)__pyx_v_tri->v1->pack->material_id;
  Py_INCREF((PyObject *)__pyx_3);
  __pyx_2 = __pyx_3 == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
  Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
  if (__pyx_2) {
    __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":1081 */
  glTexCoord2fv(__pyx_v_tri->v1->texcoord);

  /* "/home/jiba/src/soya/model/land.pyx":1082 */
  glNormal3fv(__pyx_v_tri->v1->normal);

  /* "/home/jiba/src/soya/model/land.pyx":1083 */
  glVertex3fv(__pyx_v_tri->v1->coord);

  /* "/home/jiba/src/soya/model/land.pyx":1086 */
  __pyx_v_index = (__pyx_v_tri->v2 - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/land.pyx":1087 */
  __pyx_3 = (PyObject *)__pyx_v_tri->v2->pack->material_id;
  Py_INCREF((PyObject *)__pyx_3);
  __pyx_1 = __pyx_3 == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
  Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
  if (__pyx_1) {
    __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);
    goto __pyx_L5;
  }
  /*else*/ {
    __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":1089 */
  glTexCoord2fv(__pyx_v_tri->v2->texcoord);

  /* "/home/jiba/src/soya/model/land.pyx":1090 */
  glNormal3fv(__pyx_v_tri->v2->normal);

  /* "/home/jiba/src/soya/model/land.pyx":1091 */
  glVertex3fv(__pyx_v_tri->v2->coord);

  /* "/home/jiba/src/soya/model/land.pyx":1094 */
  __pyx_v_index = (__pyx_v_tri->v3 - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/land.pyx":1095 */
  __pyx_3 = (PyObject *)__pyx_v_tri->v3->pack->material_id;
  Py_INCREF((PyObject *)__pyx_3);
  __pyx_2 = __pyx_3 == ((PyObject *)__pyx_v_5_soya_renderer->current_material);
  Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
  if (__pyx_2) {
    __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);
    goto __pyx_L6;
  }
  /*else*/ {
    __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/land.pyx":1097 */
  glTexCoord2fv(__pyx_v_tri->v3->texcoord);

  /* "/home/jiba/src/soya/model/land.pyx":1098 */
  glNormal3fv(__pyx_v_tri->v3->normal);

  /* "/home/jiba/src/soya/model/land.pyx":1099 */
  glVertex3fv(__pyx_v_tri->v3->coord);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Land._tri_render_secondpass");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_5_Land__render(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_v_cur;
  int __pyx_v_index;
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  struct __pyx_t_5_soya__LandTri (*__pyx_v_tri);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/model/land.pyx":1108 */
  __pyx_v_5_soya_land_disableColor();

  /* "/home/jiba/src/soya/model/land.pyx":1115 */
  __pyx_v_cur = __pyx_v_5_soya_renderer->data->nb;

  /* "/home/jiba/src/soya/model/land.pyx":1116 */
  __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

  /* "/home/jiba/src/soya/model/land.pyx":1118 */
  __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1119 */
    while (1) {
      __pyx_L3:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/land.pyx":1120 */
      __pyx_2 = (PyObject *)__pyx_v_pack->material_id;
      Py_INCREF((PyObject *)__pyx_2);
      ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id));
      Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/land.pyx":1122 */
      glBegin(GL_TRIANGLES);

      /* "/home/jiba/src/soya/model/land.pyx":1123 */
      __pyx_v_tri = ((struct __pyx_t_5_soya__LandTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

      /* "/home/jiba/src/soya/model/land.pyx":1124 */
      while (1) {
        __pyx_L5:;
        __pyx_1 = (__pyx_v_tri != 0);
        if (!__pyx_1) break;

        /* "/home/jiba/src/soya/model/land.pyx":1126 */
        __pyx_1 = (__pyx_v_self->_colors != 0);
        if (__pyx_1) {
          __pyx_v_5_soya_land_drawColor((__pyx_v_self->_colors + __pyx_v_index));
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/model/land.pyx":1128 */
        glTexCoord2fv(__pyx_v_tri->v1->texcoord);

        /* "/home/jiba/src/soya/model/land.pyx":1129 */
        glNormal3fv(__pyx_v_tri->v1->normal);

        /* "/home/jiba/src/soya/model/land.pyx":1130 */
        glVertex3fv(__pyx_v_tri->v1->coord);

        /* "/home/jiba/src/soya/model/land.pyx":1133 */
        __pyx_1 = (__pyx_v_self->_colors != 0);
        if (__pyx_1) {
          __pyx_v_5_soya_land_drawColor((__pyx_v_self->_colors + __pyx_v_index));
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/model/land.pyx":1135 */
        glTexCoord2fv(__pyx_v_tri->v2->texcoord);

        /* "/home/jiba/src/soya/model/land.pyx":1136 */
        glNormal3fv(__pyx_v_tri->v2->normal);

        /* "/home/jiba/src/soya/model/land.pyx":1137 */
        glVertex3fv(__pyx_v_tri->v2->coord);

        /* "/home/jiba/src/soya/model/land.pyx":1140 */
        __pyx_1 = (__pyx_v_self->_colors != 0);
        if (__pyx_1) {
          __pyx_v_5_soya_land_drawColor((__pyx_v_self->_colors + __pyx_v_index));
          goto __pyx_L9;
        }
        __pyx_L9:;

        /* "/home/jiba/src/soya/model/land.pyx":1142 */
        glTexCoord2fv(__pyx_v_tri->v3->texcoord);

        /* "/home/jiba/src/soya/model/land.pyx":1143 */
        glNormal3fv(__pyx_v_tri->v3->normal);

        /* "/home/jiba/src/soya/model/land.pyx":1144 */
        glVertex3fv(__pyx_v_tri->v3->coord);

        /* "/home/jiba/src/soya/model/land.pyx":1146 */
        __pyx_v_tri = ((struct __pyx_t_5_soya__LandTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/land.pyx":1148 */
      glEnd();

      /* "/home/jiba/src/soya/model/land.pyx":1149 */
      __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_SECONDPASS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1153 */
    glEnable(GL_BLEND);

    /* "/home/jiba/src/soya/model/land.pyx":1158 */
    while (1) {
      __pyx_L10:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/land.pyx":1159 */
      __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_PACK_SPECIAL);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1160 */
        __pyx_2 = (PyObject *)__pyx_v_pack->material_id;
        Py_INCREF((PyObject *)__pyx_2);
        ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id));
        Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;

        /* "/home/jiba/src/soya/model/land.pyx":1161 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/model/land.pyx":1162 */
        __pyx_v_tri = ((struct __pyx_t_5_soya__LandTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

        /* "/home/jiba/src/soya/model/land.pyx":1163 */
        while (1) {
          __pyx_L13:;
          __pyx_1 = (__pyx_v_tri != 0);
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/land.pyx":1164 */
          ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_vertex_render_special(__pyx_v_self,__pyx_v_tri->v1);

          /* "/home/jiba/src/soya/model/land.pyx":1165 */
          ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_vertex_render_special(__pyx_v_self,__pyx_v_tri->v2);

          /* "/home/jiba/src/soya/model/land.pyx":1166 */
          ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_vertex_render_special(__pyx_v_self,__pyx_v_tri->v3);

          /* "/home/jiba/src/soya/model/land.pyx":1167 */
          __pyx_v_tri = ((struct __pyx_t_5_soya__LandTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
        }
        __pyx_L14:;

        /* "/home/jiba/src/soya/model/land.pyx":1168 */
        glEnd();
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1170 */
        while (1) {
          __pyx_L15:;
          __pyx_1 = (chunk_get_ptr(__pyx_v_5_soya_renderer->data) != 0);
          if (!__pyx_1) break;
        }
        __pyx_L16:;
      }
      __pyx_L12:;

      /* "/home/jiba/src/soya/model/land.pyx":1172 */
      __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/model/land.pyx":1175 */
    glDepthFunc(GL_LEQUAL);

    /* "/home/jiba/src/soya/model/land.pyx":1176 */
    glPolygonOffset((-1.0),0.0);

    /* "/home/jiba/src/soya/model/land.pyx":1177 */
    __pyx_v_5_soya_renderer->data->nb = __pyx_v_cur;

    /* "/home/jiba/src/soya/model/land.pyx":1178 */
    __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

    /* "/home/jiba/src/soya/model/land.pyx":1179 */
    while (1) {
      __pyx_L17:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/land.pyx":1180 */
      __pyx_1 = (!(__pyx_v_pack->option & __pyx_e_5_soya_PACK_SPECIAL));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1181 */
        __pyx_2 = (PyObject *)__pyx_v_pack->material_id;
        Py_INCREF((PyObject *)__pyx_2);
        ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id)->__pyx_base.__pyx_vtab)->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_pack->material_id));
        Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;

        /* "/home/jiba/src/soya/model/land.pyx":1182 */
        glEnable(GL_POLYGON_OFFSET_FILL);

        /* "/home/jiba/src/soya/model/land.pyx":1183 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/model/land.pyx":1184 */
        __pyx_v_tri = ((struct __pyx_t_5_soya__LandTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

        /* "/home/jiba/src/soya/model/land.pyx":1185 */
        while (1) {
          __pyx_L20:;
          __pyx_1 = (__pyx_v_tri != 0);
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/land.pyx":1186 */
          ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_render_secondpass(__pyx_v_self,__pyx_v_tri);

          /* "/home/jiba/src/soya/model/land.pyx":1187 */
          __pyx_v_tri = ((struct __pyx_t_5_soya__LandTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
        }
        __pyx_L21:;

        /* "/home/jiba/src/soya/model/land.pyx":1188 */
        glEnd();

        /* "/home/jiba/src/soya/model/land.pyx":1189 */
        glDisable(GL_POLYGON_OFFSET_FILL);
        goto __pyx_L19;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1191 */
        while (1) {
          __pyx_L22:;
          __pyx_1 = (chunk_get_ptr(__pyx_v_5_soya_renderer->data) != 0);
          if (!__pyx_1) break;
        }
        __pyx_L23:;
      }
      __pyx_L19:;

      /* "/home/jiba/src/soya/model/land.pyx":1193 */
      __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
    }
    __pyx_L18:;

    /* "/home/jiba/src/soya/model/land.pyx":1195 */
    glDisable(GL_BLEND);

    /* "/home/jiba/src/soya/model/land.pyx":1196 */
    glDepthFunc(GL_LESS);

    /* "/home/jiba/src/soya/model/land.pyx":1197 */
    glDisable(GL_POLYGON_OFFSET_FILL);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1199 */
  __pyx_v_5_soya_land_drawColor(__pyx_v_5_soya_white);

  /* "/home/jiba/src/soya/model/land.pyx":1200 */
  __pyx_v_5_soya_land_enableColor();

  /* "/home/jiba/src/soya/model/land.pyx":1201 */
  glDisableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/model/land.pyx":1202 */
  glDisableClientState(GL_NORMAL_ARRAY);

  /* "/home/jiba/src/soya/model/land.pyx":1203 */
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Land._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_5_Land__tri_raypick(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri),float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data) {
  float __pyx_v_r;
  float __pyx_v_root_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/model/land.pyx":1207 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1208 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_raydata,__pyx_v_data);

    /* "/home/jiba/src/soya/model/land.pyx":1209 */
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_raydata,__pyx_v_data);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1211 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID);
      if (__pyx_1) {
        __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID);
        if (__pyx_1) {
          __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID);
        }
      }
    }
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/land.pyx":1216 */
    __pyx_1 = triangle_raypick(__pyx_v_raydata,__pyx_v_tri->v1->coord,__pyx_v_tri->v2->coord,__pyx_v_tri->v3->coord,__pyx_v_tri->normal,__pyx_v_data->option,(&__pyx_v_r));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":1217 */
      __pyx_v_root_r = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._distance_out(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_r);

      /* "/home/jiba/src/soya/model/land.pyx":1218 */
      __pyx_1 = (__pyx_v_root_r < __pyx_v_data->root_result);
      if (!__pyx_1) {
        __pyx_1 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1219 */
        __pyx_v_data->result = __pyx_v_r;

        /* "/home/jiba/src/soya/model/land.pyx":1220 */
        __pyx_v_data->root_result = __pyx_v_root_r;

        /* "/home/jiba/src/soya/model/land.pyx":1221 */
        Py_INCREF(((PyObject *)__pyx_v_self));
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
        __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_self);

        /* "/home/jiba/src/soya/model/land.pyx":1222 */
        memcpy(__pyx_v_data->normal,__pyx_v_tri->normal,(3 * (sizeof(float ))));
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static void __pyx_f_5_soya_5_Land__full_raypick(struct __pyx_obj_5_soya__Land *__pyx_v_self,__pyx_t_5_soya_LandVertex (*__pyx_v_v1),__pyx_t_5_soya_LandVertex (*__pyx_v_v2),__pyx_t_5_soya_LandVertex (*__pyx_v_v3),float (*__pyx_v_normal),float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data) {
  float (*__pyx_v_coord1);
  float (*__pyx_v_coord2);
  float (*__pyx_v_coord3);
  float __pyx_v_a;
  float __pyx_v_b;
  float __pyx_v_c;
  float __pyx_v_root_a;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/model/land.pyx":1227 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS));
  if (!__pyx_1) {
    __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID));
    if (!__pyx_1) {
      __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID));
      if (!__pyx_1) {
        __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID));
      }
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1231 */
    __pyx_v_coord1 = __pyx_v_v1->coord;

    /* "/home/jiba/src/soya/model/land.pyx":1232 */
    __pyx_v_coord2 = __pyx_v_v2->coord;

    /* "/home/jiba/src/soya/model/land.pyx":1233 */
    __pyx_v_coord3 = __pyx_v_v3->coord;

    /* "/home/jiba/src/soya/model/land.pyx":1235 */
    __pyx_v_a = (((-(__pyx_v_raydata[5])) * ((__pyx_v_coord1[0]) - (__pyx_v_raydata[0]))) + ((__pyx_v_raydata[3]) * ((__pyx_v_coord1[2]) - (__pyx_v_raydata[2]))));

    /* "/home/jiba/src/soya/model/land.pyx":1236 */
    __pyx_1 = (__pyx_v_a < (2 * __pyx_v_self->_scale_factor));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":1237 */
      __pyx_v_b = (((-(__pyx_v_raydata[5])) * ((__pyx_v_coord2[0]) - (__pyx_v_raydata[0]))) + ((__pyx_v_raydata[3]) * ((__pyx_v_coord2[2]) - (__pyx_v_raydata[2]))));

      /* "/home/jiba/src/soya/model/land.pyx":1238 */
      __pyx_v_c = (((-(__pyx_v_raydata[5])) * ((__pyx_v_coord3[0]) - (__pyx_v_raydata[0]))) + ((__pyx_v_raydata[3]) * ((__pyx_v_coord3[2]) - (__pyx_v_raydata[2]))));

      /* "/home/jiba/src/soya/model/land.pyx":1240 */
      __pyx_2 = (__pyx_v_a > 0.0);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_b > 0.0);
        if (__pyx_2) {
          __pyx_2 = (__pyx_v_c > 0.0);
        }
      }
      __pyx_1 = (!__pyx_2);
      if (__pyx_1) {
        __pyx_2 = (__pyx_v_a < 0.0);
        if (__pyx_2) {
          __pyx_2 = (__pyx_v_b < 0.0);
          if (__pyx_2) {
            __pyx_2 = (__pyx_v_c < 0.0);
          }
        }
        __pyx_1 = (!__pyx_2);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1241 */
        __pyx_2 = triangle_raypick(__pyx_v_raydata,__pyx_v_coord1,__pyx_v_coord2,__pyx_v_coord3,__pyx_v_normal,__pyx_v_data->option,(&__pyx_v_a));
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/land.pyx":1242 */
          __pyx_v_root_a = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._distance_out(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_a);

          /* "/home/jiba/src/soya/model/land.pyx":1243 */
          __pyx_1 = (__pyx_v_root_a < __pyx_v_data->root_result);
          if (!__pyx_1) {
            __pyx_1 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
          }
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/land.pyx":1244 */
            __pyx_v_data->result = __pyx_v_a;

            /* "/home/jiba/src/soya/model/land.pyx":1245 */
            __pyx_v_data->root_result = __pyx_v_root_a;

            /* "/home/jiba/src/soya/model/land.pyx":1246 */
            Py_INCREF(((PyObject *)__pyx_v_self));
            Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
            __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_self);

            /* "/home/jiba/src/soya/model/land.pyx":1247 */
            memcpy(__pyx_v_data->normal,__pyx_v_normal,(3 * (sizeof(float ))));
            goto __pyx_L6;
          }
          __pyx_L6:;
          goto __pyx_L5;
        }
        __pyx_L5:;
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._full_raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static void __pyx_f_5_soya_5_Land__full_raypick_rect(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_x1,int __pyx_v_z1,int __pyx_v_x2,int __pyx_v_z2,float (*__pyx_v_raydata),struct __pyx_obj_5_soya_RaypickData *__pyx_v_data) {
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5_soya_LandVertex (*__pyx_v_p);
  __pyx_t_5_soya_LandVertex (*__pyx_v_p0);
  float (*__pyx_v_normal);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/model/land.pyx":1253 */
  __pyx_v_p0 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_x1,__pyx_v_z1);

  /* "/home/jiba/src/soya/model/land.pyx":1255 */
  for (__pyx_v_j = __pyx_v_z1; __pyx_v_j < __pyx_v_z2; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":1256 */
    __pyx_v_p = __pyx_v_p0;

    /* "/home/jiba/src/soya/model/land.pyx":1257 */
    __pyx_v_normal = (__pyx_v_self->_normals + (6 * (__pyx_v_x1 + (__pyx_v_j * (__pyx_v_self->_nb_vertex_width - 1)))));

    /* "/home/jiba/src/soya/model/land.pyx":1258 */
    for (__pyx_v_i = __pyx_v_x1; __pyx_v_i < __pyx_v_x2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":1259 */
      __pyx_1 = (!((__pyx_v_i + __pyx_v_j) & 1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1260 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick(__pyx_v_self,(__pyx_v_p + __pyx_v_self->_nb_vertex_width),((__pyx_v_p + __pyx_v_self->_nb_vertex_width) + 1),__pyx_v_p,__pyx_v_normal,__pyx_v_raydata,__pyx_v_data);

        /* "/home/jiba/src/soya/model/land.pyx":1261 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/land.pyx":1262 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick(__pyx_v_self,(__pyx_v_p + 1),__pyx_v_p,((__pyx_v_p + __pyx_v_self->_nb_vertex_width) + 1),__pyx_v_normal,__pyx_v_raydata,__pyx_v_data);

        /* "/home/jiba/src/soya/model/land.pyx":1263 */
        __pyx_v_normal = (__pyx_v_normal + 3);
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1265 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick(__pyx_v_self,__pyx_v_p,(__pyx_v_p + __pyx_v_self->_nb_vertex_width),(__pyx_v_p + 1),__pyx_v_normal,__pyx_v_raydata,__pyx_v_data);

        /* "/home/jiba/src/soya/model/land.pyx":1266 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/land.pyx":1267 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick(__pyx_v_self,((__pyx_v_p + __pyx_v_self->_nb_vertex_width) + 1),(__pyx_v_p + 1),(__pyx_v_p + __pyx_v_self->_nb_vertex_width),__pyx_v_normal,__pyx_v_raydata,__pyx_v_data);

        /* "/home/jiba/src/soya/model/land.pyx":1268 */
        __pyx_v_normal = (__pyx_v_normal + 3);
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/land.pyx":1269 */
      __pyx_v_p = (__pyx_v_p + 1);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/land.pyx":1270 */
    __pyx_v_p0 = (__pyx_v_p0 + __pyx_v_self->_nb_vertex_width);
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._full_raypick_rect");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static void __pyx_f_5_soya_5_Land__raypick(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_v_i;
  int __pyx_v_x;
  int __pyx_v_z;
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch);
  float (*__pyx_v_data);
  float __pyx_v_f;
  float __pyx_v_x1;
  float __pyx_v_z1;
  float __pyx_v_x2;
  float __pyx_v_z2;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/model/land.pyx":1273 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1279 */
  __pyx_v_data = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_raypick_data);

  /* "/home/jiba/src/soya/model/land.pyx":1280 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":1282 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_REAL_LOD_RAYPICK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1283 */
    __pyx_1 = __pyx_v_self->_nb_patchs;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":1284 */
      __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

      /* "/home/jiba/src/soya/model/land.pyx":1285 */
      __pyx_2 = (!sphere_raypick(__pyx_v_data,__pyx_v_patch->sphere));
      if (__pyx_2) {
        goto __pyx_L5;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/model/land.pyx":1287 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick(__pyx_v_self,__pyx_v_patch->tri_top,__pyx_v_data,__pyx_v_raypick_data);

      /* "/home/jiba/src/soya/model/land.pyx":1288 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick(__pyx_v_self,__pyx_v_patch->tri_left,__pyx_v_data,__pyx_v_raypick_data);

      /* "/home/jiba/src/soya/model/land.pyx":1289 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick(__pyx_v_self,__pyx_v_patch->tri_right,__pyx_v_data,__pyx_v_raypick_data);

      /* "/home/jiba/src/soya/model/land.pyx":1290 */
      ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick(__pyx_v_self,__pyx_v_patch->tri_bottom,__pyx_v_data,__pyx_v_raypick_data);
      __pyx_L5:;
    }
    __pyx_L6:;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1293 */
    __pyx_2 = ((__pyx_v_data[3]) == 0.0);
    if (__pyx_2) {
      __pyx_2 = ((__pyx_v_data[5]) == 0.0);
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/land.pyx":1294 */
      __pyx_v_x = ((int )((__pyx_v_data[0]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/land.pyx":1295 */
      __pyx_v_z = ((int )((__pyx_v_data[2]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/land.pyx":1296 */
      __pyx_1 = 0.0 <= __pyx_v_x;
      if (__pyx_1) {
        __pyx_1 = __pyx_v_x < __pyx_v_self->_nb_vertex_width;
      }
      if (__pyx_1) {
        __pyx_1 = 0.0 <= __pyx_v_z;
        if (__pyx_1) {
          __pyx_1 = __pyx_v_z < __pyx_v_self->_nb_vertex_depth;
        }
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1297 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_rect(__pyx_v_self,__pyx_v_x,__pyx_v_z,(__pyx_v_x + 1),(__pyx_v_z + 1),__pyx_v_data,__pyx_v_raypick_data);
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":1299 */
      __pyx_2 = ((__pyx_v_data[6]) < 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/land.pyx":1300 */
        __pyx_1 = __pyx_v_self->_nb_patchs;
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

          /* "/home/jiba/src/soya/model/land.pyx":1301 */
          __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

          /* "/home/jiba/src/soya/model/land.pyx":1302 */
          __pyx_2 = (!sphere_raypick(__pyx_v_data,__pyx_v_patch->sphere));
          if (__pyx_2) {
            goto __pyx_L11;
            goto __pyx_L13;
          }
          __pyx_L13:;

          /* "/home/jiba/src/soya/model/land.pyx":1304 */
          ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_rect(__pyx_v_self,((int )((__pyx_v_patch->tri_top->v3->coord[0]) / __pyx_v_self->_scale_factor)),((int )((__pyx_v_patch->tri_top->v3->coord[2]) / __pyx_v_self->_scale_factor)),((int )((__pyx_v_patch->tri_bottom->v3->coord[0]) / __pyx_v_self->_scale_factor)),((int )((__pyx_v_patch->tri_bottom->v3->coord[2]) / __pyx_v_self->_scale_factor)),__pyx_v_data,__pyx_v_raypick_data);
          __pyx_L11:;
        }
        __pyx_L12:;
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1311 */
        __pyx_2 = (__pyx_v_raypick_data->option & __pyx_e_5_soya_RAYPICK_HALF_LINE);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/land.pyx":1312 */
          __pyx_v_x1 = (__pyx_v_data[0]);

          /* "/home/jiba/src/soya/model/land.pyx":1313 */
          __pyx_v_z1 = (__pyx_v_data[2]);
          goto __pyx_L14;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/land.pyx":1315 */
          __pyx_v_x1 = ((__pyx_v_data[0]) - ((__pyx_v_data[6]) * (__pyx_v_data[3])));

          /* "/home/jiba/src/soya/model/land.pyx":1316 */
          __pyx_v_z1 = ((__pyx_v_data[2]) - ((__pyx_v_data[6]) * (__pyx_v_data[5])));
        }
        __pyx_L14:;

        /* "/home/jiba/src/soya/model/land.pyx":1317 */
        __pyx_v_x2 = ((__pyx_v_data[0]) + ((__pyx_v_data[6]) * (__pyx_v_data[3])));

        /* "/home/jiba/src/soya/model/land.pyx":1318 */
        __pyx_v_z2 = ((__pyx_v_data[2]) + ((__pyx_v_data[6]) * (__pyx_v_data[5])));

        /* "/home/jiba/src/soya/model/land.pyx":1319 */
        __pyx_1 = (__pyx_v_x1 > __pyx_v_x2);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/land.pyx":1320 */
          __pyx_v_f = __pyx_v_x1;

          /* "/home/jiba/src/soya/model/land.pyx":1321 */
          __pyx_v_x1 = __pyx_v_x2;

          /* "/home/jiba/src/soya/model/land.pyx":1322 */
          __pyx_v_x2 = __pyx_v_f;
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "/home/jiba/src/soya/model/land.pyx":1323 */
        __pyx_2 = (__pyx_v_z1 > __pyx_v_z2);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/land.pyx":1324 */
          __pyx_v_f = __pyx_v_z1;

          /* "/home/jiba/src/soya/model/land.pyx":1325 */
          __pyx_v_z1 = __pyx_v_z2;

          /* "/home/jiba/src/soya/model/land.pyx":1326 */
          __pyx_v_z2 = __pyx_v_f;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "/home/jiba/src/soya/model/land.pyx":1328 */
        __pyx_v_x1 = (__pyx_v_x1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1329 */
        __pyx_v_z1 = (__pyx_v_z1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1330 */
        __pyx_v_x2 = (__pyx_v_x2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1331 */
        __pyx_v_z2 = (__pyx_v_z2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1332 */
        __pyx_1 = (__pyx_v_x2 < 0.0);
        if (__pyx_1) {
          goto __pyx_L0;
          goto __pyx_L17;
        }
        __pyx_L17:;

        /* "/home/jiba/src/soya/model/land.pyx":1333 */
        __pyx_2 = (__pyx_v_z2 < 0.0);
        if (__pyx_2) {
          goto __pyx_L0;
          goto __pyx_L18;
        }
        __pyx_L18:;

        /* "/home/jiba/src/soya/model/land.pyx":1334 */
        __pyx_1 = (__pyx_v_x1 >= ((float )__pyx_v_self->_nb_vertex_width));
        if (__pyx_1) {
          goto __pyx_L0;
          goto __pyx_L19;
        }
        __pyx_L19:;

        /* "/home/jiba/src/soya/model/land.pyx":1335 */
        __pyx_2 = (__pyx_v_z1 >= ((float )__pyx_v_self->_nb_vertex_depth));
        if (__pyx_2) {
          goto __pyx_L0;
          goto __pyx_L20;
        }
        __pyx_L20:;

        /* "/home/jiba/src/soya/model/land.pyx":1336 */
        __pyx_1 = (__pyx_v_x1 < 0.0);
        if (__pyx_1) {
          __pyx_v_x1 = 0.0;
          goto __pyx_L21;
        }
        __pyx_L21:;

        /* "/home/jiba/src/soya/model/land.pyx":1337 */
        __pyx_2 = (__pyx_v_z1 < 0.0);
        if (__pyx_2) {
          __pyx_v_z1 = 0.0;
          goto __pyx_L22;
        }
        __pyx_L22:;

        /* "/home/jiba/src/soya/model/land.pyx":1338 */
        __pyx_v_x2 = (__pyx_v_x2 + 1.0);

        /* "/home/jiba/src/soya/model/land.pyx":1339 */
        __pyx_v_z2 = (__pyx_v_z2 + 1.0);

        /* "/home/jiba/src/soya/model/land.pyx":1340 */
        __pyx_1 = (__pyx_v_x2 >= ((float )__pyx_v_self->_nb_vertex_width));
        if (__pyx_1) {
          __pyx_v_x2 = (((float )__pyx_v_self->_nb_vertex_width) - 1);
          goto __pyx_L23;
        }
        __pyx_L23:;

        /* "/home/jiba/src/soya/model/land.pyx":1341 */
        __pyx_2 = (__pyx_v_z2 >= ((float )__pyx_v_self->_nb_vertex_depth));
        if (__pyx_2) {
          __pyx_v_z2 = (((float )__pyx_v_self->_nb_vertex_depth) - 1);
          goto __pyx_L24;
        }
        __pyx_L24:;

        /* "/home/jiba/src/soya/model/land.pyx":1342 */
        ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_rect(__pyx_v_self,((int )__pyx_v_x1),((int )__pyx_v_z1),((int )__pyx_v_x2),((int )__pyx_v_z2),__pyx_v_data,__pyx_v_raypick_data);
      }
      __pyx_L10:;
    }
    __pyx_L8:;
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_5_Land__tri_raypick_b(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_t_5_soya__LandTri (*__pyx_v_tri),float (*__pyx_v_raydata),int __pyx_v_option) {
  float __pyx_v_r;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1346 */
  __pyx_1 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1347 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick_b(__pyx_v_self,__pyx_v_tri->left_child,__pyx_v_raydata,__pyx_v_option);
    if (__pyx_1) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/land.pyx":1348 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick_b(__pyx_v_self,__pyx_v_tri->right_child,__pyx_v_raydata,__pyx_v_option);
    if (__pyx_1) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1350 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":1351 */
      __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID);
      if (__pyx_1) {
        __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID);
        if (__pyx_1) {
          __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID);
        }
      }
      if (__pyx_1) {
        __pyx_r = 0;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/land.pyx":1354 */
    __pyx_1 = triangle_raypick(__pyx_v_raydata,__pyx_v_tri->v1->coord,__pyx_v_tri->v2->coord,__pyx_v_tri->v3->coord,__pyx_v_tri->normal,__pyx_v_option,(&__pyx_v_r));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":1355 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1356 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._tri_raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land__full_raypick_b(struct __pyx_obj_5_soya__Land *__pyx_v_self,__pyx_t_5_soya_LandVertex (*__pyx_v_v1),__pyx_t_5_soya_LandVertex (*__pyx_v_v2),__pyx_t_5_soya_LandVertex (*__pyx_v_v3),float (*__pyx_v_normal),float (*__pyx_v_raydata),int __pyx_v_option) {
  float (*__pyx_v_coord1);
  float (*__pyx_v_coord2);
  float (*__pyx_v_coord3);
  float __pyx_v_a;
  float __pyx_v_b;
  float __pyx_v_c;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1361 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS));
  if (!__pyx_1) {
    __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID));
    if (!__pyx_1) {
      __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID));
      if (!__pyx_1) {
        __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_LAND_VERTEX_NON_SOLID));
      }
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1365 */
    __pyx_v_coord1 = __pyx_v_v1->coord;

    /* "/home/jiba/src/soya/model/land.pyx":1366 */
    __pyx_v_coord2 = __pyx_v_v2->coord;

    /* "/home/jiba/src/soya/model/land.pyx":1367 */
    __pyx_v_coord3 = __pyx_v_v3->coord;

    /* "/home/jiba/src/soya/model/land.pyx":1369 */
    __pyx_v_a = (((-(__pyx_v_raydata[5])) * ((__pyx_v_coord1[0]) - (__pyx_v_raydata[0]))) + ((__pyx_v_raydata[3]) * ((__pyx_v_coord1[2]) - (__pyx_v_raydata[2]))));

    /* "/home/jiba/src/soya/model/land.pyx":1370 */
    __pyx_1 = (__pyx_v_a < (2 * __pyx_v_self->_scale_factor));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/land.pyx":1371 */
      __pyx_v_b = (((-(__pyx_v_raydata[5])) * ((__pyx_v_coord2[0]) - (__pyx_v_raydata[0]))) + ((__pyx_v_raydata[3]) * ((__pyx_v_coord2[2]) - (__pyx_v_raydata[2]))));

      /* "/home/jiba/src/soya/model/land.pyx":1372 */
      __pyx_v_c = (((-(__pyx_v_raydata[5])) * ((__pyx_v_coord3[0]) - (__pyx_v_raydata[0]))) + ((__pyx_v_raydata[3]) * ((__pyx_v_coord3[2]) - (__pyx_v_raydata[2]))));

      /* "/home/jiba/src/soya/model/land.pyx":1373 */
      __pyx_2 = (__pyx_v_a > 0.0);
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_b > 0.0);
        if (__pyx_2) {
          __pyx_2 = (__pyx_v_c > 0.0);
        }
      }
      __pyx_1 = (!__pyx_2);
      if (__pyx_1) {
        __pyx_2 = (__pyx_v_a < 0.0);
        if (__pyx_2) {
          __pyx_2 = (__pyx_v_b < 0.0);
          if (__pyx_2) {
            __pyx_2 = (__pyx_v_c < 0.0);
          }
        }
        __pyx_1 = (!__pyx_2);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1374 */
        __pyx_2 = triangle_raypick(__pyx_v_raydata,__pyx_v_coord1,__pyx_v_coord2,__pyx_v_coord3,__pyx_v_normal,__pyx_v_option,(&__pyx_v_a));
        if (__pyx_2) {
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L5;
        }
        __pyx_L5:;
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1375 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._full_raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land__full_raypick_rect_b(struct __pyx_obj_5_soya__Land *__pyx_v_self,int __pyx_v_x1,int __pyx_v_z1,int __pyx_v_x2,int __pyx_v_z2,float (*__pyx_v_raydata),int __pyx_v_option) {
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5_soya_LandVertex (*__pyx_v_p);
  __pyx_t_5_soya_LandVertex (*__pyx_v_p0);
  float (*__pyx_v_normal);
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1381 */
  __pyx_v_p0 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(__pyx_v_self,__pyx_v_x1,__pyx_v_z1);

  /* "/home/jiba/src/soya/model/land.pyx":1383 */
  for (__pyx_v_j = __pyx_v_z1; __pyx_v_j < __pyx_v_z2; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/land.pyx":1384 */
    __pyx_v_p = __pyx_v_p0;

    /* "/home/jiba/src/soya/model/land.pyx":1385 */
    __pyx_v_normal = (__pyx_v_self->_normals + (6 * (__pyx_v_x1 + (__pyx_v_j * (__pyx_v_self->_nb_vertex_width - 1)))));

    /* "/home/jiba/src/soya/model/land.pyx":1386 */
    for (__pyx_v_i = __pyx_v_x1; __pyx_v_i < __pyx_v_x2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":1387 */
      __pyx_1 = (!((__pyx_v_i + __pyx_v_j) & 1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1388 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_b(__pyx_v_self,(__pyx_v_p + __pyx_v_self->_nb_vertex_width),((__pyx_v_p + __pyx_v_self->_nb_vertex_width) + 1),__pyx_v_p,__pyx_v_normal,__pyx_v_raydata,__pyx_v_option);
        if (__pyx_1) {
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/model/land.pyx":1389 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/land.pyx":1390 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_b(__pyx_v_self,(__pyx_v_p + 1),__pyx_v_p,((__pyx_v_p + __pyx_v_self->_nb_vertex_width) + 1),__pyx_v_normal,__pyx_v_raydata,__pyx_v_option);
        if (__pyx_1) {
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/model/land.pyx":1391 */
        __pyx_v_normal = (__pyx_v_normal + 3);
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1393 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_b(__pyx_v_self,__pyx_v_p,(__pyx_v_p + __pyx_v_self->_nb_vertex_width),(__pyx_v_p + 1),__pyx_v_normal,__pyx_v_raydata,__pyx_v_option);
        if (__pyx_1) {
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L9;
        }
        __pyx_L9:;

        /* "/home/jiba/src/soya/model/land.pyx":1394 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/land.pyx":1395 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_b(__pyx_v_self,((__pyx_v_p + __pyx_v_self->_nb_vertex_width) + 1),(__pyx_v_p + 1),(__pyx_v_p + __pyx_v_self->_nb_vertex_width),__pyx_v_normal,__pyx_v_raydata,__pyx_v_option);
        if (__pyx_1) {
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L10;
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/model/land.pyx":1396 */
        __pyx_v_normal = (__pyx_v_normal + 3);
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/land.pyx":1397 */
      __pyx_v_p = (__pyx_v_p + 1);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/land.pyx":1398 */
    __pyx_v_p0 = (__pyx_v_p0 + __pyx_v_self->_nb_vertex_width);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":1399 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._full_raypick_rect_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_5_Land__raypick_b(struct __pyx_obj_5_soya__Land *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_raypick_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  int __pyx_v_i;
  int __pyx_v_x;
  int __pyx_v_z;
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch);
  float (*__pyx_v_data);
  float __pyx_v_x1;
  float __pyx_v_z1;
  float __pyx_v_x2;
  float __pyx_v_z2;
  float __pyx_v_f;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_raypick_data);
  Py_INCREF((PyObject *)__pyx_v_raypickable);

  /* "/home/jiba/src/soya/model/land.pyx":1402 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1408 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":1409 */
  __pyx_v_data = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_raypick_data);

  /* "/home/jiba/src/soya/model/land.pyx":1411 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_REAL_LOD_RAYPICK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1412 */
    __pyx_1 = __pyx_v_self->_nb_patchs;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":1413 */
      __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

      /* "/home/jiba/src/soya/model/land.pyx":1414 */
      __pyx_2 = (!sphere_raypick(__pyx_v_data,__pyx_v_patch->sphere));
      if (__pyx_2) {
        goto __pyx_L5;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/model/land.pyx":1416 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick_b(__pyx_v_self,__pyx_v_patch->tri_top,__pyx_v_data,__pyx_v_raypick_data->option);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/model/land.pyx":1417 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick_b(__pyx_v_self,__pyx_v_patch->tri_left,__pyx_v_data,__pyx_v_raypick_data->option);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/model/land.pyx":1418 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick_b(__pyx_v_self,__pyx_v_patch->tri_right,__pyx_v_data,__pyx_v_raypick_data->option);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/model/land.pyx":1419 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_raypick_b(__pyx_v_self,__pyx_v_patch->tri_bottom,__pyx_v_data,__pyx_v_raypick_data->option);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L11;
      }
      __pyx_L11:;
      __pyx_L5:;
    }
    __pyx_L6:;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1422 */
    __pyx_2 = ((__pyx_v_data[3]) == 0.0);
    if (__pyx_2) {
      __pyx_2 = ((__pyx_v_data[5]) == 0.0);
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/land.pyx":1423 */
      __pyx_v_x = ((int )((__pyx_v_data[0]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/land.pyx":1424 */
      __pyx_v_z = ((int )((__pyx_v_data[2]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/land.pyx":1426 */
      __pyx_1 = 0.0 <= __pyx_v_x;
      if (__pyx_1) {
        __pyx_1 = __pyx_v_x < __pyx_v_self->_nb_vertex_width;
      }
      if (__pyx_1) {
        __pyx_1 = 0.0 <= __pyx_v_z;
        if (__pyx_1) {
          __pyx_1 = __pyx_v_z < __pyx_v_self->_nb_vertex_depth;
        }
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1427 */
        __pyx_r = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_rect_b(__pyx_v_self,__pyx_v_x,__pyx_v_z,(__pyx_v_x + 1),(__pyx_v_z + 1),__pyx_v_data,__pyx_v_raypick_data->option);
        goto __pyx_L0;
        goto __pyx_L13;
      }
      __pyx_L13:;
      goto __pyx_L12;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/land.pyx":1429 */
      __pyx_2 = ((__pyx_v_data[6]) < 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/land.pyx":1430 */
        __pyx_1 = __pyx_v_self->_nb_patchs;
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

          /* "/home/jiba/src/soya/model/land.pyx":1431 */
          __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

          /* "/home/jiba/src/soya/model/land.pyx":1432 */
          __pyx_2 = (!sphere_raypick(__pyx_v_data,__pyx_v_patch->sphere));
          if (__pyx_2) {
            goto __pyx_L15;
            goto __pyx_L17;
          }
          __pyx_L17:;

          /* "/home/jiba/src/soya/model/land.pyx":1434 */
          __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_rect_b(__pyx_v_self,(((int )(__pyx_v_patch->tri_top->v3->coord[0])) / __pyx_v_self->_scale_factor),(((int )(__pyx_v_patch->tri_top->v3->coord[2])) / __pyx_v_self->_scale_factor),(((int )(__pyx_v_patch->tri_bottom->v3->coord[0])) / __pyx_v_self->_scale_factor),(((int )(__pyx_v_patch->tri_bottom->v3->coord[2])) / __pyx_v_self->_scale_factor),__pyx_v_data,__pyx_v_raypick_data->option);
          if (__pyx_2) {
            __pyx_r = 1;
            goto __pyx_L0;
            goto __pyx_L18;
          }
          __pyx_L18:;
          __pyx_L15:;
        }
        __pyx_L16:;
        goto __pyx_L14;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1440 */
        __pyx_2 = (__pyx_v_raypick_data->option & __pyx_e_5_soya_RAYPICK_HALF_LINE);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/land.pyx":1441 */
          __pyx_v_x1 = (__pyx_v_data[0]);

          /* "/home/jiba/src/soya/model/land.pyx":1442 */
          __pyx_v_z1 = (__pyx_v_data[2]);
          goto __pyx_L19;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/land.pyx":1444 */
          __pyx_v_x1 = ((__pyx_v_data[0]) - ((__pyx_v_data[6]) * (__pyx_v_data[3])));

          /* "/home/jiba/src/soya/model/land.pyx":1445 */
          __pyx_v_z1 = ((__pyx_v_data[2]) - ((__pyx_v_data[6]) * (__pyx_v_data[5])));
        }
        __pyx_L19:;

        /* "/home/jiba/src/soya/model/land.pyx":1446 */
        __pyx_v_x2 = ((__pyx_v_data[0]) + ((__pyx_v_data[6]) * (__pyx_v_data[3])));

        /* "/home/jiba/src/soya/model/land.pyx":1447 */
        __pyx_v_z2 = ((__pyx_v_data[2]) + ((__pyx_v_data[6]) * (__pyx_v_data[5])));

        /* "/home/jiba/src/soya/model/land.pyx":1448 */
        __pyx_1 = (__pyx_v_x1 > __pyx_v_x2);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/land.pyx":1449 */
          __pyx_v_f = __pyx_v_x1;

          /* "/home/jiba/src/soya/model/land.pyx":1450 */
          __pyx_v_x1 = __pyx_v_x2;

          /* "/home/jiba/src/soya/model/land.pyx":1451 */
          __pyx_v_x2 = __pyx_v_f;
          goto __pyx_L20;
        }
        __pyx_L20:;

        /* "/home/jiba/src/soya/model/land.pyx":1452 */
        __pyx_2 = (__pyx_v_z1 > __pyx_v_z2);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/land.pyx":1453 */
          __pyx_v_f = __pyx_v_z1;

          /* "/home/jiba/src/soya/model/land.pyx":1454 */
          __pyx_v_z1 = __pyx_v_z2;

          /* "/home/jiba/src/soya/model/land.pyx":1455 */
          __pyx_v_z2 = __pyx_v_f;
          goto __pyx_L21;
        }
        __pyx_L21:;

        /* "/home/jiba/src/soya/model/land.pyx":1456 */
        __pyx_v_x1 = (__pyx_v_x1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1457 */
        __pyx_v_z1 = (__pyx_v_z1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1458 */
        __pyx_v_x2 = (__pyx_v_x2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1459 */
        __pyx_v_z2 = (__pyx_v_z2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/land.pyx":1460 */
        __pyx_1 = (__pyx_v_x2 < 0.0);
        if (__pyx_1) {
          __pyx_r = 0;
          goto __pyx_L0;
          goto __pyx_L22;
        }
        __pyx_L22:;

        /* "/home/jiba/src/soya/model/land.pyx":1461 */
        __pyx_2 = (__pyx_v_z2 < 0.0);
        if (__pyx_2) {
          __pyx_r = 0;
          goto __pyx_L0;
          goto __pyx_L23;
        }
        __pyx_L23:;

        /* "/home/jiba/src/soya/model/land.pyx":1462 */
        __pyx_1 = (__pyx_v_x1 >= ((float )__pyx_v_self->_nb_vertex_width));
        if (__pyx_1) {
          __pyx_r = 0;
          goto __pyx_L0;
          goto __pyx_L24;
        }
        __pyx_L24:;

        /* "/home/jiba/src/soya/model/land.pyx":1463 */
        __pyx_2 = (__pyx_v_z1 >= ((float )__pyx_v_self->_nb_vertex_depth));
        if (__pyx_2) {
          __pyx_r = 0;
          goto __pyx_L0;
          goto __pyx_L25;
        }
        __pyx_L25:;

        /* "/home/jiba/src/soya/model/land.pyx":1464 */
        __pyx_1 = (__pyx_v_x1 < 0.0);
        if (__pyx_1) {
          __pyx_v_x1 = 0.0;
          goto __pyx_L26;
        }
        __pyx_L26:;

        /* "/home/jiba/src/soya/model/land.pyx":1465 */
        __pyx_2 = (__pyx_v_z1 < 0.0);
        if (__pyx_2) {
          __pyx_v_z1 = 0.0;
          goto __pyx_L27;
        }
        __pyx_L27:;

        /* "/home/jiba/src/soya/model/land.pyx":1466 */
        __pyx_v_x2 = (__pyx_v_x2 + 1.0);

        /* "/home/jiba/src/soya/model/land.pyx":1467 */
        __pyx_v_z2 = (__pyx_v_z2 + 1.0);

        /* "/home/jiba/src/soya/model/land.pyx":1468 */
        __pyx_1 = (__pyx_v_x2 >= ((float )__pyx_v_self->_nb_vertex_width));
        if (__pyx_1) {
          __pyx_v_x2 = (((float )__pyx_v_self->_nb_vertex_width) - 1);
          goto __pyx_L28;
        }
        __pyx_L28:;

        /* "/home/jiba/src/soya/model/land.pyx":1469 */
        __pyx_2 = (__pyx_v_z2 >= ((float )__pyx_v_self->_nb_vertex_depth));
        if (__pyx_2) {
          __pyx_v_z2 = (((float )__pyx_v_self->_nb_vertex_depth) - 1);
          goto __pyx_L29;
        }
        __pyx_L29:;

        /* "/home/jiba/src/soya/model/land.pyx":1470 */
        __pyx_r = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_full_raypick_rect_b(__pyx_v_self,((int )__pyx_v_x1),((int )__pyx_v_z1),((int )__pyx_v_x2),((int )__pyx_v_z2),__pyx_v_data,__pyx_v_raypick_data->option);
        goto __pyx_L0;
      }
      __pyx_L14:;
    }
    __pyx_L12:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":1471 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_raypick_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land__collect_raypickables(struct __pyx_obj_5_soya__Land *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1474 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1477 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_self)));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_5_Land_get_true_height_and_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Land_get_true_height_and_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  float __pyx_v_z;
  int __pyx_v_i;
  int __pyx_v_j;
  float __pyx_v_k;
  float __pyx_v_t;
  float (*__pyx_v_norm);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v1);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v2);
  struct __pyx_t_5_soya__LandPatch (*__pyx_v_patch);
  struct __pyx_t_5_soya__LandTri (*__pyx_v_tri);
  int __pyx_v_ix;
  int __pyx_v_iz;
  float __pyx_v_nx;
  float __pyx_v_nz;
  __pyx_t_5_soya_LandVertex (*__pyx_v_v3);
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  long __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"x","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ff", __pyx_argnames, &__pyx_v_x, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1491 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(((struct __pyx_obj_5_soya__Land *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1492 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_LAND_REAL_LOD_RAYPICK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1494 */
    __pyx_1 = ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_patchs;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":1495 */
      __pyx_v_patch = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_patchs + __pyx_v_i);

      /* "/home/jiba/src/soya/model/land.pyx":1496 */
      __pyx_v_v1 = __pyx_v_patch->tri_top->v3;

      /* "/home/jiba/src/soya/model/land.pyx":1497 */
      __pyx_v_v2 = __pyx_v_patch->tri_bottom->v3;

      /* "/home/jiba/src/soya/model/land.pyx":1498 */
      __pyx_2 = (__pyx_v_v1->coord[0]) <= __pyx_v_x;
      if (__pyx_2) {
        __pyx_2 = __pyx_v_x <= (__pyx_v_v2->coord[0]);
      }
      if (__pyx_2) {
        __pyx_2 = (__pyx_v_v1->coord[2]) <= __pyx_v_z;
        if (__pyx_2) {
          __pyx_2 = __pyx_v_z <= (__pyx_v_v2->coord[2]);
        }
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/land.pyx":1502 */
        __pyx_v_tri = __pyx_v_patch->tri_top;

        /* "/home/jiba/src/soya/model/land.pyx":1503 */
        for (__pyx_v_j = 0; __pyx_v_j < 4; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/land.pyx":1504 */
          __pyx_f_5_soya_land_get_height_at_factors(__pyx_v_tri->v1,__pyx_v_tri->v2,__pyx_v_tri->v3,__pyx_v_x,__pyx_v_z,(&__pyx_v_k),(&__pyx_v_t));

          /* "/home/jiba/src/soya/model/land.pyx":1505 */
          __pyx_2 = (-EPSILON) <= __pyx_v_k;
          if (__pyx_2) {
            __pyx_2 = __pyx_v_k <= (1.0 + EPSILON);
          }
          if (__pyx_2) {
            __pyx_2 = (-EPSILON) <= __pyx_v_t;
            if (__pyx_2) {
              __pyx_2 = __pyx_v_t <= (1.0 + EPSILON);
            }
            if (__pyx_2) {
              __pyx_2 = (((__pyx_v_k + __pyx_v_t) - 1.0) < EPSILON);
            }
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/model/land.pyx":1506 */
            while (1) {
              __pyx_L10:;
              __pyx_3 = 1;
              if (!__pyx_3) break;

              /* "/home/jiba/src/soya/model/land.pyx":1507 */
              __pyx_f_5_soya_land_get_height_at_factors(__pyx_v_tri->v1,__pyx_v_tri->v2,__pyx_v_tri->v3,__pyx_v_x,__pyx_v_z,(&__pyx_v_k),(&__pyx_v_t));

              /* "/home/jiba/src/soya/model/land.pyx":1508 */
              __pyx_2 = __pyx_f_5_soya_land_tri_has_child(__pyx_v_tri);
              if (__pyx_2) {

                /* "/home/jiba/src/soya/model/land.pyx":1509 */
                __pyx_2 = (__pyx_v_k >= __pyx_v_t);
                if (__pyx_2) {
                  __pyx_v_tri = __pyx_v_tri->right_child;
                  goto __pyx_L13;
                }
                /*else*/ {
                  __pyx_v_tri = __pyx_v_tri->left_child;
                }
                __pyx_L13:;
                goto __pyx_L12;
              }
              /*else*/ {

                /* "/home/jiba/src/soya/model/land.pyx":1512 */
                __pyx_v_norm = __pyx_v_tri->normal;

                /* "/home/jiba/src/soya/model/land.pyx":1513 */
                __pyx_4 = PyFloat_FromDouble((((__pyx_v_tri->v1->coord[1]) + (__pyx_v_k * ((__pyx_v_tri->v2->coord[1]) - (__pyx_v_tri->v1->coord[1])))) + (__pyx_v_t * ((__pyx_v_tri->v3->coord[1]) - (__pyx_v_tri->v1->coord[1]))))); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                __pyx_6 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                __pyx_7 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                __pyx_8 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                Py_INCREF((PyObject *)__pyx_v_self);
                PyTuple_SET_ITEM(__pyx_9, 0, __pyx_v_self);
                PyTuple_SET_ITEM(__pyx_9, 1, __pyx_6);
                PyTuple_SET_ITEM(__pyx_9, 2, __pyx_7);
                PyTuple_SET_ITEM(__pyx_9, 3, __pyx_8);
                __pyx_6 = 0;
                __pyx_7 = 0;
                __pyx_8 = 0;
                __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_9); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                Py_DECREF(__pyx_5); __pyx_5 = 0;
                Py_DECREF(__pyx_9); __pyx_9 = 0;
                __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1513; goto __pyx_L1;}
                PyTuple_SET_ITEM(__pyx_7, 0, __pyx_4);
                PyTuple_SET_ITEM(__pyx_7, 1, __pyx_6);
                __pyx_4 = 0;
                __pyx_6 = 0;
                __pyx_r = __pyx_7;
                __pyx_7 = 0;
                goto __pyx_L0;
              }
              __pyx_L12:;
            }
            __pyx_L11:;
            goto __pyx_L9;
          }
          __pyx_L9:;

          /* "/home/jiba/src/soya/model/land.pyx":1515 */
          __pyx_v_tri = (__pyx_v_tri + 1);
          __pyx_L7:;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/model/land.pyx":1517 */
        goto __pyx_L5;
        goto __pyx_L6;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/land.pyx":1520 */
    __pyx_v_nx = (__pyx_v_x / ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_scale_factor);

    /* "/home/jiba/src/soya/model/land.pyx":1521 */
    __pyx_v_nz = (__pyx_v_z / ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_scale_factor);

    /* "/home/jiba/src/soya/model/land.pyx":1522 */
    __pyx_v_ix = ((int )__pyx_v_nx);

    /* "/home/jiba/src/soya/model/land.pyx":1523 */
    __pyx_v_iz = ((int )__pyx_v_nz);

    /* "/home/jiba/src/soya/model/land.pyx":1524 */
    __pyx_2 = 0 <= __pyx_v_ix;
    if (__pyx_2) {
      __pyx_2 = __pyx_v_ix < ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width;
    }
    if (__pyx_2) {
      __pyx_2 = 0 <= __pyx_v_iz;
      if (__pyx_2) {
        __pyx_2 = __pyx_v_iz < ((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_depth;
      }
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/land.pyx":1525 */
      __pyx_1 = (!((__pyx_v_ix + __pyx_v_iz) & 1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/land.pyx":1526 */
        __pyx_2 = ((__pyx_v_nz - __pyx_v_iz) > (__pyx_v_nx - __pyx_v_ix));
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/land.pyx":1527 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ix,(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/land.pyx":1528 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ix,__pyx_v_iz);

          /* "/home/jiba/src/soya/model/land.pyx":1529 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(__pyx_v_ix + 1),(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/land.pyx":1530 */
          __pyx_f_5_soya_land_get_height_at_factors(__pyx_v_v1,__pyx_v_v2,__pyx_v_v3,__pyx_v_x,__pyx_v_z,(&__pyx_v_k),(&__pyx_v_t));

          /* "/home/jiba/src/soya/model/land.pyx":1531 */
          __pyx_v_norm = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width - 1)))));

          /* "/home/jiba/src/soya/model/land.pyx":1532 */
          __pyx_8 = PyFloat_FromDouble((((__pyx_v_v1->coord[1]) + (__pyx_v_k * ((__pyx_v_v2->coord[1]) - (__pyx_v_v1->coord[1])))) + (__pyx_v_t * ((__pyx_v_v3->coord[1]) - (__pyx_v_v1->coord[1]))))); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          __pyx_9 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          __pyx_4 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          __pyx_6 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          Py_INCREF((PyObject *)__pyx_v_self);
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_self);
          PyTuple_SET_ITEM(__pyx_7, 1, __pyx_9);
          PyTuple_SET_ITEM(__pyx_7, 2, __pyx_4);
          PyTuple_SET_ITEM(__pyx_7, 3, __pyx_6);
          __pyx_9 = 0;
          __pyx_4 = 0;
          __pyx_6 = 0;
          __pyx_9 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1532; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_8);
          PyTuple_SET_ITEM(__pyx_4, 1, __pyx_9);
          __pyx_8 = 0;
          __pyx_9 = 0;
          __pyx_r = __pyx_4;
          __pyx_4 = 0;
          goto __pyx_L0;
          goto __pyx_L16;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/land.pyx":1534 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(__pyx_v_ix + 1),__pyx_v_iz);

          /* "/home/jiba/src/soya/model/land.pyx":1535 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(__pyx_v_ix + 1),(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/land.pyx":1536 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ix,__pyx_v_iz);

          /* "/home/jiba/src/soya/model/land.pyx":1537 */
          __pyx_f_5_soya_land_get_height_at_factors(__pyx_v_v1,__pyx_v_v2,__pyx_v_v3,__pyx_v_x,__pyx_v_z,(&__pyx_v_k),(&__pyx_v_t));

          /* "/home/jiba/src/soya/model/land.pyx":1538 */
          __pyx_v_norm = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width - 1))))) + 3);

          /* "/home/jiba/src/soya/model/land.pyx":1539 */
          __pyx_6 = PyFloat_FromDouble((((__pyx_v_v1->coord[1]) + (__pyx_v_k * ((__pyx_v_v2->coord[1]) - (__pyx_v_v1->coord[1])))) + (__pyx_v_t * ((__pyx_v_v3->coord[1]) - (__pyx_v_v1->coord[1]))))); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          __pyx_7 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          __pyx_8 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          __pyx_9 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          __pyx_4 = PyTuple_New(4); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          Py_INCREF((PyObject *)__pyx_v_self);
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
          PyTuple_SET_ITEM(__pyx_4, 1, __pyx_7);
          PyTuple_SET_ITEM(__pyx_4, 2, __pyx_8);
          PyTuple_SET_ITEM(__pyx_4, 3, __pyx_9);
          __pyx_7 = 0;
          __pyx_8 = 0;
          __pyx_9 = 0;
          __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_8 = PyTuple_New(2); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1539; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_8, 0, __pyx_6);
          PyTuple_SET_ITEM(__pyx_8, 1, __pyx_7);
          __pyx_6 = 0;
          __pyx_7 = 0;
          __pyx_r = __pyx_8;
          __pyx_8 = 0;
          goto __pyx_L0;
        }
        __pyx_L16:;
        goto __pyx_L15;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/land.pyx":1542 */
        __pyx_1 = ((((__pyx_v_nz - __pyx_v_iz) + __pyx_v_nx) - __pyx_v_ix) < 1);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/land.pyx":1543 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ix,__pyx_v_iz);

          /* "/home/jiba/src/soya/model/land.pyx":1544 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(__pyx_v_ix + 1),__pyx_v_iz);

          /* "/home/jiba/src/soya/model/land.pyx":1545 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ix,(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/land.pyx":1546 */
          __pyx_f_5_soya_land_get_height_at_factors(__pyx_v_v1,__pyx_v_v2,__pyx_v_v3,__pyx_v_x,__pyx_v_z,(&__pyx_v_k),(&__pyx_v_t));

          /* "/home/jiba/src/soya/model/land.pyx":1547 */
          __pyx_v_norm = (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width - 1)))));

          /* "/home/jiba/src/soya/model/land.pyx":1548 */
          __pyx_9 = PyFloat_FromDouble((((__pyx_v_v1->coord[1]) + (__pyx_v_k * ((__pyx_v_v2->coord[1]) - (__pyx_v_v1->coord[1])))) + (__pyx_v_t * ((__pyx_v_v3->coord[1]) - (__pyx_v_v1->coord[1]))))); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          __pyx_4 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          __pyx_6 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          __pyx_7 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          Py_INCREF((PyObject *)__pyx_v_self);
          PyTuple_SET_ITEM(__pyx_8, 0, __pyx_v_self);
          PyTuple_SET_ITEM(__pyx_8, 1, __pyx_4);
          PyTuple_SET_ITEM(__pyx_8, 2, __pyx_6);
          PyTuple_SET_ITEM(__pyx_8, 3, __pyx_7);
          __pyx_4 = 0;
          __pyx_6 = 0;
          __pyx_7 = 0;
          __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_8); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_8); __pyx_8 = 0;
          __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1548; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_6, 0, __pyx_9);
          PyTuple_SET_ITEM(__pyx_6, 1, __pyx_4);
          __pyx_9 = 0;
          __pyx_4 = 0;
          __pyx_r = __pyx_6;
          __pyx_6 = 0;
          goto __pyx_L0;
          goto __pyx_L17;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/land.pyx":1550 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(__pyx_v_ix + 1),(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/land.pyx":1551 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),__pyx_v_ix,(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/land.pyx":1552 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Land *)((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Land *)__pyx_v_self),(__pyx_v_ix + 1),__pyx_v_iz);

          /* "/home/jiba/src/soya/model/land.pyx":1553 */
          __pyx_f_5_soya_land_get_height_at_factors(__pyx_v_v1,__pyx_v_v2,__pyx_v_v3,__pyx_v_x,__pyx_v_z,(&__pyx_v_k),(&__pyx_v_t));

          /* "/home/jiba/src/soya/model/land.pyx":1554 */
          __pyx_v_norm = ((((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Land *)__pyx_v_self)->_nb_vertex_width - 1))))) + 3);

          /* "/home/jiba/src/soya/model/land.pyx":1555 */
          __pyx_7 = PyFloat_FromDouble((((__pyx_v_v1->coord[1]) + (__pyx_v_k * ((__pyx_v_v2->coord[1]) - (__pyx_v_v1->coord[1])))) + (__pyx_v_t * ((__pyx_v_v3->coord[1]) - (__pyx_v_v1->coord[1]))))); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          __pyx_8 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          __pyx_9 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          __pyx_4 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          Py_INCREF((PyObject *)__pyx_v_self);
          PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_self);
          PyTuple_SET_ITEM(__pyx_6, 1, __pyx_8);
          PyTuple_SET_ITEM(__pyx_6, 2, __pyx_9);
          PyTuple_SET_ITEM(__pyx_6, 3, __pyx_4);
          __pyx_8 = 0;
          __pyx_9 = 0;
          __pyx_4 = 0;
          __pyx_8 = PyObject_CallObject(__pyx_5, __pyx_6); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __pyx_9 = PyTuple_New(2); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1555; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_9, 0, __pyx_7);
          PyTuple_SET_ITEM(__pyx_9, 1, __pyx_8);
          __pyx_7 = 0;
          __pyx_8 = 0;
          __pyx_r = __pyx_9;
          __pyx_9 = 0;
          goto __pyx_L0;
        }
        __pyx_L17:;
      }
      __pyx_L15:;
      goto __pyx_L14;
    }
    __pyx_L14:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":1557 */
  __pyx_4 = PyFloat_FromDouble((-1.0)); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1557; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1557; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
  Py_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_5, 1, Py_None);
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya._Land.get_true_height_and_normal");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Land___getcstate__(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_nb;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v);
  PyObject *__pyx_v_material_id2index;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_material_id2index = Py_None; Py_INCREF(__pyx_v_material_id2index);

  /* "/home/jiba/src/soya/model/land.pyx":1565 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1565; goto __pyx_L1;}
  Py_DECREF(__pyx_v_material_id2index);
  __pyx_v_material_id2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":1566 */
  __pyx_2 = PyObject_Length(__pyx_v_self->_materials); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1566; goto __pyx_L1;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {
    __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1566; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1566; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1566; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (PyObject_SetItem(__pyx_v_material_id2index, __pyx_4, __pyx_1) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1566; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":1567 */
  __pyx_v_nb = (__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/land.pyx":1569 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/land.pyx":1570 */
  chunk_add_int_endian_safe(__pyx_v_chunk,(__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_LAND_INITED)));

  /* "/home/jiba/src/soya/model/land.pyx":1571 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/land.pyx":1572 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vertex_width);

  /* "/home/jiba/src/soya/model/land.pyx":1573 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/land.pyx":1574 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_patch_size);

  /* "/home/jiba/src/soya/model/land.pyx":1575 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_texture_factor);

  /* "/home/jiba/src/soya/model/land.pyx":1576 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_scale_factor);

  /* "/home/jiba/src/soya/model/land.pyx":1577 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_split_factor);

  /* "/home/jiba/src/soya/model/land.pyx":1578 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_colors);

  /* "/home/jiba/src/soya/model/land.pyx":1580 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_COLORED);
  if (__pyx_2) {
    __pyx_2 = (__pyx_v_self->_nb_colors > 0);
  }
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/land.pyx":1581 */
    chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

    /* "/home/jiba/src/soya/model/land.pyx":1582 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_colors,__pyx_v_nb);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":1584 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_2) {
    chunk_add_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_options,__pyx_v_nb);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":1586 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/land.pyx":1587 */
    __pyx_v_v = (__pyx_v_self->_vertices + __pyx_v_i);

    /* "/home/jiba/src/soya/model/land.pyx":1588 */
    chunk_add_float_endian_safe(__pyx_v_chunk,(__pyx_v_v->coord[1]));

    /* "/home/jiba/src/soya/model/land.pyx":1589 */
    __pyx_3 = (PyObject *)__pyx_v_v->pack->material_id;
    Py_INCREF((PyObject *)__pyx_3);
    __pyx_4 = PyObject_GetItem(__pyx_v_material_id2index, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1589; goto __pyx_L1;}
    Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1589; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_2);
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/land.pyx":1591 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1591; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1591; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  Py_INCREF(__pyx_v_self->_materials);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_self->_materials);
  __pyx_1 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Land.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_material_id2index);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Land___setcstate__(struct __pyx_obj_5_soya__Land *__pyx_v_self,PyObject *__pyx_v_cstate) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_nb;
  int __pyx_v_temp;
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  __pyx_t_5_soya_LandVertex (*__pyx_v_v);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/land.pyx":1598 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1598; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1598; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->_materials);
  __pyx_v_self->_materials = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":1599 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1599; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1599; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/land.pyx":1601 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/land.pyx":1602 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/land.pyx":1603 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/land.pyx":1604 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vertex_depth));

  /* "/home/jiba/src/soya/model/land.pyx":1605 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_patch_size));

  /* "/home/jiba/src/soya/model/land.pyx":1606 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_texture_factor));

  /* "/home/jiba/src/soya/model/land.pyx":1607 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_scale_factor));

  /* "/home/jiba/src/soya/model/land.pyx":1608 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_split_factor));

  /* "/home/jiba/src/soya/model/land.pyx":1609 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/land.pyx":1610 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/land.pyx":1612 */
  __pyx_v_nb = (__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/land.pyx":1613 */
  __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_COLORED);
  if (__pyx_3) {
    __pyx_3 = (__pyx_v_self->_nb_colors > 0);
  }
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/land.pyx":1614 */
    __pyx_v_self->_colors = ((float (*))malloc(((4 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/land.pyx":1615 */
    __pyx_v_self->_vertex_colors = ((int (*))malloc((__pyx_v_nb * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/land.pyx":1616 */
    chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

    /* "/home/jiba/src/soya/model/land.pyx":1617 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_colors,__pyx_v_nb);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_self->_colors = 0;
    __pyx_v_self->_vertex_colors = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1620 */
  __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/land.pyx":1621 */
    __pyx_v_self->_vertex_options = ((char (*))malloc((__pyx_v_nb * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/land.pyx":1622 */
    chunk_get_chars_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_options,__pyx_v_nb);
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_v_self->_vertex_options = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/land.pyx":1625 */
  __pyx_3 = (__pyx_v_self->_nb_vertex_width != 0);
  if (__pyx_3) {
    __pyx_3 = (__pyx_v_self->_nb_vertex_depth != 0);
  }
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/land.pyx":1626 */
    __pyx_v_self->_vertices = ((__pyx_t_5_soya_LandVertex (*))malloc((__pyx_v_nb * (sizeof(__pyx_t_5_soya_LandVertex )))));

    /* "/home/jiba/src/soya/model/land.pyx":1627 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/land.pyx":1628 */
      __pyx_v_v = (__pyx_v_self->_vertices + __pyx_v_i);

      /* "/home/jiba/src/soya/model/land.pyx":1629 */
      chunk_get_float_endian_safe(__pyx_v_chunk,(__pyx_v_v->coord + 1));

      /* "/home/jiba/src/soya/model/land.pyx":1630 */
      chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_temp));

      /* "/home/jiba/src/soya/model/land.pyx":1631 */
      __pyx_1 = PyInt_FromLong(__pyx_v_temp); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1631; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1631; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_v_v->pack = ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_2)->__pyx_base.__pyx_vtab)->_pack(((struct __pyx_obj_5_soya__Material *)__pyx_2),__pyx_e_5_soya_FACE_TRIANGLE);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_L5:;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/land.pyx":1632 */
    __pyx_v_self->_normals = ((float (*))malloc(((((__pyx_v_self->_nb_vertex_width - 1) * (__pyx_v_self->_nb_vertex_depth - 1)) * 6) * (sizeof(float )))));
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_v_self->_vertices = 0;
    __pyx_v_self->_normals = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/land.pyx":1635 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/land.pyx":1636 */
  ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Land.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_5_Land__check_vertex_options(struct __pyx_obj_5_soya__Land *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1640 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_VERTEX_OPTIONS));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1641 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_LAND_VERTEX_OPTIONS);

    /* "/home/jiba/src/soya/model/land.pyx":1643 */
    __pyx_v_self->_vertex_options = ((char (*))calloc((__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth),(sizeof(char ))));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._check_vertex_options");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_5_Land__check_color(struct __pyx_obj_5_soya__Land *__pyx_v_self,float (*__pyx_v_color)) {
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_v_my_white;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/land.pyx":1647 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LAND_COLORED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/land.pyx":1648 */
    __pyx_v_nb = (__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth);

    /* "/home/jiba/src/soya/model/land.pyx":1649 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_LAND_COLORED);

    /* "/home/jiba/src/soya/model/land.pyx":1650 */
    __pyx_v_self->_vertex_colors = ((int (*))malloc((__pyx_v_nb * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/land.pyx":1651 */
    __pyx_v_my_white = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_register_color(__pyx_v_self,__pyx_v_5_soya_white);

    /* "/home/jiba/src/soya/model/land.pyx":1652 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {
      (__pyx_v_self->_vertex_colors[__pyx_v_i]) = __pyx_v_my_white;
      __pyx_L3:;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/land.pyx":1653 */
  __pyx_1 = ((1.0 - (__pyx_v_color[3])) > EPSILON);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_vertex_options(__pyx_v_self);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/land.pyx":1654 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__Land *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_register_color(__pyx_v_self,__pyx_v_color);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Land._check_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_WaterCube__render_watercube(struct __pyx_obj_5_soya__WaterCube *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/watercube.pyx":20 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._WaterCube._render_watercube");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_static;

static PyObject *__pyx_f_5_soya__is_static_light(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__is_static_light(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_item = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"item",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_item)) return 0;
  Py_INCREF(__pyx_v_item);

  /* "/home/jiba/src/soya/model/shapifier.pyx":19 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 19; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 19; goto __pyx_L1;}
  Py_INCREF(__pyx_v_item);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_item);
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Light));
  PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__Light));
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 19; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_1); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 19; goto __pyx_L1;}
  if (__pyx_4) {
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_1 = PyObject_GetAttr(__pyx_v_item, __pyx_n_static); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 19; goto __pyx_L1;}
  }
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._is_static_light");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_item);
  return __pyx_r;
}

static struct __pyx_obj_5_soya__Shape *__pyx_f_5_soya_9Shapifier__shapify(struct __pyx_obj_5_soya_Shapifier *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__Shape *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);

  /* "/home/jiba/src/soya/model/shapifier.pyx":24 */

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Shapifier._shapify");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Shape *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya_15SimpleShapifier_6shadow___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_15SimpleShapifier_6shadow___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":45 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_SimpleShapifier *)__pyx_v_self)->_shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 45; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.SimpleShapifier.shadow.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_15SimpleShapifier_6shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_15SimpleShapifier_6shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 46; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":47 */
  ((struct __pyx_obj_5_soya_SimpleShapifier *)__pyx_v_self)->_shadow = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.SimpleShapifier.shadow.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_15SimpleShapifier_14max_face_angle___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_15SimpleShapifier_14max_face_angle___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":51 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_SimpleShapifier *)__pyx_v_self)->_max_face_angle); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.SimpleShapifier.max_face_angle.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_15SimpleShapifier_14max_face_angle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_15SimpleShapifier_14max_face_angle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 52; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":53 */
  ((struct __pyx_obj_5_soya_SimpleShapifier *)__pyx_v_self)->_max_face_angle = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.SimpleShapifier.max_face_angle.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_15SimpleShapifier___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_15SimpleShapifier___init__[] = "SimpleShapifier(**attributes) -> SimpleShapifier\n\nSee SimpleShapifier.__doc__ for more info.";
static int __pyx_f_5_soya_15SimpleShapifier___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_shadow;
  float __pyx_v_max_face_angle;
  int __pyx_r;
  static char *__pyx_argnames[] = {"shadow","max_face_angle",0};
  __pyx_v_shadow = __pyx_k126;
  __pyx_v_max_face_angle = __pyx_k127;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|if", __pyx_argnames, &__pyx_v_shadow, &__pyx_v_max_face_angle)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":59 */
  ((struct __pyx_obj_5_soya_SimpleShapifier *)__pyx_v_self)->_shadow = __pyx_v_shadow;

  /* "/home/jiba/src/soya/model/shapifier.pyx":60 */
  ((struct __pyx_obj_5_soya_SimpleShapifier *)__pyx_v_self)->_max_face_angle = __pyx_v_max_face_angle;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.SimpleShapifier.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_15SimpleShapifier___getcstate__(struct __pyx_obj_5_soya_SimpleShapifier *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":63 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->_shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 63; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->_max_face_angle); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 63; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 63; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.SimpleShapifier.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_15SimpleShapifier___setcstate__(struct __pyx_obj_5_soya_SimpleShapifier *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  float __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/shapifier.pyx":66 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 66; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->_shadow = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 66; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->_max_face_angle = __pyx_3;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 2) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 66; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya.SimpleShapifier.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_n_search_all;

static struct __pyx_obj_5_soya__Shape *__pyx_f_5_soya_15SimpleShapifier__shapify(struct __pyx_obj_5_soya_SimpleShapifier *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__SimpleShape *__pyx_v_shape;
  int __pyx_v_option;
  PyObject *__pyx_v_ligths;
  struct __pyx_obj_5_soya__Shape *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);
  __pyx_v_shape = Py_None; Py_INCREF((PyObject *) __pyx_v_shape);
  __pyx_v_ligths = Py_None; Py_INCREF(__pyx_v_ligths);

  /* "/home/jiba/src/soya/model/shapifier.pyx":72 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":73 */
  __pyx_1 = __pyx_v_self->_shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_SHAPE_PLANE_EQUATION) | __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_SHAPE_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shapifier.pyx":74 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_SimpleShape); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->_max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_option); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_world), __pyx_n_search_all); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_6);
  __pyx_6 = 0;
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_6);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_6 = 0;
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_7, __pyx_ptype_5_soya__SimpleShape)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 74; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_v_shape = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":75 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_vtab)->_build_sphere(__pyx_v_shape);

  /* "/home/jiba/src/soya/model/shapifier.pyx":76 */
  ((struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_vtab)->_build_display_list(__pyx_v_shape);

  /* "/home/jiba/src/soya/model/shapifier.pyx":77 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_r = (struct __pyx_obj_5_soya__Shape *)((PyObject *)__pyx_v_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.SimpleShapifier._shapify");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF(__pyx_v_ligths);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Shape *)__pyx_r) ;
}

static struct __pyx_obj_5_soya__Shape *__pyx_f_5_soya_14SolidShapifier__shapify(struct __pyx_obj_5_soya_SolidShapifier *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__SolidShape *__pyx_v_shape;
  int __pyx_v_option;
  PyObject *__pyx_v_ligths;
  struct __pyx_obj_5_soya__Shape *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);
  __pyx_v_shape = Py_None; Py_INCREF((PyObject *) __pyx_v_shape);
  __pyx_v_ligths = Py_None; Py_INCREF(__pyx_v_ligths);

  /* "/home/jiba/src/soya/model/shapifier.pyx":87 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":88 */
  __pyx_1 = __pyx_v_self->__pyx_base._shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_SHAPE_PLANE_EQUATION) | __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_SHAPE_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shapifier.pyx":89 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_SolidShape); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_option); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_world), __pyx_n_search_all); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_6);
  __pyx_6 = 0;
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_6);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_6 = 0;
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_7, __pyx_ptype_5_soya__SolidShape)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 89; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_v_shape = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":90 */
  ((struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_sphere(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_shape));

  /* "/home/jiba/src/soya/model/shapifier.pyx":91 */
  ((struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_display_list(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_shape));

  /* "/home/jiba/src/soya/model/shapifier.pyx":92 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_r = (struct __pyx_obj_5_soya__Shape *)((PyObject *)__pyx_v_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.SolidShapifier._shapify");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF(__pyx_v_ligths);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Shape *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya_13TreeShapifier_19collapsing_distance___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_13TreeShapifier_19collapsing_distance___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":123 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_collapsing_distance); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 123; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.TreeShapifier.collapsing_distance.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_13TreeShapifier_19collapsing_distance___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_13TreeShapifier_19collapsing_distance___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 124; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":125 */
  ((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_collapsing_distance = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.TreeShapifier.collapsing_distance.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13TreeShapifier_7quality___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_13TreeShapifier_7quality___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":129 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_quality); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 129; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.TreeShapifier.quality.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_13TreeShapifier_7quality___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_13TreeShapifier_7quality___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 130; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":131 */
  ((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_quality = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.TreeShapifier.quality.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13TreeShapifier_16max_child_radius___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_13TreeShapifier_16max_child_radius___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":135 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_max_child_radius); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 135; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.TreeShapifier.max_child_radius.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_13TreeShapifier_16max_child_radius___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_13TreeShapifier_16max_child_radius___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 136; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":137 */
  ((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_max_child_radius = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.TreeShapifier.max_child_radius.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_13TreeShapifier___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_13TreeShapifier___init__[] = "TreeShapifier(**attributes) -> TreeShapifier\n\nSee TreeShapifier.__doc__ for more info.";
static int __pyx_f_5_soya_13TreeShapifier___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_shadow;
  float __pyx_v_max_face_angle;
  float __pyx_v_collapsing_distance;
  int __pyx_v_quality;
  float __pyx_v_max_child_radius;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"shadow","max_face_angle","collapsing_distance","quality","max_child_radius",0};
  __pyx_v_shadow = __pyx_k128;
  __pyx_v_max_face_angle = __pyx_k129;
  __pyx_v_collapsing_distance = __pyx_k130;
  __pyx_v_quality = __pyx_k131;
  __pyx_v_max_child_radius = __pyx_k132;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|iffif", __pyx_argnames, &__pyx_v_shadow, &__pyx_v_max_face_angle, &__pyx_v_collapsing_distance, &__pyx_v_quality, &__pyx_v_max_child_radius)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":143 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_SimpleShapifier), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 143; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_shadow); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 143; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 143; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 143; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 143; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":144 */
  ((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_collapsing_distance = __pyx_v_collapsing_distance;

  /* "/home/jiba/src/soya/model/shapifier.pyx":145 */
  ((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_quality = __pyx_v_quality;

  /* "/home/jiba/src/soya/model/shapifier.pyx":146 */
  ((struct __pyx_obj_5_soya_TreeShapifier *)__pyx_v_self)->_max_child_radius = __pyx_v_max_child_radius;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.TreeShapifier.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_13TreeShapifier___getcstate__(struct __pyx_obj_5_soya_TreeShapifier *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":149 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->__pyx_base._shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._max_face_angle); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->_collapsing_distance); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_self->_quality); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(__pyx_v_self->_max_child_radius); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 149; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(5); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 149; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_6, 3, __pyx_4);
  PyTuple_SET_ITEM(__pyx_6, 4, __pyx_5);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_6;
  __pyx_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya.TreeShapifier.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_13TreeShapifier___setcstate__(struct __pyx_obj_5_soya_TreeShapifier *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  float __pyx_3;
  float __pyx_4;
  int __pyx_5;
  float __pyx_6;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/shapifier.pyx":152 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->__pyx_base._shadow = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->__pyx_base._max_face_angle = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->_collapsing_distance = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->_quality = __pyx_5;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 4); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->_max_child_radius = __pyx_6;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 5) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 152; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya.TreeShapifier.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static struct __pyx_obj_5_soya__Shape *__pyx_f_5_soya_13TreeShapifier__shapify(struct __pyx_obj_5_soya_TreeShapifier *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__TreeShape *__pyx_v_shape;
  int __pyx_v_option;
  struct __pyx_obj_5_soya__Shape *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);
  __pyx_v_shape = Py_None; Py_INCREF((PyObject *) __pyx_v_shape);

  /* "/home/jiba/src/soya/model/shapifier.pyx":157 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":158 */
  __pyx_1 = __pyx_v_self->__pyx_base._shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_SHAPE_PLANE_EQUATION) | __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_SHAPE_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shapifier.pyx":159 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_TreeShape); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_option); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_world), __pyx_n_search_all); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_6);
  __pyx_6 = 0;
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_6);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_6 = 0;
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_7, __pyx_ptype_5_soya__TreeShape)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_v_shape = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":160 */
  ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_tree(__pyx_v_shape);

  /* "/home/jiba/src/soya/model/shapifier.pyx":161 */
  ((struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_optimize_tree(__pyx_v_shape,__pyx_v_self->_collapsing_distance,__pyx_v_self->_quality,__pyx_v_self->_max_child_radius);

  /* "/home/jiba/src/soya/model/shapifier.pyx":162 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_r = (struct __pyx_obj_5_soya__Shape *)((PyObject *)__pyx_v_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.TreeShapifier._shapify");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Shape *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya_20CellShadingShapifier_6shader___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_20CellShadingShapifier_6shader___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":191 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_shader));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_shader);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingShapifier.shader.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_20CellShadingShapifier_6shader___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_20CellShadingShapifier_6shader___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_soya__Material, 1, "x")) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 192; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":193 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_shader));
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_shader = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingShapifier.shader.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_20CellShadingShapifier_13outline_color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_20CellShadingShapifier_13outline_color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":197 */
  Py_INCREF(((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_color);
  __pyx_r = ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_color;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingShapifier.outline_color.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_20CellShadingShapifier_13outline_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_20CellShadingShapifier_13outline_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/home/jiba/src/soya/model/shapifier.pyx":199 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF(((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_color);
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_color = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingShapifier.outline_color.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_20CellShadingShapifier_13outline_width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_20CellShadingShapifier_13outline_width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":203 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_width); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 203; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CellShadingShapifier.outline_width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_20CellShadingShapifier_13outline_width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_20CellShadingShapifier_13outline_width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 204; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":205 */
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_width = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingShapifier.outline_width.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_20CellShadingShapifier_19outline_attenuation___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_20CellShadingShapifier_19outline_attenuation___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":209 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_attenuation); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 209; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.CellShadingShapifier.outline_attenuation.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_20CellShadingShapifier_19outline_attenuation___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_20CellShadingShapifier_19outline_attenuation___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  float __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyFloat_AsDouble(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 210; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":211 */
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_attenuation = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingShapifier.outline_attenuation.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_20CellShadingShapifier___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_20CellShadingShapifier___init__[] = "CellShadingShapifier(**attributes) -> CellShadingShapifier\n\nSee CellShadingShapifier.__doc__ for more info.";
static int __pyx_f_5_soya_20CellShadingShapifier___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_shadow;
  float __pyx_v_max_face_angle;
  struct __pyx_obj_5_soya__Material *__pyx_v_shader = 0;
  PyObject *__pyx_v_outline_color = 0;
  float __pyx_v_outline_width;
  float __pyx_v_outline_attenuation;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {"shadow","max_face_angle","shader","outline_color","outline_width","outline_attenuation",0};
  __pyx_v_shadow = __pyx_k133;
  __pyx_v_max_face_angle = __pyx_k134;
  __pyx_v_shader = __pyx_k135;
  __pyx_v_outline_color = __pyx_k136;
  __pyx_v_outline_width = __pyx_k137;
  __pyx_v_outline_attenuation = __pyx_k138;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|ifOOff", __pyx_argnames, &__pyx_v_shadow, &__pyx_v_max_face_angle, &__pyx_v_shader, &__pyx_v_outline_color, &__pyx_v_outline_width, &__pyx_v_outline_attenuation)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shader);
  Py_INCREF(__pyx_v_outline_color);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shader), __pyx_ptype_5_soya__Material, 1, "shader")) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 213; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":217 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_SimpleShapifier), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 217; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_shadow); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 217; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 217; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 217; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 217; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":218 */
  __pyx_3 = ((PyObject *)__pyx_v_shader);
  Py_INCREF((PyObject *)__pyx_3);
  __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 218; goto __pyx_L1;}
  if (!__pyx_5) {
    Py_DECREF((PyObject *)__pyx_3); __pyx_3 = 0;
    __pyx_3 = ((PyObject *)__pyx_v_5_soya__SHADER_DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_3);
  }
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 218; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_shader));
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_shader = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":219 */
  Py_INCREF(__pyx_v_outline_color);
  Py_DECREF(((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_color);
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_color = __pyx_v_outline_color;

  /* "/home/jiba/src/soya/model/shapifier.pyx":220 */
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_width = __pyx_v_outline_width;

  /* "/home/jiba/src/soya/model/shapifier.pyx":221 */
  ((struct __pyx_obj_5_soya_CellShadingShapifier *)__pyx_v_self)->_outline_attenuation = __pyx_v_outline_attenuation;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.CellShadingShapifier.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shader);
  Py_DECREF(__pyx_v_outline_color);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_20CellShadingShapifier___getcstate__(struct __pyx_obj_5_soya_CellShadingShapifier *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/shapifier.pyx":224 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->__pyx_base._shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 224; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._max_face_angle); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 224; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->_outline_width); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 224; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_self->_outline_attenuation); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 224; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(6); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 224; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_shader));
  PyTuple_SET_ITEM(__pyx_5, 2, ((PyObject *)__pyx_v_self->_shader));
  Py_INCREF(__pyx_v_self->_outline_color);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_v_self->_outline_color);
  PyTuple_SET_ITEM(__pyx_5, 4, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 5, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.CellShadingShapifier.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_20CellShadingShapifier___setcstate__(struct __pyx_obj_5_soya_CellShadingShapifier *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  float __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  float __pyx_6;
  float __pyx_7;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/shapifier.pyx":228 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->__pyx_base._shadow = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_self->__pyx_base._max_face_angle = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_shader));
  __pyx_v_self->_shader = __pyx_1;
  __pyx_1 = 0;
  __pyx_4 = __Pyx_UnpackItem(__pyx_v_cstate, 3); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_outline_color);
  __pyx_v_self->_outline_color = __pyx_4;
  __pyx_4 = 0;
  __pyx_5 = __Pyx_UnpackItem(__pyx_v_cstate, 4); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_v_self->_outline_width = __pyx_6;
  __pyx_5 = __Pyx_UnpackItem(__pyx_v_cstate, 5); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  __pyx_7 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_v_self->_outline_attenuation = __pyx_7;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 6) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 228; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya.CellShadingShapifier.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static struct __pyx_obj_5_soya__Shape *__pyx_f_5_soya_20CellShadingShapifier__shapify(struct __pyx_obj_5_soya_CellShadingShapifier *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__CellShadingShape *__pyx_v_shape;
  int __pyx_v_option;
  struct __pyx_obj_5_soya__Shape *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);
  __pyx_v_shape = Py_None; Py_INCREF((PyObject *) __pyx_v_shape);

  /* "/home/jiba/src/soya/model/shapifier.pyx":233 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":234 */
  __pyx_1 = __pyx_v_self->__pyx_base._shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_SHAPE_PLANE_EQUATION) | __pyx_e_5_soya_SHAPE_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_SHAPE_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/shapifier.pyx":235 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_CellShadingShape); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base._max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((((__pyx_v_option | __pyx_e_5_soya_SHAPE_PLANE_EQUATION) | __pyx_e_5_soya_SHAPE_NEIGHBORS) | __pyx_e_5_soya_SHAPE_CELLSHADING)); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_world), __pyx_n_search_all); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_7, 0, __pyx_6);
  __pyx_6 = 0;
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_7); __pyx_7 = 0;
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_world));
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_4);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_6);
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_6 = 0;
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_7, __pyx_ptype_5_soya__CellShadingShape)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 235; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_v_shape = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":236 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_sphere(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_shape));

  /* "/home/jiba/src/soya/model/shapifier.pyx":237 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_cellshading(__pyx_v_shape,__pyx_v_self->_shader,__pyx_v_self->_outline_color,__pyx_v_self->_outline_width,__pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/model/shapifier.pyx":238 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_v_shape->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_display_list(((struct __pyx_obj_5_soya__SimpleShape *)__pyx_v_shape));

  /* "/home/jiba/src/soya/model/shapifier.pyx":239 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_r = (struct __pyx_obj_5_soya__Shape *)((PyObject *)__pyx_v_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.CellShadingShapifier._shapify");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Shape *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya__set_default_shapifier(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__set_default_shapifier(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_Shapifier *__pyx_v_shapifier = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"shapifier",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_shapifier)) return 0;
  Py_INCREF((PyObject *)__pyx_v_shapifier);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shapifier), __pyx_ptype_5_soya_Shapifier, 1, "shapifier")) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 244; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/shapifier.pyx":246 */
  Py_INCREF(((PyObject *)__pyx_v_shapifier));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__DEFAULT_SHAPIFIER));
  __pyx_v_5_soya__DEFAULT_SHAPIFIER = ((PyObject *)__pyx_v_shapifier);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._set_default_shapifier");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_shapifier);
  return __pyx_r;
}

static void __pyx_f_5_soya_quit_cal3d(void) {

  /* "/home/jiba/src/soya/cal3d/shape.pyx":28 */
  free(__pyx_v_5_soya_cal3d_texcoords_array);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":29 */
  free(__pyx_v_5_soya_cal3d_shades_array);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":30 */
  free(__pyx_v_5_soya_cal3d_facesides_array);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.quit_cal3d");
  __pyx_L0:;
}

static PyObject *__pyx_n_struct;
static PyObject *__pyx_n_array;
static PyObject *__pyx_n_unpack;
static PyObject *__pyx_n_iii;
static PyObject *__pyx_n_read;
static PyObject *__pyx_n_c;

static PyObject *__pyx_k275p;

static char (__pyx_k275[]) = " ";

static PyObject *__pyx_f_5_soya_load_raw_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_load_raw_image[] = "Loads a \".raw\" image file, which are used by Cal3D example (see cal3d_data).\nReturns a Soya image object, suitable for model.material.image.";
static PyObject *__pyx_f_5_soya_load_raw_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_nb_colors;
  int __pyx_v_line_length;
  int __pyx_v_y;
  PyObject *__pyx_v_struct;
  PyObject *__pyx_v_array;
  PyObject *__pyx_v_f;
  PyObject *__pyx_v_data;
  PyObject *__pyx_v_data2;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  int __pyx_6;
  int __pyx_7;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF(__pyx_v_filename);
  __pyx_v_struct = Py_None; Py_INCREF(__pyx_v_struct);
  __pyx_v_array = Py_None; Py_INCREF(__pyx_v_array);
  __pyx_v_f = Py_None; Py_INCREF(__pyx_v_f);
  __pyx_v_data = Py_None; Py_INCREF(__pyx_v_data);
  __pyx_v_data2 = Py_None; Py_INCREF(__pyx_v_data2);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":36 */
  __pyx_1 = __Pyx_Import(__pyx_n_struct, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_v_struct);
  __pyx_v_struct = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":36 */
  __pyx_1 = __Pyx_Import(__pyx_n_array, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_DECREF(__pyx_v_array);
  __pyx_v_array = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":38 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_filename);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_f);
  __pyx_v_f = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":39 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_struct, __pyx_n_unpack); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_read); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(12); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_INCREF(__pyx_n_iii);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_iii);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
  __pyx_3 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_4, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_width = __pyx_5;
  __pyx_1 = __Pyx_UnpackItem(__pyx_4, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_6 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_height = __pyx_6;
  __pyx_2 = __Pyx_UnpackItem(__pyx_4, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_7 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_nb_colors = __pyx_7;
  if (__Pyx_EndUnpack(__pyx_4, 3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":40 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_array, __pyx_n_array); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_read); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_INCREF(__pyx_n_c);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_c);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_4);
  __pyx_4 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_data);
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":43 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_array, __pyx_n_array); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_5 = PyObject_Length(__pyx_v_data); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_1 = PyNumber_Multiply(__pyx_k275p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_INCREF(__pyx_n_c);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_n_c);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_1);
  __pyx_1 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_data2);
  __pyx_v_data2 = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":44 */
  __pyx_v_line_length = (__pyx_v_width * __pyx_v_nb_colors);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":45 */
  for (__pyx_v_y = 0; __pyx_v_y < __pyx_v_height; ++__pyx_v_y) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":46 */
    __pyx_1 = PySequence_GetSlice(__pyx_v_data, (((__pyx_v_height - __pyx_v_y) - 1) * __pyx_v_line_length), ((__pyx_v_height - __pyx_v_y) * __pyx_v_line_length)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 46; goto __pyx_L1;}
    if (PySequence_SetSlice(__pyx_v_data2, (__pyx_v_y * __pyx_v_line_length), ((__pyx_v_y + 1) * __pyx_v_line_length), __pyx_1) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 46; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":48 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Image); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_data2, __pyx_n_tostring); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyInt_FromLong(__pyx_v_width); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_height); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_8 = PyInt_FromLong(__pyx_v_nb_colors); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_9, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_9, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_9, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_9, 3, __pyx_8);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_8 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_9); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 48; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_9); __pyx_9 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_AddTraceback("_soya.load_raw_image");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_struct);
  Py_DECREF(__pyx_v_array);
  Py_DECREF(__pyx_v_f);
  Py_DECREF(__pyx_v_data);
  Py_DECREF(__pyx_v_data2);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_n_path;
static PyObject *__pyx_n_dirname;
static PyObject *__pyx_n_basename;
static PyObject *__pyx_n_readlines;
static PyObject *__pyx_n_rstrip;
static PyObject *__pyx_n_int;
static PyObject *__pyx_n_skeleton;
static PyObject *__pyx_n_load_skeleton;
static PyObject *__pyx_n_join;
static PyObject *__pyx_n_mesh;
static PyObject *__pyx_n_load_mesh;
static PyObject *__pyx_n_material;
static PyObject *__pyx_n_load_material;
static PyObject *__pyx_n_animation;
static PyObject *__pyx_n_load_animation;
static PyObject *__pyx_n_sphere;
static PyObject *__pyx_n_map;
static PyObject *__pyx_n_cellshading;
static PyObject *__pyx_n_set_cellshading;
static PyObject *__pyx_n_cellshading_shader;
static PyObject *__pyx_n_cellshading_outline_width;
static PyObject *__pyx_n_cellshading_outline_attenuation;
static PyObject *__pyx_n_cellshading_outline_color;
static PyObject *__pyx_n_build_materials;

static PyObject *__pyx_k277p;
static PyObject *__pyx_k278p;
static PyObject *__pyx_k291p;
static PyObject *__pyx_k292p;

static char (__pyx_k277[]) = "#";
static char (__pyx_k278[]) = "=";
static char (__pyx_k291[]) = ",";
static char (__pyx_k292[]) = "Warning: unknows Cal3D .cfg tag:   %s=%s";

static PyObject *__pyx_f_5_soya_parse_cal3d_cfg_file(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_parse_cal3d_cfg_file[] = "Reads a the Cal3D .cfg file, and creates and returns a Cal3D shape from it.";
static PyObject *__pyx_f_5_soya_parse_cal3d_cfg_file(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_soya;
  struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_shape;
  int __pyx_v_i;
  PyObject *__pyx_v_dirname;
  PyObject *__pyx_v_already_done;
  PyObject *__pyx_v_line;
  PyObject *__pyx_v_parts;
  PyObject *__pyx_v_key;
  PyObject *__pyx_v_value;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  int __pyx_6;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  float __pyx_9;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF(__pyx_v_filename);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);
  __pyx_v_shape = Py_None; Py_INCREF((PyObject *) __pyx_v_shape);
  __pyx_v_dirname = Py_None; Py_INCREF(__pyx_v_dirname);
  __pyx_v_already_done = Py_None; Py_INCREF(__pyx_v_already_done);
  __pyx_v_line = Py_None; Py_INCREF(__pyx_v_line);
  __pyx_v_parts = Py_None; Py_INCREF(__pyx_v_parts);
  __pyx_v_key = Py_None; Py_INCREF(__pyx_v_key);
  __pyx_v_value = Py_None; Py_INCREF(__pyx_v_value);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":52 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 52; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":55 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_Cal3dShape); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 55; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 55; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 55; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dShape)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 55; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_v_shape = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":56 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 56; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_dirname); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_filename);
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_dirname);
  __pyx_v_dirname = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":57 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_basename); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_INCREF(__pyx_v_dirname);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_dirname);
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_shape->__pyx_base._filename);
  __pyx_v_shape->__pyx_base._filename = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":58 */
  Py_INCREF(__pyx_v_filename);
  Py_DECREF(__pyx_v_shape->_full_filename);
  __pyx_v_shape->_full_filename = __pyx_v_filename;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":62 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_v_already_done);
  __pyx_v_already_done = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":64 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_filename);
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_readlines); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_3 = PyObject_GetIter(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  for (;;) {
    __pyx_L2:;
    __pyx_1 = PyIter_Next(__pyx_3);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_line);
    __pyx_v_line = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":65 */
    __pyx_2 = __pyx_v_line;
    Py_INCREF(__pyx_2);
    __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 65; goto __pyx_L1;}
    if (__pyx_4) {
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 65; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_v_line, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 65; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      if (PyObject_Cmp(__pyx_5, __pyx_k277p, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 65; goto __pyx_L1;}
      __pyx_4 = __pyx_4 != 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_2 = PyInt_FromLong(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 65; goto __pyx_L1;}
    }
    __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 65; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":66 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_split); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 66; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 66; goto __pyx_L1;}
      Py_INCREF(__pyx_k278p);
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k278p);
      __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 66; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_v_parts);
      __pyx_v_parts = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":67 */
      __pyx_4 = PyObject_Length(__pyx_v_parts); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 67; goto __pyx_L1;}
      __pyx_6 = (__pyx_4 == 2);
      if (__pyx_6) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":68 */
        __pyx_1 = __Pyx_UnpackItem(__pyx_v_parts, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 68; goto __pyx_L1;}
        Py_DECREF(__pyx_v_key);
        __pyx_v_key = __pyx_1;
        __pyx_1 = 0;
        __pyx_5 = __Pyx_UnpackItem(__pyx_v_parts, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 68; goto __pyx_L1;}
        Py_DECREF(__pyx_v_value);
        __pyx_v_value = __pyx_5;
        __pyx_5 = 0;
        if (__Pyx_EndUnpack(__pyx_v_parts, 2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 68; goto __pyx_L1;}

        /* "/home/jiba/src/soya/cal3d/shape.pyx":69 */
        __pyx_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_rstrip); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 69; goto __pyx_L1;}
        __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 69; goto __pyx_L1;}
        __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 69; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_v_value);
        __pyx_v_value = __pyx_5;
        __pyx_5 = 0;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":70 */
        /*try:*/ {
          __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 70; goto __pyx_L6;}
          __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 70; goto __pyx_L6;}
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_value);
          __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 70; goto __pyx_L6;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_v_value);
          __pyx_v_value = __pyx_5;
          __pyx_5 = 0;
        }
        goto __pyx_L7;
        __pyx_L6:;
        Py_XDECREF(__pyx_2); __pyx_2 = 0;
        Py_XDECREF(__pyx_1); __pyx_1 = 0;
        Py_XDECREF(__pyx_5); __pyx_5 = 0;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":71 */
        /*except:*/ {
          __Pyx_AddTraceback("_soya.parse_cal3d_cfg_file");
          __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 71; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":72 */
          /*try:*/ {
            __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 72; goto __pyx_L8;}
            __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 72; goto __pyx_L8;}
            Py_INCREF(__pyx_v_value);
            PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_value);
            __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 72; goto __pyx_L8;}
            Py_DECREF(__pyx_1); __pyx_1 = 0;
            Py_DECREF(__pyx_5); __pyx_5 = 0;
            Py_DECREF(__pyx_v_value);
            __pyx_v_value = __pyx_2;
            __pyx_2 = 0;
          }
          goto __pyx_L9;
          __pyx_L8:;
          Py_XDECREF(__pyx_1); __pyx_1 = 0;
          Py_XDECREF(__pyx_5); __pyx_5 = 0;
          Py_XDECREF(__pyx_2); __pyx_2 = 0;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":73 */
          /*except:*/ {
            __Pyx_AddTraceback("_soya.parse_cal3d_cfg_file");
            __pyx_1 = __Pyx_GetExcValue(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 73; goto __pyx_L1;}
            Py_DECREF(__pyx_1); __pyx_1 = 0;
            goto __pyx_L9;
          }
          __pyx_L9:;
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":75 */
        __pyx_5 = PyObject_GetAttr(__pyx_v_already_done, __pyx_n_get); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 75; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 75; goto __pyx_L1;}
        Py_INCREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_key);
        Py_INCREF(__pyx_v_value);
        PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_value);
        __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 75; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
        __pyx_2 = 0;
        __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 75; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 75; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        if (__pyx_4) {
          goto __pyx_L2;
          goto __pyx_L10;
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":76 */
        __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 76; goto __pyx_L1;}
        __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 76; goto __pyx_L1;}
        Py_INCREF(__pyx_v_key);
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_key);
        Py_INCREF(__pyx_v_value);
        PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_value);
        if (PyObject_SetItem(__pyx_v_already_done, __pyx_1, __pyx_5) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 76; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":78 */
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_skeleton, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_shape), __pyx_n_load_skeleton); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          __pyx_1 = PyObject_GetAttr(__pyx_5, __pyx_n_join); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          Py_INCREF(__pyx_v_dirname);
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_dirname);
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_5, 1, __pyx_v_value);
          __pyx_7 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_1, 0, __pyx_7);
          __pyx_7 = 0;
          __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_mesh, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_shape), __pyx_n_load_mesh); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_join); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          Py_INCREF(__pyx_v_dirname);
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_dirname);
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_value);
          __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
          __pyx_1 = 0;
          __pyx_2 = PyObject_CallObject(__pyx_7, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 79; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_material, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_shape), __pyx_n_load_material); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          __pyx_7 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(__pyx_7, __pyx_n_path); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_2 = PyObject_GetAttr(__pyx_5, __pyx_n_join); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          Py_INCREF(__pyx_v_dirname);
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_dirname);
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_7, 1, __pyx_v_value);
          __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_7); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_5);
          __pyx_5 = 0;
          __pyx_7 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_animation, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_shape), __pyx_n_load_animation); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          __pyx_7 = PyObject_GetAttr(__pyx_2, __pyx_n_join); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          Py_INCREF(__pyx_v_dirname);
          PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_dirname);
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_value);
          __pyx_2 = PyObject_CallObject(__pyx_7, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_2);
          __pyx_2 = 0;
          __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_shadow, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
          __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_value);
          __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_shape), __pyx_n_shadow, __pyx_7) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_double_sided, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
          __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_value);
          __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_shape), __pyx_n_double_sided, __pyx_5) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_sphere, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_map); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_split); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          __pyx_8 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
          PyTuple_SET_ITEM(__pyx_2, 1, __pyx_8);
          __pyx_1 = 0;
          __pyx_8 = 0;
          __pyx_5 = PyObject_CallObject(__pyx_7, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_shape), __pyx_n_sphere, __pyx_5) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_cellshading, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 85; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":86 */
          __pyx_6 = PyObject_IsTrue(__pyx_v_value); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
          if (__pyx_6) {
            __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_shape), __pyx_n_set_cellshading); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
            __pyx_8 = PyTuple_New(0); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
            __pyx_7 = PyObject_CallObject(__pyx_1, __pyx_8); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
            Py_DECREF(__pyx_1); __pyx_1 = 0;
            Py_DECREF(__pyx_8); __pyx_8 = 0;
            Py_DECREF(__pyx_7); __pyx_7 = 0;
            goto __pyx_L12;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_cellshading_shader, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 87; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_2 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_Material); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 87; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_get); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 87; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 87; goto __pyx_L1;}
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_value);
          __pyx_8 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 87; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          if (!__Pyx_TypeTest(__pyx_8, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 87; goto __pyx_L1;}
          Py_DECREF((PyObject *)((PyObject *)__pyx_v_shape->_shader));
          __pyx_v_shape->_shader = __pyx_8;
          __pyx_8 = 0;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_cellshading_outline_width, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
          __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_value);
          __pyx_5 = PyObject_CallObject(__pyx_7, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_9 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_v_shape->_outline_width = __pyx_9;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_cellshading_outline_attenuation, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 89; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 89; goto __pyx_L1;}
          __pyx_8 = PyTuple_New(1); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 89; goto __pyx_L1;}
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_8, 0, __pyx_v_value);
          __pyx_7 = PyObject_CallObject(__pyx_1, __pyx_8); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 89; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_8); __pyx_8 = 0;
          __pyx_9 = PyFloat_AsDouble(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 89; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_v_shape->_outline_attenuation = __pyx_9;
          goto __pyx_L11;
        }
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_cellshading_outline_color, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 90; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":91 */
          __pyx_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_split); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 91; goto __pyx_L1;}
          __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 91; goto __pyx_L1;}
          Py_INCREF(__pyx_k291p);
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k291p);
          __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 91; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_v_value);
          __pyx_v_value = __pyx_1;
          __pyx_1 = 0;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":92 */
          for (__pyx_v_i = 0; __pyx_v_i < 4; ++__pyx_v_i) {
            __pyx_8 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 92; goto __pyx_L1;}
            __pyx_7 = PyInt_FromLong(__pyx_v_i); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 92; goto __pyx_L1;}
            __pyx_2 = PyObject_GetItem(__pyx_v_value, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 92; goto __pyx_L1;}
            Py_DECREF(__pyx_7); __pyx_7 = 0;
            __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 92; goto __pyx_L1;}
            PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
            __pyx_2 = 0;
            __pyx_1 = PyObject_CallObject(__pyx_8, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 92; goto __pyx_L1;}
            Py_DECREF(__pyx_8); __pyx_8 = 0;
            Py_DECREF(__pyx_5); __pyx_5 = 0;
            __pyx_9 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 92; goto __pyx_L1;}
            Py_DECREF(__pyx_1); __pyx_1 = 0;
            (__pyx_v_shape->_outline_color[__pyx_v_i]) = __pyx_9;
            __pyx_L13:;
          }
          __pyx_L14:;
          goto __pyx_L11;
        }
        /*else*/ {
          __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; goto __pyx_L1;}
          Py_INCREF(__pyx_v_key);
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_v_key);
          Py_INCREF(__pyx_v_value);
          PyTuple_SET_ITEM(__pyx_7, 1, __pyx_v_value);
          __pyx_2 = PyNumber_Remainder(__pyx_k292p, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; goto __pyx_L1;}
        }
        __pyx_L11:;
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":94 */
  __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_shape), __pyx_n_build_materials); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 94; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 94; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_8, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 94; goto __pyx_L1;}
  Py_DECREF(__pyx_8); __pyx_8 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":95 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
  __pyx_r = ((PyObject *)__pyx_v_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  __Pyx_AddTraceback("_soya.parse_cal3d_cfg_file");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_soya);
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF(__pyx_v_dirname);
  Py_DECREF(__pyx_v_already_done);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_parts);
  Py_DECREF(__pyx_v_key);
  Py_DECREF(__pyx_v_value);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static void __pyx_f_5_soya_13_Cal3dSubMesh___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_13_Cal3dSubMesh___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":107 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dSubMesh *)__pyx_v_self)->_faces != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Cal3dSubMesh *)__pyx_v_self)->_faces);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":108 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dSubMesh *)__pyx_v_self)->_face_neighbors != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Cal3dSubMesh *)__pyx_v_self)->_face_neighbors);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dSubMesh.__dealloc__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_13_Cal3dSubMesh__build(struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_self,struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_shape,struct CalRenderer (*__pyx_v_cal_renderer),struct CalCoreModel (*__pyx_v_cal_core_model),struct CalCoreMesh (*__pyx_v_cal_core_mesh),int __pyx_v_mesh,int __pyx_v_submesh) {
  struct CalCoreSubmesh (*__pyx_v_cal_core_submesh);
  float (*__pyx_v_vertices);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF(__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shape);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":117 */
  __pyx_v_self->_mesh = __pyx_v_mesh;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":118 */
  __pyx_v_self->_submesh = __pyx_v_submesh;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":119 */
  __pyx_1 = PyInt_FromLong(CalCoreSubmesh_GetCoreMaterialThreadId(CalCoreMesh_GetCoreSubmesh(__pyx_v_cal_core_mesh,__pyx_v_submesh))); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 119; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_shape->_materials, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 119; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 119; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_material));
  __pyx_v_self->_material = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":121 */
  __pyx_v_cal_core_submesh = CalCoreMesh_GetCoreSubmesh(__pyx_v_cal_core_mesh,__pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":124 */
  __pyx_v_self->_nb_faces = CalCoreSubmesh_GetFaceCount(__pyx_v_cal_core_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":125 */
  __pyx_v_self->_faces = ((int (*))malloc(((__pyx_v_self->_nb_faces * 3) * (sizeof(int )))));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":126 */
  CalRenderer_GetFaces(__pyx_v_cal_renderer,__pyx_v_self->_faces);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":128 */
  __pyx_3 = (__pyx_v_5_soya_cal3d_nb_faces < __pyx_v_self->_nb_faces);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":129 */
    __pyx_v_5_soya_cal3d_facesides_array = ((int (*))realloc(__pyx_v_5_soya_cal3d_facesides_array,(__pyx_v_self->_nb_faces * (sizeof(int )))));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":130 */
    __pyx_v_5_soya_cal3d_nb_faces = __pyx_v_self->_nb_faces;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":134 */
  __pyx_v_self->_nb_vertices = CalCoreSubmesh_GetVertexCount(__pyx_v_cal_core_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":136 */
  __pyx_3 = (__pyx_v_5_soya_cal3d_nb_vertices < __pyx_v_self->_nb_vertices);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":137 */
    __pyx_v_5_soya_cal3d_texcoords_array = ((float (*))realloc(__pyx_v_5_soya_cal3d_texcoords_array,((__pyx_v_self->_nb_vertices * 2) * (sizeof(float )))));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":138 */
    __pyx_v_5_soya_cal3d_shades_array = ((float (*))realloc(__pyx_v_5_soya_cal3d_shades_array,(__pyx_v_self->_nb_vertices * (sizeof(float )))));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":139 */
    __pyx_v_5_soya_cal3d_nb_vertices = __pyx_v_self->_nb_vertices;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Cal3dSubMesh._build");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shape);
  return __pyx_r;
}

static PyObject *__pyx_n_exists;
static PyObject *__pyx_n_rb;
static PyObject *__pyx_n_wb;
static PyObject *__pyx_n_write;

static PyObject *__pyx_k294p;
static PyObject *__pyx_k296p;

static char (__pyx_k294[]) = "* Soya * Computing neighbor for Cal3D shape, and caching the result in file %s...";
static char (__pyx_k296[]) = "* Soya * Can't cache Cal3D neighbor face data in file %s";

static void __pyx_f_5_soya_13_Cal3dSubMesh__build_neighbors(struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_self,PyObject *__pyx_v_cache_filename,float (*__pyx_v_coords)) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  int __pyx_v_l;
  int __pyx_v_p1;
  int __pyx_v_p2;
  float (*__pyx_v_coord1);
  float (*__pyx_v_coord2);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  PyObject *__pyx_v_file;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  int __pyx_6;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_cache_filename);
  __pyx_v_file = Py_None; Py_INCREF(__pyx_v_file);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":150 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_CAL3D_NEIGHBORS);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":152 */
  __pyx_v_self->_face_neighbors = ((int (*))malloc(((__pyx_v_self->_nb_faces * 3) * (sizeof(int )))));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":155 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 155; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_exists); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_INCREF(__pyx_v_cache_filename);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_cache_filename);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 155; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":156 */
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 156; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 156; goto __pyx_L1;}
    Py_INCREF(__pyx_v_cache_filename);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_cache_filename);
    Py_INCREF(__pyx_n_rb);
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_n_rb);
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 156; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_file);
    __pyx_v_file = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":162 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_file, __pyx_n_read); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 162; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 162; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 162; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_3);
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":163 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_face_neighbors,(3 * __pyx_v_self->_nb_faces));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":164 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":166 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":168 */
  __pyx_1 = PyNumber_Remainder(__pyx_k294p, __pyx_v_cache_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 168; goto __pyx_L1;}
  if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 168; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 168; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/shape.pyx":170 */
  __pyx_4 = __pyx_v_self->_nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_4; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":171 */
    for (__pyx_v_k = 0; __pyx_v_k < 3; ++__pyx_v_k) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":172 */
      __pyx_v_p1 = (__pyx_v_self->_faces[((3 * __pyx_v_i) + __pyx_v_k)]);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":173 */
      __pyx_5 = (__pyx_v_k == 2);
      if (__pyx_5) {
        __pyx_v_p2 = (__pyx_v_self->_faces[(3 * __pyx_v_i)]);
        goto __pyx_L7;
      }
      /*else*/ {
        __pyx_v_p2 = (__pyx_v_self->_faces[(((3 * __pyx_v_i) + __pyx_v_k) + 1)]);
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":176 */
      __pyx_v_coord1 = (__pyx_v_coords + (3 * __pyx_v_p1));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":177 */
      __pyx_v_coord2 = (__pyx_v_coords + (3 * __pyx_v_p2));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":179 */
      __pyx_5 = __pyx_v_self->_nb_faces;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_5; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":180 */
        __pyx_6 = (__pyx_v_i == __pyx_v_j);
        if (__pyx_6) {
          goto __pyx_L8;
          goto __pyx_L10;
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":182 */
        __pyx_6 = (__pyx_v_p1 == (__pyx_v_self->_faces[(3 * __pyx_v_j)]));
        if (!__pyx_6) {
          __pyx_6 = (__pyx_v_p1 == (__pyx_v_self->_faces[((3 * __pyx_v_j) + 1)]));
          if (!__pyx_6) {
            __pyx_6 = (__pyx_v_p1 == (__pyx_v_self->_faces[((3 * __pyx_v_j) + 2)]));
          }
        }
        if (__pyx_6) {
          __pyx_6 = (__pyx_v_p2 == (__pyx_v_self->_faces[(3 * __pyx_v_j)]));
          if (!__pyx_6) {
            __pyx_6 = (__pyx_v_p2 == (__pyx_v_self->_faces[((3 * __pyx_v_j) + 1)]));
            if (!__pyx_6) {
              __pyx_6 = (__pyx_v_p2 == (__pyx_v_self->_faces[((3 * __pyx_v_j) + 2)]));
            }
          }
        }
        if (__pyx_6) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":183 */
          (__pyx_v_self->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]) = __pyx_v_j;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":184 */
          goto __pyx_L9;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":186 */
        __pyx_6 = (point_distance_to(__pyx_v_coord1,(__pyx_v_coords + (3 * (__pyx_v_self->_faces[(3 * __pyx_v_j)])))) < EPSILON);
        if (!__pyx_6) {
          __pyx_6 = (point_distance_to(__pyx_v_coord1,(__pyx_v_coords + (3 * (__pyx_v_self->_faces[((3 * __pyx_v_j) + 1)])))) < EPSILON);
          if (!__pyx_6) {
            __pyx_6 = (point_distance_to(__pyx_v_coord1,(__pyx_v_coords + (3 * (__pyx_v_self->_faces[((3 * __pyx_v_j) + 2)])))) < EPSILON);
          }
        }
        if (__pyx_6) {
          __pyx_6 = (point_distance_to(__pyx_v_coord2,(__pyx_v_coords + (3 * (__pyx_v_self->_faces[(3 * __pyx_v_j)])))) < EPSILON);
          if (!__pyx_6) {
            __pyx_6 = (point_distance_to(__pyx_v_coord2,(__pyx_v_coords + (3 * (__pyx_v_self->_faces[((3 * __pyx_v_j) + 1)])))) < EPSILON);
            if (!__pyx_6) {
              __pyx_6 = (point_distance_to(__pyx_v_coord2,(__pyx_v_coords + (3 * (__pyx_v_self->_faces[((3 * __pyx_v_j) + 2)])))) < EPSILON);
            }
          }
        }
        if (__pyx_6) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":187 */
          (__pyx_v_self->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]) = __pyx_v_j;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":188 */
          goto __pyx_L9;
          goto __pyx_L12;
        }
        __pyx_L12:;
        __pyx_L8:;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":190 */
        (__pyx_v_self->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]) = (-1);
      }
      __pyx_L9:;
      __pyx_L5:;
    }
    __pyx_L6:;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":193 */
  /*try:*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":194 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 194; goto __pyx_L13;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 194; goto __pyx_L13;}
    Py_INCREF(__pyx_v_cache_filename);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_cache_filename);
    Py_INCREF(__pyx_n_wb);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n_wb);
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 194; goto __pyx_L13;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_file);
    __pyx_v_file = __pyx_1;
    __pyx_1 = 0;
  }
  goto __pyx_L14;
  __pyx_L13:;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":195 */
  /*except:*/ {
    __Pyx_AddTraceback("_soya._build_neighbors");
    __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 195; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":196 */
    __pyx_3 = PyNumber_Remainder(__pyx_k296p, __pyx_v_cache_filename); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 196; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 196; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 196; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/shape.pyx":197 */
    goto __pyx_L0;
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":199 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/cal3d/shape.pyx":200 */
  chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_face_neighbors,(3 * __pyx_v_self->_nb_faces));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":201 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_file, __pyx_n_write); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  __pyx_2 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Cal3dSubMesh._build_neighbors");
  __pyx_L0:;
  Py_DECREF(__pyx_v_file);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_cache_filename);
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_8filename___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_8filename___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":224 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->__pyx_base._filename);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->__pyx_base._filename;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.filename.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_13full_filename___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_13full_filename___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":228 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_full_filename);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_full_filename;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.full_filename.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_9materials___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_9materials___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":232 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_materials);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_materials;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.materials.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_6meshes___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_6meshes___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":236 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_meshes);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_meshes;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.meshes.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_10animations___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_10animations___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":240 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_animations);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_animations;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.animations.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_6sphere___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_6sphere___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":244 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 244; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_r = __pyx_5;
  __pyx_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dShape.sphere.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Cal3dShape_6sphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_sphere); /*proto*/
static int __pyx_f_5_soya_11_Cal3dShape_6sphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_sphere) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  float __pyx_2;
  float __pyx_3;
  float __pyx_4;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_sphere);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":246 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_sphere, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[0]) = __pyx_2;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_sphere, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[1]) = __pyx_3;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_sphere, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[2]) = __pyx_4;
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_sphere, 3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_sphere, 4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dShape.sphere.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_sphere);
  return __pyx_r;
}

static PyObject *__pyx_k298p;

static char (__pyx_k297[]) = "";
static char (__pyx_k298[]) = "CalCoreModel_Create failed: %s";

static int __pyx_f_5_soya_11_Cal3dShape___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_11_Cal3dShape___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":250 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 250; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_meshes);
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_meshes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":251 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 251; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_animations);
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_animations = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":252 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 252; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":253 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 253; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_submeshes);
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_submeshes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":254 */
  (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_sphere[3]) = (-1.0);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":255 */
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model = CalCoreModel_New(__pyx_k297);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":256 */
  __pyx_2 = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model == 0);
  if (__pyx_2) {
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 256; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 256; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k298p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 256; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 256; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 256; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 256; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":258 */
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option = __pyx_e_5_soya_CAL3D_DOUBLE_SIDED;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Cal3dShape.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_12double_sided___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_12double_sided___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":262 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 262; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dShape.double_sided.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Cal3dShape_12double_sided___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_11_Cal3dShape_12double_sided___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 263; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/shape.pyx":264 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option | __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option & (~__pyx_e_5_soya_CAL3D_DOUBLE_SIDED));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.double_sided.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_6shadow___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_6shadow___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":269 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option & __pyx_e_5_soya_CAL3D_SHADOW)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 269; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dShape.shadow.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_11_Cal3dShape_6shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_11_Cal3dShape_6shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  int __pyx_v_x;
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsLong(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 270; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/shape.pyx":271 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option | __pyx_e_5_soya_CAL3D_SHADOW);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option & (~__pyx_e_5_soya_CAL3D_SHADOW));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.shadow.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_11cellshading___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_11cellshading___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":276 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option & __pyx_e_5_soya_CAL3D_CELL_SHADING)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dShape.cellshading.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_set_cellshading(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_set_cellshading(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Material *__pyx_v_shader = 0;
  PyObject *__pyx_v_outline_color = 0;
  float __pyx_v_outline_width;
  float __pyx_v_outline_attenuation;
  int __pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  float __pyx_4;
  static char *__pyx_argnames[] = {"shader","outline_color","outline_width","outline_attenuation",0};
  __pyx_v_shader = __pyx_k140;
  __pyx_v_outline_color = __pyx_k141;
  __pyx_v_outline_width = __pyx_k142;
  __pyx_v_outline_attenuation = __pyx_k143;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOff", __pyx_argnames, &__pyx_v_shader, &__pyx_v_outline_color, &__pyx_v_outline_width, &__pyx_v_outline_attenuation)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shader);
  Py_INCREF(__pyx_v_outline_color);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shader), __pyx_ptype_5_soya__Material, 1, "shader")) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 278; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/shape.pyx":280 */
  __pyx_1 = ((PyObject *)__pyx_v_shader);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 280; goto __pyx_L1;}
  if (!__pyx_2) {
    Py_DECREF((PyObject *)__pyx_1); __pyx_1 = 0;
    __pyx_1 = ((PyObject *)__pyx_v_5_soya__SHADER_DEFAULT_MATERIAL);
    Py_INCREF((PyObject *)__pyx_1);
  }
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 280; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_shader));
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_shader = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":281 */
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_outline_width = __pyx_v_outline_width;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":282 */
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_outline_attenuation = __pyx_v_outline_attenuation;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":283 */
  for (__pyx_v_i = 0; __pyx_v_i < 4; ++__pyx_v_i) {
    __pyx_1 = PyInt_FromLong(__pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 283; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_outline_color, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 283; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 283; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_outline_color[__pyx_v_i]) = __pyx_4;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":285 */
  ((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_option | __pyx_e_5_soya_CAL3D_CELL_SHADING);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Cal3dShape.set_cellshading");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shader);
  Py_DECREF(__pyx_v_outline_color);
  return __pyx_r;
}

static PyObject *__pyx_k299p;

static char (__pyx_k299[]) = "CalRenderer_BeginRendering failed: %s";

static void __pyx_f_5_soya_11_Cal3dShape__build_submeshes(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self) {
  struct CalRenderer (*__pyx_v_cal_renderer);
  struct CalModel (*__pyx_v_cal_model);
  struct CalCoreMesh (*__pyx_v_cal_core_mesh);
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_my_submesh;
  int __pyx_v_nb_mesh;
  int __pyx_v_nb_submesh;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_my_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_my_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":294 */
  __pyx_v_cal_model = CalModel_New(__pyx_v_self->_core_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":295 */
  __pyx_v_nb_mesh = CalCoreModel_GetCoreMeshCount(__pyx_v_self->_core_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":296 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_mesh; ++__pyx_v_i) {
    CalModel_AttachMesh(__pyx_v_cal_model,__pyx_v_i);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":297 */
  CalModel_SetMaterialSet(__pyx_v_cal_model,0);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":299 */
  __pyx_v_cal_renderer = CalModel_GetRenderer(__pyx_v_cal_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":300 */
  __pyx_1 = (CalRenderer_BeginRendering(__pyx_v_cal_renderer) == 0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 300; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 300; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k299p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 300; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 300; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 300; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 300; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":302 */
  __pyx_v_self->_nb_faces = 0;
  __pyx_v_self->_nb_vertices = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":304 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_mesh; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":305 */
    __pyx_v_cal_core_mesh = CalCoreModel_GetCoreMesh(__pyx_v_self->_core_model,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":306 */
    __pyx_v_nb_submesh = CalCoreMesh_GetCoreSubmeshCount(__pyx_v_cal_core_mesh);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":307 */
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_submesh; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":308 */
      CalRenderer_SelectMeshSubmesh(__pyx_v_cal_renderer,__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":310 */
      __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 310; goto __pyx_L1;}
      __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya__Cal3dSubMesh), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 310; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 310; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_my_submesh));
      __pyx_v_my_submesh = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":311 */
      __pyx_4 = ((struct __pyx_vtabstruct_5_soya__Cal3dSubMesh *)__pyx_v_my_submesh->__pyx_vtab)->_build(__pyx_v_my_submesh,__pyx_v_self,__pyx_v_cal_renderer,__pyx_v_self->_core_model,__pyx_v_cal_core_mesh,__pyx_v_i,__pyx_v_j); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 311; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":312 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self->_submeshes, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 312; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 312; goto __pyx_L1;}
      Py_INCREF(((PyObject *)__pyx_v_my_submesh));
      PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_my_submesh));
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 312; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":313 */
      __pyx_v_self->_nb_faces = (__pyx_v_self->_nb_faces + __pyx_v_my_submesh->_nb_faces);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":314 */
      __pyx_v_self->_nb_vertices = (__pyx_v_self->_nb_vertices + __pyx_v_my_submesh->_nb_vertices);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":315 */
      __pyx_1 = (__pyx_v_my_submesh->_material->_option & __pyx_e_5_soya_MATERIAL_ALPHA);
      if (__pyx_1) {
        __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_CAL3D_ALPHA);
        goto __pyx_L9;
      }
      __pyx_L9:;
      __pyx_L7:;
    }
    __pyx_L8:;
    __pyx_L5:;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":317 */
  CalRenderer_EndRendering(__pyx_v_cal_renderer);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":318 */
  CalModel_Delete(__pyx_v_cal_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":319 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_CAL3D_INITED);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._build_submeshes");
  __pyx_L0:;
  Py_DECREF(__pyx_v_my_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_11_Cal3dShape__set_face_neighborhood(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,int __pyx_v_index1,int __pyx_v_index2,GLfloat (*__pyx_v_vertices)) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":336 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Cal3dShape._set_face_neighborhood");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_11_Cal3dShape__set_cell_shading(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya__Material *__pyx_v_shader,GLfloat (*__pyx_v_color),GLfloat __pyx_v_line_width_factor) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shader);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":340 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Cal3dShape._set_cell_shading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shader);
}

static PyObject *__pyx_k300p;
static PyObject *__pyx_k301p;
static PyObject *__pyx_k302p;
static PyObject *__pyx_k303p;

static char (__pyx_k300[]) = "erreur 1";
static char (__pyx_k301[]) = "CalRenderer_BeginRendering failed: %s";
static char (__pyx_k302[]) = "neighbors_%s-%s";
static char (__pyx_k303[]) = "neighbors_%s-%s";

static void __pyx_f_5_soya_11_Cal3dShape__render(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_volume;
  struct CalRenderer (*__pyx_v_cal_renderer);
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh;
  GLfloat (*__pyx_v_ptrf);
  GLfloat (*__pyx_v_ptrn);
  int __pyx_v_j;
  float (*__pyx_v_shades);
  float (*__pyx_v_plane);
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  long __pyx_8;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_volume = Py_None; Py_INCREF((PyObject *) __pyx_v_volume);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":355 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya__Cal3dVolume)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 355; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_coordsyst));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_volume));
  __pyx_v_volume = ((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":356 */
  __pyx_v_ptrf = __pyx_v_volume->_vertex_coords;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":357 */
  __pyx_v_ptrn = __pyx_v_volume->_vertex_normals;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":359 */
  __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_SECONDPASS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":360 */
    __pyx_1 = (__pyx_v_volume->_face_plane_ok == 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_volume->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_volume);
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":362 */
    __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,__pyx_v_coordsyst);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":363 */
    __pyx_v_plane = __pyx_v_volume->_face_planes;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":364 */
    __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 364; goto __pyx_L1;}
    for (;;) {
      __pyx_L4:;
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 364; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 364; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_submesh));
      __pyx_v_submesh = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":365 */
      __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 365; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(__pyx_v_volume->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 365; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 365; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":366 */
        ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_outline(__pyx_v_self,__pyx_v_submesh,__pyx_v_frustum,__pyx_v_ptrf,__pyx_v_ptrn,__pyx_v_plane);
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":367 */
      __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":368 */
      __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":369 */
      __pyx_v_plane = (__pyx_v_plane + (__pyx_v_submesh->_nb_faces * 4));
    }
    __pyx_L5:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":370 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":372 */
  __pyx_v_cal_renderer = CalModel_GetRenderer(__pyx_v_volume->_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":374 */
  __pyx_1 = (CalRenderer_BeginRendering(__pyx_v_cal_renderer) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":375 */
    if (__Pyx_PrintItem(__pyx_k300p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 375; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 375; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 375; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 375; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/shape.pyx":376 */
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 376; goto __pyx_L1;}
    __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 376; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k301p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 376; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 376; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 376; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 376; goto __pyx_L1;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":378 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
  if (__pyx_1) {
    glDisable(GL_CULL_FACE);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":379 */
  glEnableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":380 */
  glEnableClientState(GL_NORMAL_ARRAY);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":381 */
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":383 */
  __pyx_4 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 383; goto __pyx_L1;}
  for (;;) {
    __pyx_L9:;
    __pyx_2 = PyIter_Next(__pyx_4);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 383; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 383; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":384 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 384; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_volume->_attached_meshes, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 384; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 384; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":389 */
      CalRenderer_SelectMeshSubmesh(__pyx_v_cal_renderer,__pyx_v_submesh->_mesh,__pyx_v_submesh->_submesh);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":392 */
      CalRenderer_GetVertices(__pyx_v_cal_renderer,__pyx_v_ptrf);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":393 */
      CalRenderer_GetNormals(__pyx_v_cal_renderer,__pyx_v_ptrn);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":394 */
      CalRenderer_GetTextureCoordinates(__pyx_v_cal_renderer,0,__pyx_v_5_soya_cal3d_texcoords_array);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":395 */
      glVertexPointer(3,GL_FLOAT,0,__pyx_v_ptrf);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":396 */
      glNormalPointer(GL_FLOAT,0,__pyx_v_ptrn);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":397 */
      glTexCoordPointer(2,GL_FLOAT,0,__pyx_v_5_soya_cal3d_texcoords_array);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":399 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_submesh->_material), __pyx_n_activate); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 399; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 399; goto __pyx_L1;}
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 399; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_5); __pyx_5 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":401 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_CELL_SHADING);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":402 */
        __pyx_1 = (!(__pyx_v_submesh->_option & __pyx_e_5_soya_CAL3D_NEIGHBORS));
        if (__pyx_1) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":403 */
          __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_join); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_dirname); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_INCREF(__pyx_v_self->_full_filename);
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self->_full_filename);
          __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          __pyx_2 = PyInt_FromLong(__pyx_v_submesh->_submesh); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_7, 0, __pyx_3);
          PyTuple_SET_ITEM(__pyx_7, 1, __pyx_2);
          __pyx_3 = 0;
          __pyx_2 = 0;
          __pyx_3 = PyNumber_Remainder(__pyx_k302p, __pyx_7); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_2, 0, __pyx_6);
          PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
          __pyx_6 = 0;
          __pyx_3 = 0;
          __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 403; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          ((struct __pyx_vtabstruct_5_soya__Cal3dSubMesh *)__pyx_v_submesh->__pyx_vtab)->_build_neighbors(__pyx_v_submesh,__pyx_7,__pyx_v_ptrf);
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          goto __pyx_L13;
        }
        __pyx_L13:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":405 */
        __pyx_v_shades = __pyx_v_5_soya_cal3d_shades_array;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":406 */
        ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading(__pyx_v_self,__pyx_v_coordsyst,__pyx_v_shades,__pyx_v_submesh->_nb_vertices,__pyx_v_ptrf,__pyx_v_ptrn);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":409 */
        glActiveTextureARB(GL_TEXTURE1);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":410 */
        __pyx_1 = (__pyx_v_self->_shader->_id == 0);
        if (__pyx_1) {
          ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_self->_shader->__pyx_base.__pyx_vtab)->_init_texture(__pyx_v_self->_shader);
          goto __pyx_L14;
        }
        __pyx_L14:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":411 */
        glEnable(GL_TEXTURE_2D);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":412 */
        glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":413 */
        glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_shader->_id);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":414 */
        glActiveTextureARB(GL_TEXTURE0);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":416 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":417 */
        __pyx_8 = (__pyx_v_submesh->_nb_faces * 3);
        for (__pyx_v_j = 0; __pyx_v_j < __pyx_8; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":418 */
          glMultiTexCoord2fARB(GL_TEXTURE1,(__pyx_v_shades[(__pyx_v_submesh->_faces[__pyx_v_j])]),(__pyx_v_shades[(__pyx_v_submesh->_faces[__pyx_v_j])]));

          /* "/home/jiba/src/soya/cal3d/shape.pyx":422 */
          glArrayElement((__pyx_v_submesh->_faces[__pyx_v_j]));
          __pyx_L15:;
        }
        __pyx_L16:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":423 */
        glEnd();

        /* "/home/jiba/src/soya/cal3d/shape.pyx":426 */
        glActiveTextureARB(GL_TEXTURE1);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":427 */
        glDisable(GL_TEXTURE_2D);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":428 */
        glActiveTextureARB(GL_TEXTURE0);
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":431 */
        __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_SHADOW);
        if (__pyx_1) {
          __pyx_1 = (!(__pyx_v_submesh->_option & __pyx_e_5_soya_CAL3D_NEIGHBORS));
        }
        if (__pyx_1) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":432 */
          __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          __pyx_3 = PyObject_GetAttr(__pyx_6, __pyx_n_path); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_join); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          __pyx_7 = PyObject_GetAttr(__pyx_2, __pyx_n_path); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          __pyx_6 = PyObject_GetAttr(__pyx_7, __pyx_n_dirname); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_INCREF(__pyx_v_self->_full_filename);
          PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self->_full_filename);
          __pyx_2 = PyObject_CallObject(__pyx_6, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_7 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          __pyx_6 = PyInt_FromLong(__pyx_v_submesh->_submesh); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_3, 0, __pyx_7);
          PyTuple_SET_ITEM(__pyx_3, 1, __pyx_6);
          __pyx_7 = 0;
          __pyx_6 = 0;
          __pyx_7 = PyNumber_Remainder(__pyx_k303p, __pyx_3); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
          PyTuple_SET_ITEM(__pyx_6, 1, __pyx_7);
          __pyx_2 = 0;
          __pyx_7 = 0;
          __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_6); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 432; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          Py_DECREF(__pyx_6); __pyx_6 = 0;
          ((struct __pyx_vtabstruct_5_soya__Cal3dSubMesh *)__pyx_v_submesh->__pyx_vtab)->_build_neighbors(__pyx_v_submesh,__pyx_3,__pyx_v_ptrf);
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          goto __pyx_L17;
        }
        __pyx_L17:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":434 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":435 */
        __pyx_8 = (__pyx_v_submesh->_nb_faces * 3);
        for (__pyx_v_j = 0; __pyx_v_j < __pyx_8; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":439 */
          glArrayElement((__pyx_v_submesh->_faces[__pyx_v_j]));
          __pyx_L18:;
        }
        __pyx_L19:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":440 */
        glEnd();
      }
      __pyx_L12:;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":442 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":443 */
    __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));
  }
  __pyx_L10:;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":445 */
  CalRenderer_EndRendering(__pyx_v_cal_renderer);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":446 */
  glDisableClientState(GL_NORMAL_ARRAY);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":447 */
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":448 */
  glDisableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":449 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
  if (__pyx_1) {
    glEnable(GL_CULL_FACE);
    goto __pyx_L20;
  }
  __pyx_L20:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_volume);
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_k304p;
static PyObject *__pyx_k305p;

static char (__pyx_k304[]) = "erreur 1";
static char (__pyx_k305[]) = "CalRenderer_BeginRendering failed: %s";

static void __pyx_f_5_soya_11_Cal3dShape__build_vertices(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_volume) {
  struct CalRenderer (*__pyx_v_cal_renderer);
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh;
  GLfloat (*__pyx_v_ptrf);
  GLfloat (*__pyx_v_ptrn);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_volume);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":457 */
  __pyx_v_ptrf = __pyx_v_volume->_vertex_coords;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":458 */
  __pyx_v_ptrn = __pyx_v_volume->_vertex_normals;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":460 */
  __pyx_v_cal_renderer = CalModel_GetRenderer(__pyx_v_volume->_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":462 */
  __pyx_1 = (CalRenderer_BeginRendering(__pyx_v_cal_renderer) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":463 */
    if (__Pyx_PrintItem(__pyx_k304p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 463; goto __pyx_L1;}
    __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 463; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 463; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 463; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/shape.pyx":464 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 464; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 464; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k305p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 464; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 464; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 464; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 464; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":466 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 466; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 466; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 466; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":467 */
    __pyx_4 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 467; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_volume->_attached_meshes, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 467; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 467; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":468 */
      CalRenderer_SelectMeshSubmesh(__pyx_v_cal_renderer,__pyx_v_submesh->_mesh,__pyx_v_submesh->_submesh);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":471 */
      CalRenderer_GetVertices(__pyx_v_cal_renderer,__pyx_v_ptrf);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":472 */
      CalRenderer_GetNormals(__pyx_v_cal_renderer,__pyx_v_ptrn);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":474 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":475 */
    __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));
  }
  __pyx_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":477 */
  CalRenderer_EndRendering(__pyx_v_cal_renderer);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._build_vertices");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_volume);
}

static void __pyx_f_5_soya_11_Cal3dShape__prepare_cellshading(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,float (*__pyx_v_shades),int __pyx_v_nb_vertices,float (*__pyx_v_coords),float (*__pyx_v_vnormals)) {
  int __pyx_v_n;
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":483 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_renderer->top_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 483; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 483; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 483; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_cast_into(__pyx_v_light,__pyx_v_coordsyst);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":484 */
  __pyx_2 = PyObject_GetIter(__pyx_v_5_soya_renderer->current_context->lights); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 484; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_1 = PyIter_Next(__pyx_2);
    if (!__pyx_1) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 484; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 484; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_1;
    __pyx_1 = 0;
    ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_cast_into(__pyx_v_light,__pyx_v_coordsyst);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":486 */
  for (__pyx_v_n = 0; __pyx_v_n < __pyx_v_nb_vertices; ++__pyx_v_n) {
    (__pyx_v_shades[__pyx_v_n]) = 0.5;
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":487 */
  ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading_shades(__pyx_v_self,__pyx_v_shades,__pyx_v_5_soya_renderer->top_lights,__pyx_v_nb_vertices,__pyx_v_coords,__pyx_v_vnormals);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":488 */
  ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading_shades(__pyx_v_self,__pyx_v_shades,__pyx_v_5_soya_renderer->current_context->lights,__pyx_v_nb_vertices,__pyx_v_coords,__pyx_v_vnormals);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":491 */
  for (__pyx_v_n = 0; __pyx_v_n < __pyx_v_nb_vertices; ++__pyx_v_n) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":494 */
    __pyx_3 = ((__pyx_v_shades[__pyx_v_n]) > 0.95);
    if (__pyx_3) {
      (__pyx_v_shades[__pyx_v_n]) = 0.95;
      goto __pyx_L10;
    }
    __pyx_3 = ((__pyx_v_shades[__pyx_v_n]) < 0.05);
    if (__pyx_3) {
      (__pyx_v_shades[__pyx_v_n]) = 0.05;
      goto __pyx_L10;
    }
    __pyx_L10:;
    __pyx_L8:;
  }
  __pyx_L9:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._prepare_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_11_Cal3dShape__prepare_cellshading_shades(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,float (*__pyx_v_shades),PyObject *__pyx_v_lights,int __pyx_v_nb_vertices,float (*__pyx_v_coords),float (*__pyx_v_vnormals)) {
  struct __pyx_obj_5_soya__Light *__pyx_v_light;
  float (*__pyx_v_ptr1);
  float (*__pyx_v_ptr2);
  float (__pyx_v_v[3]);
  float __pyx_v_tmp;
  int __pyx_v_j;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_lights);
  __pyx_v_light = Py_None; Py_INCREF((PyObject *) __pyx_v_light);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":504 */
  __pyx_1 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 504; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 504; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 504; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":505 */
    __pyx_v_ptr1 = __pyx_v_vnormals;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":506 */
    __pyx_3 = (__pyx_v_light->_w == 0.0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":507 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_vertices; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":508 */
        __pyx_v_tmp = (-vector_dot_product(__pyx_v_ptr1,__pyx_v_light->_data));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":509 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":510 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);
        __pyx_L5:;
      }
      __pyx_L6:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":513 */
      __pyx_v_ptr2 = __pyx_v_coords;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":514 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_vertices; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":515 */
        (__pyx_v_v[0]) = ((__pyx_v_light->_data[0]) - (__pyx_v_ptr2[0]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":516 */
        (__pyx_v_v[1]) = ((__pyx_v_light->_data[1]) - (__pyx_v_ptr2[1]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":517 */
        (__pyx_v_v[2]) = ((__pyx_v_light->_data[2]) - (__pyx_v_ptr2[2]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":518 */
        vector_normalize(__pyx_v_v);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":519 */
        __pyx_v_tmp = vector_dot_product(__pyx_v_ptr1,__pyx_v_v);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":520 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":521 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":522 */
        __pyx_v_ptr2 = (__pyx_v_ptr2 + 3);
        __pyx_L7:;
      }
      __pyx_L8:;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._prepare_cellshading_shades");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_light);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_lights);
}

static void __pyx_f_5_soya_11_Cal3dShape__render_outline(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh,__pyx_t_5_soya_Frustum (*__pyx_v_frustum),float (*__pyx_v_coords),float (*__pyx_v_vnormals),float (*__pyx_v_plane)) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  float __pyx_v_d;
  float (__pyx_v_plane2[4]);
  int (*__pyx_v_facesides);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int (*__pyx_v_vertex_used);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":534 */
  __pyx_v_facesides = __pyx_v_5_soya_cal3d_facesides_array;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":537 */
  __pyx_v_d = (sphere_distance_point(__pyx_v_self->_sphere,__pyx_v_frustum->position) * __pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":538 */
  __pyx_1 = (__pyx_v_d < 1.0);
  if (__pyx_1) {
    __pyx_v_d = __pyx_v_self->_outline_width;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":540 */
    __pyx_v_d = (__pyx_v_self->_outline_width / __pyx_v_d);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":541 */
    __pyx_1 = (__pyx_v_d < 2.0);
    if (__pyx_1) {
      __pyx_v_d = 2.0;
      goto __pyx_L3;
    }
    __pyx_L3:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":543 */
  ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_5_soya__DEFAULT_MATERIAL->__pyx_base.__pyx_vtab)->_activate(__pyx_v_5_soya__DEFAULT_MATERIAL);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":544 */
  glLineWidth(__pyx_v_d);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":545 */
  glColor4fv(__pyx_v_self->_outline_color);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":546 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":547 */
  glDepthFunc(GL_LEQUAL);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":550 */
  __pyx_1 = __pyx_v_submesh->_nb_faces;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":551 */
    __pyx_2 = ((((((__pyx_v_plane[0]) * (__pyx_v_frustum->position[0])) + ((__pyx_v_plane[1]) * (__pyx_v_frustum->position[1]))) + ((__pyx_v_plane[2]) * (__pyx_v_frustum->position[2]))) + (__pyx_v_plane[3])) > 0.0);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":552 */
      (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_FRONT;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":554 */
      (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_BACK;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":556 */
    __pyx_v_plane = (__pyx_v_plane + 4);
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":559 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/cal3d/shape.pyx":560 */
  chunk_register(__pyx_v_chunk,(__pyx_v_submesh->_nb_vertices * (sizeof(int ))));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":562 */
  __pyx_v_vertex_used = ((int (*))__pyx_v_chunk->content);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":563 */
  __pyx_2 = __pyx_v_submesh->_nb_vertices;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {
    (__pyx_v_vertex_used[__pyx_v_i]) = (-1);
    __pyx_L7:;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":567 */
  glBegin(GL_LINES);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":568 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":569 */
    __pyx_2 = __pyx_v_submesh->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":570 */
      for (__pyx_v_j = 0; __pyx_v_j < 3; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":571 */
        __pyx_v_k = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_j)]);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":572 */
        __pyx_1 = (__pyx_v_k == (-1));
        if (!__pyx_1) {
          __pyx_1 = ((__pyx_v_facesides[__pyx_v_k]) != (__pyx_v_facesides[__pyx_v_i]));
        }
        if (__pyx_1) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":573 */
          (__pyx_v_vertex_used[(__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)])]) = 1;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":576 */
          glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)]))));

          /* "/home/jiba/src/soya/cal3d/shape.pyx":577 */
          __pyx_1 = (__pyx_v_j < 2);
          if (__pyx_1) {
            glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[(((3 * __pyx_v_i) + __pyx_v_j) + 1)]))));
            goto __pyx_L15;
          }
          /*else*/ {
            glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[(3 * __pyx_v_i)]))));
          }
          __pyx_L15:;
          goto __pyx_L14;
        }
        __pyx_L14:;
        __pyx_L12:;
      }
      __pyx_L13:;
      __pyx_L10:;
    }
    __pyx_L11:;
    goto __pyx_L9;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":581 */
    __pyx_1 = __pyx_v_submesh->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":582 */
      __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_FRONT);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":584 */
        for (__pyx_v_j = 0; __pyx_v_j < 3; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":585 */
          __pyx_v_k = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_j)]);

          /* "/home/jiba/src/soya/cal3d/shape.pyx":586 */
          __pyx_2 = (__pyx_v_k == (-1));
          if (!__pyx_2) {
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_k]) == __pyx_e_5_soya_FACE_BACK);
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/cal3d/shape.pyx":587 */
            (__pyx_v_vertex_used[(__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)])]) = 1;

            /* "/home/jiba/src/soya/cal3d/shape.pyx":590 */
            glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)]))));

            /* "/home/jiba/src/soya/cal3d/shape.pyx":591 */
            __pyx_2 = (__pyx_v_j < 2);
            if (__pyx_2) {
              glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[(((3 * __pyx_v_i) + __pyx_v_j) + 1)]))));
              goto __pyx_L22;
            }
            /*else*/ {
              glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[(3 * __pyx_v_i)]))));
            }
            __pyx_L22:;
            goto __pyx_L21;
          }
          __pyx_L21:;
          __pyx_L19:;
        }
        __pyx_L20:;
        goto __pyx_L18;
      }
      __pyx_L18:;
      __pyx_L16:;
    }
    __pyx_L17:;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":594 */
  glEnd();

  /* "/home/jiba/src/soya/cal3d/shape.pyx":596 */
  glPointSize((__pyx_v_d / 2));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":598 */
  glBegin(GL_POINTS);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":599 */
  __pyx_2 = __pyx_v_submesh->_nb_vertices;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":600 */
    __pyx_1 = ((__pyx_v_vertex_used[__pyx_v_i]) == 1);
    if (__pyx_1) {
      glVertex3fv((__pyx_v_coords + (__pyx_v_i * 3)));
      goto __pyx_L25;
    }
    __pyx_L25:;
    __pyx_L23:;
  }
  __pyx_L24:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":601 */
  glEnd();

  /* "/home/jiba/src/soya/cal3d/shape.pyx":603 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":605 */
  glLineWidth(1.0);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":606 */
  glPointSize(1.0);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":607 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":608 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":609 */
  glColor4fv(__pyx_v_5_soya_white);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Cal3dShape._render_outline");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_submesh);
}

static void __pyx_f_5_soya_11_Cal3dShape___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_11_Cal3dShape___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":614 */
  CalCoreModel_Delete(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dShape.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k306p;

static char (__pyx_k306[]) = "CalCoreModel_LoadCoreSkeleton failed: %s";

static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_skeleton(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_skeleton(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_r;
  char (*__pyx_1);
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_filename);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":617 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
  __pyx_2 = (CalCoreModel_LoadCoreSkeleton(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_1) == 0);
  if (__pyx_2) {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
    __pyx_5 = PyNumber_Remainder(__pyx_k306p, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 617; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dShape.load_skeleton");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_k307p;

static char (__pyx_k307[]) = "CalCoreModel_LoadCoreMesh failed on file %s: %s";

static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_mesh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_mesh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_i;
  PyObject *__pyx_r;
  char (*__pyx_1);
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_filename);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":621 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 621; goto __pyx_L1;}
  __pyx_v_i = CalCoreModel_LoadCoreMesh(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_1);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":622 */
  __pyx_2 = (__pyx_v_i == (-1));
  if (__pyx_2) {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k307p, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 622; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":623 */
  __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_path); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_basename); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_filename);
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_5 = PySequence_GetSlice(__pyx_6, 0, (-4)); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (PyObject_SetItem(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_meshes, __pyx_5, __pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 623; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":624 */
  __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 624; goto __pyx_L1;}
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Cal3dShape.load_mesh");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_k308p;

static char (__pyx_k308[]) = "CalCoreModel_LoadCoreMaterial failed on file %s: %s";

static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_i;
  PyObject *__pyx_r;
  char (*__pyx_1);
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_filename);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":628 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 628; goto __pyx_L1;}
  __pyx_v_i = CalCoreModel_LoadCoreMaterial(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_1);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":629 */
  __pyx_2 = (__pyx_v_i == (-1));
  if (__pyx_2) {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k308p, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 629; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":630 */
  __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 630; goto __pyx_L1;}
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dShape.load_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_k309p;

static char (__pyx_k309[]) = "CalCoreModel_LoadCoreAnimation failed on file %s: %s";

static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_animation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_load_animation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_i;
  PyObject *__pyx_r;
  char (*__pyx_1);
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_filename);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":634 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 634; goto __pyx_L1;}
  __pyx_v_i = CalCoreModel_LoadCoreAnimation(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_1);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":635 */
  __pyx_2 = (__pyx_v_i == (-1));
  if (__pyx_2) {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyNumber_Remainder(__pyx_k309p, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[24]; __pyx_lineno = 635; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":636 */
  __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_path); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_5 = PyObject_GetAttr(__pyx_4, __pyx_n_basename); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_filename);
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_5 = PySequence_GetSlice(__pyx_6, 0, (-4)); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (PyObject_SetItem(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_animations, __pyx_5, __pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 636; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":637 */
  __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 637; goto __pyx_L1;}
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Cal3dShape.load_animation");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_11_Cal3dShape_build_materials(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_11_Cal3dShape_build_materials(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_i;
  int __pyx_v_nb;
  struct CalCoreMaterial (*__pyx_v_material);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":643 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_materials, __pyx_n___imul__); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 643; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 643; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 643; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 643; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":644 */
  __pyx_4 = (((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model == 0);
  if (__pyx_4) {
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":646 */
  __pyx_v_nb = CalCoreModel_GetCoreMaterialCount(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":647 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":648 */
    __pyx_v_material = CalCoreModel_GetCoreMaterial(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":651 */
    __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_materials, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalCoreMaterial_GetMapFilename(__pyx_v_material,0)); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; goto __pyx_L1;}
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Cal3dShape *)((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_get_material_4_cal3d(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self),__pyx_3,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,CalCoreMaterial_GetShininess(__pyx_v_material))); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":653 */
    CalCoreModel_CreateCoreMaterialThread(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":654 */
    CalCoreModel_SetCoreMaterialId(((struct __pyx_obj_5_soya__Cal3dShape *)__pyx_v_self)->_core_model,__pyx_v_i,0,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":655 */
    CalCoreMaterial_SetUserData(__pyx_v_material,((CalUserData )__pyx_v_i));
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":657 */
  CalRenderer_GetMapUserData;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Cal3dShape.build_materials");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_find;

static PyObject *__pyx_k310p;

static char (__pyx_k310[]) = ".";

static struct __pyx_obj_5_soya__Material *__pyx_f_5_soya_11_Cal3dShape__get_material_4_cal3d(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,PyObject *__pyx_v_image_filename,float __pyx_v_diffuse_r,float __pyx_v_diffuse_g,float __pyx_v_diffuse_b,float __pyx_v_diffuse_a,float __pyx_v_specular_r,float __pyx_v_specular_g,float __pyx_v_specular_b,float __pyx_v_specular_a,float __pyx_v_shininess) {
  PyObject *__pyx_v_material_name;
  struct __pyx_obj_5_soya__Material *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_image_filename);
  __pyx_v_material_name = Py_None; Py_INCREF(__pyx_v_material_name);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":688 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 688; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 688; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_basename); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 688; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 688; goto __pyx_L1;}
  Py_INCREF(__pyx_v_image_filename);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_image_filename);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 688; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_material_name);
  __pyx_v_material_name = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":689 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_material_name, __pyx_n_find); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 689; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 689; goto __pyx_L1;}
  Py_INCREF(__pyx_k310p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k310p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 689; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 689; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PySequence_GetSlice(__pyx_v_material_name, 0, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 689; goto __pyx_L1;}
  Py_DECREF(__pyx_v_material_name);
  __pyx_v_material_name = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":690 */
  /*try:*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":691 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Material); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 691; goto __pyx_L2;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 691; goto __pyx_L2;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 691; goto __pyx_L2;}
    Py_INCREF(__pyx_v_material_name);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_material_name);
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 691; goto __pyx_L2;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 691; goto __pyx_L2;}
    Py_INCREF((PyObject *)__pyx_2);
    __pyx_r = (struct __pyx_obj_5_soya__Material *)__pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  goto __pyx_L3;
  __pyx_L2:;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":692 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 692; goto __pyx_L1;}
  __pyx_4 = PyErr_ExceptionMatches(__pyx_3);
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {
    __Pyx_AddTraceback("_soya._get_material_4_cal3d");
    __pyx_1 = __Pyx_GetExcValue(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 692; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":693 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_create_material_4_cal3d(__pyx_v_self,__pyx_v_image_filename,__pyx_v_diffuse_r,__pyx_v_diffuse_g,__pyx_v_diffuse_b,__pyx_v_diffuse_a,__pyx_v_specular_r,__pyx_v_specular_g,__pyx_v_specular_b,__pyx_v_specular_a,__pyx_v_shininess)); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 693; goto __pyx_L1;}
    __pyx_r = (struct __pyx_obj_5_soya__Material *)__pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  goto __pyx_L1;
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Cal3dShape._get_material_4_cal3d");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_material_name);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_image_filename);
  return ((struct __pyx_obj_5_soya__Material *)__pyx_r) ;
}

static PyObject *__pyx_n_diffuse;
static PyObject *__pyx_n_specular;
static PyObject *__pyx_n_DIRNAME;
static PyObject *__pyx_n_endswith;

static PyObject *__pyx_k311p;
static PyObject *__pyx_k312p;
static PyObject *__pyx_k314p;

static char (__pyx_k311[]) = "__cal3dmaterial_texture_%s_diffuse_%s_%s_%s_%s_specular_%s_%s_%s_%s_shininess_%s__";
static char (__pyx_k312[]) = "";
static char (__pyx_k314[]) = ".raw";

static struct __pyx_obj_5_soya__Material *__pyx_f_5_soya_11_Cal3dShape__create_material_4_cal3d(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,PyObject *__pyx_v_image_filename,float __pyx_v_diffuse_r,float __pyx_v_diffuse_g,float __pyx_v_diffuse_b,float __pyx_v_diffuse_a,float __pyx_v_specular_r,float __pyx_v_specular_g,float __pyx_v_specular_b,float __pyx_v_specular_a,float __pyx_v_shininess) {
  PyObject *__pyx_v_material_name;
  struct __pyx_obj_5_soya__Material *__pyx_v_material;
  PyObject *__pyx_v_soya;
  PyObject *__pyx_v_path;
  PyObject *__pyx_v_file;
  struct __pyx_obj_5_soya__Material *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  PyObject *__pyx_10 = 0;
  int __pyx_11;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_image_filename);
  __pyx_v_material_name = Py_None; Py_INCREF(__pyx_v_material_name);
  __pyx_v_material = Py_None; Py_INCREF((PyObject *) __pyx_v_material);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);
  __pyx_v_path = Py_None; Py_INCREF(__pyx_v_path);
  __pyx_v_file = Py_None; Py_INCREF(__pyx_v_file);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":696 */
  __pyx_1 = PyFloat_FromDouble(__pyx_v_diffuse_r); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_diffuse_g); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_diffuse_b); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_diffuse_a); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(__pyx_v_specular_r); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(__pyx_v_specular_g); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(__pyx_v_specular_b); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(__pyx_v_specular_a); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(__pyx_v_shininess); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  __pyx_10 = PyTuple_New(10); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  Py_INCREF(__pyx_v_image_filename);
  PyTuple_SET_ITEM(__pyx_10, 0, __pyx_v_image_filename);
  PyTuple_SET_ITEM(__pyx_10, 1, __pyx_1);
  PyTuple_SET_ITEM(__pyx_10, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_10, 3, __pyx_3);
  PyTuple_SET_ITEM(__pyx_10, 4, __pyx_4);
  PyTuple_SET_ITEM(__pyx_10, 5, __pyx_5);
  PyTuple_SET_ITEM(__pyx_10, 6, __pyx_6);
  PyTuple_SET_ITEM(__pyx_10, 7, __pyx_7);
  PyTuple_SET_ITEM(__pyx_10, 8, __pyx_8);
  PyTuple_SET_ITEM(__pyx_10, 9, __pyx_9);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k311p, __pyx_10); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 696; goto __pyx_L1;}
  Py_DECREF(__pyx_10); __pyx_10 = 0;
  Py_DECREF(__pyx_v_material_name);
  __pyx_v_material_name = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":698 */
  /*try:*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":699 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Material); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 699; goto __pyx_L2;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 699; goto __pyx_L2;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 699; goto __pyx_L2;}
    Py_INCREF(__pyx_v_material_name);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_material_name);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 699; goto __pyx_L2;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 699; goto __pyx_L2;}
    Py_INCREF((PyObject *)__pyx_5);
    __pyx_r = (struct __pyx_obj_5_soya__Material *)__pyx_5;
    __pyx_5 = 0;
    goto __pyx_L0;
  }
  goto __pyx_L3;
  __pyx_L2:;
  Py_XDECREF(__pyx_6); __pyx_6 = 0;
  Py_XDECREF(__pyx_7); __pyx_7 = 0;
  Py_XDECREF(__pyx_8); __pyx_8 = 0;
  Py_XDECREF(__pyx_9); __pyx_9 = 0;
  Py_XDECREF(__pyx_10); __pyx_10 = 0;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;
  Py_XDECREF(__pyx_2); __pyx_2 = 0;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;
  Py_XDECREF(__pyx_4); __pyx_4 = 0;
  Py_XDECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":700 */
  __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 700; goto __pyx_L1;}
  __pyx_11 = PyErr_ExceptionMatches(__pyx_6);
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (__pyx_11) {
    __Pyx_AddTraceback("_soya._create_material_4_cal3d");
    __pyx_7 = __Pyx_GetExcValue(); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 700; goto __pyx_L1;}
    Py_DECREF(__pyx_7); __pyx_7 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":701 */
    goto __pyx_L3;
  }
  goto __pyx_L1;
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":704 */
  __pyx_8 = __Pyx_GetName(__pyx_m, __pyx_n_Material); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 704; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(0); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 704; goto __pyx_L1;}
  __pyx_10 = PyObject_CallObject(__pyx_8, __pyx_9); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 704; goto __pyx_L1;}
  Py_DECREF(__pyx_8); __pyx_8 = 0;
  Py_DECREF(__pyx_9); __pyx_9 = 0;
  if (!__Pyx_TypeTest(__pyx_10, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 704; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_material));
  __pyx_v_material = __pyx_10;
  __pyx_10 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":705 */
  if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_filename, __pyx_v_material_name) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 705; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/shape.pyx":706 */
  __pyx_1 = PyFloat_FromDouble(__pyx_v_diffuse_r); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_diffuse_g); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_diffuse_b); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_diffuse_a); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 706; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 706; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_diffuse, __pyx_5) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 706; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":707 */
  __pyx_6 = PyFloat_FromDouble(__pyx_v_specular_r); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 707; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(__pyx_v_specular_g); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 707; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(__pyx_v_specular_b); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 707; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(__pyx_v_specular_a); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 707; goto __pyx_L1;}
  __pyx_10 = PyTuple_New(4); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 707; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_10, 0, __pyx_6);
  PyTuple_SET_ITEM(__pyx_10, 1, __pyx_7);
  PyTuple_SET_ITEM(__pyx_10, 2, __pyx_8);
  PyTuple_SET_ITEM(__pyx_10, 3, __pyx_9);
  __pyx_6 = 0;
  __pyx_7 = 0;
  __pyx_8 = 0;
  __pyx_9 = 0;
  if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_specular, __pyx_10) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 707; goto __pyx_L1;}
  Py_DECREF(__pyx_10); __pyx_10 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":708 */
  __pyx_v_material->shininess = __pyx_v_shininess;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":710 */
  if (PyObject_Cmp(__pyx_v_image_filename, __pyx_k312p, &__pyx_11) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 710; goto __pyx_L1;}
  __pyx_11 = __pyx_11 != 0;
  if (__pyx_11) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":711 */
    __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 711; goto __pyx_L1;}
    Py_DECREF(__pyx_v_soya);
    __pyx_v_soya = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":712 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 712; goto __pyx_L1;}
    __pyx_3 = PyObject_GetIter(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 712; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    for (;;) {
      __pyx_L5:;
      __pyx_4 = PyIter_Next(__pyx_3);
      if (!__pyx_4) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 712; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_4;
      __pyx_4 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":713 */
      __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_path); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_7 = PyObject_GetAttr(__pyx_6, __pyx_n_join); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __pyx_8 = __Pyx_GetName(__pyx_m, __pyx_n_Image); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      __pyx_9 = PyObject_GetAttr(__pyx_8, __pyx_n_DIRNAME); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_8); __pyx_8 = 0;
      __pyx_10 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      __pyx_1 = PyObject_GetAttr(__pyx_10, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_10); __pyx_10 = 0;
      __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_basename); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_INCREF(__pyx_v_image_filename);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_image_filename);
      __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_INCREF(__pyx_v_path);
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_v_path);
      PyTuple_SET_ITEM(__pyx_6, 1, __pyx_9);
      PyTuple_SET_ITEM(__pyx_6, 2, __pyx_5);
      __pyx_9 = 0;
      __pyx_5 = 0;
      __pyx_8 = PyObject_CallObject(__pyx_7, __pyx_6); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L1;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      Py_DECREF(__pyx_v_file);
      __pyx_v_file = __pyx_8;
      __pyx_8 = 0;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":714 */
      __pyx_10 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; goto __pyx_L1;}
      __pyx_1 = PyObject_GetAttr(__pyx_10, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; goto __pyx_L1;}
      Py_DECREF(__pyx_10); __pyx_10 = 0;
      __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exists); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; goto __pyx_L1;}
      Py_INCREF(__pyx_v_file);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_file);
      __pyx_9 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_11 = PyObject_IsTrue(__pyx_9); if (__pyx_11 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; goto __pyx_L1;}
      Py_DECREF(__pyx_9); __pyx_9 = 0;
      if (__pyx_11) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":715 */
        __pyx_5 = PyObject_GetAttr(__pyx_v_image_filename, __pyx_n_endswith); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
        __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
        Py_INCREF(__pyx_k314p);
        PyTuple_SET_ITEM(__pyx_7, 0, __pyx_k314p);
        __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        __pyx_11 = PyObject_IsTrue(__pyx_6); if (__pyx_11 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        if (__pyx_11) {
          __pyx_8 = __Pyx_GetName(__pyx_m, __pyx_n_load_raw_image); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
          __pyx_10 = PyTuple_New(1); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
          Py_INCREF(__pyx_v_file);
          PyTuple_SET_ITEM(__pyx_10, 0, __pyx_v_file);
          __pyx_1 = PyObject_CallObject(__pyx_8, __pyx_10); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
          Py_DECREF(__pyx_8); __pyx_8 = 0;
          Py_DECREF(__pyx_10); __pyx_10 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_texture, __pyx_1) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 715; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          goto __pyx_L8;
        }
        /*else*/ {
          __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_open_image); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 716; goto __pyx_L1;}
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 716; goto __pyx_L1;}
          Py_INCREF(__pyx_v_file);
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_file);
          __pyx_9 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 716; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_texture, __pyx_9) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 716; goto __pyx_L1;}
          Py_DECREF(__pyx_9); __pyx_9 = 0;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":717 */
        goto __pyx_L6;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    /*else*/ {
      ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_set_texture_from_model(__pyx_v_self,__pyx_v_material,__pyx_v_image_filename);
    }
    __pyx_L6:;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":720 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_material));
  __pyx_r = (struct __pyx_obj_5_soya__Material *)((PyObject *)__pyx_v_material);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  Py_XDECREF(__pyx_10);
  __Pyx_AddTraceback("_soya._Cal3dShape._create_material_4_cal3d");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_material_name);
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF(__pyx_v_soya);
  Py_DECREF(__pyx_v_path);
  Py_DECREF(__pyx_v_file);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_image_filename);
  return ((struct __pyx_obj_5_soya__Material *)__pyx_r) ;
}

static PyObject *__pyx_k315p;

static char (__pyx_k315[]) = ".raw";

static void __pyx_f_5_soya_11_Cal3dShape__set_texture_from_model(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya__Material *__pyx_v_material,PyObject *__pyx_v_image_filename) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_material);
  Py_INCREF(__pyx_v_image_filename);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":724 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_join); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_path); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_dirname); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self->_full_filename);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self->_full_filename);
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
  Py_INCREF(__pyx_v_image_filename);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_image_filename);
  __pyx_4 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 724; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_image_filename);
  __pyx_v_image_filename = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":725 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_image_filename, __pyx_n_endswith); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
  Py_INCREF(__pyx_k315p);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k315p);
  __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_5 = PyObject_IsTrue(__pyx_2); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_5) {
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_load_raw_image); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
    Py_INCREF(__pyx_v_image_filename);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_image_filename);
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_texture, __pyx_1) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 725; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_open_image); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; goto __pyx_L1;}
    Py_INCREF(__pyx_v_image_filename);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_image_filename);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_texture, __pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._set_texture_from_model");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF(__pyx_v_image_filename);
}

static int __pyx_f_5_soya_11_Cal3dShape__shadow(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh;
  struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_volume;
  GLfloat (*__pyx_v_ptrf);
  GLfloat (*__pyx_v_ptrn);
  GLfloat (*__pyx_v_plane);
  int __pyx_v_i;
  int __pyx_v_r;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);
  __pyx_v_volume = Py_None; Py_INCREF((PyObject *) __pyx_v_volume);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":730 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_SHADOW));
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":737 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya__Cal3dVolume)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 737; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_coordsyst));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_volume));
  __pyx_v_volume = ((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":738 */
  __pyx_1 = (__pyx_v_volume->_face_plane_ok == 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_volume->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_volume);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":740 */
  __pyx_v_ptrf = __pyx_v_volume->_vertex_coords;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":741 */
  __pyx_v_ptrn = __pyx_v_volume->_vertex_normals;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":742 */
  __pyx_v_plane = __pyx_v_volume->_face_planes;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":743 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":744 */
  __pyx_v_r = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":746 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 746; goto __pyx_L1;}
  for (;;) {
    __pyx_L4:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 746; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 746; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":747 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_volume->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":748 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_shadow2(__pyx_v_self,__pyx_v_submesh,__pyx_v_volume,__pyx_v_light,__pyx_v_ptrf,__pyx_v_ptrn,__pyx_v_plane);
      if (__pyx_1) {
        __pyx_v_r = 1;
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":749 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":750 */
    __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":751 */
    __pyx_v_plane = (__pyx_v_plane + (__pyx_v_submesh->_nb_faces * 4));

    /* "/home/jiba/src/soya/cal3d/shape.pyx":752 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":754 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._shadow");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_volume);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static PyObject *__pyx_k316p;

static char (__pyx_k316[]) = "* Soya * warning : drawing shadow for non-closed shape (can't join segments)!";

static int __pyx_f_5_soya_11_Cal3dShape__shadow2(struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_self,struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh,struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_volume,struct __pyx_obj_5_soya__Light *__pyx_v_light,float (*__pyx_v_coords),float (*__pyx_v_vnormals),float (*__pyx_v_plane)) {
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  int __pyx_v_neighbor_face;
  float (*__pyx_v_coord_ptr);
  double (*__pyx_v_coord_ptrd);
  float (__pyx_v_coord[4]);
  float (__pyx_v_cone[9]);
  float __pyx_v_b;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  int __pyx_v_p1;
  int __pyx_v_p2;
  int __pyx_v_nb_inter;
  int __pyx_v_nb_segment;
  int (*__pyx_v_facesides);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk2);
  float (__pyx_v_fp1[3]);
  float (__pyx_v_fp2[3]);
  float (__pyx_v_inter1[3]);
  float (__pyx_v_inter2[3]);
  float (__pyx_v_face_data[15]);
  float (__pyx_v_v1[3]);
  float (__pyx_v_v2[3]);
  int (__pyx_v_nb_points[3]);
  PyObject *__pyx_v_joined;
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  double __pyx_3;
  double __pyx_4;
  double __pyx_5;
  double __pyx_6;
  PyObject *__pyx_7 = 0;
  PyObject *__pyx_8 = 0;
  PyObject *__pyx_9 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_submesh);
  Py_INCREF((PyObject *)__pyx_v_volume);
  Py_INCREF((PyObject *)__pyx_v_light);
  __pyx_v_joined = Py_None; Py_INCREF(__pyx_v_joined);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":769 */
  __pyx_v_facesides = __pyx_v_5_soya_cal3d_facesides_array;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":777 */
  __pyx_v_b = __pyx_v_5_soya_renderer->current_camera->_back;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":781 */
  ((struct __pyx_vtabstruct_5_soya__Light *)__pyx_v_light->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_cast_into(__pyx_v_light,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_volume));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":782 */
  __pyx_1 = (__pyx_v_light->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":783 */
    cone_from_sphere_and_vector(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":784 */
    __pyx_1 = __pyx_v_submesh->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":786 */
      __pyx_2 = (vector_dot_product(__pyx_v_light->_data,(__pyx_v_plane + (4 * __pyx_v_i))) >= 0.0);
      if (__pyx_2) {
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_BACK;
        goto __pyx_L5;
      }
      /*else*/ {
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_FRONT;
      }
      __pyx_L5:;
      __pyx_L3:;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":790 */
    __pyx_2 = (cone_from_sphere_and_origin(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b) == 0);
    if (__pyx_2) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":791 */
    __pyx_1 = __pyx_v_submesh->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":793 */
      __pyx_2 = ((((((__pyx_v_light->_data[0]) * (__pyx_v_plane[0])) + ((__pyx_v_light->_data[1]) * (__pyx_v_plane[1]))) + ((__pyx_v_light->_data[2]) * (__pyx_v_plane[2]))) + (__pyx_v_plane[3])) > 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":794 */
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_FRONT;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":796 */
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_BACK;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":797 */
      __pyx_v_plane = (__pyx_v_plane + 4);
      __pyx_L7:;
    }
    __pyx_L8:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":800 */
  glStencilFunc(GL_ALWAYS,1,4294967295);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":801 */
  glFrontFace(GL_CW);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":804 */
  glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":805 */
  glLoadMatrixf(__pyx_v_volume->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":806 */
  glNewList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST,GL_COMPILE_AND_EXECUTE);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":809 */
  __pyx_v_frustum = ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_volume));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":810 */
  (__pyx_v_coord[0]) = (0.5 * ((__pyx_v_frustum->points[0]) + (__pyx_v_frustum->points[6])));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":811 */
  (__pyx_v_coord[1]) = (0.5 * ((__pyx_v_frustum->points[1]) + (__pyx_v_frustum->points[7])));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":812 */
  (__pyx_v_coord[2]) = (0.5 * ((__pyx_v_frustum->points[2]) + (__pyx_v_frustum->points[8])));

  /* "/home/jiba/src/soya/cal3d/shape.pyx":813 */
  (__pyx_v_coord[3]) = point_distance_to(__pyx_v_coord,__pyx_v_frustum->points);

  /* "/home/jiba/src/soya/cal3d/shape.pyx":814 */
  __pyx_2 = sphere_is_in_cone(__pyx_v_coord,__pyx_v_cone);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":819 */
    __pyx_3 = 0.0;
    __pyx_4 = 0.0;
    __pyx_5 = (-1.0);
    __pyx_6 = ((-0.1) - __pyx_v_5_soya_renderer->current_camera->_front);
    (__pyx_v_plane[0]) = __pyx_3;
    (__pyx_v_plane[1]) = __pyx_4;
    (__pyx_v_plane[2]) = __pyx_5;
    (__pyx_v_plane[3]) = __pyx_6;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":821 */
    __pyx_v_chunk = get_chunk();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":822 */
    __pyx_v_chunk2 = get_chunk();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":823 */
    __pyx_v_nb_inter = 0;
    __pyx_v_nb_segment = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":826 */
    __pyx_1 = __pyx_v_submesh->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":827 */
      __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":829 */
        for (__pyx_v_k = 0; __pyx_v_k < 3; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":830 */
          __pyx_v_neighbor_face = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]);

          /* "/home/jiba/src/soya/cal3d/shape.pyx":833 */
          __pyx_2 = (__pyx_v_neighbor_face == (-1));
          if (!__pyx_2) {
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_neighbor_face]) == __pyx_e_5_soya_FACE_LIGHT_FRONT);
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/cal3d/shape.pyx":835 */
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":836 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/cal3d/shape.pyx":837 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L18;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L18:;
              goto __pyx_L17;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":840 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L19;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L19:;

              /* "/home/jiba/src/soya/cal3d/shape.pyx":842 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L17:;

            /* "/home/jiba/src/soya/cal3d/shape.pyx":844 */
            __pyx_v_nb_segment = (__pyx_v_nb_segment + 1);

            /* "/home/jiba/src/soya/cal3d/shape.pyx":845 */
            chunk_add(__pyx_v_chunk,(__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_p1)]))),(3 * (sizeof(float ))));

            /* "/home/jiba/src/soya/cal3d/shape.pyx":846 */
            chunk_add(__pyx_v_chunk,(__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_p2)]))),(3 * (sizeof(float ))));

            /* "/home/jiba/src/soya/cal3d/shape.pyx":847 */
            chunk_add_int(__pyx_v_chunk,(-1));
            goto __pyx_L16;
          }
          __pyx_L16:;
          __pyx_L14:;
        }
        __pyx_L15:;
        goto __pyx_L13;
      }
      __pyx_L13:;
      __pyx_L11:;
    }
    __pyx_L12:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":850 */
    __pyx_7 = PyDict_New(); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 850; goto __pyx_L1;}
    Py_DECREF(__pyx_v_joined);
    __pyx_v_joined = __pyx_7;
    __pyx_7 = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":851 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_segment; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":852 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_segment; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":853 */
        __pyx_2 = (__pyx_v_i == __pyx_v_j);
        if (__pyx_2) {
          goto __pyx_L22;
          goto __pyx_L24;
        }
        __pyx_L24:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":854 */
        __pyx_7 = PyObject_GetAttr(__pyx_v_joined, __pyx_n_has_key); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 854; goto __pyx_L1;}
        __pyx_8 = PyInt_FromLong(__pyx_v_j); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 854; goto __pyx_L1;}
        __pyx_9 = PyTuple_New(1); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 854; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_9, 0, __pyx_8);
        __pyx_8 = 0;
        __pyx_8 = PyObject_CallObject(__pyx_7, __pyx_9); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 854; goto __pyx_L1;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(__pyx_9); __pyx_9 = 0;
        __pyx_1 = PyObject_IsTrue(__pyx_8); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 854; goto __pyx_L1;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        if (__pyx_1) {
          goto __pyx_L22;
          goto __pyx_L25;
        }
        __pyx_L25:;

        /* "/home/jiba/src/soya/cal3d/shape.pyx":856 */
        __pyx_2 = (memcmp(((__pyx_v_chunk->content + (__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int ))))) + (3 * (sizeof(float )))),(__pyx_v_chunk->content + (__pyx_v_j * ((6 * (sizeof(float ))) + (sizeof(int ))))),(3 * (sizeof(float )))) == 0);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":857 */
          (((int (*))(__pyx_v_chunk->content + ((__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int )))) + (6 * (sizeof(float ))))))[0]) = __pyx_v_j;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":858 */
          __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 858; goto __pyx_L1;}
          __pyx_9 = PyInt_FromLong(__pyx_v_j); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 858; goto __pyx_L1;}
          if (PyObject_SetItem(__pyx_v_joined, __pyx_9, __pyx_7) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 858; goto __pyx_L1;}
          Py_DECREF(__pyx_9); __pyx_9 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;

          /* "/home/jiba/src/soya/cal3d/shape.pyx":859 */
          goto __pyx_L23;
          goto __pyx_L26;
        }
        __pyx_L26:;
        __pyx_L22:;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":861 */
        if (__Pyx_PrintItem(__pyx_k316p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 861; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 861; goto __pyx_L1;}
      }
      __pyx_L23:;
      __pyx_L20:;
    }
    __pyx_L21:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":863 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":864 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":865 */
    for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nb_segment; ++__pyx_v_k) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":866 */
      __pyx_1 = (__pyx_v_i == (-1));
      if (__pyx_1) {
        goto __pyx_L28;
        goto __pyx_L29;
      }
      __pyx_L29:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":867 */
      __pyx_v_coord_ptr = ((float (*))(__pyx_v_chunk->content + (__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int ))))));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":869 */
      __pyx_v_i = (((int (*))(__pyx_v_chunk->content + ((__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int )))) + (6 * (sizeof(float ))))))[0]);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":871 */
      memcpy(__pyx_v_fp1,__pyx_v_coord_ptr,(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":872 */
      memcpy(__pyx_v_fp2,(__pyx_v_coord_ptr + 3),(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":874 */
      __pyx_2 = (__pyx_v_light->_w == 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":875 */
        memcpy(__pyx_v_v1,__pyx_v_light->_data,(3 * (sizeof(float ))));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":876 */
        memcpy(__pyx_v_v2,__pyx_v_light->_data,(3 * (sizeof(float ))));
        goto __pyx_L30;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":878 */
        (__pyx_v_v1[0]) = ((__pyx_v_fp1[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":879 */
        (__pyx_v_v1[1]) = ((__pyx_v_fp1[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":880 */
        (__pyx_v_v1[2]) = ((__pyx_v_fp1[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":881 */
        vector_normalize(__pyx_v_v1);

        /* "/home/jiba/src/soya/cal3d/shape.pyx":883 */
        (__pyx_v_v2[0]) = ((__pyx_v_fp2[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":884 */
        (__pyx_v_v2[1]) = ((__pyx_v_fp2[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":885 */
        (__pyx_v_v2[2]) = ((__pyx_v_fp2[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":886 */
        vector_normalize(__pyx_v_v2);
      }
      __pyx_L30:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":889 */
      point_by_matrix(__pyx_v_fp1,((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_volume->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_volume)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":890 */
      point_by_matrix(__pyx_v_fp1,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":892 */
      point_by_matrix(__pyx_v_fp2,((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_volume->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_volume)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":893 */
      point_by_matrix(__pyx_v_fp2,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":895 */
      vector_by_matrix(__pyx_v_v1,((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_volume->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_volume)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":896 */
      vector_by_matrix(__pyx_v_v1,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":898 */
      vector_by_matrix(__pyx_v_v2,((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_volume->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_volume)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":899 */
      vector_by_matrix(__pyx_v_v2,((struct __pyx_vtabstruct_5_soya__Camera *)__pyx_v_5_soya_renderer->current_camera->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._inverted_root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_5_soya_renderer->current_camera)));

      /* "/home/jiba/src/soya/cal3d/shape.pyx":902 */
      __pyx_f_5_soya_segment_projection_intersect_plane(__pyx_v_fp1,__pyx_v_v1,__pyx_v_fp2,__pyx_v_v2,__pyx_v_b,__pyx_v_plane,__pyx_v_inter1,__pyx_v_inter2,__pyx_v_face_data,__pyx_v_nb_points);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":904 */
      glBegin(GL_POLYGON);

      /* "/home/jiba/src/soya/cal3d/shape.pyx":905 */
      __pyx_1 = (__pyx_v_nb_points[0]);
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":906 */
        glVertex3fv((__pyx_v_face_data + (__pyx_v_j * 3)));
        __pyx_L31:;
      }
      __pyx_L32:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":907 */
      glEnd();

      /* "/home/jiba/src/soya/cal3d/shape.pyx":909 */
      __pyx_2 = (__pyx_v_nb_points[1]);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":910 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[0])));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":911 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[1])));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":912 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[2])));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":913 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L33;
      }
      __pyx_L33:;

      /* "/home/jiba/src/soya/cal3d/shape.pyx":915 */
      __pyx_1 = (__pyx_v_nb_points[2]);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":916 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[0])));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":917 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[1])));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":918 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[2])));

        /* "/home/jiba/src/soya/cal3d/shape.pyx":919 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L34;
      }
      __pyx_L34:;
      __pyx_L27:;
    }
    __pyx_L28:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":921 */
    glLoadMatrixf(__pyx_v_volume->__pyx_base._render_matrix);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":923 */
    glEndList();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":926 */
    glDisable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":927 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":928 */
    gluTessBeginPolygon(__pyx_v_5_soya_SHADOW_TESS,0);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":929 */
    gluTessBeginContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":930 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_inter; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":931 */
      gluTessVertex(__pyx_v_5_soya_SHADOW_TESS,(((double (*))__pyx_v_chunk2->content) + (__pyx_v_i * 3)),(((double (*))__pyx_v_chunk2->content) + (__pyx_v_i * 3)));
      __pyx_L35:;
    }
    __pyx_L36:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":932 */
    gluTessEndContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":933 */
    gluTessEndPolygon(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":934 */
    glLoadMatrixf(__pyx_v_volume->__pyx_base._render_matrix);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":935 */
    glEnable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":939 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":940 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":941 */
    glCallList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":945 */
    __pyx_v_i = __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":946 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":947 */
    while (1) {
      __pyx_L37:;
      __pyx_2 = (__pyx_v_5_soya_SHADOW_TESS_CHUNK->nb < __pyx_v_i);
      if (!__pyx_2) break;
      free(chunk_get_ptr(__pyx_v_5_soya_SHADOW_TESS_CHUNK));
    }
    __pyx_L38:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":949 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":951 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":952 */
    drop_chunk(__pyx_v_chunk2);
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/shape.pyx":957 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":958 */
    __pyx_1 = __pyx_v_submesh->_nb_faces;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/shape.pyx":959 */
      __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
      if (!__pyx_2) {
        __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
      }
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/shape.pyx":960 */
        for (__pyx_v_k = 0; __pyx_v_k < 3; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/cal3d/shape.pyx":961 */
          __pyx_v_neighbor_face = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]);

          /* "/home/jiba/src/soya/cal3d/shape.pyx":965 */
          __pyx_2 = (__pyx_v_neighbor_face == (-1));
          if (!__pyx_2) {
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_neighbor_face]) != (__pyx_v_facesides[__pyx_v_i]));
          }
          if (__pyx_2) {

            /* "/home/jiba/src/soya/cal3d/shape.pyx":967 */
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":968 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/cal3d/shape.pyx":969 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L46;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L46:;
              goto __pyx_L45;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":972 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L47;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L47:;

              /* "/home/jiba/src/soya/cal3d/shape.pyx":974 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L45:;

            /* "/home/jiba/src/soya/cal3d/shape.pyx":976 */
            __pyx_v_coord_ptr = (__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_p1)])));

            /* "/home/jiba/src/soya/cal3d/shape.pyx":977 */
            glVertex3fv(__pyx_v_coord_ptr);

            /* "/home/jiba/src/soya/cal3d/shape.pyx":980 */
            __pyx_2 = (__pyx_v_light->_w == 0.0);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":981 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_light->_data[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_light->_data[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_light->_data[2]))));
              goto __pyx_L48;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":983 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/cal3d/shape.pyx":984 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/cal3d/shape.pyx":985 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/cal3d/shape.pyx":986 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/cal3d/shape.pyx":987 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_coord[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_coord[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_coord[2]))));
            }
            __pyx_L48:;

            /* "/home/jiba/src/soya/cal3d/shape.pyx":989 */
            __pyx_v_coord_ptr = (__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_p2)])));

            /* "/home/jiba/src/soya/cal3d/shape.pyx":992 */
            __pyx_2 = (__pyx_v_light->_w == 0.0);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":993 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_light->_data[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_light->_data[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_light->_data[2]))));
              goto __pyx_L49;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/shape.pyx":995 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/cal3d/shape.pyx":996 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/cal3d/shape.pyx":997 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/cal3d/shape.pyx":998 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/cal3d/shape.pyx":999 */
              glVertex3f(((__pyx_v_coord_ptr[0]) + (__pyx_v_b * (__pyx_v_coord[0]))),((__pyx_v_coord_ptr[1]) + (__pyx_v_b * (__pyx_v_coord[1]))),((__pyx_v_coord_ptr[2]) + (__pyx_v_b * (__pyx_v_coord[2]))));
            }
            __pyx_L49:;

            /* "/home/jiba/src/soya/cal3d/shape.pyx":1001 */
            glVertex3fv(__pyx_v_coord_ptr);
            goto __pyx_L44;
          }
          __pyx_L44:;
          __pyx_L42:;
        }
        __pyx_L43:;
        goto __pyx_L41;
      }
      __pyx_L41:;
      __pyx_L39:;
    }
    __pyx_L40:;

    /* "/home/jiba/src/soya/cal3d/shape.pyx":1004 */
    glEnd();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":1005 */
    glEndList();

    /* "/home/jiba/src/soya/cal3d/shape.pyx":1008 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":1009 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/cal3d/shape.pyx":1010 */
    glCallList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST);
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":1085 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_7);
  Py_XDECREF(__pyx_8);
  Py_XDECREF(__pyx_9);
  __Pyx_WriteUnraisable("_soya._Cal3dShape._shadow2");
  __pyx_L0:;
  Py_DECREF(__pyx_v_joined);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_volume);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume___getcstate__(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":34 */
  __pyx_1 = __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 34; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 34; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_shape));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_shape));
  Py_INCREF(__pyx_v_self->_attached_meshes);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_self->_attached_meshes);
  Py_INCREF(__pyx_v_self->_attached_coordsysts);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_self->_attached_coordsysts);
  __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Cal3dVolume.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k317p;
static PyObject *__pyx_k318p;
static PyObject *__pyx_k319p;
static PyObject *__pyx_k320p;

static char (__pyx_k317[]) = "erreur CalModel_Create";
static char (__pyx_k318[]) = "CalModel_Create failed: %s";
static char (__pyx_k319[]) = "erreur CalModel_AttachMesh";
static char (__pyx_k320[]) = "CalModel_AttachMesh failed: %s";

static void __pyx_f_5_soya_12_Cal3dVolume___setcstate__(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_i;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  long __pyx_5;
  int __pyx_6;
  int __pyx_7;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_i = Py_None; Py_INCREF(__pyx_v_i);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":37 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 37; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya_CoordSyst->__pyx_base.__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":38 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Cal3dShape)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_shape));
  __pyx_v_self->_shape = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":39 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->_attached_meshes);
  __pyx_v_self->_attached_meshes = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":40 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->_attached_coordsysts);
  __pyx_v_self->_attached_coordsysts = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":42 */
  __pyx_3 = PyObject_IsTrue(((PyObject *)__pyx_v_self->_shape)); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 42; goto __pyx_L1;}
  if (__pyx_3) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":43 */
    __pyx_v_self->_model = CalModel_New(__pyx_v_self->_shape->_core_model);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":44 */
    __pyx_3 = (__pyx_v_self->_model == 0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":45 */
      if (__Pyx_PrintItem(__pyx_k317p) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 45; goto __pyx_L1;}
      __pyx_1 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 45; goto __pyx_L1;}
      if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 45; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 45; goto __pyx_L1;}

      /* "/home/jiba/src/soya/cal3d/volume.pyx":46 */
      __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 46; goto __pyx_L1;}
      __pyx_1 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 46; goto __pyx_L1;}
      __pyx_4 = PyNumber_Remainder(__pyx_k318p, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 46; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 46; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4);
      __pyx_4 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 46; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[25]; __pyx_lineno = 46; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":48 */
    __pyx_3 = PyObject_Length(__pyx_v_self->_attached_meshes); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 48; goto __pyx_L1;}
    for (__pyx_5 = 0; __pyx_5 < __pyx_3; ++__pyx_5) {
      __pyx_2 = PyInt_FromLong(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 48; goto __pyx_L1;}
      Py_DECREF(__pyx_v_i);
      __pyx_v_i = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/cal3d/volume.pyx":49 */
      __pyx_1 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_v_i); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 49; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 49; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_1, __pyx_4, &__pyx_6) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 49; goto __pyx_L1;}
      __pyx_6 = __pyx_6 == 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (__pyx_6) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":50 */
        __pyx_6 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 50; goto __pyx_L1;}
        __pyx_7 = (CalModel_AttachMesh(__pyx_v_self->_model,__pyx_6) == 0);
        if (__pyx_7) {

          /* "/home/jiba/src/soya/cal3d/volume.pyx":51 */
          if (__Pyx_PrintItem(__pyx_k319p) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 51; goto __pyx_L1;}
          __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 51; goto __pyx_L1;}
          if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 51; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 51; goto __pyx_L1;}

          /* "/home/jiba/src/soya/cal3d/volume.pyx":52 */
          __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 52; goto __pyx_L1;}
          __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 52; goto __pyx_L1;}
          __pyx_2 = PyNumber_Remainder(__pyx_k320p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 52; goto __pyx_L1;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 52; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
          __pyx_2 = 0;
          __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 52; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __Pyx_Raise(__pyx_2, 0, 0);
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          {__pyx_filename = __pyx_f[25]; __pyx_lineno = 52; goto __pyx_L1;}
          goto __pyx_L7;
        }
        __pyx_L7:;
        goto __pyx_L6;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":53 */
    ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dVolume.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_5shape___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_5shape___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":57 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dVolume.shape.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_set_shape;

static int __pyx_f_5_soya_12_Cal3dVolume_5shape___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_shape); /*proto*/
static int __pyx_f_5_soya_12_Cal3dVolume_5shape___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_shape) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shape);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Cal3dShape, 1, "shape")) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 58; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/volume.pyx":59 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_shape); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 59; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_shape);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_shape);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Cal3dVolume.shape.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shape);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_15attached_meshes___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_15attached_meshes___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":63 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dVolume.attached_meshes.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_19attached_coordsysts___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_19attached_coordsysts___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":67 */
  Py_INCREF(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts);
  __pyx_r = ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dVolume.attached_coordsysts.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_Cal3dVolume___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume___init__[] = "Cal3dVolume(parent = None, shape = None, visible_meshes = None)\n\nCreates a new Cal3D volume. PARENT is the volume\'s parent, and SHAPE is the Cal3D\nshape (you cannot use \"normal\" Soya\'s shape here !).\n\nATTACHED_MESHES is a list of meshes names to attach; if ATTACHED_MESHES is None,\nall meshes are attached. See volume.shape.meshes to get the list of available\nmesh names.";
static int __pyx_f_5_soya_12_Cal3dVolume___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__World *__pyx_v_parent = 0;
  struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_shape = 0;
  PyObject *__pyx_v_attached_meshes = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"parent","shape","attached_meshes",0};
  __pyx_v_parent = __pyx_k144;
  __pyx_v_shape = __pyx_k145;
  __pyx_v_attached_meshes = __pyx_k146;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_shape, &__pyx_v_attached_meshes)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_shape);
  Py_INCREF(__pyx_v_attached_meshes);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 69; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Cal3dShape, 1, "shape")) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 69; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/volume.pyx":78 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 78; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 78; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_parent));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_parent));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 78; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":79 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 79; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes);
  ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":80 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 80; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts);
  ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":82 */
  __pyx_4 = PyObject_IsTrue(((PyObject *)__pyx_v_shape)); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 82; goto __pyx_L1;}
  if (__pyx_4) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":83 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 83; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 83; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_shape));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_shape));
    Py_INCREF(__pyx_v_attached_meshes);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_attached_meshes);
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 83; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Cal3dVolume.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF(__pyx_v_attached_meshes);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_Cal3dVolume___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_12_Cal3dVolume___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":86 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":87 */
    CalModel_Delete(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":89 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_coords != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_coords);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":90 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_normals != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_normals);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":91 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_face_planes != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_face_planes);
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dVolume.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_attach;

static PyObject *__pyx_k321p;
static PyObject *__pyx_k322p;

static char (__pyx_k321[]) = "error CalModel_Create";
static char (__pyx_k322[]) = "CalModel_Create failed: %s";

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_set_shape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_set_shape(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Cal3dShape *__pyx_v_shape = 0;
  PyObject *__pyx_v_attached_meshes = 0;
  int __pyx_v_i;
  int __pyx_v_nb;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"shape","attached_meshes",0};
  __pyx_v_attached_meshes = __pyx_k147;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_shape, &__pyx_v_attached_meshes)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_shape);
  Py_INCREF(__pyx_v_attached_meshes);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), __pyx_ptype_5_soya__Cal3dShape, 1, "shape")) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 93; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/volume.pyx":95 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":96 */
    CalModel_Delete(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":97 */
    __pyx_3 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_n___imul__); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 97; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 97; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 97; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 97; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":99 */
  __pyx_1 = ((PyObject *)__pyx_v_shape) == Py_None;
  if (__pyx_1) {
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Cal3dShape)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 99; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape));
    ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape = Py_None;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":101 */
    Py_INCREF(((PyObject *)__pyx_v_shape));
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape));
    ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape = ((PyObject *)__pyx_v_shape);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":102 */
    ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model = CalModel_New(__pyx_v_shape->_core_model);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":103 */
    __pyx_2 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model == 0);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":104 */
      if (__Pyx_PrintItem(__pyx_k321p) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 104; goto __pyx_L1;}
      __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 104; goto __pyx_L1;}
      if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 104; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 104; goto __pyx_L1;}

      /* "/home/jiba/src/soya/cal3d/volume.pyx":105 */
      __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 105; goto __pyx_L1;}
      __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 105; goto __pyx_L1;}
      __pyx_3 = PyNumber_Remainder(__pyx_k322p, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 105; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 105; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
      __pyx_3 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 105; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __Pyx_Raise(__pyx_3, 0, 0);
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      {__pyx_filename = __pyx_f[25]; __pyx_lineno = 105; goto __pyx_L1;}
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":107 */
    __pyx_v_nb = CalCoreModel_GetCoreMeshCount(__pyx_v_shape->_core_model);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":108 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {
      __pyx_5 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 108; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 108; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 108; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
      __pyx_4 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 108; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_L5:;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":109 */
    __pyx_1 = __pyx_v_attached_meshes == Py_None;
    __pyx_2 = (!__pyx_1);
    if (__pyx_2) {
      __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_attach); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 109; goto __pyx_L1;}
      __pyx_3 = PySequence_Tuple(__pyx_v_attached_meshes); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 109; goto __pyx_L1;}
      __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 109; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      goto __pyx_L7;
    }
    /*else*/ {
      ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_attach_all(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self));
    }
    __pyx_L7:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dVolume.set_shape");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shape);
  Py_DECREF(__pyx_v_attached_meshes);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_Cal3dVolume__build_submeshes(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":113 */
  __pyx_1 = (!(__pyx_v_self->_shape->_option & __pyx_e_5_soya_CAL3D_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->_shape->__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self->_shape);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":115 */
  __pyx_1 = (__pyx_v_self->_vertex_coords != 0);
  if (__pyx_1) {
    free(__pyx_v_self->_vertex_coords);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":116 */
  __pyx_1 = (__pyx_v_self->_vertex_normals != 0);
  if (__pyx_1) {
    free(__pyx_v_self->_vertex_normals);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":117 */
  __pyx_1 = (__pyx_v_self->_face_planes != 0);
  if (__pyx_1) {
    free(__pyx_v_self->_face_planes);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":119 */
  __pyx_v_self->_vertex_coords = ((GLfloat (*))malloc(((__pyx_v_self->_shape->_nb_vertices * 3) * (sizeof(GLfloat )))));

  /* "/home/jiba/src/soya/cal3d/volume.pyx":120 */
  __pyx_v_self->_vertex_normals = ((GLfloat (*))malloc(((__pyx_v_self->_shape->_nb_vertices * 3) * (sizeof(GLfloat )))));

  /* "/home/jiba/src/soya/cal3d/volume.pyx":121 */
  __pyx_v_self->_face_planes = ((GLfloat (*))malloc(((__pyx_v_self->_shape->_nb_faces * 4) * (sizeof(GLfloat )))));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._build_submeshes");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n__build_vertices;

static void __pyx_f_5_soya_12_Cal3dVolume__build_face_planes(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self) {
  float (*__pyx_v_ptrf);
  float (*__pyx_v_plane);
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":128 */
  __pyx_1 = (__pyx_v_self->_vertex_ok < 0);
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n__build_vertices); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 128; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 128; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 128; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 128; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":130 */
  __pyx_v_plane = __pyx_v_self->_face_planes;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":132 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":133 */
  __pyx_v_ptrf = __pyx_v_self->_vertex_coords;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":134 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_shape->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 134; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_4 = PyIter_Next(__pyx_2);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 134; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 134; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":135 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 135; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 135; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 135; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":136 */
      __pyx_1 = __pyx_v_submesh->_nb_faces;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":137 */
        face_plane((__pyx_v_plane + (4 * __pyx_v_j)),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[(3 * __pyx_v_j)]))),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_j) + 1)]))),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_j) + 2)]))));
        __pyx_L6:;
      }
      __pyx_L7:;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":140 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":141 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":142 */
    __pyx_v_plane = (__pyx_v_plane + (__pyx_v_submesh->_nb_faces * 4));
  }
  __pyx_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":144 */
  __pyx_v_self->_face_plane_ok = 1;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._build_face_planes");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_meshes;

static PyObject *__pyx_k323p;
static PyObject *__pyx_k324p;

static char (__pyx_k323[]) = "erreur CalModel_AttachMesh";
static char (__pyx_k324[]) = "CalModel_AttachMesh failed: %s";

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_attach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_attach[] = "Cal3DVolume.attach(mesh_name_1, ...)\n\nAttaches new meshes named MESH_NAME_1, ... to the volume.\nSee volume.shape.meshes to get the list of available mesh names.\nAttaching several meshes at the same time can be faster.";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_attach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mesh_names = 0;
  int __pyx_v_i;
  PyObject *__pyx_v_mesh_name;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_mesh_names, 0) < 0) return 0;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_mesh_names);
    return 0;
  }
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_mesh_name = Py_None; Py_INCREF(__pyx_v_mesh_name);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":153 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":154 */
    __pyx_2 = PyObject_GetIter(__pyx_v_mesh_names); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 154; goto __pyx_L1;}
    for (;;) {
      __pyx_L3:;
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 154; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_mesh_name);
      __pyx_v_mesh_name = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/volume.pyx":155 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape), __pyx_n_meshes); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 155; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(__pyx_3, __pyx_v_mesh_name); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 155; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 155; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_v_i = __pyx_1;

      /* "/home/jiba/src/soya/cal3d/volume.pyx":156 */
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 156; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 156; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 156; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_4, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 156; goto __pyx_L1;}
      __pyx_1 = __pyx_1 == 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":157 */
        __pyx_1 = (CalModel_AttachMesh(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model,__pyx_v_i) == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/cal3d/volume.pyx":158 */
          if (__Pyx_PrintItem(__pyx_k323p) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 158; goto __pyx_L1;}
          __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 158; goto __pyx_L1;}
          if (__Pyx_PrintItem(__pyx_4) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 158; goto __pyx_L1;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 158; goto __pyx_L1;}

          /* "/home/jiba/src/soya/cal3d/volume.pyx":159 */
          __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 159; goto __pyx_L1;}
          __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 159; goto __pyx_L1;}
          __pyx_5 = PyNumber_Remainder(__pyx_k324p, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 159; goto __pyx_L1;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 159; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
          __pyx_5 = 0;
          __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 159; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __Pyx_Raise(__pyx_5, 0, 0);
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          {__pyx_filename = __pyx_f[25]; __pyx_lineno = 159; goto __pyx_L1;}
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "/home/jiba/src/soya/cal3d/volume.pyx":161 */
        __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 161; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 161; goto __pyx_L1;}
        if (PyObject_SetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_4, __pyx_3) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 161; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L4:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":162 */
    ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dVolume.attach");
  __pyx_r = 0;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_mesh_names);
  Py_DECREF(__pyx_v_mesh_name);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_k325p;
static PyObject *__pyx_k326p;

static char (__pyx_k325[]) = "erreur CalModel_DetachMesh";
static char (__pyx_k326[]) = "CalModel_DetachMesh failed: %s";

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_detach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_detach[] = "Cal3DVolume.detach(mesh_name_1, ...)\n\nDetaches meshes named MESH_NAME_1, ... to the volume.\nDetaching several meshes at the same time can be faster.";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_detach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mesh_names = 0;
  int __pyx_v_i;
  PyObject *__pyx_v_mesh_name;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_mesh_names, 0) < 0) return 0;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_mesh_names);
    return 0;
  }
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_mesh_name = Py_None; Py_INCREF(__pyx_v_mesh_name);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":170 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":171 */
    __pyx_2 = PyObject_GetIter(__pyx_v_mesh_names); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 171; goto __pyx_L1;}
    for (;;) {
      __pyx_L3:;
      __pyx_3 = PyIter_Next(__pyx_2);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 171; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_mesh_name);
      __pyx_v_mesh_name = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/volume.pyx":172 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape), __pyx_n_meshes); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 172; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(__pyx_3, __pyx_v_mesh_name); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 172; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 172; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_v_i = __pyx_1;

      /* "/home/jiba/src/soya/cal3d/volume.pyx":173 */
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 173; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 173; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 173; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_4, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 173; goto __pyx_L1;}
      __pyx_1 = __pyx_1 == 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":174 */
        __pyx_1 = (CalModel_DetachMesh(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model,__pyx_v_i) == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/cal3d/volume.pyx":175 */
          if (__Pyx_PrintItem(__pyx_k325p) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 175; goto __pyx_L1;}
          __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 175; goto __pyx_L1;}
          if (__Pyx_PrintItem(__pyx_4) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 175; goto __pyx_L1;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 175; goto __pyx_L1;}

          /* "/home/jiba/src/soya/cal3d/volume.pyx":176 */
          __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
          __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
          __pyx_5 = PyNumber_Remainder(__pyx_k326p, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_4, 0, __pyx_5);
          __pyx_5 = 0;
          __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          Py_DECREF(__pyx_4); __pyx_4 = 0;
          __Pyx_Raise(__pyx_5, 0, 0);
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "/home/jiba/src/soya/cal3d/volume.pyx":177 */
        __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 177; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 177; goto __pyx_L1;}
        if (PyObject_SetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_4, __pyx_3) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 177; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;
    }
    __pyx_L4:;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":178 */
    ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dVolume.detach");
  __pyx_r = 0;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_mesh_names);
  Py_DECREF(__pyx_v_mesh_name);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_k327p;
static PyObject *__pyx_k328p;

static char (__pyx_k327[]) = "erreur CalModel_AttachMesh";
static char (__pyx_k328[]) = "CalModel_AttachMesh failed: %s";

static void __pyx_f_5_soya_12_Cal3dVolume__attach_all(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":182 */
  __pyx_1 = (__pyx_v_self->_model != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":183 */
    __pyx_1 = PyObject_Length(__pyx_v_self->_attached_meshes); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 183; goto __pyx_L1;}
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":184 */
      __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 184; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 184; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 184; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 184; goto __pyx_L1;}
      __pyx_4 = __pyx_4 == 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      if (__pyx_4) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":185 */
        __pyx_4 = (CalModel_AttachMesh(__pyx_v_self->_model,__pyx_v_i) == 0);
        if (__pyx_4) {

          /* "/home/jiba/src/soya/cal3d/volume.pyx":186 */
          if (__Pyx_PrintItem(__pyx_k327p) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 186; goto __pyx_L1;}
          __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 186; goto __pyx_L1;}
          if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 186; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 186; goto __pyx_L1;}

          /* "/home/jiba/src/soya/cal3d/volume.pyx":187 */
          __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
          __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
          __pyx_5 = PyNumber_Remainder(__pyx_k328p, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
          PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
          __pyx_5 = 0;
          __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_3); __pyx_3 = 0;
          __Pyx_Raise(__pyx_5, 0, 0);
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "/home/jiba/src/soya/cal3d/volume.pyx":188 */
        __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 188; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 188; goto __pyx_L1;}
        if (PyObject_SetItem(__pyx_v_self->_attached_meshes, __pyx_3, __pyx_2) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 188; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;
      __pyx_L3:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":189 */
    ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._attach_all");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_is_attached(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_is_attached[] = "Cal3DVolume.is_attached(mesh_name)\n\nChecks if the mesh called MESH_NAME is attached to the volume.";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_is_attached(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mesh_name = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"mesh_name",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_mesh_name)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_mesh_name);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":195 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape), __pyx_n_meshes); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 195; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_1, __pyx_v_mesh_name); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_meshes, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 195; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Cal3dVolume.is_attached");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_name);
  return __pyx_r;
}

static PyObject *__pyx_k329p;
static PyObject *__pyx_k330p;

static char (__pyx_k329[]) = "No bone named %s !";
static char (__pyx_k330[]) = "Cannot attach to bone, shape is None !";

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_attach_to_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_attach_to_bone[] = "Cal3DVolume.attach_to_bone(coordsyst, bone_name)\n\nAttaches COORDSYST (usually a world) to the bone named BONE_NAME.\nAs the bone moved (because of animation), COORDSYST will be moved too.\nSee tutorial character-animation-2.py.";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_attach_to_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst = 0;
  PyObject *__pyx_v_bone_name = 0;
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  char (*__pyx_3);
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  static char *__pyx_argnames[] = {"coordsyst","bone_name",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_coordsyst, &__pyx_v_bone_name)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF(__pyx_v_bone_name);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 197; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/volume.pyx":204 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":205 */
    __pyx_3 = PyString_AsString(__pyx_v_bone_name); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 205; goto __pyx_L1;}
    __pyx_v_i = CalCoreSkeleton_GetCoreBoneId(CalCoreModel_GetCoreSkeleton(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape->_core_model),__pyx_3);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":206 */
    __pyx_1 = (__pyx_v_i == (-1));
    if (__pyx_1) {
      __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 206; goto __pyx_L1;}
      __pyx_5 = PyNumber_Remainder(__pyx_k329p, __pyx_v_bone_name); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 206; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 206; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
      __pyx_5 = 0;
      __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 206; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      __Pyx_Raise(__pyx_5, 0, 0);
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      {__pyx_filename = __pyx_f[25]; __pyx_lineno = 206; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":207 */
    __pyx_4 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 207; goto __pyx_L1;}
    __pyx_6 = PyInt_FromLong(__pyx_v_i); if (!__pyx_6) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 207; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 207; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_coordsyst));
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_6);
    __pyx_6 = 0;
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 207; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 207; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 208; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 208; goto __pyx_L1;}
    Py_INCREF(__pyx_k330p);
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_k330p);
    __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 208; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __Pyx_Raise(__pyx_5, 0, 0);
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    {__pyx_filename = __pyx_f[25]; __pyx_lineno = 208; goto __pyx_L1;}
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_AddTraceback("_soya._Cal3dVolume.attach_to_bone");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_bone_name);
  return __pyx_r;
}

static PyObject *__pyx_n_attached_coordsysts;

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_detach_from_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_detach_from_bone[] = "Cal3DVolume.detach_from_bone(coordsyst)\n\nDetaches COORDSYST from the bone it has been attached to.";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_detach_from_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst = 0;
  int __pyx_v_i;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {"coordsyst",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_coordsyst)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 210; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/volume.pyx":215 */
  __pyx_1 = PyObject_Length(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 215; goto __pyx_L1;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":216 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 216; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 216; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 216; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 216; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_5 = __pyx_4 == ((PyObject *)__pyx_v_coordsyst);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_5) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":217 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_attached_coordsysts); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 217; goto __pyx_L1;}
      __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 217; goto __pyx_L1;}
      if (PyObject_DelItem(__pyx_3, __pyx_2) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 217; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/cal3d/volume.pyx":218 */
      __pyx_r = Py_None; Py_INCREF(__pyx_r);
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Cal3dVolume.detach_from_bone");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  return __pyx_r;
}

static PyObject *__pyx_n_repr;

static PyObject *__pyx_k331p;
static PyObject *__pyx_k332p;

static char (__pyx_k331[]) = "<Cal3dVolume, no shape>";
static char (__pyx_k332[]) = "<Cal3dVolume, shape %s>";

static PyObject *__pyx_f_5_soya_12_Cal3dVolume___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":221 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape) == Py_None;
  if (__pyx_1) {
    Py_INCREF(__pyx_k331p);
    __pyx_r = __pyx_k331p;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_repr); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 222; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_shape); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 222; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 222; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 222; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyNumber_Remainder(__pyx_k332p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 222; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Cal3dVolume.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_round_duration;


static PyObject *__pyx_f_5_soya_12_Cal3dVolume_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_v_soya;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  float __pyx_5;
  static char *__pyx_argnames[] = {"proportion",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_proportion)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":225 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":226 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_delta_time); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_IDLER); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_round_duration); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_3 = PyNumber_Multiply(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_2 = PyNumber_Add(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 226; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_delta_time = __pyx_5;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Cal3dVolume.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_soya);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_blend_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_animate_blend_cycle[] = "Cal3DVolume.animate_blend_cycle(animation_name, weight = 1.0, fade_in = 0.2)\n\nPlays animation ANIMATION_NAME in cycle.\nSee volume.shape.animations for the list of available animations.\n\nWEIGHT is the weight of the animation (usefull is several animations are played\nsimultaneously), and FADE_IN is the time (in second) needed to reach this weight\n(in order to avoid a brutal transition).\n\nNotice that the animation will NOT start at its beginning, but at the current global\nanimation time, which is shared by all cycles (see animate_reset if you want to start\na cycle at its beginning).";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_blend_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_animation_name = 0;
  float __pyx_v_weight;
  float __pyx_v_fade_in;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"animation_name","weight","fade_in",0};
  __pyx_v_weight = __pyx_k148;
  __pyx_v_fade_in = __pyx_k149;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|ff", __pyx_argnames, &__pyx_v_animation_name, &__pyx_v_weight, &__pyx_v_fade_in)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":241 */
  __pyx_1 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape->_animations, __pyx_v_animation_name); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 241; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 241; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  CalMixer_BlendCycle(CalModel_GetMixer(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model),__pyx_2,__pyx_v_weight,__pyx_v_fade_in);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dVolume.animate_blend_cycle");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_clear_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_animate_clear_cycle[] = "Cal3DVolume.animate_clear_cycle(animation_name, fade_out = 0.2)\n\nStops playing animation ANIMATION_NAME in cycle.\nFADE_OUT is the time (in second) needed to stop the animation (in order to avoid\na brutal transition).";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_clear_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_animation_name = 0;
  float __pyx_v_fade_out;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"animation_name","fade_out",0};
  __pyx_v_fade_out = __pyx_k150;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|f", __pyx_argnames, &__pyx_v_animation_name, &__pyx_v_fade_out)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":249 */
  __pyx_1 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape->_animations, __pyx_v_animation_name); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  CalMixer_ClearCycle(CalModel_GetMixer(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model),__pyx_2,__pyx_v_fade_out);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dVolume.animate_clear_cycle");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_execute_action(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_animate_execute_action[] = "Cal3DVolume.animate_execute_action(animation_name, fade_in = 0.2, fade_out = 0.2)\n\nPlays animation ANIMATION_NAME once.\nSee volume.shape.animations for the list of available animations.\nFADE_IN and FADE_OUT are the time (in second) needed to reach full weight, and to\nstop the animation (in order to avoid brutal transitions).";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_execute_action(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_animation_name = 0;
  float __pyx_v_fade_in;
  float __pyx_v_fade_out;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  static char *__pyx_argnames[] = {"animation_name","fade_in","fade_out",0};
  __pyx_v_fade_in = __pyx_k151;
  __pyx_v_fade_out = __pyx_k152;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|ff", __pyx_argnames, &__pyx_v_animation_name, &__pyx_v_fade_in, &__pyx_v_fade_out)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":258 */
  __pyx_1 = PyObject_GetItem(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape->_animations, __pyx_v_animation_name); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 258; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 258; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  CalMixer_ExecuteAction(CalModel_GetMixer(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model),__pyx_2,__pyx_v_fade_in,__pyx_v_fade_out);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Cal3dVolume.animate_execute_action");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_Cal3dVolume_animate_reset[] = "Cal3DVolume.animate_reset()\n\nRemoves all animations (both cycle and action animation).\nIt also resets the cycle animation time : i.e. cycles will restart from their beginning.";
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_animate_reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":267 */
  CalMixer_UpdateAnimation(CalModel_GetMixer(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model),0.0);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dVolume.animate_reset");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_set_lod_level(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_set_lod_level(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_lod_level;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"lod_level",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_lod_level)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":273 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model != 0);
  if (__pyx_1) {
    CalModel_SetLodLevel(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model,__pyx_v_lod_level);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Cal3dVolume.set_lod_level");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  int __pyx_1;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":276 */
  ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_ok = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_ok - 1);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":277 */
  ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_face_plane_ok = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_face_plane_ok - 1);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":279 */
  __pyx_2 = ((PyObject *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_ok < 0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":280 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n__build_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 280; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 280; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 280; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 280; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Cal3dVolume.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_Cal3dVolume__build_vertices(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_Cal3dVolume__build_vertices(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_vertices;
  int __pyx_v_bone_id;
  struct CalBone (*__pyx_v_bone);
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_csyst;
  float (*__pyx_v_trans);
  float (*__pyx_v_quat);
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  static char *__pyx_argnames[] = {"vertices",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "i", __pyx_argnames, &__pyx_v_vertices)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_csyst = Py_None; Py_INCREF((PyObject *) __pyx_v_csyst);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":288 */
  CalModel_Update(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model,((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_delta_time);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":289 */
  ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_delta_time = 0.0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":291 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_attached_coordsysts); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
      break;
    }
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_csyst));
    __pyx_v_csyst = __pyx_3;
    __pyx_3 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
    __pyx_5 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_bone_id = __pyx_5;
    if (__Pyx_EndUnpack(__pyx_2, 2) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 291; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":292 */
    __pyx_v_bone = CalSkeleton_GetBone(CalModel_GetSkeleton(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_model),__pyx_v_bone_id);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":293 */
    __pyx_v_quat = CalQuaternion_Get(CalBone_GetRotationAbsolute(__pyx_v_bone));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":294 */
    (__pyx_v_quat[3]) = (-(__pyx_v_quat[3]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":295 */
    matrix_from_quaternion(__pyx_v_csyst->_matrix,__pyx_v_quat);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":296 */
    __pyx_v_trans = CalVector_Get(CalBone_GetTranslationAbsolute(__pyx_v_bone));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":297 */
    (__pyx_v_csyst->_matrix[12]) = ((GLfloat )(__pyx_v_trans[0]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":298 */
    (__pyx_v_csyst->_matrix[13]) = ((GLfloat )(__pyx_v_trans[1]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":299 */
    (__pyx_v_csyst->_matrix[14]) = ((GLfloat )(__pyx_v_trans[2]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":300 */
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_csyst->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(__pyx_v_csyst);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":302 */
  __pyx_5 = (__pyx_v_vertices == 1);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":303 */
    ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape->__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_shape,((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":304 */
    ((struct __pyx_obj_5_soya__Cal3dVolume *)__pyx_v_self)->_vertex_ok = 1;
    goto __pyx_L4;
  }
  __pyx_L4:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Cal3dVolume._build_vertices");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_csyst);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_Cal3dVolume__batch(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_v_bone_id;
  struct CalBone (*__pyx_v_bone);
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_csyst;
  float (*__pyx_v_trans);
  float (*__pyx_v_quat);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  __pyx_v_csyst = Py_None; Py_INCREF((PyObject *) __pyx_v_csyst);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":313 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":314 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":316 */
  CalModel_Update(__pyx_v_self->_model,__pyx_v_self->_delta_time);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":317 */
  __pyx_v_self->_delta_time = 0.0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":320 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_attached_coordsysts); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
      break;
    }
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_csyst));
    __pyx_v_csyst = __pyx_4;
    __pyx_4 = 0;
    __pyx_5 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
    __pyx_1 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    __pyx_v_bone_id = __pyx_1;
    if (__Pyx_EndUnpack(__pyx_3, 2) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 320; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":321 */
    __pyx_v_bone = CalSkeleton_GetBone(CalModel_GetSkeleton(__pyx_v_self->_model),__pyx_v_bone_id);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":322 */
    __pyx_v_quat = CalQuaternion_Get(CalBone_GetRotationAbsolute(__pyx_v_bone));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":323 */
    (__pyx_v_quat[3]) = (-(__pyx_v_quat[3]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":324 */
    matrix_from_quaternion(__pyx_v_csyst->_matrix,__pyx_v_quat);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":325 */
    __pyx_v_trans = CalVector_Get(CalBone_GetTranslationAbsolute(__pyx_v_bone));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":326 */
    (__pyx_v_csyst->_matrix[12]) = ((GLfloat )(__pyx_v_trans[0]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":327 */
    (__pyx_v_csyst->_matrix[13]) = ((GLfloat )(__pyx_v_trans[1]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":328 */
    (__pyx_v_csyst->_matrix[14]) = ((GLfloat )(__pyx_v_trans[2]));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":329 */
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_csyst->__pyx_base.__pyx_base.__pyx_vtab)->_invalidate(__pyx_v_csyst);
  }
  __pyx_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":331 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":332 */
    __pyx_1 = ((__pyx_v_self->_shape->_sphere[3]) != (-1.0));
    if (__pyx_1) {
      __pyx_1 = (sphere_in_frustum(((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_frustum(__pyx_v_5_soya_renderer,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)),__pyx_v_self->_shape->_sphere) == 0);
    }
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":336 */
    __pyx_v_self->_vertex_ok = 1;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":337 */
    multiply_matrix(__pyx_v_self->__pyx_base._render_matrix,__pyx_v_coordsyst->_render_matrix,__pyx_v_self->__pyx_base._matrix);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":338 */
    __pyx_1 = (__pyx_v_self->_shape->_option & __pyx_e_5_soya_CAL3D_ALPHA);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":339 */
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->alpha,((PyObject *)__pyx_v_self->_shape),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),(-1));
      goto __pyx_L7;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":341 */
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->opaque,((PyObject *)__pyx_v_self->_shape),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),(-1));
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":344 */
    __pyx_1 = (__pyx_v_self->_shape->_option & __pyx_e_5_soya_CAL3D_CELL_SHADING);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_self->_shape->_outline_width > 0.0);
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":345 */
      ((struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_v_5_soya_renderer->__pyx_vtab)->_batch(__pyx_v_5_soya_renderer,__pyx_v_5_soya_renderer->secondpass,((PyObject *)__pyx_v_self->_shape),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),(-1));
      goto __pyx_L8;
    }
    __pyx_L8:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_csyst);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static int __pyx_f_5_soya_12_Cal3dVolume__shadow(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_r;
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":348 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_r = ((struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_v_self->_shape->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._shadow(((struct __pyx_obj_5_soya__Shape *)__pyx_v_self->_shape),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_light);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":349 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._shadow");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_Cal3dVolume__raypick(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_raydata);
  float (*__pyx_v_ptrf);
  float (*__pyx_v_plane);
  float __pyx_v_z;
  float __pyx_v_root_z;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_r;
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":354 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":355 */
  __pyx_1 = (__pyx_v_self->_vertex_ok < 0);
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n__build_vertices); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 355; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 355; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 355; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 355; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":356 */
  __pyx_1 = (__pyx_v_self->_face_plane_ok < 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_self);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":364 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_data);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":365 */
  __pyx_1 = ((__pyx_v_self->_shape->_sphere[3]) > 0.0);
  if (__pyx_1) {
    __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_self->_shape->_sphere) == 0);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":367 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":368 */
  __pyx_v_plane = __pyx_v_self->_face_planes;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":369 */
  __pyx_v_ptrf = __pyx_v_self->_vertex_coords;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":370 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_shape->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 370; goto __pyx_L1;}
  for (;;) {
    __pyx_L6:;
    __pyx_4 = PyIter_Next(__pyx_2);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 370; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 370; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":371 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 371; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 371; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 371; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":372 */
      __pyx_1 = __pyx_v_submesh->_nb_faces;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":373 */
        __pyx_v_r = triangle_raypick(__pyx_v_raydata,(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[(3 * __pyx_v_j)]))),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_j) + 1)]))),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_j) + 2)]))),(__pyx_v_plane + (4 * __pyx_v_j)),__pyx_v_data->option,(&__pyx_v_z));

        /* "/home/jiba/src/soya/cal3d/volume.pyx":375 */
        __pyx_5 = (__pyx_v_r != 0);
        if (__pyx_5) {

          /* "/home/jiba/src/soya/cal3d/volume.pyx":376 */
          __pyx_v_root_z = ((struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._distance_out(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_z);

          /* "/home/jiba/src/soya/cal3d/volume.pyx":377 */
          __pyx_5 = ((PyObject *)__pyx_v_data->result_coordsyst) == Py_None;
          if (!__pyx_5) {
            __pyx_5 = (fabs(__pyx_v_root_z) < fabs(__pyx_v_data->root_result));
          }
          if (__pyx_5) {

            /* "/home/jiba/src/soya/cal3d/volume.pyx":378 */
            __pyx_v_data->result = __pyx_v_z;

            /* "/home/jiba/src/soya/cal3d/volume.pyx":379 */
            __pyx_v_data->root_result = __pyx_v_root_z;

            /* "/home/jiba/src/soya/cal3d/volume.pyx":380 */
            Py_INCREF(((PyObject *)__pyx_v_self));
            Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
            __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_self);

            /* "/home/jiba/src/soya/cal3d/volume.pyx":381 */
            __pyx_5 = (__pyx_v_r == __pyx_e_5_soya_RAYPICK_DIRECT);
            if (__pyx_5) {
              memcpy(__pyx_v_data->normal,(__pyx_v_plane + (4 * __pyx_v_j)),(3 * (sizeof(float ))));
              goto __pyx_L13;
            }
            __pyx_5 = (__pyx_v_r == __pyx_e_5_soya_RAYPICK_INDIRECT);
            if (__pyx_5) {

              /* "/home/jiba/src/soya/cal3d/volume.pyx":383 */
              __pyx_5 = (__pyx_v_self->_shape->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
              if (__pyx_5) {

                /* "/home/jiba/src/soya/cal3d/volume.pyx":384 */
                (__pyx_v_data->normal[0]) = (-((__pyx_v_plane + (4 * __pyx_v_j))[0]));

                /* "/home/jiba/src/soya/cal3d/volume.pyx":385 */
                (__pyx_v_data->normal[1]) = (-((__pyx_v_plane + (4 * __pyx_v_j))[1]));

                /* "/home/jiba/src/soya/cal3d/volume.pyx":386 */
                (__pyx_v_data->normal[2]) = (-((__pyx_v_plane + (4 * __pyx_v_j))[2]));
                goto __pyx_L14;
              }
              /*else*/ {
                memcpy(__pyx_v_data->normal,(__pyx_v_plane + (4 * __pyx_v_j)),(3 * (sizeof(float ))));
              }
              __pyx_L14:;
              goto __pyx_L13;
            }
            __pyx_L13:;

            /* "/home/jiba/src/soya/cal3d/volume.pyx":388 */
            vector_normalize(__pyx_v_data->normal);
            goto __pyx_L12;
          }
          __pyx_L12:;
          goto __pyx_L11;
        }
        __pyx_L11:;
        __pyx_L9:;
      }
      __pyx_L10:;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":390 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "/home/jiba/src/soya/cal3d/volume.pyx":391 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/volume.pyx":392 */
    __pyx_v_plane = (__pyx_v_plane + (__pyx_v_submesh->_nb_faces * 4));
  }
  __pyx_L7:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._raypick");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static int __pyx_f_5_soya_12_Cal3dVolume__raypick_b(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_parent) {
  float (*__pyx_v_raydata);
  float (*__pyx_v_ptrf);
  float (*__pyx_v_plane);
  float __pyx_v_z;
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_data);
  Py_INCREF((PyObject *)__pyx_v_parent);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":395 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_shape) == Py_None;
  if (!__pyx_1) {
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_NON_SOLID);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":401 */
  __pyx_1 = (__pyx_v_self->_vertex_ok < 0);
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n__build_vertices); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 401; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 401; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 401; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 401; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":404 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_parent->__pyx_base.__pyx_base.__pyx_vtab)->_raypick_data(__pyx_v_parent,__pyx_v_data);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":405 */
  __pyx_1 = ((__pyx_v_self->_shape->_sphere[3]) > 0.0);
  if (__pyx_1) {
    __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_self->_shape->_sphere) == 0);
  }
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":407 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":408 */
  __pyx_v_plane = __pyx_v_self->_face_planes;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":409 */
  __pyx_v_ptrf = __pyx_v_self->_vertex_coords;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":410 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_shape->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 410; goto __pyx_L1;}
  for (;;) {
    __pyx_L5:;
    __pyx_4 = PyIter_Next(__pyx_2);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 410; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 410; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/cal3d/volume.pyx":411 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 411; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 411; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 411; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/volume.pyx":412 */
      __pyx_1 = __pyx_v_submesh->_nb_faces;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/volume.pyx":413 */
        __pyx_5 = (triangle_raypick(__pyx_v_raydata,(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[(3 * __pyx_v_j)]))),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_j) + 1)]))),(__pyx_v_ptrf + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_j) + 2)]))),(__pyx_v_plane + (4 * __pyx_v_j)),__pyx_v_data->option,(&__pyx_v_z)) != 0);
        if (__pyx_5) {
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        __pyx_L8:;
      }
      __pyx_L9:;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __pyx_L6:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":415 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._raypick_b");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_parent);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_Cal3dVolume__collect_raypickables(struct __pyx_obj_5_soya__Cal3dVolume *__pyx_v_self,__pyx_t_5_soya_Chunk (*__pyx_v_items),float (*__pyx_v_rsphere),float (*__pyx_v_sphere)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/volume.pyx":418 */
  __pyx_1 = ((__pyx_v_self->_shape->_sphere[3]) < 0.0);
  if (!__pyx_1) {
    __pyx_1 = (sphere_distance_sphere(__pyx_v_sphere,__pyx_v_self->_shape->_sphere) < 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/volume.pyx":419 */
    chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_self)));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Cal3dVolume._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_5Glyph___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_5Glyph___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_unichar = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {"unichar",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_unichar)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_unichar);

  /* "/home/jiba/src/soya/text/text.pyx":31 */
  Py_INCREF(__pyx_v_unichar);
  Py_DECREF(((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->unichar);
  ((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->unichar = __pyx_v_unichar;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Glyph.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_unichar);
  return __pyx_r;
}

static PyObject *__pyx_k334p;

static char (__pyx_k334[]) = "<Glyph '%s' %s x %s>";

static PyObject *__pyx_f_5_soya_5Glyph___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5Glyph___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":34 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->width); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 34; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->height); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 34; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 34; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->unichar);
  PyTuple_SET_ITEM(__pyx_3, 0, ((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->unichar);
  PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);
  PyTuple_SET_ITEM(__pyx_3, 2, __pyx_2);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k334p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 34; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Glyph.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_4Font_6height___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_6height___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":51 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Font.height.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_4Font_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_5width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":55 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_width); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 55; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Font.width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k335p;
static PyObject *__pyx_k336p;

static char (__pyx_k335[]) = "os.path";
static char (__pyx_k336[]) = "Cannot open font file %s";

static int __pyx_f_5_soya_4Font___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_4Font___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  int __pyx_v_width;
  int __pyx_v_height;
  PyObject *__pyx_v_os;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  int __pyx_5;
  static char *__pyx_argnames[] = {"filename","width","height",0};
  __pyx_v_width = __pyx_k153;
  __pyx_v_height = __pyx_k154;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|ii", __pyx_argnames, &__pyx_v_filename, &__pyx_v_width, &__pyx_v_height)) return -1;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_filename);
  __pyx_v_os = Py_None; Py_INCREF(__pyx_v_os);

  /* "/home/jiba/src/soya/text/text.pyx":58 */
  __pyx_1 = __Pyx_Import(__pyx_k335p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 58; goto __pyx_L1;}
  Py_DECREF(__pyx_v_os);
  __pyx_v_os = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":59 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_os, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exists); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_filename);
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
    Py_INCREF(__pyx_k336p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k336p);
    Py_INCREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_filename);
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[26]; __pyx_lineno = 59; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":61 */
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_width = __pyx_v_width;

  /* "/home/jiba/src/soya/text/text.pyx":62 */
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height = (__pyx_v_height + 4);

  /* "/home/jiba/src/soya/text/text.pyx":63 */
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels_height = (-1);

  /* "/home/jiba/src/soya/text/text.pyx":64 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_glyphs);
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_glyphs = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":65 */
  Py_INCREF(__pyx_v_filename);
  Py_DECREF(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->filename);
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->filename = __pyx_v_filename;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Font.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_os);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_n_ImportError;

static PyObject *__pyx_k338p;
static PyObject *__pyx_k339p;
static PyObject *__pyx_k340p;

static char (__pyx_k337[]) = "Real initialization, which is not done in __init__, since we need Soya to be fully\ninitialized to make OpenGL calls.";
static char (__pyx_k338[]) = "Cannot init FreeType";
static char (__pyx_k339[]) = "Cannot open font file %s";
static char (__pyx_k340[]) = "Cannot set char size";

static void __pyx_f_5_soya_4Font__init(struct __pyx_obj_5_soya_Font *__pyx_v_self) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  char (*__pyx_5);
  long __pyx_6;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":68 */
  __pyx_k337;

  /* "/home/jiba/src/soya/text/text.pyx":70 */
  glGenTextures(1,(&__pyx_v_self->_tex_id));

  /* "/home/jiba/src/soya/text/text.pyx":71 */
  glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":72 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":73 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":74 */
  glBindTexture(GL_TEXTURE_2D,0);

  /* "/home/jiba/src/soya/text/text.pyx":78 */
  __pyx_1 = (__pyx_v_5_soya_library_inited == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":79 */
    __pyx_1 = FT_Init_FreeType((&__pyx_v_5_soya_library));
    if (__pyx_1) {
      __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ImportError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 79; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 79; goto __pyx_L1;}
      Py_INCREF(__pyx_k338p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k338p);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 79; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __Pyx_Raise(__pyx_4, 0, 0);
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      {__pyx_filename = __pyx_f[26]; __pyx_lineno = 79; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/text/text.pyx":80 */
    __pyx_v_5_soya_library_inited = 1;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":83 */
  __pyx_5 = PyString_AsString(__pyx_v_self->filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 83; goto __pyx_L1;}
  __pyx_1 = FT_New_Face(__pyx_v_5_soya_library,__pyx_5,0,(&__pyx_v_self->_face));
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 83; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 83; goto __pyx_L1;}
    Py_INCREF(__pyx_k339p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k339p);
    Py_INCREF(__pyx_v_self->filename);
    PyTuple_SET_ITEM(__pyx_3, 1, __pyx_v_self->filename);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 83; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[26]; __pyx_lineno = 83; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/text/text.pyx":84 */
  __pyx_1 = FT_Set_Char_Size(__pyx_v_self->_face,0,(__pyx_v_self->_face->units_per_EM * 64),0,0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 84; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 84; goto __pyx_L1;}
    Py_INCREF(__pyx_k340p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k340p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 84; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[26]; __pyx_lineno = 84; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/text/text.pyx":85 */
  __pyx_6 = (__pyx_v_self->_face->face_flags & FT_FACE_FLAG_SCALABLE);
  if (__pyx_6) {
    FT_Set_Pixel_Sizes(__pyx_v_self->_face,__pyx_v_self->_width,__pyx_v_self->_height);
    goto __pyx_L6;
  }
  /*else*/ {
    FT_Set_Pixel_Sizes(__pyx_v_self->_face,0,0);
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya.Font._init");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static void __pyx_f_5_soya_4Font___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_4Font___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":98 */
  FT_Done_Face(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_face);

  /* "/home/jiba/src/soya/text/text.pyx":99 */
  glDeleteTextures(1,(&((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_tex_id));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.Font.__dealloc__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_n_ord;

static struct __pyx_obj_5_soya_Glyph *__pyx_f_5_soya_4Font__get_glyph(struct __pyx_obj_5_soya_Font *__pyx_v_self,PyObject *__pyx_v_char_) {
  int __pyx_v_code;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  struct __pyx_obj_5_soya_Glyph *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_char_);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);

  /* "/home/jiba/src/soya/text/text.pyx":104 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ord); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 104; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 104; goto __pyx_L1;}
  Py_INCREF(__pyx_v_char_);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_char_);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 104; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 104; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_code = __pyx_4;

  /* "/home/jiba/src/soya/text/text.pyx":105 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_glyphs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 105; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_code); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 105; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 105; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 105; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 105; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_glyph));
  __pyx_v_glyph = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":106 */
  __pyx_4 = ((PyObject *)__pyx_v_glyph) == Py_None;
  if (__pyx_4) {
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya_Font *)__pyx_v_self->__pyx_vtab)->_gen_glyph(__pyx_v_self,__pyx_v_char_,__pyx_v_code); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 106; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 106; goto __pyx_L1;}
    Py_INCREF(__pyx_1);
    Py_DECREF(((PyObject *)__pyx_v_glyph));
    __pyx_v_glyph = __pyx_1;
    __pyx_3 = PyInt_FromLong(__pyx_v_code); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 106; goto __pyx_L1;}
    if (PyObject_SetItem(__pyx_v_self->_glyphs, __pyx_3, __pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 106; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":107 */
  Py_INCREF(((PyObject *)__pyx_v_glyph));
  __pyx_r = (struct __pyx_obj_5_soya_Glyph *)((PyObject *)__pyx_v_glyph);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Font._get_glyph");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_char_);
  return ((struct __pyx_obj_5_soya_Glyph *)__pyx_r) ;
}

static PyObject *__pyx_k341p;
static PyObject *__pyx_k342p;

static char (__pyx_k341[]) = "Glyph %s does not exist !";
static char (__pyx_k342[]) = " ";

static PyObject *__pyx_f_5_soya_4Font__gen_glyph(struct __pyx_obj_5_soya_Font *__pyx_v_self,PyObject *__pyx_v_char_,int __pyx_v_code) {
  int __pyx_v_glyph_index;
  int __pyx_v_j;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  FT_Bitmap __pyx_v_bitmap;
  int __pyx_v_g_height;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_char_);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);

  /* "/home/jiba/src/soya/text/text.pyx":116 */
  __pyx_1 = (__pyx_v_self->_pixels_height == (-1));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_Font *)__pyx_v_self->__pyx_vtab)->_init(__pyx_v_self);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":118 */
  __pyx_1 = __pyx_v_self->_rendering;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":118 */
    glEnd();

    /* "/home/jiba/src/soya/text/text.pyx":118 */
    __pyx_v_self->_rendering = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":120 */
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_INCREF(__pyx_v_char_);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_char_);
  __pyx_3 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_Glyph), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 120; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_glyph));
  __pyx_v_glyph = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":121 */
  __pyx_v_glyph_index = FT_Get_Char_Index(__pyx_v_self->_face,__pyx_v_code);

  /* "/home/jiba/src/soya/text/text.pyx":123 */
  __pyx_1 = (FT_Load_Glyph(__pyx_v_self->_face,__pyx_v_glyph_index,FT_LOAD_DEFAULT) != 0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 123; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_glyph_index); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 123; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k341p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 123; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 123; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 123; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_4, 0, 0);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    {__pyx_filename = __pyx_f[26]; __pyx_lineno = 123; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/text/text.pyx":124 */
  __pyx_1 = (__pyx_v_self->_face->glyph->format != FT_GLYPH_FORMAT_BITMAP);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":125 */
    FT_Render_Glyph(__pyx_v_self->_face->glyph,FT_RENDER_MODE_NORMAL);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/text/text.pyx":127 */
  __pyx_v_bitmap = __pyx_v_self->_face->glyph->bitmap;

  /* "/home/jiba/src/soya/text/text.pyx":128 */
  __pyx_v_g_height = __pyx_v_bitmap.rows;

  /* "/home/jiba/src/soya/text/text.pyx":130 */
  __pyx_1 = ((__pyx_v_self->_current_x + __pyx_v_bitmap.width) > __pyx_v_5_soya_MAX_TEXTURE_SIZE);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":131 */
    __pyx_v_self->_current_x = 0;

    /* "/home/jiba/src/soya/text/text.pyx":132 */
    __pyx_v_self->_current_y = ((__pyx_v_self->_current_y + __pyx_v_self->_current_height) + 1);

    /* "/home/jiba/src/soya/text/text.pyx":133 */
    __pyx_v_self->_current_height = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/text/text.pyx":135 */
  __pyx_1 = (__pyx_v_g_height > __pyx_v_self->_current_height);
  if (__pyx_1) {
    __pyx_v_self->_current_height = __pyx_v_g_height;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/text/text.pyx":137 */
  __pyx_1 = ((__pyx_v_self->_current_y + __pyx_v_g_height) > __pyx_v_self->_pixels_height);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":138 */
    ((struct __pyx_vtabstruct_5_soya_Font *)__pyx_v_self->__pyx_vtab)->_sizeup_pixel(__pyx_v_self,(__pyx_v_self->_current_y + __pyx_v_g_height));
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/text/text.pyx":140 */
  if (PyObject_Cmp(__pyx_v_char_, __pyx_k342p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_1 = __pyx_1 == 0;
  if (__pyx_1) {
    __pyx_v_glyph->width = (__pyx_v_self->_width / 2);
    goto __pyx_L9;
  }
  /*else*/ {
    __pyx_v_glyph->width = __pyx_v_bitmap.width;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/text/text.pyx":142 */
  __pyx_v_glyph->height = __pyx_v_g_height;

  /* "/home/jiba/src/soya/text/text.pyx":143 */
  __pyx_v_glyph->_pixels_x1 = (((float )__pyx_v_self->_current_x) / ((float )__pyx_v_5_soya_MAX_TEXTURE_SIZE));

  /* "/home/jiba/src/soya/text/text.pyx":144 */
  __pyx_v_glyph->_pixels_y1 = (((float )__pyx_v_self->_current_y) / ((float )__pyx_v_self->_pixels_height));

  /* "/home/jiba/src/soya/text/text.pyx":145 */
  __pyx_v_glyph->_pixels_x2 = ((((float )__pyx_v_self->_current_x) + __pyx_v_glyph->width) / ((float )__pyx_v_5_soya_MAX_TEXTURE_SIZE));

  /* "/home/jiba/src/soya/text/text.pyx":146 */
  __pyx_v_glyph->_pixels_y2 = ((((float )__pyx_v_self->_current_y) + __pyx_v_glyph->height) / ((float )__pyx_v_self->_pixels_height));

  /* "/home/jiba/src/soya/text/text.pyx":147 */
  __pyx_v_glyph->y = (__pyx_v_self->_height - __pyx_v_self->_face->glyph->bitmap_top);

  /* "/home/jiba/src/soya/text/text.pyx":148 */
  __pyx_v_glyph->x = __pyx_v_self->_face->glyph->bitmap_left;

  /* "/home/jiba/src/soya/text/text.pyx":150 */
  __pyx_1 = __pyx_v_bitmap.rows;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/text/text.pyx":151 */
    memcpy(((__pyx_v_self->_pixels + __pyx_v_self->_current_x) + ((__pyx_v_self->_current_y + __pyx_v_j) * __pyx_v_5_soya_MAX_TEXTURE_SIZE)),(__pyx_v_bitmap.buffer + (__pyx_v_bitmap.pitch * __pyx_v_j)),__pyx_v_bitmap.pitch);
    __pyx_L10:;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/text/text.pyx":153 */
  __pyx_v_self->_current_x = ((__pyx_v_self->_current_x + __pyx_v_glyph->width) + 5);

  /* "/home/jiba/src/soya/text/text.pyx":155 */
  glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":156 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":157 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":158 */
  glTexImage2D(GL_TEXTURE_2D,0,GL_ALPHA,__pyx_v_5_soya_MAX_TEXTURE_SIZE,__pyx_v_self->_pixels_height,0,GL_ALPHA,GL_UNSIGNED_BYTE,__pyx_v_self->_pixels);

  /* "/home/jiba/src/soya/text/text.pyx":164 */
  Py_INCREF(((PyObject *)__pyx_v_glyph));
  __pyx_r = ((PyObject *)__pyx_v_glyph);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Font._gen_glyph");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_char_);
  return __pyx_r;
}

static PyObject *__pyx_n_MemoryError;
static PyObject *__pyx_n_max;

static PyObject *__pyx_k343p;

static char (__pyx_k343[]) = "Too many characters in font %s -- no space left on texture.";

static void __pyx_f_5_soya_4Font__sizeup_pixel(struct __pyx_obj_5_soya_Font *__pyx_v_self,int __pyx_v_height) {
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  int __pyx_v_i;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  long __pyx_7;
  Py_INCREF(__pyx_v_self);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);

  /* "/home/jiba/src/soya/text/text.pyx":167 */
  __pyx_1 = (__pyx_v_height < 32);
  if (__pyx_1) {
    __pyx_v_height = 32;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_height < 64);
  if (__pyx_1) {
    __pyx_v_height = 64;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_height < 128);
  if (__pyx_1) {
    __pyx_v_height = 128;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_height < 256);
  if (__pyx_1) {
    __pyx_v_height = 256;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_height < 512);
  if (__pyx_1) {
    __pyx_v_height = 512;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_height < 1024);
  if (__pyx_1) {
    __pyx_v_height = 1024;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_height < 2048);
  if (__pyx_1) {
    __pyx_v_height = 2048;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_MemoryError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 174; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k343p, ((PyObject *)__pyx_v_self)); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 174; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 174; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 174; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __Pyx_Raise(__pyx_3, 0, 0);
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    {__pyx_filename = __pyx_f[26]; __pyx_lineno = 174; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":177 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_glyphs, __pyx_n_values); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 177; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 177; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 177; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 177; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  for (;;) {
    __pyx_L3:;
    __pyx_4 = PyIter_Next(__pyx_2);
    if (!__pyx_4) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 177; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 177; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_glyph));
    __pyx_v_glyph = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":178 */
    __pyx_v_glyph->_pixels_y1 = ((__pyx_v_glyph->_pixels_y1 / __pyx_v_height) * __pyx_v_self->_pixels_height);

    /* "/home/jiba/src/soya/text/text.pyx":179 */
    __pyx_v_glyph->_pixels_y2 = ((__pyx_v_glyph->_pixels_y2 / __pyx_v_height) * __pyx_v_self->_pixels_height);
  }
  __pyx_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":181 */
  __pyx_v_self->_pixels = ((GLubyte (*))realloc(__pyx_v_self->_pixels,((__pyx_v_5_soya_MAX_TEXTURE_SIZE * __pyx_v_height) * (sizeof(GLubyte )))));

  /* "/home/jiba/src/soya/text/text.pyx":185 */
  __pyx_3 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_self->_pixels_height); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_6, 1, __pyx_5);
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_5 = PyNumber_Multiply(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_1 = (__pyx_v_5_soya_MAX_TEXTURE_SIZE * __pyx_v_height);
  for (__pyx_v_i = __pyx_7; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/text/text.pyx":186 */
    (__pyx_v_self->_pixels[__pyx_v_i]) = 0;
    __pyx_L5:;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/text/text.pyx":188 */
  __pyx_v_self->_pixels_height = __pyx_v_height;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya.Font._sizeup_pixel");
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_self);
}

static PyObject *__pyx_k344p;

static char (__pyx_k344[]) = "<Font '%s', width = %s, height = %s, %s characters loaded>";

static PyObject *__pyx_f_5_soya_4Font___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_4Font___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":191 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_width); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 191; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 191; goto __pyx_L1;}
  __pyx_3 = PyObject_Length(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_glyphs); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 191; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 191; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 191; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->filename);
  PyTuple_SET_ITEM(__pyx_5, 0, ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->filename);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_4 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k344p, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 191; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.Font.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_4Font_get_glyph(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_get_glyph(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_chr = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"chr",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_chr)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_chr);

  /* "/home/jiba/src/soya/text/text.pyx":194 */
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_chr)); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 194; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.Font.get_glyph");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_chr);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_4Font_create_glyphs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_create_glyphs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  PyObject *__pyx_v_char_;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"text",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_text)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);
  __pyx_v_char_ = Py_None; Py_INCREF(__pyx_v_char_);

  /* "/home/jiba/src/soya/text/text.pyx":197 */
  __pyx_1 = PyObject_GetIter(__pyx_v_text); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_2;
    __pyx_2 = 0;
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya.Font.create_glyphs");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_char_);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static PyObject *__pyx_k345p;

static char (__pyx_k345[]) = "\n";

static PyObject *__pyx_f_5_soya_4Font_get_print_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_get_print_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  float __pyx_v_width;
  float __pyx_v_height;
  float __pyx_v_line_width;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  PyObject *__pyx_v_char_;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"text",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_text)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);
  __pyx_v_char_ = Py_None; Py_INCREF(__pyx_v_char_);

  /* "/home/jiba/src/soya/text/text.pyx":202 */
  __pyx_v_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":203 */
  __pyx_v_height = ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height;

  /* "/home/jiba/src/soya/text/text.pyx":204 */
  __pyx_v_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":206 */
  __pyx_1 = PyObject_GetIter(__pyx_v_text); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 206; goto __pyx_L1;}
  for (;;) {
    __pyx_L2:;
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 206; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":207 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k345p, &__pyx_3) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 207; goto __pyx_L1;}
    __pyx_3 = __pyx_3 == 0;
    if (__pyx_3) {

      /* "/home/jiba/src/soya/text/text.pyx":208 */
      __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":209 */
      __pyx_3 = (__pyx_v_width < __pyx_v_line_width);
      if (__pyx_3) {
        __pyx_v_width = __pyx_v_line_width;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/text/text.pyx":210 */
      __pyx_v_line_width = 0.0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":212 */
      __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 212; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":213 */
      __pyx_v_line_width = ((__pyx_v_line_width + __pyx_v_glyph->x) + __pyx_v_glyph->width);
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":214 */
  __pyx_3 = (__pyx_v_width < __pyx_v_line_width);
  if (__pyx_3) {
    __pyx_v_width = __pyx_v_line_width;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/text/text.pyx":216 */
  __pyx_2 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 216; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(__pyx_v_height); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 216; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 216; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_1);
  __pyx_2 = 0;
  __pyx_1 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Font.get_print_size");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_char_);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static PyObject *__pyx_k346p;
static PyObject *__pyx_k347p;
static PyObject *__pyx_k348p;
static PyObject *__pyx_k349p;

static char (__pyx_k346[]) = "";
static char (__pyx_k347[]) = "\n";
static char (__pyx_k348[]) = " ";
static char (__pyx_k349[]) = "\n";

static PyObject *__pyx_f_5_soya_4Font_wordwrap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_4Font_wordwrap[] = " return a tuple like:\n      ( max_line_width, total_height, wrapped text ) \n    ";
static PyObject *__pyx_f_5_soya_4Font_wordwrap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  float __pyx_v_width;
  float __pyx_v_height;
  float __pyx_v_line_width;
  float __pyx_v_max_line_width;
  float __pyx_v_char_width;
  int __pyx_v_word_start;
  int __pyx_v_i;
  int __pyx_v_nb;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  PyObject *__pyx_v_text2;
  PyObject *__pyx_v_char_;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"text","width",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Of", __pyx_argnames, &__pyx_v_text, &__pyx_v_width)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);
  __pyx_v_text2 = Py_None; Py_INCREF(__pyx_v_text2);
  __pyx_v_char_ = Py_None; Py_INCREF(__pyx_v_char_);

  /* "/home/jiba/src/soya/text/text.pyx":226 */
  __pyx_v_height = ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height;

  /* "/home/jiba/src/soya/text/text.pyx":227 */
  __pyx_v_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":228 */
  __pyx_v_max_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":229 */
  __pyx_v_word_start = (-1);

  /* "/home/jiba/src/soya/text/text.pyx":230 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/text/text.pyx":231 */
  __pyx_1 = PyObject_Length(__pyx_v_text); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_v_nb = __pyx_1;

  /* "/home/jiba/src/soya/text/text.pyx":232 */
  Py_INCREF(__pyx_k346p);
  Py_DECREF(__pyx_v_text2);
  __pyx_v_text2 = __pyx_k346p;

  /* "/home/jiba/src/soya/text/text.pyx":233 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_nb);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/text/text.pyx":234 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 234; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_text, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 234; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":235 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k347p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 235; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/text/text.pyx":236 */
      __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":237 */
      __pyx_1 = (__pyx_v_line_width > __pyx_v_max_line_width);
      if (__pyx_1) {
        __pyx_v_max_line_width = __pyx_v_line_width;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/text/text.pyx":238 */
      __pyx_v_line_width = 0.0;

      /* "/home/jiba/src/soya/text/text.pyx":239 */
      __pyx_v_word_start = (-1);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":241 */
      if (PyObject_Cmp(__pyx_v_char_, __pyx_k348p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 241; goto __pyx_L1;}
      __pyx_1 = __pyx_1 == 0;
      if (__pyx_1) {
        __pyx_v_word_start = __pyx_v_i;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/text/text.pyx":242 */
      __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 242; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":243 */
      __pyx_v_line_width = ((__pyx_v_line_width + __pyx_v_glyph->width) + __pyx_v_glyph->x);

      /* "/home/jiba/src/soya/text/text.pyx":244 */
      __pyx_1 = (__pyx_v_line_width > __pyx_v_width);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_word_start != (-1));
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/text/text.pyx":245 */
        __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

        /* "/home/jiba/src/soya/text/text.pyx":246 */
        __pyx_1 = (__pyx_v_line_width > __pyx_v_max_line_width);
        if (__pyx_1) {
          __pyx_v_max_line_width = __pyx_v_line_width;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/text/text.pyx":247 */
        __pyx_v_line_width = 0.0;

        /* "/home/jiba/src/soya/text/text.pyx":248 */
        __pyx_1 = PyObject_Length(__pyx_v_text2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
        __pyx_3 = PySequence_GetSlice(__pyx_v_text, __pyx_1, __pyx_v_word_start); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
        __pyx_2 = PyNumber_Add(__pyx_v_text2, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_3 = PyNumber_Add(__pyx_2, __pyx_k349p); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_v_text2);
        __pyx_v_text2 = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":249 */
        __pyx_v_i = __pyx_v_word_start;

        /* "/home/jiba/src/soya/text/text.pyx":250 */
        __pyx_v_word_start = (-1);
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/text/text.pyx":251 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":252 */
  __pyx_1 = (__pyx_v_line_width > __pyx_v_max_line_width);
  if (__pyx_1) {
    __pyx_v_max_line_width = __pyx_v_line_width;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/text/text.pyx":253 */
  __pyx_1 = PyObject_Length(__pyx_v_text2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_2 = PySequence_GetSlice(__pyx_v_text, __pyx_1, 0x7fffffff); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
  __pyx_3 = PyNumber_Add(__pyx_v_text2, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_v_text2);
  __pyx_v_text2 = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":254 */
  __pyx_2 = PyFloat_FromDouble(__pyx_v_max_line_width); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 254; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_height); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 254; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 254; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
  Py_INCREF(__pyx_v_text2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_v_text2);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.Font.wordwrap");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_text2);
  Py_DECREF(__pyx_v_char_);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static PyObject *__pyx_k350p;
static PyObject *__pyx_k351p;

static char (__pyx_k350[]) = "\n";
static char (__pyx_k351[]) = " ";

static PyObject *__pyx_f_5_soya_4Font_wordwrap_line(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_4Font_wordwrap_line[] = " return a tuple like :\n      ( max_line_width, total_height, [ (\'line1\', line1width), (\'line2\', linewidth2) ... ] ) \n    ";
static PyObject *__pyx_f_5_soya_4Font_wordwrap_line(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  float __pyx_v_width;
  float __pyx_v_height;
  float __pyx_v_line_width;
  float __pyx_v_max_line_width;
  float __pyx_v_char_width;
  int __pyx_v_word_start;
  int __pyx_v_i;
  int __pyx_v_nb;
  int __pyx_v_line_start;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  PyObject *__pyx_v_lines;
  PyObject *__pyx_v_char_;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"text","width",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Of", __pyx_argnames, &__pyx_v_text, &__pyx_v_width)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);
  __pyx_v_lines = Py_None; Py_INCREF(__pyx_v_lines);
  __pyx_v_char_ = Py_None; Py_INCREF(__pyx_v_char_);

  /* "/home/jiba/src/soya/text/text.pyx":263 */
  __pyx_v_height = ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height;

  /* "/home/jiba/src/soya/text/text.pyx":264 */
  __pyx_v_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":265 */
  __pyx_v_max_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":266 */
  __pyx_v_word_start = (-1);

  /* "/home/jiba/src/soya/text/text.pyx":267 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/text/text.pyx":268 */
  __pyx_1 = PyObject_Length(__pyx_v_text); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 268; goto __pyx_L1;}
  __pyx_v_nb = __pyx_1;

  /* "/home/jiba/src/soya/text/text.pyx":269 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 269; goto __pyx_L1;}
  Py_DECREF(__pyx_v_lines);
  __pyx_v_lines = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":270 */
  __pyx_v_line_start = 0;

  /* "/home/jiba/src/soya/text/text.pyx":271 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_nb);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/text/text.pyx":272 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 272; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_text, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 272; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":273 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k350p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 273; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/text/text.pyx":274 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_lines, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 274; goto __pyx_L1;}
      __pyx_3 = PySequence_GetSlice(__pyx_v_text, __pyx_v_line_start, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 274; goto __pyx_L1;}
      __pyx_4 = PyFloat_FromDouble(__pyx_v_line_width); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 274; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 274; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
      PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
      __pyx_3 = 0;
      __pyx_4 = 0;
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 274; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
      __pyx_5 = 0;
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 274; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":275 */
      __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":276 */
      __pyx_1 = (__pyx_v_line_width > __pyx_v_max_line_width);
      if (__pyx_1) {
        __pyx_v_max_line_width = __pyx_v_line_width;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/text/text.pyx":277 */
      __pyx_v_line_width = 0.0;

      /* "/home/jiba/src/soya/text/text.pyx":278 */
      __pyx_v_word_start = (-1);

      /* "/home/jiba/src/soya/text/text.pyx":279 */
      __pyx_v_line_start = (__pyx_v_i + 1);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":281 */
      if (PyObject_Cmp(__pyx_v_char_, __pyx_k351p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 281; goto __pyx_L1;}
      __pyx_1 = __pyx_1 == 0;
      if (__pyx_1) {
        __pyx_v_word_start = __pyx_v_i;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/text/text.pyx":282 */
      __pyx_5 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 282; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":283 */
      __pyx_v_char_width = (__pyx_v_glyph->width + __pyx_v_glyph->x);

      /* "/home/jiba/src/soya/text/text.pyx":284 */
      __pyx_v_line_width = (__pyx_v_line_width + __pyx_v_char_width);

      /* "/home/jiba/src/soya/text/text.pyx":285 */
      __pyx_1 = (__pyx_v_line_width > __pyx_v_width);
      if (__pyx_1) {
        __pyx_1 = (__pyx_v_word_start != (-1));
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/text/text.pyx":286 */
        __pyx_2 = PyObject_GetAttr(__pyx_v_lines, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 286; goto __pyx_L1;}
        __pyx_3 = PySequence_GetSlice(__pyx_v_text, __pyx_v_line_start, __pyx_v_word_start); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 286; goto __pyx_L1;}
        __pyx_4 = PyFloat_FromDouble((__pyx_v_line_width - __pyx_v_char_width)); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 286; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 286; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
        PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
        __pyx_3 = 0;
        __pyx_4 = 0;
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 286; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
        __pyx_5 = 0;
        __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 286; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_4); __pyx_4 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":287 */
        __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

        /* "/home/jiba/src/soya/text/text.pyx":288 */
        __pyx_1 = (__pyx_v_line_width > __pyx_v_max_line_width);
        if (__pyx_1) {
          __pyx_v_max_line_width = __pyx_v_line_width;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/text/text.pyx":289 */
        __pyx_v_line_width = 0.0;

        /* "/home/jiba/src/soya/text/text.pyx":290 */
        __pyx_v_line_start = (__pyx_v_word_start + 1);

        /* "/home/jiba/src/soya/text/text.pyx":291 */
        __pyx_v_i = __pyx_v_word_start;

        /* "/home/jiba/src/soya/text/text.pyx":292 */
        __pyx_v_word_start = (-1);
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/text/text.pyx":293 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":294 */
  __pyx_1 = (__pyx_v_line_width > __pyx_v_max_line_width);
  if (__pyx_1) {
    __pyx_v_max_line_width = __pyx_v_line_width;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/text/text.pyx":295 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_lines, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_2 = PySequence_GetSlice(__pyx_v_text, __pyx_v_line_start, 0x7fffffff); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_line_width); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 295; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 295; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 295; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":296 */
  __pyx_4 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(__pyx_v_height); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 296; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5);
  Py_INCREF(__pyx_v_lines);
  PyTuple_SET_ITEM(__pyx_2, 2, __pyx_v_lines);
  __pyx_4 = 0;
  __pyx_5 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.Font.wordwrap_line");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_lines);
  Py_DECREF(__pyx_v_char_);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static PyObject *__pyx_k352p;

static char (__pyx_k352[]) = "\n";

static PyObject *__pyx_f_5_soya_4Font_draw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_draw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  int __pyx_v_cull_face;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  float __pyx_v_x_orig;
  PyObject *__pyx_v_char_;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"text","x","y","z","cull_face",0};
  __pyx_v_z = __pyx_k155;
  __pyx_v_cull_face = __pyx_k156;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Off|fi", __pyx_argnames, &__pyx_v_text, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_cull_face)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);
  __pyx_v_char_ = Py_None; Py_INCREF(__pyx_v_char_);

  /* "/home/jiba/src/soya/text/text.pyx":302 */
  __pyx_1 = (__pyx_v_cull_face == 0);
  if (__pyx_1) {
    glDisable(GL_CULL_FACE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":303 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/text/text.pyx":304 */
  glEnable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":305 */
  glBindTexture(GL_TEXTURE_2D,((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":307 */
  __pyx_v_x_orig = __pyx_v_x;

  /* "/home/jiba/src/soya/text/text.pyx":308 */
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 0;

  /* "/home/jiba/src/soya/text/text.pyx":309 */
  __pyx_2 = PyObject_GetIter(__pyx_v_text); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 309; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 309; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":310 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k352p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/text/text.pyx":311 */
      __pyx_v_x = __pyx_v_x_orig;

      /* "/home/jiba/src/soya/text/text.pyx":312 */
      __pyx_v_y = (__pyx_v_y + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":314 */
      __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 314; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":315 */
      __pyx_1 = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering == 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/text/text.pyx":315 */
        glBegin(GL_QUADS);

        /* "/home/jiba/src/soya/text/text.pyx":315 */
        ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 1;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/text/text.pyx":317 */
      __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->x);

      /* "/home/jiba/src/soya/text/text.pyx":318 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y1);

      /* "/home/jiba/src/soya/text/text.pyx":318 */
      glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);

      /* "/home/jiba/src/soya/text/text.pyx":319 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y2);

      /* "/home/jiba/src/soya/text/text.pyx":319 */
      glVertex3f(__pyx_v_x,((__pyx_v_y + __pyx_v_glyph->y) + __pyx_v_glyph->height),__pyx_v_z);

      /* "/home/jiba/src/soya/text/text.pyx":320 */
      __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->width);

      /* "/home/jiba/src/soya/text/text.pyx":321 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y2);

      /* "/home/jiba/src/soya/text/text.pyx":321 */
      glVertex3f(__pyx_v_x,((__pyx_v_y + __pyx_v_glyph->y) + __pyx_v_glyph->height),__pyx_v_z);

      /* "/home/jiba/src/soya/text/text.pyx":322 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y1);

      /* "/home/jiba/src/soya/text/text.pyx":322 */
      glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);
    }
    __pyx_L5:;
  }
  __pyx_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":324 */
  __pyx_1 = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":324 */
    glEnd();

    /* "/home/jiba/src/soya/text/text.pyx":324 */
    ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/text/text.pyx":326 */
  __pyx_1 = (__pyx_v_cull_face == 0);
  if (__pyx_1) {
    glEnable(GL_CULL_FACE);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/text/text.pyx":327 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":328 */
  glBindTexture(GL_TEXTURE_2D,0);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya.Font.draw");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_char_);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static PyObject *__pyx_n_wordwrap;
static PyObject *__pyx_n_wordwrap_line;
static PyObject *__pyx_n_unicode;
static PyObject *__pyx_n_decode;
static PyObject *__pyx_n_latin;

static PyObject *__pyx_k353p;

static char (__pyx_k353[]) = "\n";

static PyObject *__pyx_f_5_soya_4Font_draw_area(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_4Font_draw_area(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_text = 0;
  float __pyx_v_x;
  float __pyx_v_y;
  float __pyx_v_z;
  float __pyx_v_width;
  float __pyx_v_box_height;
  int __pyx_v_align;
  struct __pyx_obj_5_soya_Glyph *__pyx_v_glyph;
  float __pyx_v_w;
  float __pyx_v_h;
  float __pyx_v_x_orig;
  PyObject *__pyx_v_char_;
  PyObject *__pyx_v_lines;
  PyObject *__pyx_v_line;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  float __pyx_5;
  float __pyx_6;
  PyObject *__pyx_7 = 0;
  int __pyx_8;
  static char *__pyx_argnames[] = {"text","x","y","z","width","box_height","align",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Offfffi", __pyx_argnames, &__pyx_v_text, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_width, &__pyx_v_box_height, &__pyx_v_align)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_text);
  __pyx_v_glyph = Py_None; Py_INCREF((PyObject *) __pyx_v_glyph);
  __pyx_v_char_ = Py_None; Py_INCREF(__pyx_v_char_);
  __pyx_v_lines = Py_None; Py_INCREF(__pyx_v_lines);
  __pyx_v_line = Py_None; Py_INCREF(__pyx_v_line);

  /* "/home/jiba/src/soya/text/text.pyx":334 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/text/text.pyx":335 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/text/text.pyx":336 */
  glEnable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":337 */
  glBindTexture(GL_TEXTURE_2D,((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":339 */
  __pyx_v_x_orig = __pyx_v_x;

  /* "/home/jiba/src/soya/text/text.pyx":340 */
  ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 0;

  /* "/home/jiba/src/soya/text/text.pyx":341 */
  __pyx_1 = (__pyx_v_align == __pyx_e_5_soya_TEXT_ALIGN_LEFT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":342 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_wordwrap); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_INCREF(__pyx_v_text);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_text);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_v_width = __pyx_5;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_h = __pyx_6;
    __pyx_2 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_DECREF(__pyx_v_text);
    __pyx_v_text = __pyx_2;
    __pyx_2 = 0;
    if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 342; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":344 */
    __pyx_4 = PyObject_GetIter(__pyx_v_text); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 344; goto __pyx_L1;}
    for (;;) {
      __pyx_L3:;
      __pyx_2 = PyIter_Next(__pyx_4);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 344; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_char_);
      __pyx_v_char_ = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":345 */
      if (PyObject_Cmp(__pyx_v_char_, __pyx_k353p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 345; goto __pyx_L1;}
      __pyx_1 = __pyx_1 == 0;
      if (__pyx_1) {

        /* "/home/jiba/src/soya/text/text.pyx":346 */
        __pyx_v_x = __pyx_v_x_orig;

        /* "/home/jiba/src/soya/text/text.pyx":347 */
        __pyx_v_y = (__pyx_v_y + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

        /* "/home/jiba/src/soya/text/text.pyx":348 */
        __pyx_1 = (__pyx_v_y >= __pyx_v_box_height);
        if (__pyx_1) {
          goto __pyx_L4;
          goto __pyx_L6;
        }
        __pyx_L6:;
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/text/text.pyx":350 */
        __pyx_3 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 350; goto __pyx_L1;}
        Py_DECREF(((PyObject *)__pyx_v_glyph));
        __pyx_v_glyph = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":351 */
        __pyx_1 = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/text/text.pyx":351 */
          glBegin(GL_QUADS);

          /* "/home/jiba/src/soya/text/text.pyx":351 */
          ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 1;
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/text/text.pyx":353 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->x);

        /* "/home/jiba/src/soya/text/text.pyx":354 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":354 */
        glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":355 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y2);

        /* "/home/jiba/src/soya/text/text.pyx":355 */
        glVertex3f(__pyx_v_x,((__pyx_v_y + __pyx_v_glyph->y) + __pyx_v_glyph->height),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":356 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->width);

        /* "/home/jiba/src/soya/text/text.pyx":357 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y2);

        /* "/home/jiba/src/soya/text/text.pyx":357 */
        glVertex3f(__pyx_v_x,((__pyx_v_y + __pyx_v_glyph->y) + __pyx_v_glyph->height),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":358 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":358 */
        glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);
      }
      __pyx_L5:;
    }
    __pyx_L4:;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_align == __pyx_e_5_soya_TEXT_ALIGN_CENTER);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":362 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_wordwrap_line); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_INCREF(__pyx_v_text);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_text);
    PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_v_width = __pyx_5;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_h = __pyx_6;
    __pyx_2 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF(__pyx_v_lines);
    __pyx_v_lines = __pyx_2;
    __pyx_2 = 0;
    if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 362; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":363 */
    __pyx_4 = PyObject_GetIter(__pyx_v_lines); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 363; goto __pyx_L1;}
    for (;;) {
      __pyx_L8:;
      __pyx_2 = PyIter_Next(__pyx_4);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 363; goto __pyx_L1;}
        break;
      }
      __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 363; goto __pyx_L1;}
      Py_DECREF(__pyx_v_line);
      __pyx_v_line = __pyx_3;
      __pyx_3 = 0;
      __pyx_7 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_7) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 363; goto __pyx_L1;}
      __pyx_5 = PyFloat_AsDouble(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 363; goto __pyx_L1;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      __pyx_v_w = __pyx_5;
      if (__Pyx_EndUnpack(__pyx_2, 2) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 363; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":364 */
      __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_7) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
      __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
      Py_INCREF(__pyx_v_line);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_line);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2);
      __pyx_2 = 0;
      __pyx_2 = PyObject_CallObject(__pyx_7, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
      Py_DECREF(__pyx_7); __pyx_7 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_8 = (!__pyx_1);
      if (__pyx_8) {
        __pyx_7 = PyObject_GetAttr(__pyx_v_line, __pyx_n_decode); if (!__pyx_7) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
        Py_INCREF(__pyx_n_latin);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_latin);
        __pyx_2 = PyObject_CallObject(__pyx_7, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_v_line);
        __pyx_v_line = __pyx_2;
        __pyx_2 = 0;
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/text/text.pyx":366 */
      __pyx_v_x = (__pyx_v_x_orig + ((__pyx_v_width - __pyx_v_w) / 2.0));

      /* "/home/jiba/src/soya/text/text.pyx":367 */
      __pyx_7 = PyObject_GetIter(__pyx_v_line); if (!__pyx_7) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 367; goto __pyx_L1;}
      for (;;) {
        __pyx_L11:;
        __pyx_3 = PyIter_Next(__pyx_7);
        if (!__pyx_3) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 367; goto __pyx_L1;}
          break;
        }
        Py_DECREF(__pyx_v_char_);
        __pyx_v_char_ = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":368 */
        __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya_Font *)((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->__pyx_vtab)->_get_glyph(((struct __pyx_obj_5_soya_Font *)__pyx_v_self),__pyx_v_char_)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 368; goto __pyx_L1;}
        Py_DECREF(((PyObject *)__pyx_v_glyph));
        __pyx_v_glyph = __pyx_2;
        __pyx_2 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":369 */
        __pyx_1 = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/text/text.pyx":369 */
          glBegin(GL_QUADS);

          /* "/home/jiba/src/soya/text/text.pyx":369 */
          ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 1;
          goto __pyx_L13;
        }
        __pyx_L13:;

        /* "/home/jiba/src/soya/text/text.pyx":371 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->x);

        /* "/home/jiba/src/soya/text/text.pyx":372 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":372 */
        glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":373 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y2);

        /* "/home/jiba/src/soya/text/text.pyx":373 */
        glVertex3f(__pyx_v_x,((__pyx_v_y + __pyx_v_glyph->y) + __pyx_v_glyph->height),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":374 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->width);

        /* "/home/jiba/src/soya/text/text.pyx":375 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y2);

        /* "/home/jiba/src/soya/text/text.pyx":375 */
        glVertex3f(__pyx_v_x,((__pyx_v_y + __pyx_v_glyph->y) + __pyx_v_glyph->height),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":376 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":376 */
        glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);
      }
      __pyx_L12:;
      Py_DECREF(__pyx_7); __pyx_7 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":378 */
      __pyx_v_y = (__pyx_v_y + ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":379 */
      __pyx_8 = (__pyx_v_y >= __pyx_v_box_height);
      if (__pyx_8) {
        goto __pyx_L9;
        goto __pyx_L14;
      }
      __pyx_L14:;
    }
    __pyx_L9:;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":382 */
  __pyx_1 = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":382 */
    glEnd();

    /* "/home/jiba/src/soya/text/text.pyx":382 */
    ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_rendering = 0;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/text/text.pyx":384 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/text/text.pyx":385 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":386 */
  glBindTexture(GL_TEXTURE_2D,0);

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_7);
  __Pyx_AddTraceback("_soya.Font.draw_area");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_glyph);
  Py_DECREF(__pyx_v_char_);
  Py_DECREF(__pyx_v_lines);
  Py_DECREF(__pyx_v_line);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_text);
  return __pyx_r;
}

static PyObject *__pyx_n_new;

static PyObject *__pyx_k355p;

static char (__pyx_k355[]) = "PIL.Image";

static PyObject *__pyx_f_5_soya_4Font__image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_4Font__image[] = "Debugging stuff -- return the font loaded glyphs as a PIL image.";
static PyObject *__pyx_f_5_soya_4Font__image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_PIL;
  int __pyx_v_i;
  int __pyx_v_size;
  GLubyte (*__pyx_v_pixels);
  PyObject *__pyx_v_image;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_PIL = Py_None; Py_INCREF(__pyx_v_PIL);
  __pyx_v_image = Py_None; Py_INCREF(__pyx_v_image);

  /* "/home/jiba/src/soya/text/text.pyx":390 */
  __pyx_1 = __Pyx_Import(__pyx_k355p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 390; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":393 */
  __pyx_v_size = (((__pyx_v_5_soya_MAX_TEXTURE_SIZE * ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels_height) * 3) * (sizeof(GLubyte )));

  /* "/home/jiba/src/soya/text/text.pyx":394 */
  __pyx_v_pixels = ((GLubyte (*))malloc(__pyx_v_size));

  /* "/home/jiba/src/soya/text/text.pyx":395 */
  __pyx_2 = (__pyx_v_5_soya_MAX_TEXTURE_SIZE * ((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels_height);
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/text/text.pyx":396 */
    (__pyx_v_pixels[(3 * __pyx_v_i)]) = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels[__pyx_v_i]);

    /* "/home/jiba/src/soya/text/text.pyx":397 */
    (__pyx_v_pixels[((3 * __pyx_v_i) + 1)]) = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels[__pyx_v_i]);

    /* "/home/jiba/src/soya/text/text.pyx":398 */
    (__pyx_v_pixels[((3 * __pyx_v_i) + 2)]) = (((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels[__pyx_v_i]);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":400 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_new); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(((struct __pyx_obj_5_soya_Font *)__pyx_v_self)->_pixels_height); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4);
  __pyx_1 = 0;
  __pyx_4 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_INCREF(__pyx_n_RGB);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_n_RGB);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);
  __pyx_5 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_image);
  __pyx_v_image = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":401 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_image, __pyx_n_fromstring); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 401; goto __pyx_L1;}
  __pyx_3 = PyString_FromStringAndSize(((char (*))__pyx_v_pixels),__pyx_v_size); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 401; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 401; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
  __pyx_3 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 401; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":402 */
  Py_INCREF(__pyx_v_image);
  __pyx_r = __pyx_v_image;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya.Font._image");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_PIL);
  Py_DECREF(__pyx_v_image);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_ALL_EVENTS, "ALL_EVENTS"},
  {&__pyx_n_Atmosphere, "Atmosphere"},
  {&__pyx_n_BEFORE_RENDER, "BEFORE_RENDER"},
  {&__pyx_n_BLACK, "BLACK"},
  {&__pyx_n_COORDSYS_LEFTHANDED, "COORDSYS_LEFTHANDED"},
  {&__pyx_n_Cal3dShape, "Cal3dShape"},
  {&__pyx_n_Cal3dVolume, "Cal3dVolume"},
  {&__pyx_n_Camera, "Camera"},
  {&__pyx_n_CellShadingShape, "CellShadingShape"},
  {&__pyx_n_DIRNAME, "DIRNAME"},
  {&__pyx_n_FLIP_TOP_BOTTOM, "FLIP_TOP_BOTTOM"},
  {&__pyx_n_Face, "Face"},
  {&__pyx_n_GLError, "GLError"},
  {&__pyx_n_GL_INVALID_ENUM, "GL_INVALID_ENUM"},
  {&__pyx_n_GL_INVALID_OPERATION, "GL_INVALID_OPERATION"},
  {&__pyx_n_GL_OUT_OF_MEMORY, "GL_OUT_OF_MEMORY"},
  {&__pyx_n_GL_STACK_OVERFLOW, "GL_STACK_OVERFLOW"},
  {&__pyx_n_GL_STACK_UNDERFLOW, "GL_STACK_UNDERFLOW"},
  {&__pyx_n_IDLEING_ITEMS, "IDLEING_ITEMS"},
  {&__pyx_n_IDLER, "IDLER"},
  {&__pyx_n_Image, "Image"},
  {&__pyx_n_ImportError, "ImportError"},
  {&__pyx_n_L, "L"},
  {&__pyx_n_Light, "Light"},
  {&__pyx_n_Material, "Material"},
  {&__pyx_n_MemoryError, "MemoryError"},
  {&__pyx_n_NotImplementedError, "NotImplementedError"},
  {&__pyx_n_OBJECT_NON_SOLID, "OBJECT_NON_SOLID"},
  {&__pyx_n_P, "P"},
  {&__pyx_n_P3_VERTEX_ALPHA, "P3_VERTEX_ALPHA"},
  {&__pyx_n_Particles, "Particles"},
  {&__pyx_n_Point, "Point"},
  {&__pyx_n_Portal, "Portal"},
  {&__pyx_n_REMOVABLE, "REMOVABLE"},
  {&__pyx_n_RGB, "RGB"},
  {&__pyx_n_RGBA, "RGBA"},
  {&__pyx_n_RaypickContext, "RaypickContext"},
  {&__pyx_n_RuntimeError, "RuntimeError"},
  {&__pyx_n_SDL_ALLEVENTS, "SDL_ALLEVENTS"},
  {&__pyx_n_Set, "Set"},
  {&__pyx_n_Shape, "Shape"},
  {&__pyx_n_SimpleShape, "SimpleShape"},
  {&__pyx_n_SolidShape, "SolidShape"},
  {&__pyx_n_StandardError, "StandardError"},
  {&__pyx_n_TRANSPARENT, "TRANSPARENT"},
  {&__pyx_n_TreeShape, "TreeShape"},
  {&__pyx_n_VERSION, "VERSION"},
  {&__pyx_n_ValueError, "ValueError"},
  {&__pyx_n_Vector, "Vector"},
  {&__pyx_n_Volume, "Volume"},
  {&__pyx_n_WHITE, "WHITE"},
  {&__pyx_n_WaterCube, "WaterCube"},
  {&__pyx_n_WeakKeyDictionary, "WeakKeyDictionary"},
  {&__pyx_n_World, "World"},
  {&__pyx_n___class__, "__class__"},
  {&__pyx_n___deepcopy__, "__deepcopy__"},
  {&__pyx_n___dict__, "__dict__"},
  {&__pyx_n___div__, "__div__"},
  {&__pyx_n___getstate__, "__getstate__"},
  {&__pyx_n___imul__, "__imul__"},
  {&__pyx_n___init__, "__init__"},
  {&__pyx_n___name__, "__name__"},
  {&__pyx_n___new__, "__new__"},
  {&__pyx_n___setstate__, "__setstate__"},
  {&__pyx_n__build_vertices, "_build_vertices"},
  {&__pyx_n__is_static_light, "_is_static_light"},
  {&__pyx_n__parent, "_parent"},
  {&__pyx_n__reconstructor, "_reconstructor"},
  {&__pyx_n__set_default_material, "_set_default_material"},
  {&__pyx_n__set_default_shapifier, "_set_default_shapifier"},
  {&__pyx_n__set_particle_default_material, "_set_particle_default_material"},
  {&__pyx_n__set_shader_default_material, "_set_shader_default_material"},
  {&__pyx_n_abs, "abs"},
  {&__pyx_n_activate, "activate"},
  {&__pyx_n_activated, "activated"},
  {&__pyx_n_add, "add"},
  {&__pyx_n_add_mul_vector, "add_mul_vector"},
  {&__pyx_n_add_vector, "add_vector"},
  {&__pyx_n_added_into, "added_into"},
  {&__pyx_n_advance_time, "advance_time"},
  {&__pyx_n_angle_to, "angle_to"},
  {&__pyx_n_animation, "animation"},
  {&__pyx_n_append, "append"},
  {&__pyx_n_array, "array"},
  {&__pyx_n_atexit, "atexit"},
  {&__pyx_n_attach, "attach"},
  {&__pyx_n_attached_coordsysts, "attached_coordsysts"},
  {&__pyx_n_back, "back"},
  {&__pyx_n_basename, "basename"},
  {&__pyx_n_batch, "batch"},
  {&__pyx_n_begin_round, "begin_round"},
  {&__pyx_n_best_direction, "best_direction"},
  {&__pyx_n_best_position, "best_position"},
  {&__pyx_n_beyond_name, "beyond_name"},
  {&__pyx_n_bottom, "bottom"},
  {&__pyx_n_build_materials, "build_materials"},
  {&__pyx_n_c, "c"},
  {&__pyx_n_cellshading, "cellshading"},
  {&__pyx_n_cellshading_outline_attenuation, "cellshading_outline_attenuation"},
  {&__pyx_n_cellshading_outline_color, "cellshading_outline_color"},
  {&__pyx_n_cellshading_outline_width, "cellshading_outline_width"},
  {&__pyx_n_cellshading_shader, "cellshading_shader"},
  {&__pyx_n_check_error, "check_error"},
  {&__pyx_n_clear_events, "clear_events"},
  {&__pyx_n_clone, "clone"},
  {&__pyx_n_cmp, "cmp"},
  {&__pyx_n_convert_to, "convert_to"},
  {&__pyx_n_copy, "copy"},
  {&__pyx_n_cursor_set_visible, "cursor_set_visible"},
  {&__pyx_n_darwin, "darwin"},
  {&__pyx_n_decode, "decode"},
  {&__pyx_n_deepcopy, "deepcopy"},
  {&__pyx_n_diffuse, "diffuse"},
  {&__pyx_n_dirname, "dirname"},
  {&__pyx_n_distance_to, "distance_to"},
  {&__pyx_n_double_sided, "double_sided"},
  {&__pyx_n_end_round, "end_round"},
  {&__pyx_n_endswith, "endswith"},
  {&__pyx_n_exists, "exists"},
  {&__pyx_n_extend, "extend"},
  {&__pyx_n_face, "face"},
  {&__pyx_n_filename, "filename"},
  {&__pyx_n_find, "find"},
  {&__pyx_n_float, "float"},
  {&__pyx_n_fromstring, "fromstring"},
  {&__pyx_n_front, "front"},
  {&__pyx_n_fx_advance_time, "fx_advance_time"},
  {&__pyx_n_fx_quit, "fx_quit"},
  {&__pyx_n_generate, "generate"},
  {&__pyx_n_get, "get"},
  {&__pyx_n_get_grab_input, "get_grab_input"},
  {&__pyx_n_get_max_texture_size, "get_max_texture_size"},
  {&__pyx_n_get_mod, "get_mod"},
  {&__pyx_n_get_mouse_rel_pos, "get_mouse_rel_pos"},
  {&__pyx_n_get_particle_position, "get_particle_position"},
  {&__pyx_n_get_renderer, "get_renderer"},
  {&__pyx_n_get_root, "get_root"},
  {&__pyx_n_get_screen_height, "get_screen_height"},
  {&__pyx_n_get_screen_width, "get_screen_width"},
  {&__pyx_n_getattr, "getattr"},
  {&__pyx_n_has_alpha_vertex, "has_alpha_vertex"},
  {&__pyx_n_has_key, "has_key"},
  {&__pyx_n_height, "height"},
  {&__pyx_n_i, "i"},
  {&__pyx_n_id, "id"},
  {&__pyx_n_idle, "idle"},
  {&__pyx_n_iii, "iii"},
  {&__pyx_n_image_from_pil, "image_from_pil"},
  {&__pyx_n_inactivated, "inactivated"},
  {&__pyx_n_index, "index"},
  {&__pyx_n_init, "init"},
  {&__pyx_n_init_texture, "init_texture"},
  {&__pyx_n_inited, "inited"},
  {&__pyx_n_insert, "insert"},
  {&__pyx_n_int, "int"},
  {&__pyx_n_is_alpha, "is_alpha"},
  {&__pyx_n_is_in_frustum, "is_in_frustum"},
  {&__pyx_n_is_inside, "is_inside"},
  {&__pyx_n_isinstance, "isinstance"},
  {&__pyx_n_iter, "iter"},
  {&__pyx_n_join, "join"},
  {&__pyx_n_keys, "keys"},
  {&__pyx_n_land, "land"},
  {&__pyx_n_land_free_patchs, "land_free_patchs"},
  {&__pyx_n_latin, "latin"},
  {&__pyx_n_left, "left"},
  {&__pyx_n_length, "length"},
  {&__pyx_n_list, "list"},
  {&__pyx_n_load_animation, "load_animation"},
  {&__pyx_n_load_beyond, "load_beyond"},
  {&__pyx_n_load_material, "load_material"},
  {&__pyx_n_load_mesh, "load_mesh"},
  {&__pyx_n_load_raw_image, "load_raw_image"},
  {&__pyx_n_load_skeleton, "load_skeleton"},
  {&__pyx_n_look_at, "look_at"},
  {&__pyx_n_map, "map"},
  {&__pyx_n_material, "material"},
  {&__pyx_n_max, "max"},
  {&__pyx_n_mesh, "mesh"},
  {&__pyx_n_meshes, "meshes"},
  {&__pyx_n_min, "min"},
  {&__pyx_n_mode, "mode"},
  {&__pyx_n_move, "move"},
  {&__pyx_n_mygenerate, "mygenerate"},
  {&__pyx_n_name, "name"},
  {&__pyx_n_nb_max_particles, "nb_max_particles"},
  {&__pyx_n_nb_particles, "nb_particles"},
  {&__pyx_n_new, "new"},
  {&__pyx_n_next_round_tasks, "next_round_tasks"},
  {&__pyx_n_normal, "normal"},
  {&__pyx_n_normalize, "normalize"},
  {&__pyx_n_open, "open"},
  {&__pyx_n_open_image, "open_image"},
  {&__pyx_n_option, "option"},
  {&__pyx_n_ord, "ord"},
  {&__pyx_n_os, "os"},
  {&__pyx_n_parent, "parent"},
  {&__pyx_n_parse_cal3d_cfg_file, "parse_cal3d_cfg_file"},
  {&__pyx_n_path, "path"},
  {&__pyx_n_pixels, "pixels"},
  {&__pyx_n_platform, "platform"},
  {&__pyx_n_pop, "pop"},
  {&__pyx_n_predicat, "predicat"},
  {&__pyx_n_process_event, "process_event"},
  {&__pyx_n_quit, "quit"},
  {&__pyx_n_random, "random"},
  {&__pyx_n_raypick, "raypick"},
  {&__pyx_n_rb, "rb"},
  {&__pyx_n_read, "read"},
  {&__pyx_n_readlines, "readlines"},
  {&__pyx_n_recursive, "recursive"},
  {&__pyx_n_regenerate, "regenerate"},
  {&__pyx_n_register, "register"},
  {&__pyx_n_removable, "removable"},
  {&__pyx_n_remove, "remove"},
  {&__pyx_n_render, "render"},
  {&__pyx_n_repr, "repr"},
  {&__pyx_n_resize, "resize"},
  {&__pyx_n_reverse, "reverse"},
  {&__pyx_n_right, "right"},
  {&__pyx_n_root_widget, "root_widget"},
  {&__pyx_n_round_duration, "round_duration"},
  {&__pyx_n_rstrip, "rstrip"},
  {&__pyx_n_save, "save"},
  {&__pyx_n_scale, "scale"},
  {&__pyx_n_screenshot, "screenshot"},
  {&__pyx_n_search, "search"},
  {&__pyx_n_search_all, "search_all"},
  {&__pyx_n_set_cellshading, "set_cellshading"},
  {&__pyx_n_set_colors, "set_colors"},
  {&__pyx_n_set_gamma, "set_gamma"},
  {&__pyx_n_set_grab_input, "set_grab_input"},
  {&__pyx_n_set_length, "set_length"},
  {&__pyx_n_set_mouse_pos, "set_mouse_pos"},
  {&__pyx_n_set_particle, "set_particle"},
  {&__pyx_n_set_particle2, "set_particle2"},
  {&__pyx_n_set_quality, "set_quality"},
  {&__pyx_n_set_root_widget, "set_root_widget"},
  {&__pyx_n_set_shape, "set_shape"},
  {&__pyx_n_set_sizes, "set_sizes"},
  {&__pyx_n_set_start_end, "set_start_end"},
  {&__pyx_n_set_use_unicode, "set_use_unicode"},
  {&__pyx_n_set_video, "set_video"},
  {&__pyx_n_set_xyz, "set_xyz"},
  {&__pyx_n_sets, "sets"},
  {&__pyx_n_shadow, "shadow"},
  {&__pyx_n_shape, "shape"},
  {&__pyx_n_shapifier, "shapifier"},
  {&__pyx_n_size, "size"},
  {&__pyx_n_skeleton, "skeleton"},
  {&__pyx_n_sleep, "sleep"},
  {&__pyx_n_sort, "sort"},
  {&__pyx_n_soya, "soya"},
  {&__pyx_n_specular, "specular"},
  {&__pyx_n_sphere, "sphere"},
  {&__pyx_n_split, "split"},
  {&__pyx_n_start_new_thread, "start_new_thread"},
  {&__pyx_n_static, "static"},
  {&__pyx_n_struct, "struct"},
  {&__pyx_n_subgenerate, "subgenerate"},
  {&__pyx_n_sys, "sys"},
  {&__pyx_n_texture, "texture"},
  {&__pyx_n_thread, "thread"},
  {&__pyx_n_time, "time"},
  {&__pyx_n_to_render, "to_render"},
  {&__pyx_n_toggle_wireframe, "toggle_wireframe"},
  {&__pyx_n_top, "top"},
  {&__pyx_n_tostring, "tostring"},
  {&__pyx_n_transform, "transform"},
  {&__pyx_n_transpose, "transpose"},
  {&__pyx_n_tuple, "tuple"},
  {&__pyx_n_turn_incline, "turn_incline"},
  {&__pyx_n_unicode, "unicode"},
  {&__pyx_n_unload_beyond, "unload_beyond"},
  {&__pyx_n_unpack, "unpack"},
  {&__pyx_n_values, "values"},
  {&__pyx_n_vector_to, "vector_to"},
  {&__pyx_n_vertices, "vertices"},
  {&__pyx_n_wb, "wb"},
  {&__pyx_n_weakref, "weakref"},
  {&__pyx_n_widget_advance_time, "widget_advance_time"},
  {&__pyx_n_widget_begin_round, "widget_begin_round"},
  {&__pyx_n_widget_end_round, "widget_end_round"},
  {&__pyx_n_width, "width"},
  {&__pyx_n_will_render, "will_render"},
  {&__pyx_n_wordwrap, "wordwrap"},
  {&__pyx_n_wordwrap_line, "wordwrap_line"},
  {&__pyx_n_write, "write"},
  {0, 0}
};

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_k1p, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_k2p, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_k139p, __pyx_k139, sizeof(__pyx_k139)},
  {&__pyx_k159p, __pyx_k159, sizeof(__pyx_k159)},
  {&__pyx_k160p, __pyx_k160, sizeof(__pyx_k160)},
  {&__pyx_k161p, __pyx_k161, sizeof(__pyx_k161)},
  {&__pyx_k162p, __pyx_k162, sizeof(__pyx_k162)},
  {&__pyx_k163p, __pyx_k163, sizeof(__pyx_k163)},
  {&__pyx_k164p, __pyx_k164, sizeof(__pyx_k164)},
  {&__pyx_k165p, __pyx_k165, sizeof(__pyx_k165)},
  {&__pyx_k166p, __pyx_k166, sizeof(__pyx_k166)},
  {&__pyx_k167p, __pyx_k167, sizeof(__pyx_k167)},
  {&__pyx_k168p, __pyx_k168, sizeof(__pyx_k168)},
  {&__pyx_k171p, __pyx_k171, sizeof(__pyx_k171)},
  {&__pyx_k174p, __pyx_k174, sizeof(__pyx_k174)},
  {&__pyx_k175p, __pyx_k175, sizeof(__pyx_k175)},
  {&__pyx_k176p, __pyx_k176, sizeof(__pyx_k176)},
  {&__pyx_k179p, __pyx_k179, sizeof(__pyx_k179)},
  {&__pyx_k180p, __pyx_k180, sizeof(__pyx_k180)},
  {&__pyx_k191p, __pyx_k191, sizeof(__pyx_k191)},
  {&__pyx_k192p, __pyx_k192, sizeof(__pyx_k192)},
  {&__pyx_k198p, __pyx_k198, sizeof(__pyx_k198)},
  {&__pyx_k199p, __pyx_k199, sizeof(__pyx_k199)},
  {&__pyx_k200p, __pyx_k200, sizeof(__pyx_k200)},
  {&__pyx_k201p, __pyx_k201, sizeof(__pyx_k201)},
  {&__pyx_k203p, __pyx_k203, sizeof(__pyx_k203)},
  {&__pyx_k204p, __pyx_k204, sizeof(__pyx_k204)},
  {&__pyx_k206p, __pyx_k206, sizeof(__pyx_k206)},
  {&__pyx_k207p, __pyx_k207, sizeof(__pyx_k207)},
  {&__pyx_k212p, __pyx_k212, sizeof(__pyx_k212)},
  {&__pyx_k214p, __pyx_k214, sizeof(__pyx_k214)},
  {&__pyx_k219p, __pyx_k219, sizeof(__pyx_k219)},
  {&__pyx_k220p, __pyx_k220, sizeof(__pyx_k220)},
  {&__pyx_k224p, __pyx_k224, sizeof(__pyx_k224)},
  {&__pyx_k226p, __pyx_k226, sizeof(__pyx_k226)},
  {&__pyx_k227p, __pyx_k227, sizeof(__pyx_k227)},
  {&__pyx_k228p, __pyx_k228, sizeof(__pyx_k228)},
  {&__pyx_k233p, __pyx_k233, sizeof(__pyx_k233)},
  {&__pyx_k234p, __pyx_k234, sizeof(__pyx_k234)},
  {&__pyx_k241p, __pyx_k241, sizeof(__pyx_k241)},
  {&__pyx_k242p, __pyx_k242, sizeof(__pyx_k242)},
  {&__pyx_k246p, __pyx_k246, sizeof(__pyx_k246)},
  {&__pyx_k247p, __pyx_k247, sizeof(__pyx_k247)},
  {&__pyx_k248p, __pyx_k248, sizeof(__pyx_k248)},
  {&__pyx_k249p, __pyx_k249, sizeof(__pyx_k249)},
  {&__pyx_k250p, __pyx_k250, sizeof(__pyx_k250)},
  {&__pyx_k251p, __pyx_k251, sizeof(__pyx_k251)},
  {&__pyx_k252p, __pyx_k252, sizeof(__pyx_k252)},
  {&__pyx_k253p, __pyx_k253, sizeof(__pyx_k253)},
  {&__pyx_k254p, __pyx_k254, sizeof(__pyx_k254)},
  {&__pyx_k255p, __pyx_k255, sizeof(__pyx_k255)},
  {&__pyx_k256p, __pyx_k256, sizeof(__pyx_k256)},
  {&__pyx_k260p, __pyx_k260, sizeof(__pyx_k260)},
  {&__pyx_k261p, __pyx_k261, sizeof(__pyx_k261)},
  {&__pyx_k262p, __pyx_k262, sizeof(__pyx_k262)},
  {&__pyx_k263p, __pyx_k263, sizeof(__pyx_k263)},
  {&__pyx_k264p, __pyx_k264, sizeof(__pyx_k264)},
  {&__pyx_k268p, __pyx_k268, sizeof(__pyx_k268)},
  {&__pyx_k269p, __pyx_k269, sizeof(__pyx_k269)},
  {&__pyx_k275p, __pyx_k275, sizeof(__pyx_k275)},
  {&__pyx_k277p, __pyx_k277, sizeof(__pyx_k277)},
  {&__pyx_k278p, __pyx_k278, sizeof(__pyx_k278)},
  {&__pyx_k291p, __pyx_k291, sizeof(__pyx_k291)},
  {&__pyx_k292p, __pyx_k292, sizeof(__pyx_k292)},
  {&__pyx_k294p, __pyx_k294, sizeof(__pyx_k294)},
  {&__pyx_k296p, __pyx_k296, sizeof(__pyx_k296)},
  {&__pyx_k298p, __pyx_k298, sizeof(__pyx_k298)},
  {&__pyx_k299p, __pyx_k299, sizeof(__pyx_k299)},
  {&__pyx_k300p, __pyx_k300, sizeof(__pyx_k300)},
  {&__pyx_k301p, __pyx_k301, sizeof(__pyx_k301)},
  {&__pyx_k302p, __pyx_k302, sizeof(__pyx_k302)},
  {&__pyx_k303p, __pyx_k303, sizeof(__pyx_k303)},
  {&__pyx_k304p, __pyx_k304, sizeof(__pyx_k304)},
  {&__pyx_k305p, __pyx_k305, sizeof(__pyx_k305)},
  {&__pyx_k306p, __pyx_k306, sizeof(__pyx_k306)},
  {&__pyx_k307p, __pyx_k307, sizeof(__pyx_k307)},
  {&__pyx_k308p, __pyx_k308, sizeof(__pyx_k308)},
  {&__pyx_k309p, __pyx_k309, sizeof(__pyx_k309)},
  {&__pyx_k310p, __pyx_k310, sizeof(__pyx_k310)},
  {&__pyx_k311p, __pyx_k311, sizeof(__pyx_k311)},
  {&__pyx_k312p, __pyx_k312, sizeof(__pyx_k312)},
  {&__pyx_k314p, __pyx_k314, sizeof(__pyx_k314)},
  {&__pyx_k315p, __pyx_k315, sizeof(__pyx_k315)},
  {&__pyx_k316p, __pyx_k316, sizeof(__pyx_k316)},
  {&__pyx_k317p, __pyx_k317, sizeof(__pyx_k317)},
  {&__pyx_k318p, __pyx_k318, sizeof(__pyx_k318)},
  {&__pyx_k319p, __pyx_k319, sizeof(__pyx_k319)},
  {&__pyx_k320p, __pyx_k320, sizeof(__pyx_k320)},
  {&__pyx_k321p, __pyx_k321, sizeof(__pyx_k321)},
  {&__pyx_k322p, __pyx_k322, sizeof(__pyx_k322)},
  {&__pyx_k323p, __pyx_k323, sizeof(__pyx_k323)},
  {&__pyx_k324p, __pyx_k324, sizeof(__pyx_k324)},
  {&__pyx_k325p, __pyx_k325, sizeof(__pyx_k325)},
  {&__pyx_k326p, __pyx_k326, sizeof(__pyx_k326)},
  {&__pyx_k327p, __pyx_k327, sizeof(__pyx_k327)},
  {&__pyx_k328p, __pyx_k328, sizeof(__pyx_k328)},
  {&__pyx_k329p, __pyx_k329, sizeof(__pyx_k329)},
  {&__pyx_k330p, __pyx_k330, sizeof(__pyx_k330)},
  {&__pyx_k331p, __pyx_k331, sizeof(__pyx_k331)},
  {&__pyx_k332p, __pyx_k332, sizeof(__pyx_k332)},
  {&__pyx_k334p, __pyx_k334, sizeof(__pyx_k334)},
  {&__pyx_k335p, __pyx_k335, sizeof(__pyx_k335)},
  {&__pyx_k336p, __pyx_k336, sizeof(__pyx_k336)},
  {&__pyx_k338p, __pyx_k338, sizeof(__pyx_k338)},
  {&__pyx_k339p, __pyx_k339, sizeof(__pyx_k339)},
  {&__pyx_k340p, __pyx_k340, sizeof(__pyx_k340)},
  {&__pyx_k341p, __pyx_k341, sizeof(__pyx_k341)},
  {&__pyx_k342p, __pyx_k342, sizeof(__pyx_k342)},
  {&__pyx_k343p, __pyx_k343, sizeof(__pyx_k343)},
  {&__pyx_k344p, __pyx_k344, sizeof(__pyx_k344)},
  {&__pyx_k345p, __pyx_k345, sizeof(__pyx_k345)},
  {&__pyx_k346p, __pyx_k346, sizeof(__pyx_k346)},
  {&__pyx_k347p, __pyx_k347, sizeof(__pyx_k347)},
  {&__pyx_k348p, __pyx_k348, sizeof(__pyx_k348)},
  {&__pyx_k349p, __pyx_k349, sizeof(__pyx_k349)},
  {&__pyx_k350p, __pyx_k350, sizeof(__pyx_k350)},
  {&__pyx_k351p, __pyx_k351, sizeof(__pyx_k351)},
  {&__pyx_k352p, __pyx_k352, sizeof(__pyx_k352)},
  {&__pyx_k353p, __pyx_k353, sizeof(__pyx_k353)},
  {&__pyx_k355p, __pyx_k355, sizeof(__pyx_k355)},
  {0, 0, 0}
};
static struct __pyx_vtabstruct_5_soya__CObj __pyx_vtable_5_soya__CObj;

static PyObject *__pyx_tp_new_5_soya__CObj(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya__CObj *p = (struct __pyx_obj_5_soya__CObj *)o;
  p->__pyx_vtab = (struct __pyx_vtabstruct_5_soya__CObj *)__pyx_vtabptr_5_soya__CObj;
  return o;
}

static void __pyx_tp_dealloc_5_soya__CObj(PyObject *o) {
  struct __pyx_obj_5_soya__CObj *p = (struct __pyx_obj_5_soya__CObj *)o;
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya__CObj(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__CObj *p = (struct __pyx_obj_5_soya__CObj *)o;
  return 0;
}

static int __pyx_tp_clear_5_soya__CObj(PyObject *o) {
  struct __pyx_obj_5_soya__CObj *p = (struct __pyx_obj_5_soya__CObj *)o;
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__CObj[] = {
  {"__getstate__", (PyCFunction)__pyx_f_5_soya_5_CObj___getstate__, METH_VARARGS|METH_KEYWORDS, 0},
  {"__setstate__", (PyCFunction)__pyx_f_5_soya_5_CObj___setstate__, METH_VARARGS|METH_KEYWORDS, 0},
  {"__reduce__", (PyCFunction)__pyx_f_5_soya_5_CObj___reduce__, METH_VARARGS|METH_KEYWORDS, 0},
  {"__deepcopy__", (PyCFunction)__pyx_f_5_soya_5_CObj___deepcopy__, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__CObj = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__CObj = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__CObj = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__CObj = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__CObj = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._CObj", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__CObj), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__CObj, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__CObj, /*tp_as_number*/
  &__pyx_tp_as_sequence__CObj, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__CObj, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__CObj, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__CObj, /*tp_traverse*/
  __pyx_tp_clear_5_soya__CObj, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__CObj, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__CObj, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Image __pyx_vtable_5_soya__Image;

static PyObject *__pyx_tp_new_5_soya__Image(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Image *p = (struct __pyx_obj_5_soya__Image *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Image *)__pyx_vtabptr_5_soya__Image;
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Image(PyObject *o) {
  struct __pyx_obj_5_soya__Image *p = (struct __pyx_obj_5_soya__Image *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_6_Image___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_filename);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Image(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Image *p = (struct __pyx_obj_5_soya__Image *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Image(PyObject *o) {
  struct __pyx_obj_5_soya__Image *p = (struct __pyx_obj_5_soya__Image *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  Py_XDECREF(p->_filename);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_6_Image_pixels(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Image_6pixels___get__(o);
}

static int __pyx_setprop_5_soya_6_Image_pixels(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Image_6pixels___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Image[] = {
  {"__deepcopy__", (PyCFunction)__pyx_f_5_soya_6_Image___deepcopy__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Image___deepcopy__},
  {"has_border", (PyCFunction)__pyx_f_5_soya_6_Image_has_border, METH_VARARGS|METH_KEYWORDS, 0},
  {"to_pil", (PyCFunction)__pyx_f_5_soya_6_Image_to_pil, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__Image[] = {
  {"nb_color", T_INT, offsetof(struct __pyx_obj_5_soya__Image, nb_color), READONLY, 0},
  {"width", T_INT, offsetof(struct __pyx_obj_5_soya__Image, width), READONLY, 0},
  {"height", T_INT, offsetof(struct __pyx_obj_5_soya__Image, height), READONLY, 0},
  {"_filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya__Image, _filename), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Image[] = {
  {"pixels", __pyx_getprop_5_soya_6_Image_pixels, __pyx_setprop_5_soya_6_Image_pixels, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Image = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Image = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Image = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Image = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Image = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Image", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Image), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Image, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_6_Image___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Image, /*tp_as_number*/
  &__pyx_tp_as_sequence__Image, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Image, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Image, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Image object, used in particular for texture.", /*tp_doc*/
  __pyx_tp_traverse_5_soya__Image, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Image, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Image, /*tp_methods*/
  __pyx_members_5_soya__Image, /*tp_members*/
  __pyx_getsets_5_soya__Image, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_6_Image___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Image, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Material __pyx_vtable_5_soya__Material;

static PyObject *__pyx_tp_new_5_soya__Material(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Material *p = (struct __pyx_obj_5_soya__Material *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Material *)__pyx_vtabptr_5_soya__Material;
  p->_texture = Py_None; Py_INCREF((PyObject *) p->_texture);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Material(PyObject *o) {
  struct __pyx_obj_5_soya__Material *p = (struct __pyx_obj_5_soya__Material *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_9_Material___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_texture);
  Py_XDECREF(p->_filename);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Material(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Material *p = (struct __pyx_obj_5_soya__Material *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  if (p->_texture) {
    e = (*v)(((PyObject*)p->_texture), a); if (e) return e;
  }
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Material(PyObject *o) {
  struct __pyx_obj_5_soya__Material *p = (struct __pyx_obj_5_soya__Material *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  Py_XDECREF((PyObject *)p->_texture);
  p->_texture = Py_None; Py_INCREF((PyObject *) p->_texture);
  Py_XDECREF(p->_filename);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_9_Material_separate_specular(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_17separate_specular___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_separate_specular(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_17separate_specular___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_clamp(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_5clamp___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_clamp(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_5clamp___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_environment_mapping(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_19environment_mapping___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_environment_mapping(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_19environment_mapping___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_mip_map(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_7mip_map___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_mip_map(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_7mip_map___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_additive_blending(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_17additive_blending___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_additive_blending(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_17additive_blending___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_texture(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_7texture___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_texture(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_7texture___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_image(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_5image___get__(o);
}

static PyObject *__pyx_getprop_5_soya_9_Material_diffuse(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_7diffuse___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_diffuse(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_7diffuse___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_specular(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_8specular___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_specular(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_8specular___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_emissive(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_8emissive___get__(o);
}

static int __pyx_setprop_5_soya_9_Material_emissive(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9_Material_8emissive___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9_Material_opengl_id(PyObject *o, void *x) {
  return __pyx_f_5_soya_9_Material_9opengl_id___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Material[] = {
  {"activate", (PyCFunction)__pyx_f_5_soya_9_Material_activate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9_Material_activate},
  {"inactivate", (PyCFunction)__pyx_f_5_soya_9_Material_inactivate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9_Material_inactivate},
  {"is_alpha", (PyCFunction)__pyx_f_5_soya_9_Material_is_alpha, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9_Material_is_alpha},
  {"has_mask", (PyCFunction)__pyx_f_5_soya_9_Material_has_mask, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9_Material_has_mask},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__Material[] = {
  {"_id", T_UINT, offsetof(struct __pyx_obj_5_soya__Material, _id), READONLY, 0},
  {"shininess", T_FLOAT, offsetof(struct __pyx_obj_5_soya__Material, shininess), 0, 0},
  {"_filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya__Material, _filename), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Material[] = {
  {"separate_specular", __pyx_getprop_5_soya_9_Material_separate_specular, __pyx_setprop_5_soya_9_Material_separate_specular, 0, 0},
  {"clamp", __pyx_getprop_5_soya_9_Material_clamp, __pyx_setprop_5_soya_9_Material_clamp, 0, 0},
  {"environment_mapping", __pyx_getprop_5_soya_9_Material_environment_mapping, __pyx_setprop_5_soya_9_Material_environment_mapping, 0, 0},
  {"mip_map", __pyx_getprop_5_soya_9_Material_mip_map, __pyx_setprop_5_soya_9_Material_mip_map, 0, 0},
  {"additive_blending", __pyx_getprop_5_soya_9_Material_additive_blending, __pyx_setprop_5_soya_9_Material_additive_blending, 0, 0},
  {"texture", __pyx_getprop_5_soya_9_Material_texture, __pyx_setprop_5_soya_9_Material_texture, 0, 0},
  {"image", __pyx_getprop_5_soya_9_Material_image, 0, 0, 0},
  {"diffuse", __pyx_getprop_5_soya_9_Material_diffuse, __pyx_setprop_5_soya_9_Material_diffuse, 0, 0},
  {"specular", __pyx_getprop_5_soya_9_Material_specular, __pyx_setprop_5_soya_9_Material_specular, 0, 0},
  {"emissive", __pyx_getprop_5_soya_9_Material_emissive, __pyx_setprop_5_soya_9_Material_emissive, 0, 0},
  {"opengl_id", __pyx_getprop_5_soya_9_Material_opengl_id, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Material = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Material = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Material = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Material = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Material = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Material", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Material), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Material, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_9_Material___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Material, /*tp_as_number*/
  &__pyx_tp_as_sequence__Material, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Material, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Material, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Material, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Material, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Material, /*tp_methods*/
  __pyx_members_5_soya__Material, /*tp_members*/
  __pyx_getsets_5_soya__Material, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_9_Material___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Material, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Shape __pyx_vtable_5_soya__Shape;

static PyObject *__pyx_tp_new_5_soya__Shape(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Shape *p = (struct __pyx_obj_5_soya__Shape *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Shape *)__pyx_vtabptr_5_soya__Shape;
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Shape(PyObject *o) {
  struct __pyx_obj_5_soya__Shape *p = (struct __pyx_obj_5_soya__Shape *)o;
  Py_XDECREF(p->_filename);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Shape(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Shape *p = (struct __pyx_obj_5_soya__Shape *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Shape(PyObject *o) {
  struct __pyx_obj_5_soya__Shape *p = (struct __pyx_obj_5_soya__Shape *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  Py_XDECREF(p->_filename);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__Shape[] = {
  {"__deepcopy__", (PyCFunction)__pyx_f_5_soya_6_Shape___deepcopy__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Shape___deepcopy__},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__Shape[] = {
  {"_filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya__Shape, _filename), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Shape = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Shape = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Shape = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Shape = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Shape = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Shape", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Shape), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Shape, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_6_Shape___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Shape, /*tp_as_number*/
  &__pyx_tp_as_sequence__Shape, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Shape, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Shape, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Shape, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Shape, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Shape, /*tp_methods*/
  __pyx_members_5_soya__Shape, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Shape, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__SimpleShape __pyx_vtable_5_soya__SimpleShape;

static PyObject *__pyx_tp_new_5_soya__SimpleShape(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Shape->tp_new(t, a, k);
  struct __pyx_obj_5_soya__SimpleShape *p = (struct __pyx_obj_5_soya__SimpleShape *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__SimpleShape *)__pyx_vtabptr_5_soya__SimpleShape;
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return o;
}

static void __pyx_tp_dealloc_5_soya__SimpleShape(PyObject *o) {
  struct __pyx_obj_5_soya__SimpleShape *p = (struct __pyx_obj_5_soya__SimpleShape *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_12_SimpleShape___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_materials);
  __pyx_ptype_5_soya__Shape->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__SimpleShape(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__SimpleShape *p = (struct __pyx_obj_5_soya__SimpleShape *)o;
  __pyx_ptype_5_soya__Shape->tp_traverse(o, v, a);
  if (p->_materials) {
    e = (*v)(p->_materials, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__SimpleShape(PyObject *o) {
  struct __pyx_obj_5_soya__SimpleShape *p = (struct __pyx_obj_5_soya__SimpleShape *)o;
  __pyx_ptype_5_soya__Shape->tp_clear(o);
  Py_XDECREF(p->_materials);
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_12_SimpleShape_option(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleShape_6option___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleShape_materials(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleShape_9materials___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleShape_nb_coords(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleShape_9nb_coords___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleShape_nb_vertices(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleShape_11nb_vertices___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleShape_nb_faces(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleShape_8nb_faces___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleShape_sphere(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleShape_6sphere___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__SimpleShape[] = {
  {"get_face", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_face, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_SimpleShape_get_face},
  {"get_vertex_index", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_vertex_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_SimpleShape_get_vertex_index},
  {"get_vertex", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_vertex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_SimpleShape_get_vertex},
  {"get_neighbor", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_neighbor, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_neighbor_side", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_neighbor_side, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_simple_neighbor", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_simple_neighbor, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_simple_neighbor_side", (PyCFunction)__pyx_f_5_soya_12_SimpleShape_get_simple_neighbor_side, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__SimpleShape[] = {
  {"option", __pyx_getprop_5_soya_12_SimpleShape_option, 0, 0, 0},
  {"materials", __pyx_getprop_5_soya_12_SimpleShape_materials, 0, 0, 0},
  {"nb_coords", __pyx_getprop_5_soya_12_SimpleShape_nb_coords, 0, 0, 0},
  {"nb_vertices", __pyx_getprop_5_soya_12_SimpleShape_nb_vertices, 0, 0, 0},
  {"nb_faces", __pyx_getprop_5_soya_12_SimpleShape_nb_faces, 0, 0, 0},
  {"sphere", __pyx_getprop_5_soya_12_SimpleShape_sphere, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SimpleShape = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__SimpleShape = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__SimpleShape = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SimpleShape = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__SimpleShape = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._SimpleShape", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__SimpleShape), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__SimpleShape, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SimpleShape, /*tp_as_number*/
  &__pyx_tp_as_sequence__SimpleShape, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SimpleShape, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SimpleShape, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__SimpleShape, /*tp_traverse*/
  __pyx_tp_clear_5_soya__SimpleShape, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__SimpleShape, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__SimpleShape, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_12_SimpleShape___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__SimpleShape, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__CellShadingShape __pyx_vtable_5_soya__CellShadingShape;

static PyObject *__pyx_tp_new_5_soya__CellShadingShape(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__SimpleShape->tp_new(t, a, k);
  struct __pyx_obj_5_soya__CellShadingShape *p = (struct __pyx_obj_5_soya__CellShadingShape *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__CellShadingShape *)__pyx_vtabptr_5_soya__CellShadingShape;
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  return o;
}

static void __pyx_tp_dealloc_5_soya__CellShadingShape(PyObject *o) {
  struct __pyx_obj_5_soya__CellShadingShape *p = (struct __pyx_obj_5_soya__CellShadingShape *)o;
  Py_XDECREF((PyObject *)p->_shader);
  __pyx_ptype_5_soya__SimpleShape->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__CellShadingShape(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__CellShadingShape *p = (struct __pyx_obj_5_soya__CellShadingShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_traverse(o, v, a);
  if (p->_shader) {
    e = (*v)(((PyObject*)p->_shader), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__CellShadingShape(PyObject *o) {
  struct __pyx_obj_5_soya__CellShadingShape *p = (struct __pyx_obj_5_soya__CellShadingShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_clear(o);
  Py_XDECREF((PyObject *)p->_shader);
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__CellShadingShape[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__CellShadingShape = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__CellShadingShape = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__CellShadingShape = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__CellShadingShape = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__CellShadingShape = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._CellShadingShape", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__CellShadingShape), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__CellShadingShape, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__CellShadingShape, /*tp_as_number*/
  &__pyx_tp_as_sequence__CellShadingShape, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__CellShadingShape, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__CellShadingShape, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__CellShadingShape, /*tp_traverse*/
  __pyx_tp_clear_5_soya__CellShadingShape, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__CellShadingShape, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__CellShadingShape, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__TreeShape __pyx_vtable_5_soya__TreeShape;

static PyObject *__pyx_tp_new_5_soya__TreeShape(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__SimpleShape->tp_new(t, a, k);
  struct __pyx_obj_5_soya__TreeShape *p = (struct __pyx_obj_5_soya__TreeShape *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__TreeShape *)__pyx_vtabptr_5_soya__TreeShape;
  return o;
}

static void __pyx_tp_dealloc_5_soya__TreeShape(PyObject *o) {
  struct __pyx_obj_5_soya__TreeShape *p = (struct __pyx_obj_5_soya__TreeShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__TreeShape(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__TreeShape *p = (struct __pyx_obj_5_soya__TreeShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__TreeShape(PyObject *o) {
  struct __pyx_obj_5_soya__TreeShape *p = (struct __pyx_obj_5_soya__TreeShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__TreeShape[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__TreeShape = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__TreeShape = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__TreeShape = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__TreeShape = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__TreeShape = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._TreeShape", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__TreeShape), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__TreeShape, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__TreeShape, /*tp_as_number*/
  &__pyx_tp_as_sequence__TreeShape, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__TreeShape, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__TreeShape, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__TreeShape, /*tp_traverse*/
  __pyx_tp_clear_5_soya__TreeShape, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__TreeShape, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__TreeShape, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Position __pyx_vtable_5_soya_Position;

static PyObject *__pyx_tp_new_5_soya_Position(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya_Position *p = (struct __pyx_obj_5_soya_Position *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Position *)__pyx_vtabptr_5_soya_Position;
  p->_parent = Py_None; Py_INCREF((PyObject *) p->_parent);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Position(PyObject *o) {
  struct __pyx_obj_5_soya_Position *p = (struct __pyx_obj_5_soya_Position *)o;
  Py_XDECREF((PyObject *)p->_parent);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_Position(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Position *p = (struct __pyx_obj_5_soya_Position *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  if (p->_parent) {
    e = (*v)(((PyObject*)p->_parent), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Position(PyObject *o) {
  struct __pyx_obj_5_soya_Position *p = (struct __pyx_obj_5_soya_Position *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  Py_XDECREF((PyObject *)p->_parent);
  p->_parent = Py_None; Py_INCREF((PyObject *) p->_parent);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Position[] = {
  {"position", (PyCFunction)__pyx_f_5_soya_8Position_position, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8Position_position},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Position = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  __pyx_f_5_soya_8Position___mod__, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Position = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Position = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Position = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Position = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Position", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Position), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Position, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Position, /*tp_as_number*/
  &__pyx_tp_as_sequence_Position, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Position, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Position, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A 3D position.\n\nIn Soya 3D, a position is defined by 3 coordinates (x, y, z) AND the\ncoordinates system in which the coordinates are defined (sometime\ncalled the \"parent\").\n\nPoints and Vectors are used for math computation; my own experiences in 3D\nhave convinced me that ANY complicated 3D computation can be heavily\nsimplified by the use of coordinates system conversions. As Soya 3D\nassociates the coordinates system along with the coordinates values, it\nperforms coordinates system conversion automagically !", /*tp_doc*/
  __pyx_tp_traverse_5_soya_Position, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Position, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Position, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_8Position___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Position, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Point __pyx_vtable_5_soya__Point;

static PyObject *__pyx_tp_new_5_soya__Point(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_Position->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Point *p = (struct __pyx_obj_5_soya__Point *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Point *)__pyx_vtabptr_5_soya__Point;
  return o;
}

static void __pyx_tp_dealloc_5_soya__Point(PyObject *o) {
  struct __pyx_obj_5_soya__Point *p = (struct __pyx_obj_5_soya__Point *)o;
  __pyx_ptype_5_soya_Position->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Point(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Point *p = (struct __pyx_obj_5_soya__Point *)o;
  __pyx_ptype_5_soya_Position->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__Point(PyObject *o) {
  struct __pyx_obj_5_soya__Point *p = (struct __pyx_obj_5_soya__Point *)o;
  __pyx_ptype_5_soya_Position->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_6_Point_parent(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Point_6parent___get__(o);
}

static int __pyx_setprop_5_soya_6_Point_parent(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Point_6parent___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Point_x(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Point_1x___get__(o);
}

static int __pyx_setprop_5_soya_6_Point_x(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Point_1x___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Point_y(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Point_1y___get__(o);
}

static int __pyx_setprop_5_soya_6_Point_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Point_1y___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Point_z(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Point_1z___get__(o);
}

static int __pyx_setprop_5_soya_6_Point_z(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Point_1z___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Point[] = {
  {"__deepcopy__", (PyCFunction)__pyx_f_5_soya_6_Point___deepcopy__, METH_VARARGS|METH_KEYWORDS, 0},
  {"position", (PyCFunction)__pyx_f_5_soya_6_Point_position, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_position},
  {"set_parent", (PyCFunction)__pyx_f_5_soya_6_Point_set_parent, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_root", (PyCFunction)__pyx_f_5_soya_6_Point_get_root, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_get_root},
  {"set_xyz", (PyCFunction)__pyx_f_5_soya_6_Point_set_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_set_xyz},
  {"move", (PyCFunction)__pyx_f_5_soya_6_Point_move, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_move},
  {"add_xyz", (PyCFunction)__pyx_f_5_soya_6_Point_add_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_add_xyz},
  {"add_vector", (PyCFunction)__pyx_f_5_soya_6_Point_add_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_add_vector},
  {"add_mul_vector", (PyCFunction)__pyx_f_5_soya_6_Point_add_mul_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_add_mul_vector},
  {"distance_to", (PyCFunction)__pyx_f_5_soya_6_Point_distance_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_distance_to},
  {"vector_to", (PyCFunction)__pyx_f_5_soya_6_Point_vector_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_vector_to},
  {"convert_to", (PyCFunction)__pyx_f_5_soya_6_Point_convert_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_convert_to},
  {"copy", (PyCFunction)__pyx_f_5_soya_6_Point_copy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_copy},
  {"clone", (PyCFunction)__pyx_f_5_soya_6_Point_clone, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Point_clone},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Point[] = {
  {"parent", __pyx_getprop_5_soya_6_Point_parent, __pyx_setprop_5_soya_6_Point_parent, 0, 0},
  {"x", __pyx_getprop_5_soya_6_Point_x, __pyx_setprop_5_soya_6_Point_x, 0, 0},
  {"y", __pyx_getprop_5_soya_6_Point_y, __pyx_setprop_5_soya_6_Point_y, 0, 0},
  {"z", __pyx_getprop_5_soya_6_Point_z, __pyx_setprop_5_soya_6_Point_z, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Point = {
  __pyx_f_5_soya_6_Point___add__, /*nb_add*/
  __pyx_f_5_soya_6_Point___sub__, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  __pyx_f_5_soya_6_Point___rshift__, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  __pyx_f_5_soya_6_Point___iadd__, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  __pyx_f_5_soya_6_Point___imod__, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Point = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Point = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Point = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Point = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Point", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Point), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Point, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_6_Point___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Point, /*tp_as_number*/
  &__pyx_tp_as_sequence__Point, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Point, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Point, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Point, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Point, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Point, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Point, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_6_Point___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Point, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Vector __pyx_vtable_5_soya__Vector;

static PyObject *__pyx_tp_new_5_soya__Vector(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Point->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Vector *p = (struct __pyx_obj_5_soya__Vector *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Vector *)__pyx_vtabptr_5_soya__Vector;
  return o;
}

static void __pyx_tp_dealloc_5_soya__Vector(PyObject *o) {
  struct __pyx_obj_5_soya__Vector *p = (struct __pyx_obj_5_soya__Vector *)o;
  __pyx_ptype_5_soya__Point->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Vector(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Vector *p = (struct __pyx_obj_5_soya__Vector *)o;
  __pyx_ptype_5_soya__Point->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__Vector(PyObject *o) {
  struct __pyx_obj_5_soya__Vector *p = (struct __pyx_obj_5_soya__Vector *)o;
  __pyx_ptype_5_soya__Point->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__Vector[] = {
  {"copy", (PyCFunction)__pyx_f_5_soya_7_Vector_copy, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_copy},
  {"cross_product", (PyCFunction)__pyx_f_5_soya_7_Vector_cross_product, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_cross_product},
  {"dot_product", (PyCFunction)__pyx_f_5_soya_7_Vector_dot_product, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_dot_product},
  {"length", (PyCFunction)__pyx_f_5_soya_7_Vector_length, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_length},
  {"set_length", (PyCFunction)__pyx_f_5_soya_7_Vector_set_length, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_set_length},
  {"normalize", (PyCFunction)__pyx_f_5_soya_7_Vector_normalize, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_normalize},
  {"set_start_end", (PyCFunction)__pyx_f_5_soya_7_Vector_set_start_end, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_set_start_end},
  {"angle_to", (PyCFunction)__pyx_f_5_soya_7_Vector_angle_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Vector_angle_to},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Vector = {
  __pyx_f_5_soya_7_Vector___add__, /*nb_add*/
  0, /*nb_subtract*/
  __pyx_f_5_soya_7_Vector___mul__, /*nb_multiply*/
  __pyx_f_5_soya_7_Vector___div__, /*nb_divide*/
  __pyx_f_5_soya_7_Vector___mod__, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  __pyx_f_5_soya_7_Vector___neg__, /*nb_negative*/
  0, /*nb_positive*/
  __pyx_f_5_soya_7_Vector___abs__, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  __pyx_f_5_soya_7_Vector___imul__, /*nb_inplace_multiply*/
  __pyx_f_5_soya_7_Vector___idiv__, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  __pyx_f_5_soya_7_Vector___truediv__, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Vector = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Vector = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Vector = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Vector = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Vector", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Vector), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Vector, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Vector, /*tp_as_number*/
  &__pyx_tp_as_sequence__Vector, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Vector, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Vector, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Vector, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Vector, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Vector, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Vector, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Vertex __pyx_vtable_5_soya__Vertex;

static PyObject *__pyx_tp_new_5_soya__Vertex(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Point->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Vertex *p = (struct __pyx_obj_5_soya__Vertex *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Vertex *)__pyx_vtabptr_5_soya__Vertex;
  p->_diffuse = Py_None; Py_INCREF(p->_diffuse);
  p->_emissive = Py_None; Py_INCREF(p->_emissive);
  p->_face = Py_None; Py_INCREF((PyObject *) p->_face);
  p->_normal = Py_None; Py_INCREF((PyObject *) p->_normal);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Vertex(PyObject *o) {
  struct __pyx_obj_5_soya__Vertex *p = (struct __pyx_obj_5_soya__Vertex *)o;
  Py_XDECREF(p->_diffuse);
  Py_XDECREF(p->_emissive);
  Py_XDECREF((PyObject *)p->_face);
  Py_XDECREF((PyObject *)p->_normal);
  __pyx_ptype_5_soya__Point->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Vertex(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Vertex *p = (struct __pyx_obj_5_soya__Vertex *)o;
  __pyx_ptype_5_soya__Point->tp_traverse(o, v, a);
  if (p->_diffuse) {
    e = (*v)(p->_diffuse, a); if (e) return e;
  }
  if (p->_emissive) {
    e = (*v)(p->_emissive, a); if (e) return e;
  }
  if (p->_face) {
    e = (*v)(((PyObject*)p->_face), a); if (e) return e;
  }
  if (p->_normal) {
    e = (*v)(((PyObject*)p->_normal), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Vertex(PyObject *o) {
  struct __pyx_obj_5_soya__Vertex *p = (struct __pyx_obj_5_soya__Vertex *)o;
  __pyx_ptype_5_soya__Point->tp_clear(o);
  Py_XDECREF(p->_diffuse);
  p->_diffuse = Py_None; Py_INCREF(p->_diffuse);
  Py_XDECREF(p->_emissive);
  p->_emissive = Py_None; Py_INCREF(p->_emissive);
  Py_XDECREF((PyObject *)p->_face);
  p->_face = Py_None; Py_INCREF((PyObject *) p->_face);
  Py_XDECREF((PyObject *)p->_normal);
  p->_normal = Py_None; Py_INCREF((PyObject *) p->_normal);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_7_Vertex_tex_x(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Vertex_5tex_x___get__(o);
}

static int __pyx_setprop_5_soya_7_Vertex_tex_x(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Vertex_5tex_x___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Vertex_tex_y(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Vertex_5tex_y___get__(o);
}

static int __pyx_setprop_5_soya_7_Vertex_tex_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Vertex_5tex_y___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Vertex_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Vertex_5color___get__(o);
}

static int __pyx_setprop_5_soya_7_Vertex_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Vertex_5color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Vertex_diffuse(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Vertex_7diffuse___get__(o);
}

static int __pyx_setprop_5_soya_7_Vertex_diffuse(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Vertex_7diffuse___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Vertex_emissive(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Vertex_8emissive___get__(o);
}

static int __pyx_setprop_5_soya_7_Vertex_emissive(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Vertex_8emissive___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Vertex_face(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Vertex_4face___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Vertex[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Vertex[] = {
  {"tex_x", __pyx_getprop_5_soya_7_Vertex_tex_x, __pyx_setprop_5_soya_7_Vertex_tex_x, 0, 0},
  {"tex_y", __pyx_getprop_5_soya_7_Vertex_tex_y, __pyx_setprop_5_soya_7_Vertex_tex_y, 0, 0},
  {"color", __pyx_getprop_5_soya_7_Vertex_color, __pyx_setprop_5_soya_7_Vertex_color, 0, 0},
  {"diffuse", __pyx_getprop_5_soya_7_Vertex_diffuse, __pyx_setprop_5_soya_7_Vertex_diffuse, 0, 0},
  {"emissive", __pyx_getprop_5_soya_7_Vertex_emissive, __pyx_setprop_5_soya_7_Vertex_emissive, 0, 0},
  {"face", __pyx_getprop_5_soya_7_Vertex_face, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Vertex = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Vertex = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Vertex = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Vertex = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Vertex = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Vertex", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Vertex), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Vertex, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Vertex, /*tp_as_number*/
  &__pyx_tp_as_sequence__Vertex, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Vertex, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Vertex, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Vertex, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Vertex, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Vertex, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Vertex, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7_Vertex___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Vertex, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_vtable_5_soya_CoordSyst;

static PyObject *__pyx_tp_new_5_soya_CoordSyst(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_Position->tp_new(t, a, k);
  struct __pyx_obj_5_soya_CoordSyst *p = (struct __pyx_obj_5_soya_CoordSyst *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_vtabptr_5_soya_CoordSyst;
  if (__pyx_f_5_soya_9CoordSyst___new__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5_soya_CoordSyst(PyObject *o) {
  struct __pyx_obj_5_soya_CoordSyst *p = (struct __pyx_obj_5_soya_CoordSyst *)o;
  __pyx_ptype_5_soya_Position->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_CoordSyst(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_CoordSyst *p = (struct __pyx_obj_5_soya_CoordSyst *)o;
  __pyx_ptype_5_soya_Position->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_CoordSyst(PyObject *o) {
  struct __pyx_obj_5_soya_CoordSyst *p = (struct __pyx_obj_5_soya_CoordSyst *)o;
  __pyx_ptype_5_soya_Position->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_parent(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_6parent___get__(o);
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_visible(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_7visible___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_visible(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_7visible___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_solid(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_5solid___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_solid(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_5solid___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_x(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_1x___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_x(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_1x___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_y(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_1y___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_1y___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_z(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_1z___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_z(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_1z___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_matrix(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_6matrix___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_matrix(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_6matrix___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_root_matrix(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_11root_matrix___get__(o);
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_inverted_root_matrix(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_20inverted_root_matrix___get__(o);
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_lefthanded(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_10lefthanded___get__(o);
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_scale_x(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_7scale_x___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_scale_x(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_7scale_x___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_scale_y(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_7scale_y___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_scale_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_7scale_y___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_scale_z(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_7scale_z___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_scale_z(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_7scale_z___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_CoordSyst[] = {
  {"added_into", (PyCFunction)__pyx_f_5_soya_9CoordSyst_added_into, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_added_into},
  {"get_sphere", (PyCFunction)__pyx_f_5_soya_9CoordSyst_get_sphere, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_get_sphere},
  {"get_box", (PyCFunction)__pyx_f_5_soya_9CoordSyst_get_box, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_get_box},
  {"get_dimension", (PyCFunction)__pyx_f_5_soya_9CoordSyst_get_dimension, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_get_dimension},
  {"set_dimension", (PyCFunction)__pyx_f_5_soya_9CoordSyst_set_dimension, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_set_dimension},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_9CoordSyst_begin_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_begin_round},
  {"end_round", (PyCFunction)__pyx_f_5_soya_9CoordSyst_end_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_end_round},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_9CoordSyst_advance_time, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_advance_time},
  {"set_scale_factors", (PyCFunction)__pyx_f_5_soya_9CoordSyst_set_scale_factors, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_set_scale_factors},
  {"get_root", (PyCFunction)__pyx_f_5_soya_9CoordSyst_get_root, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_get_root},
  {"is_inside", (PyCFunction)__pyx_f_5_soya_9CoordSyst_is_inside, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_is_inside},
  {"set_xyz", (PyCFunction)__pyx_f_5_soya_9CoordSyst_set_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_set_xyz},
  {"move", (PyCFunction)__pyx_f_5_soya_9CoordSyst_move, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_move},
  {"add_xyz", (PyCFunction)__pyx_f_5_soya_9CoordSyst_add_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_add_xyz},
  {"shift", (PyCFunction)__pyx_f_5_soya_9CoordSyst_shift, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_shift},
  {"add_vector", (PyCFunction)__pyx_f_5_soya_9CoordSyst_add_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_add_vector},
  {"add_mul_vector", (PyCFunction)__pyx_f_5_soya_9CoordSyst_add_mul_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_add_mul_vector},
  {"scale", (PyCFunction)__pyx_f_5_soya_9CoordSyst_scale, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_scale},
  {"set_identity", (PyCFunction)__pyx_f_5_soya_9CoordSyst_set_identity, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_set_identity},
  {"position", (PyCFunction)__pyx_f_5_soya_9CoordSyst_position, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_position},
  {"distance_to", (PyCFunction)__pyx_f_5_soya_9CoordSyst_distance_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_distance_to},
  {"vector_to", (PyCFunction)__pyx_f_5_soya_9CoordSyst_vector_to, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_vector_to},
  {"look_at", (PyCFunction)__pyx_f_5_soya_9CoordSyst_look_at, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_look_at},
  {"look_at_y", (PyCFunction)__pyx_f_5_soya_9CoordSyst_look_at_y, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_look_at_y},
  {"look_at_x", (PyCFunction)__pyx_f_5_soya_9CoordSyst_look_at_x, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_look_at_x},
  {"turn_lateral", (PyCFunction)__pyx_f_5_soya_9CoordSyst_turn_lateral, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_turn_lateral},
  {"turn_vertical", (PyCFunction)__pyx_f_5_soya_9CoordSyst_turn_vertical, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_turn_vertical},
  {"turn_incline", (PyCFunction)__pyx_f_5_soya_9CoordSyst_turn_incline, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_turn_incline},
  {"rotate_lateral", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_lateral, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_lateral},
  {"rotate_vertical", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_vertical, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_vertical},
  {"rotate_incline", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_incline, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_incline},
  {"rotate_axe", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_axe, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_axe},
  {"rotate_axe_xyz", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_axe_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_axe_xyz},
  {"rotate", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate},
  {"rotate_xyz", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_xyz},
  {"transform", (PyCFunction)__pyx_f_5_soya_9CoordSyst_transform, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_transform},
  {"transform_point", (PyCFunction)__pyx_f_5_soya_9CoordSyst_transform_point, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_transform_point},
  {"transform_vector", (PyCFunction)__pyx_f_5_soya_9CoordSyst_transform_vector, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_transform_vector},
  {"interpolate", (PyCFunction)__pyx_f_5_soya_9CoordSyst_interpolate, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_interpolate},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_CoordSyst[] = {
  {"parent", __pyx_getprop_5_soya_9CoordSyst_parent, 0, 0, 0},
  {"visible", __pyx_getprop_5_soya_9CoordSyst_visible, __pyx_setprop_5_soya_9CoordSyst_visible, 0, 0},
  {"solid", __pyx_getprop_5_soya_9CoordSyst_solid, __pyx_setprop_5_soya_9CoordSyst_solid, 0, 0},
  {"x", __pyx_getprop_5_soya_9CoordSyst_x, __pyx_setprop_5_soya_9CoordSyst_x, 0, 0},
  {"y", __pyx_getprop_5_soya_9CoordSyst_y, __pyx_setprop_5_soya_9CoordSyst_y, 0, 0},
  {"z", __pyx_getprop_5_soya_9CoordSyst_z, __pyx_setprop_5_soya_9CoordSyst_z, 0, 0},
  {"matrix", __pyx_getprop_5_soya_9CoordSyst_matrix, __pyx_setprop_5_soya_9CoordSyst_matrix, 0, 0},
  {"root_matrix", __pyx_getprop_5_soya_9CoordSyst_root_matrix, 0, 0, 0},
  {"inverted_root_matrix", __pyx_getprop_5_soya_9CoordSyst_inverted_root_matrix, 0, 0, 0},
  {"lefthanded", __pyx_getprop_5_soya_9CoordSyst_lefthanded, 0, 0, 0},
  {"scale_x", __pyx_getprop_5_soya_9CoordSyst_scale_x, __pyx_setprop_5_soya_9CoordSyst_scale_x, 0, 0},
  {"scale_y", __pyx_getprop_5_soya_9CoordSyst_scale_y, __pyx_setprop_5_soya_9CoordSyst_scale_y, 0, 0},
  {"scale_z", __pyx_getprop_5_soya_9CoordSyst_scale_z, __pyx_setprop_5_soya_9CoordSyst_scale_z, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CoordSyst = {
  __pyx_f_5_soya_9CoordSyst___add__, /*nb_add*/
  __pyx_f_5_soya_9CoordSyst___sub__, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  __pyx_f_5_soya_9CoordSyst___rshift__, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  __pyx_f_5_soya_9CoordSyst___iadd__, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_CoordSyst = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CoordSyst = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CoordSyst = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_CoordSyst = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.CoordSyst", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_CoordSyst), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_CoordSyst, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_9CoordSyst___repr__, /*tp_repr*/
  &__pyx_tp_as_number_CoordSyst, /*tp_as_number*/
  &__pyx_tp_as_sequence_CoordSyst, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CoordSyst, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CoordSyst, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_CoordSyst, /*tp_traverse*/
  __pyx_tp_clear_5_soya_CoordSyst, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_CoordSyst, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_CoordSyst, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_9CoordSyst___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_CoordSyst, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Camera __pyx_vtable_5_soya__Camera;

static PyObject *__pyx_tp_new_5_soya__Camera(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Camera *p = (struct __pyx_obj_5_soya__Camera *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Camera *)__pyx_vtabptr_5_soya__Camera;
  p->_to_render = Py_None; Py_INCREF((PyObject *) p->_to_render);
  p->_master = Py_None; Py_INCREF(p->_master);
  if (__pyx_f_5_soya_7_Camera___new__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5_soya__Camera(PyObject *o) {
  struct __pyx_obj_5_soya__Camera *p = (struct __pyx_obj_5_soya__Camera *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_7_Camera___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_to_render);
  Py_XDECREF(p->_master);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Camera(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Camera *p = (struct __pyx_obj_5_soya__Camera *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_to_render) {
    e = (*v)(((PyObject*)p->_to_render), a); if (e) return e;
  }
  if (p->_master) {
    e = (*v)(p->_master, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Camera(PyObject *o) {
  struct __pyx_obj_5_soya__Camera *p = (struct __pyx_obj_5_soya__Camera *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_to_render);
  p->_to_render = Py_None; Py_INCREF((PyObject *) p->_to_render);
  Py_XDECREF(p->_master);
  p->_master = Py_None; Py_INCREF(p->_master);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_7_Camera_master(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_6master___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_master(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_6master___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_to_render(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_9to_render___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_to_render(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_9to_render___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_front(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_5front___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_front(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_5front___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_back(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_4back___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_back(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_4back___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_fov(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_3fov___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_fov(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_3fov___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_left(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_4left___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_left(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_4left___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_top(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_3top___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_top(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_3top___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_5width___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_width(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_5width___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_height(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_6height___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_height(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_6height___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_partial(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_7partial___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_partial(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_7partial___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Camera_ortho(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_5ortho___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_ortho(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_5ortho___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Camera[] = {
  {"set_viewport", (PyCFunction)__pyx_f_5_soya_7_Camera_set_viewport, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Camera_set_viewport},
  {"resize", (PyCFunction)__pyx_f_5_soya_7_Camera_resize, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_screen_width", (PyCFunction)__pyx_f_5_soya_7_Camera_get_screen_width, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Camera_get_screen_width},
  {"get_screen_height", (PyCFunction)__pyx_f_5_soya_7_Camera_get_screen_height, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Camera_get_screen_height},
  {"render", (PyCFunction)__pyx_f_5_soya_7_Camera_render, METH_VARARGS|METH_KEYWORDS, 0},
  {"render_to_material", (PyCFunction)__pyx_f_5_soya_7_Camera_render_to_material, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Camera_render_to_material},
  {"coord2d_to_3d", (PyCFunction)__pyx_f_5_soya_7_Camera_coord2d_to_3d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Camera_coord2d_to_3d},
  {"coord3d_to_2d", (PyCFunction)__pyx_f_5_soya_7_Camera_coord3d_to_2d, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Camera_coord3d_to_2d},
  {"widget_begin_round", (PyCFunction)__pyx_f_5_soya_7_Camera_widget_begin_round, METH_VARARGS|METH_KEYWORDS, 0},
  {"widget_advance_time", (PyCFunction)__pyx_f_5_soya_7_Camera_widget_advance_time, METH_VARARGS|METH_KEYWORDS, 0},
  {"widget_end_round", (PyCFunction)__pyx_f_5_soya_7_Camera_widget_end_round, METH_VARARGS|METH_KEYWORDS, 0},
  {"is_in_frustum", (PyCFunction)__pyx_f_5_soya_7_Camera_is_in_frustum, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Camera[] = {
  {"master", __pyx_getprop_5_soya_7_Camera_master, __pyx_setprop_5_soya_7_Camera_master, 0, 0},
  {"to_render", __pyx_getprop_5_soya_7_Camera_to_render, __pyx_setprop_5_soya_7_Camera_to_render, 0, 0},
  {"front", __pyx_getprop_5_soya_7_Camera_front, __pyx_setprop_5_soya_7_Camera_front, 0, 0},
  {"back", __pyx_getprop_5_soya_7_Camera_back, __pyx_setprop_5_soya_7_Camera_back, 0, 0},
  {"fov", __pyx_getprop_5_soya_7_Camera_fov, __pyx_setprop_5_soya_7_Camera_fov, 0, 0},
  {"left", __pyx_getprop_5_soya_7_Camera_left, __pyx_setprop_5_soya_7_Camera_left, 0, 0},
  {"top", __pyx_getprop_5_soya_7_Camera_top, __pyx_setprop_5_soya_7_Camera_top, 0, 0},
  {"width", __pyx_getprop_5_soya_7_Camera_width, __pyx_setprop_5_soya_7_Camera_width, 0, 0},
  {"height", __pyx_getprop_5_soya_7_Camera_height, __pyx_setprop_5_soya_7_Camera_height, 0, 0},
  {"partial", __pyx_getprop_5_soya_7_Camera_partial, __pyx_setprop_5_soya_7_Camera_partial, 0, 0},
  {"ortho", __pyx_getprop_5_soya_7_Camera_ortho, __pyx_setprop_5_soya_7_Camera_ortho, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Camera = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Camera = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Camera = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Camera = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Camera = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Camera", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Camera), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Camera, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Camera, /*tp_as_number*/
  &__pyx_tp_as_sequence__Camera, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Camera, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Camera, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Camera, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Camera, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Camera, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Camera, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7_Camera___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Camera, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Light __pyx_vtable_5_soya__Light;

static PyObject *__pyx_tp_new_5_soya__Light(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Light *p = (struct __pyx_obj_5_soya__Light *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Light *)__pyx_vtabptr_5_soya__Light;
  if (__pyx_f_5_soya_6_Light___new__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5_soya__Light(PyObject *o) {
  struct __pyx_obj_5_soya__Light *p = (struct __pyx_obj_5_soya__Light *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Light(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Light *p = (struct __pyx_obj_5_soya__Light *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__Light(PyObject *o) {
  struct __pyx_obj_5_soya__Light *p = (struct __pyx_obj_5_soya__Light *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_6_Light_directional(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_11directional___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_directional(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_11directional___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_constant(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_8constant___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_constant(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_8constant___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_linear(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_6linear___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_linear(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_6linear___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_quadratic(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_9quadratic___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_quadratic(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_9quadratic___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_cast_shadow(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_11cast_shadow___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_cast_shadow(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_11cast_shadow___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_top_level(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_9top_level___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_top_level(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_9top_level___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_static(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_6static___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_static(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_6static___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_ambient(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_7ambient___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_ambient(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_7ambient___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_diffuse(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_7diffuse___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_diffuse(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_7diffuse___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_specular(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_8specular___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_specular(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_8specular___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_shadow_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_12shadow_color___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_shadow_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_12shadow_color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Light[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__Light[] = {
  {"radius", T_FLOAT, offsetof(struct __pyx_obj_5_soya__Light, radius), 0, 0},
  {"angle", T_FLOAT, offsetof(struct __pyx_obj_5_soya__Light, angle), 0, 0},
  {"exponent", T_FLOAT, offsetof(struct __pyx_obj_5_soya__Light, exponent), 0, 0},
  {"_id", T_INT, offsetof(struct __pyx_obj_5_soya__Light, _id), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Light[] = {
  {"directional", __pyx_getprop_5_soya_6_Light_directional, __pyx_setprop_5_soya_6_Light_directional, 0, 0},
  {"constant", __pyx_getprop_5_soya_6_Light_constant, __pyx_setprop_5_soya_6_Light_constant, 0, 0},
  {"linear", __pyx_getprop_5_soya_6_Light_linear, __pyx_setprop_5_soya_6_Light_linear, 0, 0},
  {"quadratic", __pyx_getprop_5_soya_6_Light_quadratic, __pyx_setprop_5_soya_6_Light_quadratic, 0, 0},
  {"cast_shadow", __pyx_getprop_5_soya_6_Light_cast_shadow, __pyx_setprop_5_soya_6_Light_cast_shadow, 0, 0},
  {"top_level", __pyx_getprop_5_soya_6_Light_top_level, __pyx_setprop_5_soya_6_Light_top_level, 0, 0},
  {"static", __pyx_getprop_5_soya_6_Light_static, __pyx_setprop_5_soya_6_Light_static, 0, 0},
  {"ambient", __pyx_getprop_5_soya_6_Light_ambient, __pyx_setprop_5_soya_6_Light_ambient, 0, 0},
  {"diffuse", __pyx_getprop_5_soya_6_Light_diffuse, __pyx_setprop_5_soya_6_Light_diffuse, 0, 0},
  {"specular", __pyx_getprop_5_soya_6_Light_specular, __pyx_setprop_5_soya_6_Light_specular, 0, 0},
  {"shadow_color", __pyx_getprop_5_soya_6_Light_shadow_color, __pyx_setprop_5_soya_6_Light_shadow_color, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Light = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Light = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Light = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Light = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Light = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Light", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Light), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Light, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Light, /*tp_as_number*/
  &__pyx_tp_as_sequence__Light, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Light, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Light, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Light, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Light, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Light, /*tp_methods*/
  __pyx_members_5_soya__Light, /*tp_members*/
  __pyx_getsets_5_soya__Light, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_6_Light___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Light, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Volume __pyx_vtable_5_soya__Volume;

static PyObject *__pyx_tp_new_5_soya__Volume(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Volume *p = (struct __pyx_obj_5_soya__Volume *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Volume *)__pyx_vtabptr_5_soya__Volume;
  p->_shape = Py_None; Py_INCREF((PyObject *) p->_shape);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Volume(PyObject *o) {
  struct __pyx_obj_5_soya__Volume *p = (struct __pyx_obj_5_soya__Volume *)o;
  Py_XDECREF((PyObject *)p->_shape);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Volume(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Volume *p = (struct __pyx_obj_5_soya__Volume *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_shape) {
    e = (*v)(((PyObject*)p->_shape), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Volume(PyObject *o) {
  struct __pyx_obj_5_soya__Volume *p = (struct __pyx_obj_5_soya__Volume *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_shape);
  p->_shape = Py_None; Py_INCREF((PyObject *) p->_shape);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_7_Volume_shape(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Volume_5shape___get__(o);
}

static int __pyx_setprop_5_soya_7_Volume_shape(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Volume_5shape___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Volume[] = {
  {"set_shape", (PyCFunction)__pyx_f_5_soya_7_Volume_set_shape, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Volume[] = {
  {"shape", __pyx_getprop_5_soya_7_Volume_shape, __pyx_setprop_5_soya_7_Volume_shape, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Volume = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Volume = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Volume = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Volume = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Volume = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Volume", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Volume), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Volume, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_7_Volume___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Volume, /*tp_as_number*/
  &__pyx_tp_as_sequence__Volume, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Volume, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Volume, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Volume, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Volume, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Volume, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Volume, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7_Volume___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Volume, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__World __pyx_vtable_5_soya__World;

static PyObject *__pyx_tp_new_5_soya__World(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Volume->tp_new(t, a, k);
  struct __pyx_obj_5_soya__World *p = (struct __pyx_obj_5_soya__World *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__World *)__pyx_vtabptr_5_soya__World;
  p->children = Py_None; Py_INCREF(p->children);
  p->_atmosphere = Py_None; Py_INCREF((PyObject *) p->_atmosphere);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  p->_shapifier = Py_None; Py_INCREF((PyObject *) p->_shapifier);
  return o;
}

static void __pyx_tp_dealloc_5_soya__World(PyObject *o) {
  struct __pyx_obj_5_soya__World *p = (struct __pyx_obj_5_soya__World *)o;
  Py_XDECREF(p->children);
  Py_XDECREF((PyObject *)p->_atmosphere);
  Py_XDECREF(p->_filename);
  Py_XDECREF((PyObject *)p->_shapifier);
  __pyx_ptype_5_soya__Volume->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__World(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__World *p = (struct __pyx_obj_5_soya__World *)o;
  __pyx_ptype_5_soya__Volume->tp_traverse(o, v, a);
  if (p->children) {
    e = (*v)(p->children, a); if (e) return e;
  }
  if (p->_atmosphere) {
    e = (*v)(((PyObject*)p->_atmosphere), a); if (e) return e;
  }
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  if (p->_shapifier) {
    e = (*v)(((PyObject*)p->_shapifier), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__World(PyObject *o) {
  struct __pyx_obj_5_soya__World *p = (struct __pyx_obj_5_soya__World *)o;
  __pyx_ptype_5_soya__Volume->tp_clear(o);
  Py_XDECREF(p->children);
  p->children = Py_None; Py_INCREF(p->children);
  Py_XDECREF((PyObject *)p->_atmosphere);
  p->_atmosphere = Py_None; Py_INCREF((PyObject *) p->_atmosphere);
  Py_XDECREF(p->_filename);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  Py_XDECREF((PyObject *)p->_shapifier);
  p->_shapifier = Py_None; Py_INCREF((PyObject *) p->_shapifier);
  return 0;
}
static PyObject *__pyx_sq_item_5_soya__World(PyObject *o, int i) {
  PyObject *r;
  PyObject *x = PyInt_FromLong(i); if(!x) return 0;
  r = o->ob_type->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_5_soya__World(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    if (__pyx_ptype_5_soya__Volume->tp_as_mapping && __pyx_ptype_5_soya__Volume->tp_as_mapping->mp_ass_subscript)
      return __pyx_ptype_5_soya__Volume->tp_as_mapping->mp_ass_subscript(o, i, v);
    PyErr_Format(PyExc_NotImplementedError,
      "Subscript assignment not supported by %s", o->ob_type->tp_name);
    return -1;
  }
  else {
    return __pyx_f_5_soya_6_World___delitem__(o, i);
  }
}

static PyObject *__pyx_getprop_5_soya_6_World_shapifier(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_World_9shapifier___get__(o);
}

static int __pyx_setprop_5_soya_6_World_shapifier(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_World_9shapifier___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_World_atmosphere(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_World_10atmosphere___get__(o);
}

static int __pyx_setprop_5_soya_6_World_atmosphere(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_World_10atmosphere___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__World[] = {
  {"get_root", (PyCFunction)__pyx_f_5_soya_6_World_get_root, METH_VARARGS|METH_KEYWORDS, 0},
  {"raypick", (PyCFunction)__pyx_f_5_soya_6_World_raypick, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_raypick},
  {"raypick_b", (PyCFunction)__pyx_f_5_soya_6_World_raypick_b, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_raypick_b},
  {"add", (PyCFunction)__pyx_f_5_soya_6_World_add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_add},
  {"append", (PyCFunction)__pyx_f_5_soya_6_World_append, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_append},
  {"insert", (PyCFunction)__pyx_f_5_soya_6_World_insert, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_insert},
  {"remove", (PyCFunction)__pyx_f_5_soya_6_World_remove, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_remove},
  {"recursive", (PyCFunction)__pyx_f_5_soya_6_World_recursive, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_recursive},
  {"subitem", (PyCFunction)__pyx_f_5_soya_6_World_subitem, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_subitem},
  {"search", (PyCFunction)__pyx_f_5_soya_6_World_search, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_search},
  {"search_name", (PyCFunction)__pyx_f_5_soya_6_World_search_name, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_search_name},
  {"search_all", (PyCFunction)__pyx_f_5_soya_6_World_search_all, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_search_all},
  {"RaypickContext", (PyCFunction)__pyx_f_5_soya_6_World_RaypickContext, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_RaypickContext},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_6_World_begin_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_begin_round},
  {"end_round", (PyCFunction)__pyx_f_5_soya_6_World_end_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_end_round},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_6_World_advance_time, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_advance_time},
  {"shapify", (PyCFunction)__pyx_f_5_soya_6_World_shapify, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_shapify},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__World[] = {
  {"children", T_OBJECT, offsetof(struct __pyx_obj_5_soya__World, children), READONLY, 0},
  {"_filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya__World, _filename), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__World[] = {
  {"shapifier", __pyx_getprop_5_soya_6_World_shapifier, __pyx_setprop_5_soya_6_World_shapifier, 0, 0},
  {"atmosphere", __pyx_getprop_5_soya_6_World_atmosphere, __pyx_setprop_5_soya_6_World_atmosphere, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__World = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__World = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5_soya__World, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__World = {
  0, /*mp_length*/
  __pyx_f_5_soya_6_World___getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__World = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__World = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._World", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__World), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__World, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__World, /*tp_as_number*/
  &__pyx_tp_as_sequence__World, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__World, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__World, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__World, /*tp_traverse*/
  __pyx_tp_clear_5_soya__World, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_f_5_soya_6_World___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__World, /*tp_methods*/
  __pyx_members_5_soya__World, /*tp_members*/
  __pyx_getsets_5_soya__World, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_6_World___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__World, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Face __pyx_vtable_5_soya__Face;

static PyObject *__pyx_tp_new_5_soya__Face(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Face *p = (struct __pyx_obj_5_soya__Face *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Face *)__pyx_vtabptr_5_soya__Face;
  p->_vertices = Py_None; Py_INCREF(p->_vertices);
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  p->_normal = Py_None; Py_INCREF((PyObject *) p->_normal);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Face(PyObject *o) {
  struct __pyx_obj_5_soya__Face *p = (struct __pyx_obj_5_soya__Face *)o;
  Py_XDECREF(p->_vertices);
  Py_XDECREF((PyObject *)p->_material);
  Py_XDECREF((PyObject *)p->_normal);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Face(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Face *p = (struct __pyx_obj_5_soya__Face *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_vertices) {
    e = (*v)(p->_vertices, a); if (e) return e;
  }
  if (p->_material) {
    e = (*v)(((PyObject*)p->_material), a); if (e) return e;
  }
  if (p->_normal) {
    e = (*v)(((PyObject*)p->_normal), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Face(PyObject *o) {
  struct __pyx_obj_5_soya__Face *p = (struct __pyx_obj_5_soya__Face *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF(p->_vertices);
  p->_vertices = Py_None; Py_INCREF(p->_vertices);
  Py_XDECREF((PyObject *)p->_material);
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  Py_XDECREF((PyObject *)p->_normal);
  p->_normal = Py_None; Py_INCREF((PyObject *) p->_normal);
  return 0;
}
static PyObject *__pyx_sq_item_5_soya__Face(PyObject *o, int i) {
  PyObject *r;
  PyObject *x = PyInt_FromLong(i); if(!x) return 0;
  r = o->ob_type->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static PyObject *__pyx_getprop_5_soya_5_Face_lit(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_3lit___get__(o);
}

static int __pyx_setprop_5_soya_5_Face_lit(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Face_3lit___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Face_smooth_lit(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_10smooth_lit___get__(o);
}

static int __pyx_setprop_5_soya_5_Face_smooth_lit(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Face_10smooth_lit___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Face_static_lit(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_10static_lit___get__(o);
}

static int __pyx_setprop_5_soya_5_Face_static_lit(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Face_10static_lit___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Face_double_sided(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_12double_sided___get__(o);
}

static int __pyx_setprop_5_soya_5_Face_double_sided(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Face_12double_sided___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Face_material(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_8material___get__(o);
}

static int __pyx_setprop_5_soya_5_Face_material(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Face_8material___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Face_vertices(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_8vertices___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Face_normal(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Face_6normal___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Face[] = {
  {"insert", (PyCFunction)__pyx_f_5_soya_5_Face_insert, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_insert},
  {"append", (PyCFunction)__pyx_f_5_soya_5_Face_append, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_append},
  {"add", (PyCFunction)__pyx_f_5_soya_5_Face_add, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_add},
  {"is_coplanar", (PyCFunction)__pyx_f_5_soya_5_Face_is_coplanar, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_is_coplanar},
  {"is_colored", (PyCFunction)__pyx_f_5_soya_5_Face_is_colored, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_is_colored},
  {"is_alpha", (PyCFunction)__pyx_f_5_soya_5_Face_is_alpha, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_is_alpha},
  {"has_alpha_vertex", (PyCFunction)__pyx_f_5_soya_5_Face_has_alpha_vertex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Face_has_alpha_vertex},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Face[] = {
  {"lit", __pyx_getprop_5_soya_5_Face_lit, __pyx_setprop_5_soya_5_Face_lit, 0, 0},
  {"smooth_lit", __pyx_getprop_5_soya_5_Face_smooth_lit, __pyx_setprop_5_soya_5_Face_smooth_lit, 0, 0},
  {"static_lit", __pyx_getprop_5_soya_5_Face_static_lit, __pyx_setprop_5_soya_5_Face_static_lit, 0, 0},
  {"double_sided", __pyx_getprop_5_soya_5_Face_double_sided, __pyx_setprop_5_soya_5_Face_double_sided, 0, 0},
  {"material", __pyx_getprop_5_soya_5_Face_material, __pyx_setprop_5_soya_5_Face_material, 0, 0},
  {"vertices", __pyx_getprop_5_soya_5_Face_vertices, 0, 0, 0},
  {"normal", __pyx_getprop_5_soya_5_Face_normal, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Face = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Face = {
  __pyx_f_5_soya_5_Face___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_5_soya__Face, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Face = {
  __pyx_f_5_soya_5_Face___len__, /*mp_length*/
  __pyx_f_5_soya_5_Face___getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Face = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Face = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Face", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Face), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Face, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_5_Face___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Face, /*tp_as_number*/
  &__pyx_tp_as_sequence__Face, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Face, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Face, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Face, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Face, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  __pyx_f_5_soya_5_Face___iter__, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Face, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Face, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_5_Face___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Face, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Cal3dVolume __pyx_vtable_5_soya__Cal3dVolume;

static PyObject *__pyx_tp_new_5_soya__Cal3dVolume(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Cal3dVolume *p = (struct __pyx_obj_5_soya__Cal3dVolume *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Cal3dVolume *)__pyx_vtabptr_5_soya__Cal3dVolume;
  p->_shape = Py_None; Py_INCREF((PyObject *) p->_shape);
  p->_attached_meshes = Py_None; Py_INCREF(p->_attached_meshes);
  p->_attached_coordsysts = Py_None; Py_INCREF(p->_attached_coordsysts);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Cal3dVolume(PyObject *o) {
  struct __pyx_obj_5_soya__Cal3dVolume *p = (struct __pyx_obj_5_soya__Cal3dVolume *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_12_Cal3dVolume___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_shape);
  Py_XDECREF(p->_attached_meshes);
  Py_XDECREF(p->_attached_coordsysts);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Cal3dVolume(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Cal3dVolume *p = (struct __pyx_obj_5_soya__Cal3dVolume *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_shape) {
    e = (*v)(((PyObject*)p->_shape), a); if (e) return e;
  }
  if (p->_attached_meshes) {
    e = (*v)(p->_attached_meshes, a); if (e) return e;
  }
  if (p->_attached_coordsysts) {
    e = (*v)(p->_attached_coordsysts, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Cal3dVolume(PyObject *o) {
  struct __pyx_obj_5_soya__Cal3dVolume *p = (struct __pyx_obj_5_soya__Cal3dVolume *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_shape);
  p->_shape = Py_None; Py_INCREF((PyObject *) p->_shape);
  Py_XDECREF(p->_attached_meshes);
  p->_attached_meshes = Py_None; Py_INCREF(p->_attached_meshes);
  Py_XDECREF(p->_attached_coordsysts);
  p->_attached_coordsysts = Py_None; Py_INCREF(p->_attached_coordsysts);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_12_Cal3dVolume_shape(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_Cal3dVolume_5shape___get__(o);
}

static int __pyx_setprop_5_soya_12_Cal3dVolume_shape(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_12_Cal3dVolume_5shape___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_12_Cal3dVolume_attached_meshes(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_Cal3dVolume_15attached_meshes___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_Cal3dVolume_attached_coordsysts(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_Cal3dVolume_19attached_coordsysts___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Cal3dVolume[] = {
  {"set_shape", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_set_shape, METH_VARARGS|METH_KEYWORDS, 0},
  {"attach", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_attach, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_attach},
  {"detach", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_detach, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_detach},
  {"is_attached", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_is_attached, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_is_attached},
  {"attach_to_bone", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_attach_to_bone, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_attach_to_bone},
  {"detach_from_bone", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_detach_from_bone, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_detach_from_bone},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_advance_time, METH_VARARGS|METH_KEYWORDS, 0},
  {"animate_blend_cycle", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_animate_blend_cycle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_animate_blend_cycle},
  {"animate_clear_cycle", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_animate_clear_cycle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_animate_clear_cycle},
  {"animate_execute_action", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_animate_execute_action, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_animate_execute_action},
  {"animate_reset", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_animate_reset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_Cal3dVolume_animate_reset},
  {"set_lod_level", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_set_lod_level, METH_VARARGS|METH_KEYWORDS, 0},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume_begin_round, METH_VARARGS|METH_KEYWORDS, 0},
  {"_build_vertices", (PyCFunction)__pyx_f_5_soya_12_Cal3dVolume__build_vertices, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Cal3dVolume[] = {
  {"shape", __pyx_getprop_5_soya_12_Cal3dVolume_shape, __pyx_setprop_5_soya_12_Cal3dVolume_shape, 0, 0},
  {"attached_meshes", __pyx_getprop_5_soya_12_Cal3dVolume_attached_meshes, 0, 0, 0},
  {"attached_coordsysts", __pyx_getprop_5_soya_12_Cal3dVolume_attached_coordsysts, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Cal3dVolume = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Cal3dVolume = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Cal3dVolume = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Cal3dVolume = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Cal3dVolume = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Cal3dVolume", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Cal3dVolume), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Cal3dVolume, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_12_Cal3dVolume___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Cal3dVolume, /*tp_as_number*/
  &__pyx_tp_as_sequence__Cal3dVolume, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Cal3dVolume, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Cal3dVolume, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Cal3DVolume\n\nA Cal3D volume (do not counfound with Volume!) wraps a Cal3D Model.\nIt displays a Cal3D shape. See Cal3DVolume.animate* methods in order to animate it.", /*tp_doc*/
  __pyx_tp_traverse_5_soya__Cal3dVolume, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Cal3dVolume, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Cal3dVolume, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Cal3dVolume, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_12_Cal3dVolume___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Cal3dVolume, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Cal3dShape __pyx_vtable_5_soya__Cal3dShape;

static PyObject *__pyx_tp_new_5_soya__Cal3dShape(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Shape->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Cal3dShape *p = (struct __pyx_obj_5_soya__Cal3dShape *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Cal3dShape *)__pyx_vtabptr_5_soya__Cal3dShape;
  p->_meshes = Py_None; Py_INCREF(p->_meshes);
  p->_animations = Py_None; Py_INCREF(p->_animations);
  p->_materials = Py_None; Py_INCREF(p->_materials);
  p->_submeshes = Py_None; Py_INCREF(p->_submeshes);
  p->_full_filename = Py_None; Py_INCREF(p->_full_filename);
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Cal3dShape(PyObject *o) {
  struct __pyx_obj_5_soya__Cal3dShape *p = (struct __pyx_obj_5_soya__Cal3dShape *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_11_Cal3dShape___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_meshes);
  Py_XDECREF(p->_animations);
  Py_XDECREF(p->_materials);
  Py_XDECREF(p->_submeshes);
  Py_XDECREF(p->_full_filename);
  Py_XDECREF((PyObject *)p->_shader);
  __pyx_ptype_5_soya__Shape->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Cal3dShape(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Cal3dShape *p = (struct __pyx_obj_5_soya__Cal3dShape *)o;
  __pyx_ptype_5_soya__Shape->tp_traverse(o, v, a);
  if (p->_meshes) {
    e = (*v)(p->_meshes, a); if (e) return e;
  }
  if (p->_animations) {
    e = (*v)(p->_animations, a); if (e) return e;
  }
  if (p->_materials) {
    e = (*v)(p->_materials, a); if (e) return e;
  }
  if (p->_submeshes) {
    e = (*v)(p->_submeshes, a); if (e) return e;
  }
  if (p->_full_filename) {
    e = (*v)(p->_full_filename, a); if (e) return e;
  }
  if (p->_shader) {
    e = (*v)(((PyObject*)p->_shader), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Cal3dShape(PyObject *o) {
  struct __pyx_obj_5_soya__Cal3dShape *p = (struct __pyx_obj_5_soya__Cal3dShape *)o;
  __pyx_ptype_5_soya__Shape->tp_clear(o);
  Py_XDECREF(p->_meshes);
  p->_meshes = Py_None; Py_INCREF(p->_meshes);
  Py_XDECREF(p->_animations);
  p->_animations = Py_None; Py_INCREF(p->_animations);
  Py_XDECREF(p->_materials);
  p->_materials = Py_None; Py_INCREF(p->_materials);
  Py_XDECREF(p->_submeshes);
  p->_submeshes = Py_None; Py_INCREF(p->_submeshes);
  Py_XDECREF(p->_full_filename);
  p->_full_filename = Py_None; Py_INCREF(p->_full_filename);
  Py_XDECREF((PyObject *)p->_shader);
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_filename(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_8filename___get__(o);
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_full_filename(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_13full_filename___get__(o);
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_materials(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_9materials___get__(o);
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_meshes(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_6meshes___get__(o);
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_animations(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_10animations___get__(o);
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_sphere(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_6sphere___get__(o);
}

static int __pyx_setprop_5_soya_11_Cal3dShape_sphere(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Cal3dShape_6sphere___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_double_sided(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_12double_sided___get__(o);
}

static int __pyx_setprop_5_soya_11_Cal3dShape_double_sided(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Cal3dShape_12double_sided___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_shadow(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_6shadow___get__(o);
}

static int __pyx_setprop_5_soya_11_Cal3dShape_shadow(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Cal3dShape_6shadow___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Cal3dShape_cellshading(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Cal3dShape_11cellshading___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Cal3dShape[] = {
  {"set_cellshading", (PyCFunction)__pyx_f_5_soya_11_Cal3dShape_set_cellshading, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_skeleton", (PyCFunction)__pyx_f_5_soya_11_Cal3dShape_load_skeleton, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_mesh", (PyCFunction)__pyx_f_5_soya_11_Cal3dShape_load_mesh, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_material", (PyCFunction)__pyx_f_5_soya_11_Cal3dShape_load_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_animation", (PyCFunction)__pyx_f_5_soya_11_Cal3dShape_load_animation, METH_VARARGS|METH_KEYWORDS, 0},
  {"build_materials", (PyCFunction)__pyx_f_5_soya_11_Cal3dShape_build_materials, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Cal3dShape[] = {
  {"filename", __pyx_getprop_5_soya_11_Cal3dShape_filename, 0, 0, 0},
  {"full_filename", __pyx_getprop_5_soya_11_Cal3dShape_full_filename, 0, 0, 0},
  {"materials", __pyx_getprop_5_soya_11_Cal3dShape_materials, 0, 0, 0},
  {"meshes", __pyx_getprop_5_soya_11_Cal3dShape_meshes, 0, 0, 0},
  {"animations", __pyx_getprop_5_soya_11_Cal3dShape_animations, 0, 0, 0},
  {"sphere", __pyx_getprop_5_soya_11_Cal3dShape_sphere, __pyx_setprop_5_soya_11_Cal3dShape_sphere, 0, 0},
  {"double_sided", __pyx_getprop_5_soya_11_Cal3dShape_double_sided, __pyx_setprop_5_soya_11_Cal3dShape_double_sided, 0, 0},
  {"shadow", __pyx_getprop_5_soya_11_Cal3dShape_shadow, __pyx_setprop_5_soya_11_Cal3dShape_shadow, 0, 0},
  {"cellshading", __pyx_getprop_5_soya_11_Cal3dShape_cellshading, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Cal3dShape = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Cal3dShape = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Cal3dShape = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Cal3dShape = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Cal3dShape = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Cal3dShape", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Cal3dShape), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Cal3dShape, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Cal3dShape, /*tp_as_number*/
  &__pyx_tp_as_sequence__Cal3dShape, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Cal3dShape, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Cal3dShape, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Cal3dShape, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Cal3dShape, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Cal3dShape, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Cal3dShape, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_11_Cal3dShape___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Cal3dShape, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Sprite __pyx_vtable_5_soya__Sprite;

static PyObject *__pyx_tp_new_5_soya__Sprite(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Sprite *p = (struct __pyx_obj_5_soya__Sprite *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Sprite *)__pyx_vtabptr_5_soya__Sprite;
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Sprite(PyObject *o) {
  struct __pyx_obj_5_soya__Sprite *p = (struct __pyx_obj_5_soya__Sprite *)o;
  Py_XDECREF((PyObject *)p->_material);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Sprite(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Sprite *p = (struct __pyx_obj_5_soya__Sprite *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_material) {
    e = (*v)(((PyObject*)p->_material), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Sprite(PyObject *o) {
  struct __pyx_obj_5_soya__Sprite *p = (struct __pyx_obj_5_soya__Sprite *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_material);
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_7_Sprite_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Sprite_5width___get__(o);
}

static int __pyx_setprop_5_soya_7_Sprite_width(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Sprite_5width___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Sprite_height(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Sprite_6height___get__(o);
}

static int __pyx_setprop_5_soya_7_Sprite_height(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Sprite_6height___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Sprite_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Sprite_5color___get__(o);
}

static int __pyx_setprop_5_soya_7_Sprite_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Sprite_5color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Sprite_material(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Sprite_8material___get__(o);
}

static int __pyx_setprop_5_soya_7_Sprite_material(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Sprite_8material___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Sprite_lit(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Sprite_3lit___get__(o);
}

static int __pyx_setprop_5_soya_7_Sprite_lit(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Sprite_3lit___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Sprite[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Sprite[] = {
  {"width", __pyx_getprop_5_soya_7_Sprite_width, __pyx_setprop_5_soya_7_Sprite_width, 0, 0},
  {"height", __pyx_getprop_5_soya_7_Sprite_height, __pyx_setprop_5_soya_7_Sprite_height, 0, 0},
  {"color", __pyx_getprop_5_soya_7_Sprite_color, __pyx_setprop_5_soya_7_Sprite_color, 0, 0},
  {"material", __pyx_getprop_5_soya_7_Sprite_material, __pyx_setprop_5_soya_7_Sprite_material, 0, 0},
  {"lit", __pyx_getprop_5_soya_7_Sprite_lit, __pyx_setprop_5_soya_7_Sprite_lit, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Sprite = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Sprite = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Sprite = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Sprite = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Sprite = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Sprite", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Sprite), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Sprite, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Sprite, /*tp_as_number*/
  &__pyx_tp_as_sequence__Sprite, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Sprite, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Sprite, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Sprite, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Sprite, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Sprite, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Sprite, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7_Sprite___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Sprite, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Portal __pyx_vtable_5_soya__Portal;

static PyObject *__pyx_tp_new_5_soya__Portal(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Portal *p = (struct __pyx_obj_5_soya__Portal *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Portal *)__pyx_vtabptr_5_soya__Portal;
  p->_beyond = Py_None; Py_INCREF((PyObject *) p->_beyond);
  p->_beyond_name = Py_None; Py_INCREF(p->_beyond_name);
  p->_context = Py_None; Py_INCREF((PyObject *) p->_context);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Portal(PyObject *o) {
  struct __pyx_obj_5_soya__Portal *p = (struct __pyx_obj_5_soya__Portal *)o;
  Py_XDECREF((PyObject *)p->_beyond);
  Py_XDECREF(p->_beyond_name);
  Py_XDECREF(p->_context);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Portal(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Portal *p = (struct __pyx_obj_5_soya__Portal *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_beyond) {
    e = (*v)(((PyObject*)p->_beyond), a); if (e) return e;
  }
  if (p->_beyond_name) {
    e = (*v)(p->_beyond_name, a); if (e) return e;
  }
  if (p->_context) {
    e = (*v)(((PyObject*)p->_context), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Portal(PyObject *o) {
  struct __pyx_obj_5_soya__Portal *p = (struct __pyx_obj_5_soya__Portal *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_beyond);
  p->_beyond = Py_None; Py_INCREF((PyObject *) p->_beyond);
  Py_XDECREF(p->_beyond_name);
  p->_beyond_name = Py_None; Py_INCREF(p->_beyond_name);
  Py_XDECREF(p->_context);
  p->_context = Py_None; Py_INCREF((PyObject *) p->_context);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_7_Portal_beyond(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Portal_6beyond___get__(o);
}

static int __pyx_setprop_5_soya_7_Portal_beyond(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Portal_6beyond___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Portal_beyond_name(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Portal_11beyond_name___get__(o);
}

static int __pyx_setprop_5_soya_7_Portal_beyond_name(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Portal_11beyond_name___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Portal_nb_clip_planes(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Portal_14nb_clip_planes___get__(o);
}

static int __pyx_setprop_5_soya_7_Portal_nb_clip_planes(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Portal_14nb_clip_planes___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_7_Portal_bound_atmosphere(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Portal_16bound_atmosphere___get__(o);
}

static int __pyx_setprop_5_soya_7_Portal_bound_atmosphere(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Portal_16bound_atmosphere___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Portal[] = {
  {"load_beyond", (PyCFunction)__pyx_f_5_soya_7_Portal_load_beyond, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Portal_load_beyond},
  {"unload_beyond", (PyCFunction)__pyx_f_5_soya_7_Portal_unload_beyond, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Portal_unload_beyond},
  {"has_passed_through", (PyCFunction)__pyx_f_5_soya_7_Portal_has_passed_through, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_7_Portal_has_passed_through},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Portal[] = {
  {"beyond", __pyx_getprop_5_soya_7_Portal_beyond, __pyx_setprop_5_soya_7_Portal_beyond, 0, 0},
  {"beyond_name", __pyx_getprop_5_soya_7_Portal_beyond_name, __pyx_setprop_5_soya_7_Portal_beyond_name, 0, 0},
  {"nb_clip_planes", __pyx_getprop_5_soya_7_Portal_nb_clip_planes, __pyx_setprop_5_soya_7_Portal_nb_clip_planes, 0, 0},
  {"bound_atmosphere", __pyx_getprop_5_soya_7_Portal_bound_atmosphere, __pyx_setprop_5_soya_7_Portal_bound_atmosphere, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Portal = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Portal = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Portal = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Portal = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Portal = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Portal", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Portal), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Portal, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Portal, /*tp_as_number*/
  &__pyx_tp_as_sequence__Portal, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Portal, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Portal, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Portal, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Portal, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Portal, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Portal, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7_Portal___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Portal, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Land __pyx_vtable_5_soya__Land;

static PyObject *__pyx_tp_new_5_soya__Land(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Land *p = (struct __pyx_obj_5_soya__Land *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Land *)__pyx_vtabptr_5_soya__Land;
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Land(PyObject *o) {
  struct __pyx_obj_5_soya__Land *p = (struct __pyx_obj_5_soya__Land *)o;
  Py_XDECREF(p->_materials);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Land(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Land *p = (struct __pyx_obj_5_soya__Land *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_materials) {
    e = (*v)(p->_materials, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Land(PyObject *o) {
  struct __pyx_obj_5_soya__Land *p = (struct __pyx_obj_5_soya__Land *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF(p->_materials);
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_5_Land_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_5width___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Land_depth(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_5depth___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Land_patch_size(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_10patch_size___get__(o);
}

static int __pyx_setprop_5_soya_5_Land_patch_size(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Land_10patch_size___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Land_has_vertex_options(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_18has_vertex_options___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Land_split_factor(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_12split_factor___get__(o);
}

static int __pyx_setprop_5_soya_5_Land_split_factor(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Land_12split_factor___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Land_scale_factor(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_12scale_factor___get__(o);
}

static int __pyx_setprop_5_soya_5_Land_scale_factor(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Land_12scale_factor___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Land_texture_factor(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_14texture_factor___get__(o);
}

static int __pyx_setprop_5_soya_5_Land_texture_factor(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Land_14texture_factor___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Land_raypick_with_LOD(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Land_16raypick_with_LOD___get__(o);
}

static int __pyx_setprop_5_soya_5_Land_raypick_with_LOD(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Land_16raypick_with_LOD___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Land[] = {
  {"from_image", (PyCFunction)__pyx_f_5_soya_5_Land_from_image, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material_layer", (PyCFunction)__pyx_f_5_soya_5_Land_set_material_layer, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material_layer_angle", (PyCFunction)__pyx_f_5_soya_5_Land_set_material_layer_angle, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_normal", (PyCFunction)__pyx_f_5_soya_5_Land_get_normal, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_height", (PyCFunction)__pyx_f_5_soya_5_Land_get_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_material", (PyCFunction)__pyx_f_5_soya_5_Land_get_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_height", (PyCFunction)__pyx_f_5_soya_5_Land_set_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"multiply_height", (PyCFunction)__pyx_f_5_soya_5_Land_multiply_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_height", (PyCFunction)__pyx_f_5_soya_5_Land_add_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material", (PyCFunction)__pyx_f_5_soya_5_Land_set_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"remove_colors", (PyCFunction)__pyx_f_5_soya_5_Land_remove_colors, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Land_remove_colors},
  {"get_vertex_option", (PyCFunction)__pyx_f_5_soya_5_Land_get_vertex_option, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Land_get_vertex_option},
  {"set_vertex_option", (PyCFunction)__pyx_f_5_soya_5_Land_set_vertex_option, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Land_set_vertex_option},
  {"set_vertex_color", (PyCFunction)__pyx_f_5_soya_5_Land_set_vertex_color, METH_VARARGS|METH_KEYWORDS, 0},
  {"reinit", (PyCFunction)__pyx_f_5_soya_5_Land_reinit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Land_reinit},
  {"compute_shadow_color", (PyCFunction)__pyx_f_5_soya_5_Land_compute_shadow_color, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_true_height_and_normal", (PyCFunction)__pyx_f_5_soya_5_Land_get_true_height_and_normal, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Land[] = {
  {"width", __pyx_getprop_5_soya_5_Land_width, 0, 0, 0},
  {"depth", __pyx_getprop_5_soya_5_Land_depth, 0, 0, 0},
  {"patch_size", __pyx_getprop_5_soya_5_Land_patch_size, __pyx_setprop_5_soya_5_Land_patch_size, 0, 0},
  {"has_vertex_options", __pyx_getprop_5_soya_5_Land_has_vertex_options, 0, 0, 0},
  {"split_factor", __pyx_getprop_5_soya_5_Land_split_factor, __pyx_setprop_5_soya_5_Land_split_factor, 0, 0},
  {"scale_factor", __pyx_getprop_5_soya_5_Land_scale_factor, __pyx_setprop_5_soya_5_Land_scale_factor, 0, 0},
  {"texture_factor", __pyx_getprop_5_soya_5_Land_texture_factor, __pyx_setprop_5_soya_5_Land_texture_factor, 0, 0},
  {"raypick_with_LOD", __pyx_getprop_5_soya_5_Land_raypick_with_LOD, __pyx_setprop_5_soya_5_Land_raypick_with_LOD, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Land = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Land = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Land = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Land = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Land = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Land", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Land), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Land, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Land, /*tp_as_number*/
  &__pyx_tp_as_sequence__Land, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Land, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Land, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Land, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Land, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Land, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Land, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_5_Land___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Land, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__WaterCube __pyx_vtable_5_soya__WaterCube;

static PyObject *__pyx_tp_new_5_soya__WaterCube(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__WaterCube *p = (struct __pyx_obj_5_soya__WaterCube *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__WaterCube *)__pyx_vtabptr_5_soya__WaterCube;
  return o;
}

static void __pyx_tp_dealloc_5_soya__WaterCube(PyObject *o) {
  struct __pyx_obj_5_soya__WaterCube *p = (struct __pyx_obj_5_soya__WaterCube *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__WaterCube(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__WaterCube *p = (struct __pyx_obj_5_soya__WaterCube *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__WaterCube(PyObject *o) {
  struct __pyx_obj_5_soya__WaterCube *p = (struct __pyx_obj_5_soya__WaterCube *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__WaterCube[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__WaterCube = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__WaterCube = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__WaterCube = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__WaterCube = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__WaterCube = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._WaterCube", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__WaterCube), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__WaterCube, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__WaterCube, /*tp_as_number*/
  &__pyx_tp_as_sequence__WaterCube, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__WaterCube, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__WaterCube, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__WaterCube, /*tp_traverse*/
  __pyx_tp_clear_5_soya__WaterCube, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__WaterCube, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__WaterCube, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Atmosphere __pyx_vtable_5_soya__Atmosphere;

static PyObject *__pyx_tp_new_5_soya__Atmosphere(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Atmosphere *p = (struct __pyx_obj_5_soya__Atmosphere *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Atmosphere *)__pyx_vtabptr_5_soya__Atmosphere;
  return o;
}

static void __pyx_tp_dealloc_5_soya__Atmosphere(PyObject *o) {
  struct __pyx_obj_5_soya__Atmosphere *p = (struct __pyx_obj_5_soya__Atmosphere *)o;
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Atmosphere(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Atmosphere *p = (struct __pyx_obj_5_soya__Atmosphere *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__Atmosphere(PyObject *o) {
  struct __pyx_obj_5_soya__Atmosphere *p = (struct __pyx_obj_5_soya__Atmosphere *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_fog(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_3fog___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_fog(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_3fog___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_fog_type(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_8fog_type___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_fog_type(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_8fog_type___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_fog_start(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_9fog_start___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_fog_start(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_9fog_start___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_fog_end(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_7fog_end___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_fog_end(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_7fog_end___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_fog_density(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_11fog_density___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_fog_density(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_11fog_density___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_ambient(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_7ambient___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_ambient(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_7ambient___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_bg_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_8bg_color___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_bg_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_8bg_color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_11_Atmosphere_fog_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_11_Atmosphere_9fog_color___get__(o);
}

static int __pyx_setprop_5_soya_11_Atmosphere_fog_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_11_Atmosphere_9fog_color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Atmosphere[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Atmosphere[] = {
  {"fog", __pyx_getprop_5_soya_11_Atmosphere_fog, __pyx_setprop_5_soya_11_Atmosphere_fog, 0, 0},
  {"fog_type", __pyx_getprop_5_soya_11_Atmosphere_fog_type, __pyx_setprop_5_soya_11_Atmosphere_fog_type, 0, 0},
  {"fog_start", __pyx_getprop_5_soya_11_Atmosphere_fog_start, __pyx_setprop_5_soya_11_Atmosphere_fog_start, 0, 0},
  {"fog_end", __pyx_getprop_5_soya_11_Atmosphere_fog_end, __pyx_setprop_5_soya_11_Atmosphere_fog_end, 0, 0},
  {"fog_density", __pyx_getprop_5_soya_11_Atmosphere_fog_density, __pyx_setprop_5_soya_11_Atmosphere_fog_density, 0, 0},
  {"ambient", __pyx_getprop_5_soya_11_Atmosphere_ambient, __pyx_setprop_5_soya_11_Atmosphere_ambient, 0, 0},
  {"bg_color", __pyx_getprop_5_soya_11_Atmosphere_bg_color, __pyx_setprop_5_soya_11_Atmosphere_bg_color, 0, 0},
  {"fog_color", __pyx_getprop_5_soya_11_Atmosphere_fog_color, __pyx_setprop_5_soya_11_Atmosphere_fog_color, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Atmosphere = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Atmosphere = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Atmosphere = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Atmosphere = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Atmosphere = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Atmosphere", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Atmosphere), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Atmosphere, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Atmosphere, /*tp_as_number*/
  &__pyx_tp_as_sequence__Atmosphere, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Atmosphere, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Atmosphere, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "Atmosphere\n\nAn Atmosphere is an object that defines all the atmospheric attributes of a World, such\nas fog, background or ambient lighting.\n\nTo apply an Atmosphere to a World, as well as everything inside the World, do :\n\n    world.atmosphere = my_atmosphere\n\nYou can safely put several Worlds one inside the other, with different Atmospheres.\n\nAttributes are :\n\n- fog: true to activate fog, false to disable fog (default value).\n\n- fog_color: the fog color (an (R, G, B, A) tuple of four floats). Defaults to black.\n\n- fog_type: the type of fog. fog_type can take 3 different values :\n  - 0, linear fog: the fog range from fog_start to fog_end (default value).\n  - 1, exponentiel fog: the fog the fog increase exponentially to fog_density and the distance.\n  - 2, exponentiel squared fog: the fog the fog increase exponentially to the square of fog_density and the distance.\n\n- fog_start: the distance at which the fog begins, if fog_type == 0. Defaults to 10.0.\n\n- fog_end: the distance at which the fog ends, if fog_type == 0. Defaults to 100.0.\n\n- fog_density: the fog density, if fog_type > 0. Defaults to 1.0.\n\n- ambient: the ambient lighting color (an (R, G, B, A) tuple of four floats). Defaults to (0.5, 0.5, 0.5, 1.0).\n\n- bg_color: the background color of the scene (an (R, G, B, A) tuple of four floats). Defaults to black.\n", /*tp_doc*/
  __pyx_tp_traverse_5_soya__Atmosphere, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Atmosphere, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Atmosphere, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Atmosphere, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_11_Atmosphere___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Atmosphere, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Renderer __pyx_vtable_5_soya_Renderer;

static PyObject *__pyx_tp_new_5_soya_Renderer(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_Renderer *p = (struct __pyx_obj_5_soya_Renderer *)o;
  p->__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Renderer *)__pyx_vtabptr_5_soya_Renderer;
  p->root_object = Py_None; Py_INCREF((PyObject *) p->root_object);
  p->current_camera = Py_None; Py_INCREF((PyObject *) p->current_camera);
  p->current_material = Py_None; Py_INCREF((PyObject *) p->current_material);
  p->current_coordsyst = Py_None; Py_INCREF((PyObject *) p->current_coordsyst);
  p->current_context = Py_None; Py_INCREF((PyObject *) p->current_context);
  p->contexts = Py_None; Py_INCREF(p->contexts);
  p->root_atmosphere = Py_None; Py_INCREF((PyObject *) p->root_atmosphere);
  p->top_lights = Py_None; Py_INCREF(p->top_lights);
  p->worlds_made = Py_None; Py_INCREF(p->worlds_made);
  p->portals = Py_None; Py_INCREF(p->portals);
  p->watercubes = Py_None; Py_INCREF(p->watercubes);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Renderer(PyObject *o) {
  struct __pyx_obj_5_soya_Renderer *p = (struct __pyx_obj_5_soya_Renderer *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_8Renderer___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->root_object);
  Py_XDECREF((PyObject *)p->current_camera);
  Py_XDECREF((PyObject *)p->current_material);
  Py_XDECREF((PyObject *)p->current_coordsyst);
  Py_XDECREF(p->current_context);
  Py_XDECREF(p->contexts);
  Py_XDECREF((PyObject *)p->root_atmosphere);
  Py_XDECREF(p->top_lights);
  Py_XDECREF(p->worlds_made);
  Py_XDECREF(p->portals);
  Py_XDECREF(p->watercubes);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_Renderer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Renderer *p = (struct __pyx_obj_5_soya_Renderer *)o;
  if (p->root_object) {
    e = (*v)(((PyObject*)p->root_object), a); if (e) return e;
  }
  if (p->current_camera) {
    e = (*v)(((PyObject*)p->current_camera), a); if (e) return e;
  }
  if (p->current_material) {
    e = (*v)(((PyObject*)p->current_material), a); if (e) return e;
  }
  if (p->current_coordsyst) {
    e = (*v)(((PyObject*)p->current_coordsyst), a); if (e) return e;
  }
  if (p->current_context) {
    e = (*v)(((PyObject*)p->current_context), a); if (e) return e;
  }
  if (p->contexts) {
    e = (*v)(p->contexts, a); if (e) return e;
  }
  if (p->root_atmosphere) {
    e = (*v)(((PyObject*)p->root_atmosphere), a); if (e) return e;
  }
  if (p->top_lights) {
    e = (*v)(p->top_lights, a); if (e) return e;
  }
  if (p->worlds_made) {
    e = (*v)(p->worlds_made, a); if (e) return e;
  }
  if (p->portals) {
    e = (*v)(p->portals, a); if (e) return e;
  }
  if (p->watercubes) {
    e = (*v)(p->watercubes, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Renderer(PyObject *o) {
  struct __pyx_obj_5_soya_Renderer *p = (struct __pyx_obj_5_soya_Renderer *)o;
  Py_XDECREF((PyObject *)p->root_object);
  p->root_object = Py_None; Py_INCREF((PyObject *) p->root_object);
  Py_XDECREF((PyObject *)p->current_camera);
  p->current_camera = Py_None; Py_INCREF((PyObject *) p->current_camera);
  Py_XDECREF((PyObject *)p->current_material);
  p->current_material = Py_None; Py_INCREF((PyObject *) p->current_material);
  Py_XDECREF((PyObject *)p->current_coordsyst);
  p->current_coordsyst = Py_None; Py_INCREF((PyObject *) p->current_coordsyst);
  Py_XDECREF(p->current_context);
  p->current_context = Py_None; Py_INCREF((PyObject *) p->current_context);
  Py_XDECREF(p->contexts);
  p->contexts = Py_None; Py_INCREF(p->contexts);
  Py_XDECREF((PyObject *)p->root_atmosphere);
  p->root_atmosphere = Py_None; Py_INCREF((PyObject *) p->root_atmosphere);
  Py_XDECREF(p->top_lights);
  p->top_lights = Py_None; Py_INCREF(p->top_lights);
  Py_XDECREF(p->worlds_made);
  p->worlds_made = Py_None; Py_INCREF(p->worlds_made);
  Py_XDECREF(p->portals);
  p->portals = Py_None; Py_INCREF(p->portals);
  Py_XDECREF(p->watercubes);
  p->watercubes = Py_None; Py_INCREF(p->watercubes);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Renderer[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Renderer = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Renderer = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Renderer = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Renderer = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Renderer = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Renderer", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Renderer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Renderer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Renderer, /*tp_as_number*/
  &__pyx_tp_as_sequence_Renderer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Renderer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Renderer, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Renderer, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Renderer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Renderer, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_8Renderer___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Renderer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_5_soya_Context(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_Context *p = (struct __pyx_obj_5_soya_Context *)o;
  p->lights = Py_None; Py_INCREF(p->lights);
  p->atmosphere = Py_None; Py_INCREF((PyObject *) p->atmosphere);
  p->portal = Py_None; Py_INCREF((PyObject *) p->portal);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Context(PyObject *o) {
  struct __pyx_obj_5_soya_Context *p = (struct __pyx_obj_5_soya_Context *)o;
  Py_XDECREF(p->lights);
  Py_XDECREF((PyObject *)p->atmosphere);
  Py_XDECREF((PyObject *)p->portal);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_Context(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Context *p = (struct __pyx_obj_5_soya_Context *)o;
  if (p->lights) {
    e = (*v)(p->lights, a); if (e) return e;
  }
  if (p->atmosphere) {
    e = (*v)(((PyObject*)p->atmosphere), a); if (e) return e;
  }
  if (p->portal) {
    e = (*v)(((PyObject*)p->portal), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Context(PyObject *o) {
  struct __pyx_obj_5_soya_Context *p = (struct __pyx_obj_5_soya_Context *)o;
  Py_XDECREF(p->lights);
  p->lights = Py_None; Py_INCREF(p->lights);
  Py_XDECREF((PyObject *)p->atmosphere);
  p->atmosphere = Py_None; Py_INCREF((PyObject *) p->atmosphere);
  Py_XDECREF((PyObject *)p->portal);
  p->portal = Py_None; Py_INCREF((PyObject *) p->portal);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Context[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Context = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Context = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Context = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Context = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Context = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Context", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Context), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Context, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Context, /*tp_as_number*/
  &__pyx_tp_as_sequence_Context, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Context, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Context, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Context, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Context, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Context, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7Context___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Context, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_5_soya_RaypickData(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_RaypickData *p = (struct __pyx_obj_5_soya_RaypickData *)o;
  p->result_coordsyst = Py_None; Py_INCREF((PyObject *) p->result_coordsyst);
  return o;
}

static void __pyx_tp_dealloc_5_soya_RaypickData(PyObject *o) {
  struct __pyx_obj_5_soya_RaypickData *p = (struct __pyx_obj_5_soya_RaypickData *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_11RaypickData___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->result_coordsyst);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_RaypickData(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_RaypickData *p = (struct __pyx_obj_5_soya_RaypickData *)o;
  if (p->result_coordsyst) {
    e = (*v)(((PyObject*)p->result_coordsyst), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_RaypickData(PyObject *o) {
  struct __pyx_obj_5_soya_RaypickData *p = (struct __pyx_obj_5_soya_RaypickData *)o;
  Py_XDECREF((PyObject *)p->result_coordsyst);
  p->result_coordsyst = Py_None; Py_INCREF((PyObject *) p->result_coordsyst);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_RaypickData[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RaypickData = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_RaypickData = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RaypickData = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RaypickData = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_RaypickData = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.RaypickData", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_RaypickData), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_RaypickData, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_RaypickData, /*tp_as_number*/
  &__pyx_tp_as_sequence_RaypickData, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RaypickData, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RaypickData, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_RaypickData, /*tp_traverse*/
  __pyx_tp_clear_5_soya_RaypickData, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_RaypickData, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_11RaypickData___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_RaypickData, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_5_soya_RaypickContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_RaypickContext *p = (struct __pyx_obj_5_soya_RaypickContext *)o;
  p->_root = Py_None; Py_INCREF((PyObject *) p->_root);
  return o;
}

static void __pyx_tp_dealloc_5_soya_RaypickContext(PyObject *o) {
  struct __pyx_obj_5_soya_RaypickContext *p = (struct __pyx_obj_5_soya_RaypickContext *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_14RaypickContext___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_root);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_RaypickContext(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_RaypickContext *p = (struct __pyx_obj_5_soya_RaypickContext *)o;
  if (p->_root) {
    e = (*v)(((PyObject*)p->_root), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_RaypickContext(PyObject *o) {
  struct __pyx_obj_5_soya_RaypickContext *p = (struct __pyx_obj_5_soya_RaypickContext *)o;
  Py_XDECREF((PyObject *)p->_root);
  p->_root = Py_None; Py_INCREF((PyObject *) p->_root);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_RaypickContext[] = {
  {"raypick", (PyCFunction)__pyx_f_5_soya_14RaypickContext_raypick, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_14RaypickContext_raypick},
  {"raypick_b", (PyCFunction)__pyx_f_5_soya_14RaypickContext_raypick_b, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_14RaypickContext_raypick_b},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RaypickContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_RaypickContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RaypickContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RaypickContext = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_RaypickContext = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.RaypickContext", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_RaypickContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_RaypickContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_RaypickContext, /*tp_as_number*/
  &__pyx_tp_as_sequence_RaypickContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RaypickContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RaypickContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_RaypickContext, /*tp_traverse*/
  __pyx_tp_clear_5_soya_RaypickContext, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_RaypickContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_14RaypickContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_RaypickContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_5_soya_Idler(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_Idler *p = (struct __pyx_obj_5_soya_Idler *)o;
  p->_next_round_tasks = Py_None; Py_INCREF(p->_next_round_tasks);
  p->_return_value = Py_None; Py_INCREF(p->_return_value);
  p->_scenes = Py_None; Py_INCREF(p->_scenes);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Idler(PyObject *o) {
  struct __pyx_obj_5_soya_Idler *p = (struct __pyx_obj_5_soya_Idler *)o;
  Py_XDECREF(p->_next_round_tasks);
  Py_XDECREF(p->_return_value);
  Py_XDECREF(p->_scenes);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_Idler(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Idler *p = (struct __pyx_obj_5_soya_Idler *)o;
  if (p->_next_round_tasks) {
    e = (*v)(p->_next_round_tasks, a); if (e) return e;
  }
  if (p->_return_value) {
    e = (*v)(p->_return_value, a); if (e) return e;
  }
  if (p->_scenes) {
    e = (*v)(p->_scenes, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Idler(PyObject *o) {
  struct __pyx_obj_5_soya_Idler *p = (struct __pyx_obj_5_soya_Idler *)o;
  Py_XDECREF(p->_next_round_tasks);
  p->_next_round_tasks = Py_None; Py_INCREF(p->_next_round_tasks);
  Py_XDECREF(p->_return_value);
  p->_return_value = Py_None; Py_INCREF(p->_return_value);
  Py_XDECREF(p->_scenes);
  p->_scenes = Py_None; Py_INCREF(p->_scenes);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_5Idler_scenes(PyObject *o, void *x) {
  return __pyx_f_5_soya_5Idler_6scenes___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5Idler_next_round_tasks(PyObject *o, void *x) {
  return __pyx_f_5_soya_5Idler_16next_round_tasks___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya_Idler[] = {
  {"start", (PyCFunction)__pyx_f_5_soya_5Idler_start, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_start},
  {"stop", (PyCFunction)__pyx_f_5_soya_5Idler_stop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_stop},
  {"reset", (PyCFunction)__pyx_f_5_soya_5Idler_reset, METH_VARARGS|METH_KEYWORDS, 0},
  {"idle", (PyCFunction)__pyx_f_5_soya_5Idler_idle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_idle},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_5Idler_begin_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_begin_round},
  {"end_round", (PyCFunction)__pyx_f_5_soya_5Idler_end_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_end_round},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_5Idler_advance_time, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_advance_time},
  {"render", (PyCFunction)__pyx_f_5_soya_5Idler_render, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5Idler_render},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya_Idler[] = {
  {"round_duration", T_DOUBLE, offsetof(struct __pyx_obj_5_soya_Idler, round_duration), 0, 0},
  {"min_frame_duration", T_DOUBLE, offsetof(struct __pyx_obj_5_soya_Idler, min_frame_duration), 0, 0},
  {"fps", T_DOUBLE, offsetof(struct __pyx_obj_5_soya_Idler, fps), READONLY, 0},
  {"running", T_INT, offsetof(struct __pyx_obj_5_soya_Idler, running), READONLY, 0},
  {"will_render", T_INT, offsetof(struct __pyx_obj_5_soya_Idler, will_render), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_Idler[] = {
  {"scenes", __pyx_getprop_5_soya_5Idler_scenes, 0, 0, 0},
  {"next_round_tasks", __pyx_getprop_5_soya_5Idler_next_round_tasks, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Idler = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Idler = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Idler = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Idler = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Idler = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Idler", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Idler), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Idler, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Idler, /*tp_as_number*/
  &__pyx_tp_as_sequence_Idler, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Idler, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Idler, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Idler\n\nA main loop, with FPS regulation.\n\nInteresting attributes:\n\n - fps (read only): the frame rate (number of frame per second, a usefull speed indicator).\n\n - running (read only): true if the Idler is idling (=running).\n\n - next_round_tasks: a list of callable (taking no arg) that will be called once, just\n   after the beginning of the next round.\n\n - scenes: the scenes associated to this idler.\n\n - round_duration: The duration of a round. Round is the idler\'s time unit. The idler calls\n   successively begin_round(), advance_time() (possibly several times) and end_round(); it\n   is granted that ALL rounds correspond to a period of duration ROUND_DURATION (though\n   the different period may not be regularly spread over time).\n   Default is 0.030.\n\n - min_frame_duration: minimum duration for a frame. This attribute can be used to limit\n   the maximum FPS to save CPU time; e.g. FPS higher than 30-40 is usually useless.\n   Default is 0.020, which limits FPS to 40 in theory and to about 33 in practice\n   (I don\'t know why there is a difference between theory and practice !).\n", /*tp_doc*/
  __pyx_tp_traverse_5_soya_Idler, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Idler, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Idler, /*tp_methods*/
  __pyx_members_5_soya_Idler, /*tp_members*/
  __pyx_getsets_5_soya_Idler, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_5Idler___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Idler, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static PyObject *__pyx_tp_new_5_soya_Glyph(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_Glyph *p = (struct __pyx_obj_5_soya_Glyph *)o;
  p->unichar = Py_None; Py_INCREF(p->unichar);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Glyph(PyObject *o) {
  struct __pyx_obj_5_soya_Glyph *p = (struct __pyx_obj_5_soya_Glyph *)o;
  Py_XDECREF(p->unichar);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_Glyph(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Glyph *p = (struct __pyx_obj_5_soya_Glyph *)o;
  if (p->unichar) {
    e = (*v)(p->unichar, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Glyph(PyObject *o) {
  struct __pyx_obj_5_soya_Glyph *p = (struct __pyx_obj_5_soya_Glyph *)o;
  Py_XDECREF(p->unichar);
  p->unichar = Py_None; Py_INCREF(p->unichar);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Glyph[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya_Glyph[] = {
  {"_pixels_x1", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, _pixels_x1), READONLY, 0},
  {"_pixels_y1", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, _pixels_y1), READONLY, 0},
  {"_pixels_x2", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, _pixels_x2), READONLY, 0},
  {"_pixels_y2", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, _pixels_y2), READONLY, 0},
  {"width", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, width), READONLY, 0},
  {"height", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, height), READONLY, 0},
  {"y", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, y), READONLY, 0},
  {"x", T_FLOAT, offsetof(struct __pyx_obj_5_soya_Glyph, x), READONLY, 0},
  {"unichar", T_OBJECT, offsetof(struct __pyx_obj_5_soya_Glyph, unichar), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Glyph = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Glyph = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Glyph = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Glyph = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Glyph = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Glyph", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Glyph), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Glyph, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_5Glyph___repr__, /*tp_repr*/
  &__pyx_tp_as_number_Glyph, /*tp_as_number*/
  &__pyx_tp_as_sequence_Glyph, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Glyph, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Glyph, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Glyph, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Glyph, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Glyph, /*tp_methods*/
  __pyx_members_5_soya_Glyph, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_5Glyph___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Glyph, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Font __pyx_vtable_5_soya_Font;

static PyObject *__pyx_tp_new_5_soya_Font(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_Font *p = (struct __pyx_obj_5_soya_Font *)o;
  p->__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Font *)__pyx_vtabptr_5_soya_Font;
  p->filename = Py_None; Py_INCREF(p->filename);
  p->_glyphs = Py_None; Py_INCREF(p->_glyphs);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Font(PyObject *o) {
  struct __pyx_obj_5_soya_Font *p = (struct __pyx_obj_5_soya_Font *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_4Font___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->filename);
  Py_XDECREF(p->_glyphs);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya_Font(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Font *p = (struct __pyx_obj_5_soya_Font *)o;
  if (p->filename) {
    e = (*v)(p->filename, a); if (e) return e;
  }
  if (p->_glyphs) {
    e = (*v)(p->_glyphs, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Font(PyObject *o) {
  struct __pyx_obj_5_soya_Font *p = (struct __pyx_obj_5_soya_Font *)o;
  Py_XDECREF(p->filename);
  p->filename = Py_None; Py_INCREF(p->filename);
  Py_XDECREF(p->_glyphs);
  p->_glyphs = Py_None; Py_INCREF(p->_glyphs);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_4Font_height(PyObject *o, void *x) {
  return __pyx_f_5_soya_4Font_6height___get__(o);
}

static PyObject *__pyx_getprop_5_soya_4Font_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_4Font_5width___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya_Font[] = {
  {"get_glyph", (PyCFunction)__pyx_f_5_soya_4Font_get_glyph, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_glyphs", (PyCFunction)__pyx_f_5_soya_4Font_create_glyphs, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_print_size", (PyCFunction)__pyx_f_5_soya_4Font_get_print_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"wordwrap", (PyCFunction)__pyx_f_5_soya_4Font_wordwrap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_4Font_wordwrap},
  {"wordwrap_line", (PyCFunction)__pyx_f_5_soya_4Font_wordwrap_line, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_4Font_wordwrap_line},
  {"draw", (PyCFunction)__pyx_f_5_soya_4Font_draw, METH_VARARGS|METH_KEYWORDS, 0},
  {"draw_area", (PyCFunction)__pyx_f_5_soya_4Font_draw_area, METH_VARARGS|METH_KEYWORDS, 0},
  {"_image", (PyCFunction)__pyx_f_5_soya_4Font__image, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_4Font__image},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya_Font[] = {
  {"filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya_Font, filename), READONLY, 0},
  {"_current_height", T_INT, offsetof(struct __pyx_obj_5_soya_Font, _current_height), READONLY, 0},
  {"_pixels_height", T_INT, offsetof(struct __pyx_obj_5_soya_Font, _pixels_height), READONLY, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_Font[] = {
  {"height", __pyx_getprop_5_soya_4Font_height, 0, 0, 0},
  {"width", __pyx_getprop_5_soya_4Font_width, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Font = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Font = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Font = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Font = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Font = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Font", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Font), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Font, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_4Font___repr__, /*tp_repr*/
  &__pyx_tp_as_number_Font, /*tp_as_number*/
  &__pyx_tp_as_sequence_Font, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Font, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Font, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Font, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Font, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Font, /*tp_methods*/
  __pyx_members_5_soya_Font, /*tp_members*/
  __pyx_getsets_5_soya_Font, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_4Font___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Font, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Shapifier __pyx_vtable_5_soya_Shapifier;

static PyObject *__pyx_tp_new_5_soya_Shapifier(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya_Shapifier *p = (struct __pyx_obj_5_soya_Shapifier *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Shapifier *)__pyx_vtabptr_5_soya_Shapifier;
  return o;
}

static void __pyx_tp_dealloc_5_soya_Shapifier(PyObject *o) {
  struct __pyx_obj_5_soya_Shapifier *p = (struct __pyx_obj_5_soya_Shapifier *)o;
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_Shapifier(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Shapifier *p = (struct __pyx_obj_5_soya_Shapifier *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_Shapifier(PyObject *o) {
  struct __pyx_obj_5_soya_Shapifier *p = (struct __pyx_obj_5_soya_Shapifier *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Shapifier[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Shapifier = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Shapifier = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Shapifier = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Shapifier = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Shapifier = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Shapifier", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Shapifier), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Shapifier, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Shapifier, /*tp_as_number*/
  &__pyx_tp_as_sequence_Shapifier, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Shapifier, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Shapifier, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Shapifier, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Shapifier, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Shapifier, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Shapifier, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Traveling __pyx_vtable_5_soya_Traveling;

static PyObject *__pyx_tp_new_5_soya_Traveling(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya_Traveling *p = (struct __pyx_obj_5_soya_Traveling *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Traveling *)__pyx_vtabptr_5_soya_Traveling;
  p->_incline_as = Py_None; Py_INCREF((PyObject *) p->_incline_as);
  return o;
}

static void __pyx_tp_dealloc_5_soya_Traveling(PyObject *o) {
  struct __pyx_obj_5_soya_Traveling *p = (struct __pyx_obj_5_soya_Traveling *)o;
  Py_XDECREF((PyObject *)p->_incline_as);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_Traveling(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Traveling *p = (struct __pyx_obj_5_soya_Traveling *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  if (p->_incline_as) {
    e = (*v)(((PyObject*)p->_incline_as), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_Traveling(PyObject *o) {
  struct __pyx_obj_5_soya_Traveling *p = (struct __pyx_obj_5_soya_Traveling *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  Py_XDECREF((PyObject *)p->_incline_as);
  p->_incline_as = Py_None; Py_INCREF((PyObject *) p->_incline_as);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_9Traveling_incline_as(PyObject *o, void *x) {
  return __pyx_f_5_soya_9Traveling_10incline_as___get__(o);
}

static int __pyx_setprop_5_soya_9Traveling_incline_as(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9Traveling_10incline_as___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9Traveling_smooth_move(PyObject *o, void *x) {
  return __pyx_f_5_soya_9Traveling_11smooth_move___get__(o);
}

static int __pyx_setprop_5_soya_9Traveling_smooth_move(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9Traveling_11smooth_move___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9Traveling_smooth_rotation(PyObject *o, void *x) {
  return __pyx_f_5_soya_9Traveling_15smooth_rotation___get__(o);
}

static int __pyx_setprop_5_soya_9Traveling_smooth_rotation(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9Traveling_15smooth_rotation___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_Traveling[] = {
  {"best_position", (PyCFunction)__pyx_f_5_soya_9Traveling_best_position, METH_VARARGS|METH_KEYWORDS, 0},
  {"best_direction", (PyCFunction)__pyx_f_5_soya_9Traveling_best_direction, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_Traveling[] = {
  {"incline_as", __pyx_getprop_5_soya_9Traveling_incline_as, __pyx_setprop_5_soya_9Traveling_incline_as, 0, 0},
  {"smooth_move", __pyx_getprop_5_soya_9Traveling_smooth_move, __pyx_setprop_5_soya_9Traveling_smooth_move, 0, 0},
  {"smooth_rotation", __pyx_getprop_5_soya_9Traveling_smooth_rotation, __pyx_setprop_5_soya_9Traveling_smooth_rotation, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Traveling = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Traveling = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Traveling = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Traveling = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Traveling = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Traveling", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Traveling), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Traveling, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Traveling, /*tp_as_number*/
  &__pyx_tp_as_sequence_Traveling, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Traveling, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Traveling, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Traveling, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Traveling, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Traveling, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_Traveling, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Traveling, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__TravelingCamera __pyx_vtable_5_soya__TravelingCamera;

static PyObject *__pyx_tp_new_5_soya__TravelingCamera(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Camera->tp_new(t, a, k);
  struct __pyx_obj_5_soya__TravelingCamera *p = (struct __pyx_obj_5_soya__TravelingCamera *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__TravelingCamera *)__pyx_vtabptr_5_soya__TravelingCamera;
  p->_travelings = Py_None; Py_INCREF(p->_travelings);
  p->_traveling = Py_None; Py_INCREF((PyObject *) p->_traveling);
  p->_speed = Py_None; Py_INCREF((PyObject *) p->_speed);
  return o;
}

static void __pyx_tp_dealloc_5_soya__TravelingCamera(PyObject *o) {
  struct __pyx_obj_5_soya__TravelingCamera *p = (struct __pyx_obj_5_soya__TravelingCamera *)o;
  Py_XDECREF(p->_travelings);
  Py_XDECREF((PyObject *)p->_traveling);
  Py_XDECREF((PyObject *)p->_speed);
  __pyx_ptype_5_soya__Camera->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__TravelingCamera(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__TravelingCamera *p = (struct __pyx_obj_5_soya__TravelingCamera *)o;
  __pyx_ptype_5_soya__Camera->tp_traverse(o, v, a);
  if (p->_travelings) {
    e = (*v)(p->_travelings, a); if (e) return e;
  }
  if (p->_traveling) {
    e = (*v)(((PyObject*)p->_traveling), a); if (e) return e;
  }
  if (p->_speed) {
    e = (*v)(((PyObject*)p->_speed), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__TravelingCamera(PyObject *o) {
  struct __pyx_obj_5_soya__TravelingCamera *p = (struct __pyx_obj_5_soya__TravelingCamera *)o;
  __pyx_ptype_5_soya__Camera->tp_clear(o);
  Py_XDECREF(p->_travelings);
  p->_travelings = Py_None; Py_INCREF(p->_travelings);
  Py_XDECREF((PyObject *)p->_traveling);
  p->_traveling = Py_None; Py_INCREF((PyObject *) p->_traveling);
  Py_XDECREF((PyObject *)p->_speed);
  p->_speed = Py_None; Py_INCREF((PyObject *) p->_speed);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_16_TravelingCamera_traveling(PyObject *o, void *x) {
  return __pyx_f_5_soya_16_TravelingCamera_9traveling___get__(o);
}

static PyObject *__pyx_getprop_5_soya_16_TravelingCamera_travelings(PyObject *o, void *x) {
  return __pyx_f_5_soya_16_TravelingCamera_10travelings___get__(o);
}

static PyObject *__pyx_getprop_5_soya_16_TravelingCamera_speed(PyObject *o, void *x) {
  return __pyx_f_5_soya_16_TravelingCamera_5speed___get__(o);
}

static int __pyx_setprop_5_soya_16_TravelingCamera_speed(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_16_TravelingCamera_5speed___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__TravelingCamera[] = {
  {"add_traveling", (PyCFunction)__pyx_f_5_soya_16_TravelingCamera_add_traveling, METH_VARARGS|METH_KEYWORDS, 0},
  {"pop_traveling", (PyCFunction)__pyx_f_5_soya_16_TravelingCamera_pop_traveling, METH_VARARGS|METH_KEYWORDS, 0},
  {"remove_traveling", (PyCFunction)__pyx_f_5_soya_16_TravelingCamera_remove_traveling, METH_VARARGS|METH_KEYWORDS, 0},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_16_TravelingCamera_advance_time, METH_VARARGS|METH_KEYWORDS, 0},
  {"zap", (PyCFunction)__pyx_f_5_soya_16_TravelingCamera_zap, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__TravelingCamera[] = {
  {"traveling", __pyx_getprop_5_soya_16_TravelingCamera_traveling, 0, 0, 0},
  {"travelings", __pyx_getprop_5_soya_16_TravelingCamera_travelings, 0, 0, 0},
  {"speed", __pyx_getprop_5_soya_16_TravelingCamera_speed, __pyx_setprop_5_soya_16_TravelingCamera_speed, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__TravelingCamera = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__TravelingCamera = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__TravelingCamera = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__TravelingCamera = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__TravelingCamera = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._TravelingCamera", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__TravelingCamera), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__TravelingCamera, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__TravelingCamera, /*tp_as_number*/
  &__pyx_tp_as_sequence__TravelingCamera, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__TravelingCamera, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__TravelingCamera, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__TravelingCamera, /*tp_traverse*/
  __pyx_tp_clear_5_soya__TravelingCamera, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__TravelingCamera, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__TravelingCamera, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_16_TravelingCamera___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__TravelingCamera, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__NoBackgroundAtmosphere __pyx_vtable_5_soya__NoBackgroundAtmosphere;

static PyObject *__pyx_tp_new_5_soya__NoBackgroundAtmosphere(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Atmosphere->tp_new(t, a, k);
  struct __pyx_obj_5_soya__NoBackgroundAtmosphere *p = (struct __pyx_obj_5_soya__NoBackgroundAtmosphere *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__NoBackgroundAtmosphere *)__pyx_vtabptr_5_soya__NoBackgroundAtmosphere;
  return o;
}

static void __pyx_tp_dealloc_5_soya__NoBackgroundAtmosphere(PyObject *o) {
  struct __pyx_obj_5_soya__NoBackgroundAtmosphere *p = (struct __pyx_obj_5_soya__NoBackgroundAtmosphere *)o;
  __pyx_ptype_5_soya__Atmosphere->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__NoBackgroundAtmosphere(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__NoBackgroundAtmosphere *p = (struct __pyx_obj_5_soya__NoBackgroundAtmosphere *)o;
  __pyx_ptype_5_soya__Atmosphere->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__NoBackgroundAtmosphere(PyObject *o) {
  struct __pyx_obj_5_soya__NoBackgroundAtmosphere *p = (struct __pyx_obj_5_soya__NoBackgroundAtmosphere *)o;
  __pyx_ptype_5_soya__Atmosphere->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__NoBackgroundAtmosphere[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__NoBackgroundAtmosphere = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__NoBackgroundAtmosphere = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__NoBackgroundAtmosphere = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__NoBackgroundAtmosphere = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__NoBackgroundAtmosphere = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._NoBackgroundAtmosphere", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__NoBackgroundAtmosphere), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__NoBackgroundAtmosphere, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__NoBackgroundAtmosphere, /*tp_as_number*/
  &__pyx_tp_as_sequence__NoBackgroundAtmosphere, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__NoBackgroundAtmosphere, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__NoBackgroundAtmosphere, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__NoBackgroundAtmosphere, /*tp_traverse*/
  __pyx_tp_clear_5_soya__NoBackgroundAtmosphere, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__NoBackgroundAtmosphere, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__NoBackgroundAtmosphere, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__SkyAtmosphere __pyx_vtable_5_soya__SkyAtmosphere;

static PyObject *__pyx_tp_new_5_soya__SkyAtmosphere(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Atmosphere->tp_new(t, a, k);
  struct __pyx_obj_5_soya__SkyAtmosphere *p = (struct __pyx_obj_5_soya__SkyAtmosphere *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__SkyAtmosphere *)__pyx_vtabptr_5_soya__SkyAtmosphere;
  p->_cloud = Py_None; Py_INCREF((PyObject *) p->_cloud);
  p->_sky_box = Py_None; Py_INCREF(p->_sky_box);
  return o;
}

static void __pyx_tp_dealloc_5_soya__SkyAtmosphere(PyObject *o) {
  struct __pyx_obj_5_soya__SkyAtmosphere *p = (struct __pyx_obj_5_soya__SkyAtmosphere *)o;
  Py_XDECREF((PyObject *)p->_cloud);
  Py_XDECREF(p->_sky_box);
  __pyx_ptype_5_soya__Atmosphere->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__SkyAtmosphere(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__SkyAtmosphere *p = (struct __pyx_obj_5_soya__SkyAtmosphere *)o;
  __pyx_ptype_5_soya__Atmosphere->tp_traverse(o, v, a);
  if (p->_cloud) {
    e = (*v)(((PyObject*)p->_cloud), a); if (e) return e;
  }
  if (p->_sky_box) {
    e = (*v)(p->_sky_box, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__SkyAtmosphere(PyObject *o) {
  struct __pyx_obj_5_soya__SkyAtmosphere *p = (struct __pyx_obj_5_soya__SkyAtmosphere *)o;
  __pyx_ptype_5_soya__Atmosphere->tp_clear(o);
  Py_XDECREF((PyObject *)p->_cloud);
  p->_cloud = Py_None; Py_INCREF((PyObject *) p->_cloud);
  Py_XDECREF(p->_sky_box);
  p->_sky_box = Py_None; Py_INCREF(p->_sky_box);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_14_SkyAtmosphere_sky_box(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_SkyAtmosphere_7sky_box___get__(o);
}

static int __pyx_setprop_5_soya_14_SkyAtmosphere_sky_box(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_SkyAtmosphere_7sky_box___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_14_SkyAtmosphere_sky_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_SkyAtmosphere_9sky_color___get__(o);
}

static int __pyx_setprop_5_soya_14_SkyAtmosphere_sky_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_SkyAtmosphere_9sky_color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_14_SkyAtmosphere_cloud(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_SkyAtmosphere_5cloud___get__(o);
}

static int __pyx_setprop_5_soya_14_SkyAtmosphere_cloud(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_SkyAtmosphere_5cloud___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_14_SkyAtmosphere_cloud_scale(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_SkyAtmosphere_11cloud_scale___get__(o);
}

static int __pyx_setprop_5_soya_14_SkyAtmosphere_cloud_scale(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_SkyAtmosphere_11cloud_scale___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__SkyAtmosphere[] = {
  {"set_sky_box", (PyCFunction)__pyx_f_5_soya_14_SkyAtmosphere_set_sky_box, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_14_SkyAtmosphere_set_sky_box},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__SkyAtmosphere[] = {
  {"sky_box", __pyx_getprop_5_soya_14_SkyAtmosphere_sky_box, __pyx_setprop_5_soya_14_SkyAtmosphere_sky_box, 0, 0},
  {"sky_color", __pyx_getprop_5_soya_14_SkyAtmosphere_sky_color, __pyx_setprop_5_soya_14_SkyAtmosphere_sky_color, 0, 0},
  {"cloud", __pyx_getprop_5_soya_14_SkyAtmosphere_cloud, __pyx_setprop_5_soya_14_SkyAtmosphere_cloud, 0, 0},
  {"cloud_scale", __pyx_getprop_5_soya_14_SkyAtmosphere_cloud_scale, __pyx_setprop_5_soya_14_SkyAtmosphere_cloud_scale, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SkyAtmosphere = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__SkyAtmosphere = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__SkyAtmosphere = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SkyAtmosphere = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__SkyAtmosphere = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._SkyAtmosphere", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__SkyAtmosphere), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__SkyAtmosphere, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SkyAtmosphere, /*tp_as_number*/
  &__pyx_tp_as_sequence__SkyAtmosphere, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SkyAtmosphere, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SkyAtmosphere, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__SkyAtmosphere, /*tp_traverse*/
  __pyx_tp_clear_5_soya__SkyAtmosphere, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__SkyAtmosphere, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__SkyAtmosphere, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_14_SkyAtmosphere___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__SkyAtmosphere, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_PythonCoordSyst __pyx_vtable_5_soya_PythonCoordSyst;

static PyObject *__pyx_tp_new_5_soya_PythonCoordSyst(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya_PythonCoordSyst *p = (struct __pyx_obj_5_soya_PythonCoordSyst *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_PythonCoordSyst *)__pyx_vtabptr_5_soya_PythonCoordSyst;
  return o;
}

static void __pyx_tp_dealloc_5_soya_PythonCoordSyst(PyObject *o) {
  struct __pyx_obj_5_soya_PythonCoordSyst *p = (struct __pyx_obj_5_soya_PythonCoordSyst *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_PythonCoordSyst(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_PythonCoordSyst *p = (struct __pyx_obj_5_soya_PythonCoordSyst *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_PythonCoordSyst(PyObject *o) {
  struct __pyx_obj_5_soya_PythonCoordSyst *p = (struct __pyx_obj_5_soya_PythonCoordSyst *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_PythonCoordSyst[] = {
  {"batch", (PyCFunction)__pyx_f_5_soya_15PythonCoordSyst_batch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_15PythonCoordSyst_batch},
  {"render", (PyCFunction)__pyx_f_5_soya_15PythonCoordSyst_render, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_15PythonCoordSyst_render},
  {"shadow", (PyCFunction)__pyx_f_5_soya_15PythonCoordSyst_shadow, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PythonCoordSyst = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_PythonCoordSyst = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_PythonCoordSyst = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PythonCoordSyst = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_PythonCoordSyst = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.PythonCoordSyst", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_PythonCoordSyst), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_PythonCoordSyst, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_PythonCoordSyst, /*tp_as_number*/
  &__pyx_tp_as_sequence_PythonCoordSyst, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PythonCoordSyst, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PythonCoordSyst, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "A CoordSyst whose rendering part is implemented in Python.\nThis class is destinated to be inherited.\nYou should override the batch and render methods.\n", /*tp_doc*/
  __pyx_tp_traverse_5_soya_PythonCoordSyst, /*tp_traverse*/
  __pyx_tp_clear_5_soya_PythonCoordSyst, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_PythonCoordSyst, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_PythonCoordSyst, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_CoordSystState __pyx_vtable_5_soya_CoordSystState;

static PyObject *__pyx_tp_new_5_soya_CoordSystState(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya_CoordSystState *p = (struct __pyx_obj_5_soya_CoordSystState *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_CoordSystState *)__pyx_vtabptr_5_soya_CoordSystState;
  return o;
}

static void __pyx_tp_dealloc_5_soya_CoordSystState(PyObject *o) {
  struct __pyx_obj_5_soya_CoordSystState *p = (struct __pyx_obj_5_soya_CoordSystState *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_CoordSystState(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_CoordSystState *p = (struct __pyx_obj_5_soya_CoordSystState *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_CoordSystState(PyObject *o) {
  struct __pyx_obj_5_soya_CoordSystState *p = (struct __pyx_obj_5_soya_CoordSystState *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_14CoordSystState_quaternion(PyObject *o, void *x) {
  return __pyx_f_5_soya_14CoordSystState_10quaternion___get__(o);
}

static int __pyx_setprop_5_soya_14CoordSystState_quaternion(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14CoordSystState_10quaternion___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_CoordSystState[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_CoordSystState[] = {
  {"quaternion", __pyx_getprop_5_soya_14CoordSystState_quaternion, __pyx_setprop_5_soya_14CoordSystState_quaternion, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CoordSystState = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_CoordSystState = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CoordSystState = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CoordSystState = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_CoordSystState = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.CoordSystState", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_CoordSystState), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_CoordSystState, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_CoordSystState, /*tp_as_number*/
  &__pyx_tp_as_sequence_CoordSystState, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CoordSystState, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CoordSystState, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "CoordSystState\n\nA State that take care of CoordSyst position, rotation and scaling.\n\nCoordSystState extend CoordSyst, and thus have similar method (e.g. set_xyz, rotate_*,\nscale, ...)", /*tp_doc*/
  __pyx_tp_traverse_5_soya_CoordSystState, /*tp_traverse*/
  __pyx_tp_clear_5_soya_CoordSystState, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_CoordSystState, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_CoordSystState, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_14CoordSystState___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_CoordSystState, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__FixTraveling __pyx_vtable_5_soya__FixTraveling;

static PyObject *__pyx_tp_new_5_soya__FixTraveling(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_Traveling->tp_new(t, a, k);
  struct __pyx_obj_5_soya__FixTraveling *p = (struct __pyx_obj_5_soya__FixTraveling *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__FixTraveling *)__pyx_vtabptr_5_soya__FixTraveling;
  p->_target = Py_None; Py_INCREF((PyObject *) p->_target);
  p->_direction = Py_None; Py_INCREF((PyObject *) p->_direction);
  return o;
}

static void __pyx_tp_dealloc_5_soya__FixTraveling(PyObject *o) {
  struct __pyx_obj_5_soya__FixTraveling *p = (struct __pyx_obj_5_soya__FixTraveling *)o;
  Py_XDECREF((PyObject *)p->_target);
  Py_XDECREF((PyObject *)p->_direction);
  __pyx_ptype_5_soya_Traveling->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__FixTraveling(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__FixTraveling *p = (struct __pyx_obj_5_soya__FixTraveling *)o;
  __pyx_ptype_5_soya_Traveling->tp_traverse(o, v, a);
  if (p->_target) {
    e = (*v)(((PyObject*)p->_target), a); if (e) return e;
  }
  if (p->_direction) {
    e = (*v)(((PyObject*)p->_direction), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__FixTraveling(PyObject *o) {
  struct __pyx_obj_5_soya__FixTraveling *p = (struct __pyx_obj_5_soya__FixTraveling *)o;
  __pyx_ptype_5_soya_Traveling->tp_clear(o);
  Py_XDECREF((PyObject *)p->_target);
  p->_target = Py_None; Py_INCREF((PyObject *) p->_target);
  Py_XDECREF((PyObject *)p->_direction);
  p->_direction = Py_None; Py_INCREF((PyObject *) p->_direction);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_13_FixTraveling_target(PyObject *o, void *x) {
  return __pyx_f_5_soya_13_FixTraveling_6target___get__(o);
}

static int __pyx_setprop_5_soya_13_FixTraveling_target(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_13_FixTraveling_6target___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_13_FixTraveling_direction(PyObject *o, void *x) {
  return __pyx_f_5_soya_13_FixTraveling_9direction___get__(o);
}

static int __pyx_setprop_5_soya_13_FixTraveling_direction(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_13_FixTraveling_9direction___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__FixTraveling[] = {
  {"best_position", (PyCFunction)__pyx_f_5_soya_13_FixTraveling_best_position, METH_VARARGS|METH_KEYWORDS, 0},
  {"best_direction", (PyCFunction)__pyx_f_5_soya_13_FixTraveling_best_direction, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__FixTraveling[] = {
  {"target", __pyx_getprop_5_soya_13_FixTraveling_target, __pyx_setprop_5_soya_13_FixTraveling_target, 0, 0},
  {"direction", __pyx_getprop_5_soya_13_FixTraveling_direction, __pyx_setprop_5_soya_13_FixTraveling_direction, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__FixTraveling = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__FixTraveling = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__FixTraveling = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__FixTraveling = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__FixTraveling = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._FixTraveling", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__FixTraveling), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__FixTraveling, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__FixTraveling, /*tp_as_number*/
  &__pyx_tp_as_sequence__FixTraveling, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__FixTraveling, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__FixTraveling, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A fixed view traveling.", /*tp_doc*/
  __pyx_tp_traverse_5_soya__FixTraveling, /*tp_traverse*/
  __pyx_tp_clear_5_soya__FixTraveling, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__FixTraveling, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__FixTraveling, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_13_FixTraveling___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__FixTraveling, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling __pyx_vtable_5_soya__ThirdPersonTraveling;

static PyObject *__pyx_tp_new_5_soya__ThirdPersonTraveling(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_Traveling->tp_new(t, a, k);
  struct __pyx_obj_5_soya__ThirdPersonTraveling *p = (struct __pyx_obj_5_soya__ThirdPersonTraveling *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__ThirdPersonTraveling *)__pyx_vtabptr_5_soya__ThirdPersonTraveling;
  p->_target = Py_None; Py_INCREF((PyObject *) p->_target);
  p->__target = Py_None; Py_INCREF((PyObject *) p->__target);
  p->_best = Py_None; Py_INCREF((PyObject *) p->_best);
  p->_result = Py_None; Py_INCREF((PyObject *) p->_result);
  p->__direction = Py_None; Py_INCREF((PyObject *) p->__direction);
  p->_direction = Py_None; Py_INCREF((PyObject *) p->_direction);
  p->__normal = Py_None; Py_INCREF((PyObject *) p->__normal);
  p->_context = Py_None; Py_INCREF((PyObject *) p->_context);
  return o;
}

static void __pyx_tp_dealloc_5_soya__ThirdPersonTraveling(PyObject *o) {
  struct __pyx_obj_5_soya__ThirdPersonTraveling *p = (struct __pyx_obj_5_soya__ThirdPersonTraveling *)o;
  Py_XDECREF((PyObject *)p->_target);
  Py_XDECREF((PyObject *)p->__target);
  Py_XDECREF((PyObject *)p->_best);
  Py_XDECREF((PyObject *)p->_result);
  Py_XDECREF((PyObject *)p->__direction);
  Py_XDECREF((PyObject *)p->_direction);
  Py_XDECREF((PyObject *)p->__normal);
  Py_XDECREF(p->_context);
  __pyx_ptype_5_soya_Traveling->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__ThirdPersonTraveling(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__ThirdPersonTraveling *p = (struct __pyx_obj_5_soya__ThirdPersonTraveling *)o;
  __pyx_ptype_5_soya_Traveling->tp_traverse(o, v, a);
  if (p->_target) {
    e = (*v)(((PyObject*)p->_target), a); if (e) return e;
  }
  if (p->__target) {
    e = (*v)(((PyObject*)p->__target), a); if (e) return e;
  }
  if (p->_best) {
    e = (*v)(((PyObject*)p->_best), a); if (e) return e;
  }
  if (p->_result) {
    e = (*v)(((PyObject*)p->_result), a); if (e) return e;
  }
  if (p->__direction) {
    e = (*v)(((PyObject*)p->__direction), a); if (e) return e;
  }
  if (p->_direction) {
    e = (*v)(((PyObject*)p->_direction), a); if (e) return e;
  }
  if (p->__normal) {
    e = (*v)(((PyObject*)p->__normal), a); if (e) return e;
  }
  if (p->_context) {
    e = (*v)(((PyObject*)p->_context), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__ThirdPersonTraveling(PyObject *o) {
  struct __pyx_obj_5_soya__ThirdPersonTraveling *p = (struct __pyx_obj_5_soya__ThirdPersonTraveling *)o;
  __pyx_ptype_5_soya_Traveling->tp_clear(o);
  Py_XDECREF((PyObject *)p->_target);
  p->_target = Py_None; Py_INCREF((PyObject *) p->_target);
  Py_XDECREF((PyObject *)p->__target);
  p->__target = Py_None; Py_INCREF((PyObject *) p->__target);
  Py_XDECREF((PyObject *)p->_best);
  p->_best = Py_None; Py_INCREF((PyObject *) p->_best);
  Py_XDECREF((PyObject *)p->_result);
  p->_result = Py_None; Py_INCREF((PyObject *) p->_result);
  Py_XDECREF((PyObject *)p->__direction);
  p->__direction = Py_None; Py_INCREF((PyObject *) p->__direction);
  Py_XDECREF((PyObject *)p->_direction);
  p->_direction = Py_None; Py_INCREF((PyObject *) p->_direction);
  Py_XDECREF((PyObject *)p->__normal);
  p->__normal = Py_None; Py_INCREF((PyObject *) p->__normal);
  Py_XDECREF(p->_context);
  p->_context = Py_None; Py_INCREF((PyObject *) p->_context);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_speed(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_5speed___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_speed(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_5speed___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_target(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_6target___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_target(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_6target___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_direction(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_9direction___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_direction(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_9direction___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_distance(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_8distance___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_distance(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_8distance___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_offset_y(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_8offset_y___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_offset_y(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_8offset_y___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_offset_y2(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_9offset_y2___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_offset_y2(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_9offset_y2___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_lateral_angle(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_13lateral_angle___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_lateral_angle(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_13lateral_angle___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_21_ThirdPersonTraveling_top_view(PyObject *o, void *x) {
  return __pyx_f_5_soya_21_ThirdPersonTraveling_8top_view___get__(o);
}

static int __pyx_setprop_5_soya_21_ThirdPersonTraveling_top_view(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_21_ThirdPersonTraveling_8top_view___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__ThirdPersonTraveling[] = {
  {"best_position", (PyCFunction)__pyx_f_5_soya_21_ThirdPersonTraveling_best_position, METH_VARARGS|METH_KEYWORDS, 0},
  {"best_direction", (PyCFunction)__pyx_f_5_soya_21_ThirdPersonTraveling_best_direction, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__ThirdPersonTraveling[] = {
  {"speed", __pyx_getprop_5_soya_21_ThirdPersonTraveling_speed, __pyx_setprop_5_soya_21_ThirdPersonTraveling_speed, 0, 0},
  {"target", __pyx_getprop_5_soya_21_ThirdPersonTraveling_target, __pyx_setprop_5_soya_21_ThirdPersonTraveling_target, 0, 0},
  {"direction", __pyx_getprop_5_soya_21_ThirdPersonTraveling_direction, __pyx_setprop_5_soya_21_ThirdPersonTraveling_direction, 0, 0},
  {"distance", __pyx_getprop_5_soya_21_ThirdPersonTraveling_distance, __pyx_setprop_5_soya_21_ThirdPersonTraveling_distance, 0, 0},
  {"offset_y", __pyx_getprop_5_soya_21_ThirdPersonTraveling_offset_y, __pyx_setprop_5_soya_21_ThirdPersonTraveling_offset_y, 0, 0},
  {"offset_y2", __pyx_getprop_5_soya_21_ThirdPersonTraveling_offset_y2, __pyx_setprop_5_soya_21_ThirdPersonTraveling_offset_y2, 0, 0},
  {"lateral_angle", __pyx_getprop_5_soya_21_ThirdPersonTraveling_lateral_angle, __pyx_setprop_5_soya_21_ThirdPersonTraveling_lateral_angle, 0, 0},
  {"top_view", __pyx_getprop_5_soya_21_ThirdPersonTraveling_top_view, __pyx_setprop_5_soya_21_ThirdPersonTraveling_top_view, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ThirdPersonTraveling = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__ThirdPersonTraveling = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__ThirdPersonTraveling = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ThirdPersonTraveling = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__ThirdPersonTraveling = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._ThirdPersonTraveling", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__ThirdPersonTraveling), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__ThirdPersonTraveling, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ThirdPersonTraveling, /*tp_as_number*/
  &__pyx_tp_as_sequence__ThirdPersonTraveling, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ThirdPersonTraveling, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ThirdPersonTraveling, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "A Tomb-Raider-like traveling.\nTARGET is a point in the character (or world) to follow.", /*tp_doc*/
  __pyx_tp_traverse_5_soya__ThirdPersonTraveling, /*tp_traverse*/
  __pyx_tp_clear_5_soya__ThirdPersonTraveling, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__ThirdPersonTraveling, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__ThirdPersonTraveling, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_21_ThirdPersonTraveling___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__ThirdPersonTraveling, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__PythonMaterial __pyx_vtable_5_soya__PythonMaterial;

static PyObject *__pyx_tp_new_5_soya__PythonMaterial(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Material->tp_new(t, a, k);
  struct __pyx_obj_5_soya__PythonMaterial *p = (struct __pyx_obj_5_soya__PythonMaterial *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__PythonMaterial *)__pyx_vtabptr_5_soya__PythonMaterial;
  return o;
}

static void __pyx_tp_dealloc_5_soya__PythonMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__PythonMaterial *p = (struct __pyx_obj_5_soya__PythonMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__PythonMaterial(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__PythonMaterial *p = (struct __pyx_obj_5_soya__PythonMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__PythonMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__PythonMaterial *p = (struct __pyx_obj_5_soya__PythonMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__PythonMaterial[] = {
  {"init_texture", (PyCFunction)__pyx_f_5_soya_15_PythonMaterial_init_texture, METH_VARARGS|METH_KEYWORDS, 0},
  {"activated", (PyCFunction)__pyx_f_5_soya_15_PythonMaterial_activated, METH_VARARGS|METH_KEYWORDS, 0},
  {"inactivated", (PyCFunction)__pyx_f_5_soya_15_PythonMaterial_inactivated, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__PythonMaterial = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__PythonMaterial = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__PythonMaterial = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__PythonMaterial = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__PythonMaterial = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._PythonMaterial", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__PythonMaterial), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__PythonMaterial, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__PythonMaterial, /*tp_as_number*/
  &__pyx_tp_as_sequence__PythonMaterial, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__PythonMaterial, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__PythonMaterial, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "A Material class that can be extended and hacked in Python.\nJust implement the following methods:\n  init_texture()\n  activated()\n  inactivated()", /*tp_doc*/
  __pyx_tp_traverse_5_soya__PythonMaterial, /*tp_traverse*/
  __pyx_tp_clear_5_soya__PythonMaterial, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__PythonMaterial, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__PythonMaterial, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__CylinderSprite __pyx_vtable_5_soya__CylinderSprite;

static PyObject *__pyx_tp_new_5_soya__CylinderSprite(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Sprite->tp_new(t, a, k);
  struct __pyx_obj_5_soya__CylinderSprite *p = (struct __pyx_obj_5_soya__CylinderSprite *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__CylinderSprite *)__pyx_vtabptr_5_soya__CylinderSprite;
  return o;
}

static void __pyx_tp_dealloc_5_soya__CylinderSprite(PyObject *o) {
  struct __pyx_obj_5_soya__CylinderSprite *p = (struct __pyx_obj_5_soya__CylinderSprite *)o;
  __pyx_ptype_5_soya__Sprite->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__CylinderSprite(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__CylinderSprite *p = (struct __pyx_obj_5_soya__CylinderSprite *)o;
  __pyx_ptype_5_soya__Sprite->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__CylinderSprite(PyObject *o) {
  struct __pyx_obj_5_soya__CylinderSprite *p = (struct __pyx_obj_5_soya__CylinderSprite *)o;
  __pyx_ptype_5_soya__Sprite->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__CylinderSprite[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__CylinderSprite = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__CylinderSprite = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__CylinderSprite = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__CylinderSprite = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__CylinderSprite = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._CylinderSprite", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__CylinderSprite), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__CylinderSprite, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__CylinderSprite, /*tp_as_number*/
  &__pyx_tp_as_sequence__CylinderSprite, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__CylinderSprite, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__CylinderSprite, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__CylinderSprite, /*tp_traverse*/
  __pyx_tp_clear_5_soya__CylinderSprite, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__CylinderSprite, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__CylinderSprite, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Bonus __pyx_vtable_5_soya__Bonus;

static PyObject *__pyx_tp_new_5_soya__Bonus(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Bonus *p = (struct __pyx_obj_5_soya__Bonus *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Bonus *)__pyx_vtabptr_5_soya__Bonus;
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  p->_halo = Py_None; Py_INCREF((PyObject *) p->_halo);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Bonus(PyObject *o) {
  struct __pyx_obj_5_soya__Bonus *p = (struct __pyx_obj_5_soya__Bonus *)o;
  Py_XDECREF((PyObject *)p->_material);
  Py_XDECREF((PyObject *)p->_halo);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Bonus(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Bonus *p = (struct __pyx_obj_5_soya__Bonus *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_material) {
    e = (*v)(((PyObject*)p->_material), a); if (e) return e;
  }
  if (p->_halo) {
    e = (*v)(((PyObject*)p->_halo), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Bonus(PyObject *o) {
  struct __pyx_obj_5_soya__Bonus *p = (struct __pyx_obj_5_soya__Bonus *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_material);
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  Py_XDECREF((PyObject *)p->_halo);
  p->_halo = Py_None; Py_INCREF((PyObject *) p->_halo);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_6_Bonus_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Bonus_5color___get__(o);
}

static int __pyx_setprop_5_soya_6_Bonus_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Bonus_5color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Bonus_material(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Bonus_8material___get__(o);
}

static int __pyx_setprop_5_soya_6_Bonus_material(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Bonus_8material___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Bonus_halo(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Bonus_4halo___get__(o);
}

static int __pyx_setprop_5_soya_6_Bonus_halo(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Bonus_4halo___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Bonus_lit(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Bonus_3lit___get__(o);
}

static int __pyx_setprop_5_soya_6_Bonus_lit(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Bonus_3lit___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Bonus[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Bonus[] = {
  {"color", __pyx_getprop_5_soya_6_Bonus_color, __pyx_setprop_5_soya_6_Bonus_color, 0, 0},
  {"material", __pyx_getprop_5_soya_6_Bonus_material, __pyx_setprop_5_soya_6_Bonus_material, 0, 0},
  {"halo", __pyx_getprop_5_soya_6_Bonus_halo, __pyx_setprop_5_soya_6_Bonus_halo, 0, 0},
  {"lit", __pyx_getprop_5_soya_6_Bonus_lit, __pyx_setprop_5_soya_6_Bonus_lit, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Bonus = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Bonus = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Bonus = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Bonus = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Bonus = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Bonus", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Bonus), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Bonus, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Bonus, /*tp_as_number*/
  &__pyx_tp_as_sequence__Bonus, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Bonus, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Bonus, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Bonus, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Bonus, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Bonus, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Bonus, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_6_Bonus___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Bonus, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Particles __pyx_vtable_5_soya__Particles;

static PyObject *__pyx_tp_new_5_soya__Particles(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Particles *p = (struct __pyx_obj_5_soya__Particles *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Particles *)__pyx_vtabptr_5_soya__Particles;
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  p->_particle_coordsyst = Py_None; Py_INCREF((PyObject *) p->_particle_coordsyst);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Particles(PyObject *o) {
  struct __pyx_obj_5_soya__Particles *p = (struct __pyx_obj_5_soya__Particles *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_10_Particles___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_material);
  Py_XDECREF((PyObject *)p->_particle_coordsyst);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Particles(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Particles *p = (struct __pyx_obj_5_soya__Particles *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_material) {
    e = (*v)(((PyObject*)p->_material), a); if (e) return e;
  }
  if (p->_particle_coordsyst) {
    e = (*v)(((PyObject*)p->_particle_coordsyst), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Particles(PyObject *o) {
  struct __pyx_obj_5_soya__Particles *p = (struct __pyx_obj_5_soya__Particles *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_material);
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  Py_XDECREF((PyObject *)p->_particle_coordsyst);
  p->_particle_coordsyst = Py_None; Py_INCREF((PyObject *) p->_particle_coordsyst);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_10_Particles_material(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_8material___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_material(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_8material___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_particle_coordsyst(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_18particle_coordsyst___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_particle_coordsyst(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_18particle_coordsyst___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_nb_particles(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_12nb_particles___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_nb_particles(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_12nb_particles___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_nb_max_particles(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_16nb_max_particles___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_nb_max_particles(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_16nb_max_particles___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_lit(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_3lit___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_lit(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_3lit___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_auto_generate_particle(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_22auto_generate_particle___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_auto_generate_particle(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_22auto_generate_particle___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_removable(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_9removable___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_removable(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_9removable___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_10_Particles_max_particles_per_round(PyObject *o, void *x) {
  return __pyx_f_5_soya_10_Particles_23max_particles_per_round___get__(o);
}

static int __pyx_setprop_5_soya_10_Particles_max_particles_per_round(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_10_Particles_23max_particles_per_round___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Particles[] = {
  {"regenerate", (PyCFunction)__pyx_f_5_soya_10_Particles_regenerate, METH_VARARGS|METH_KEYWORDS, 0},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_10_Particles_begin_round, METH_VARARGS|METH_KEYWORDS, 0},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_10_Particles_advance_time, METH_VARARGS|METH_KEYWORDS, 0},
  {"remove", (PyCFunction)__pyx_f_5_soya_10_Particles_remove, METH_VARARGS|METH_KEYWORDS, 0},
  {"generate", (PyCFunction)__pyx_f_5_soya_10_Particles_generate, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_particle", (PyCFunction)__pyx_f_5_soya_10_Particles_set_particle, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_particle2", (PyCFunction)__pyx_f_5_soya_10_Particles_set_particle2, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_particle_position", (PyCFunction)__pyx_f_5_soya_10_Particles_get_particle_position, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_particle_position", (PyCFunction)__pyx_f_5_soya_10_Particles_set_particle_position, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_colors", (PyCFunction)__pyx_f_5_soya_10_Particles_set_colors, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_sizes", (PyCFunction)__pyx_f_5_soya_10_Particles_set_sizes, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Particles[] = {
  {"material", __pyx_getprop_5_soya_10_Particles_material, __pyx_setprop_5_soya_10_Particles_material, 0, 0},
  {"particle_coordsyst", __pyx_getprop_5_soya_10_Particles_particle_coordsyst, __pyx_setprop_5_soya_10_Particles_particle_coordsyst, 0, 0},
  {"nb_particles", __pyx_getprop_5_soya_10_Particles_nb_particles, __pyx_setprop_5_soya_10_Particles_nb_particles, 0, 0},
  {"nb_max_particles", __pyx_getprop_5_soya_10_Particles_nb_max_particles, __pyx_setprop_5_soya_10_Particles_nb_max_particles, 0, 0},
  {"lit", __pyx_getprop_5_soya_10_Particles_lit, __pyx_setprop_5_soya_10_Particles_lit, 0, 0},
  {"auto_generate_particle", __pyx_getprop_5_soya_10_Particles_auto_generate_particle, __pyx_setprop_5_soya_10_Particles_auto_generate_particle, 0, 0},
  {"removable", __pyx_getprop_5_soya_10_Particles_removable, __pyx_setprop_5_soya_10_Particles_removable, 0, 0},
  {"max_particles_per_round", __pyx_getprop_5_soya_10_Particles_max_particles_per_round, __pyx_setprop_5_soya_10_Particles_max_particles_per_round, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Particles = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Particles = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Particles = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Particles = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Particles = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Particles", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Particles), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Particles, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Particles, /*tp_as_number*/
  &__pyx_tp_as_sequence__Particles, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Particles, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Particles, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Particles, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Particles, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Particles, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Particles, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_10_Particles___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Particles, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_FlagFirework __pyx_vtable_5_soya_FlagFirework;

static PyObject *__pyx_tp_new_5_soya_FlagFirework(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Particles->tp_new(t, a, k);
  struct __pyx_obj_5_soya_FlagFirework *p = (struct __pyx_obj_5_soya_FlagFirework *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_FlagFirework *)__pyx_vtabptr_5_soya_FlagFirework;
  p->_subgenerator = Py_None; Py_INCREF((PyObject *) p->_subgenerator);
  return o;
}

static void __pyx_tp_dealloc_5_soya_FlagFirework(PyObject *o) {
  struct __pyx_obj_5_soya_FlagFirework *p = (struct __pyx_obj_5_soya_FlagFirework *)o;
  Py_XDECREF((PyObject *)p->_subgenerator);
  __pyx_ptype_5_soya__Particles->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_FlagFirework(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_FlagFirework *p = (struct __pyx_obj_5_soya_FlagFirework *)o;
  __pyx_ptype_5_soya__Particles->tp_traverse(o, v, a);
  if (p->_subgenerator) {
    e = (*v)(((PyObject*)p->_subgenerator), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_FlagFirework(PyObject *o) {
  struct __pyx_obj_5_soya_FlagFirework *p = (struct __pyx_obj_5_soya_FlagFirework *)o;
  __pyx_ptype_5_soya__Particles->tp_clear(o);
  Py_XDECREF((PyObject *)p->_subgenerator);
  p->_subgenerator = Py_None; Py_INCREF((PyObject *) p->_subgenerator);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_FlagFirework[] = {
  {"remove", (PyCFunction)__pyx_f_5_soya_12FlagFirework_remove, METH_VARARGS|METH_KEYWORDS, 0},
  {"regenerate", (PyCFunction)__pyx_f_5_soya_12FlagFirework_regenerate, METH_VARARGS|METH_KEYWORDS, 0},
  {"subgenerate", (PyCFunction)__pyx_f_5_soya_12FlagFirework_subgenerate, METH_VARARGS|METH_KEYWORDS, 0},
  {"mygenerate", (PyCFunction)__pyx_f_5_soya_12FlagFirework_mygenerate, METH_VARARGS|METH_KEYWORDS, 0},
  {"generate", (PyCFunction)__pyx_f_5_soya_12FlagFirework_generate, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_FlagFirework = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_FlagFirework = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_FlagFirework = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_FlagFirework = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_FlagFirework = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.FlagFirework", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_FlagFirework), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_FlagFirework, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_FlagFirework, /*tp_as_number*/
  &__pyx_tp_as_sequence_FlagFirework, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_FlagFirework, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_FlagFirework, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_FlagFirework, /*tp_traverse*/
  __pyx_tp_clear_5_soya_FlagFirework, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_FlagFirework, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_12FlagFirework___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_FlagFirework, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_SimpleShapifier __pyx_vtable_5_soya_SimpleShapifier;

static PyObject *__pyx_tp_new_5_soya_SimpleShapifier(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_Shapifier->tp_new(t, a, k);
  struct __pyx_obj_5_soya_SimpleShapifier *p = (struct __pyx_obj_5_soya_SimpleShapifier *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_SimpleShapifier *)__pyx_vtabptr_5_soya_SimpleShapifier;
  return o;
}

static void __pyx_tp_dealloc_5_soya_SimpleShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_SimpleShapifier *p = (struct __pyx_obj_5_soya_SimpleShapifier *)o;
  __pyx_ptype_5_soya_Shapifier->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_SimpleShapifier(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_SimpleShapifier *p = (struct __pyx_obj_5_soya_SimpleShapifier *)o;
  __pyx_ptype_5_soya_Shapifier->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_SimpleShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_SimpleShapifier *p = (struct __pyx_obj_5_soya_SimpleShapifier *)o;
  __pyx_ptype_5_soya_Shapifier->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_15SimpleShapifier_shadow(PyObject *o, void *x) {
  return __pyx_f_5_soya_15SimpleShapifier_6shadow___get__(o);
}

static int __pyx_setprop_5_soya_15SimpleShapifier_shadow(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_15SimpleShapifier_6shadow___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_15SimpleShapifier_max_face_angle(PyObject *o, void *x) {
  return __pyx_f_5_soya_15SimpleShapifier_14max_face_angle___get__(o);
}

static int __pyx_setprop_5_soya_15SimpleShapifier_max_face_angle(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_15SimpleShapifier_14max_face_angle___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_SimpleShapifier[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_SimpleShapifier[] = {
  {"shadow", __pyx_getprop_5_soya_15SimpleShapifier_shadow, __pyx_setprop_5_soya_15SimpleShapifier_shadow, 0, 0},
  {"max_face_angle", __pyx_getprop_5_soya_15SimpleShapifier_max_face_angle, __pyx_setprop_5_soya_15SimpleShapifier_max_face_angle, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SimpleShapifier = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_SimpleShapifier = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SimpleShapifier = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SimpleShapifier = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_SimpleShapifier = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.SimpleShapifier", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_SimpleShapifier), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_SimpleShapifier, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_SimpleShapifier, /*tp_as_number*/
  &__pyx_tp_as_sequence_SimpleShapifier, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SimpleShapifier, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SimpleShapifier, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "SimpleShapifier\n\nShapifier for simple / normal / regular Shape. The SimpleShapifier attributes allows to\ncustomize the World -> Shape computation.\n\nAttributes are :\n\n - shadow (default 0) : enable shadows\n\n - max_face_angle (default 80.0) : if the angle (in degree) between 2 faces is less than\n   this value, vertices of the two faces can be merged if they are enough close. Set it\n   to 180.0 or more to disable this feature.", /*tp_doc*/
  __pyx_tp_traverse_5_soya_SimpleShapifier, /*tp_traverse*/
  __pyx_tp_clear_5_soya_SimpleShapifier, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_SimpleShapifier, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_SimpleShapifier, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_15SimpleShapifier___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_SimpleShapifier, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_TreeShapifier __pyx_vtable_5_soya_TreeShapifier;

static PyObject *__pyx_tp_new_5_soya_TreeShapifier(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_SimpleShapifier->tp_new(t, a, k);
  struct __pyx_obj_5_soya_TreeShapifier *p = (struct __pyx_obj_5_soya_TreeShapifier *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_TreeShapifier *)__pyx_vtabptr_5_soya_TreeShapifier;
  return o;
}

static void __pyx_tp_dealloc_5_soya_TreeShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_TreeShapifier *p = (struct __pyx_obj_5_soya_TreeShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_TreeShapifier(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_TreeShapifier *p = (struct __pyx_obj_5_soya_TreeShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_TreeShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_TreeShapifier *p = (struct __pyx_obj_5_soya_TreeShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_13TreeShapifier_collapsing_distance(PyObject *o, void *x) {
  return __pyx_f_5_soya_13TreeShapifier_19collapsing_distance___get__(o);
}

static int __pyx_setprop_5_soya_13TreeShapifier_collapsing_distance(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_13TreeShapifier_19collapsing_distance___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_13TreeShapifier_quality(PyObject *o, void *x) {
  return __pyx_f_5_soya_13TreeShapifier_7quality___get__(o);
}

static int __pyx_setprop_5_soya_13TreeShapifier_quality(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_13TreeShapifier_7quality___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_13TreeShapifier_max_child_radius(PyObject *o, void *x) {
  return __pyx_f_5_soya_13TreeShapifier_16max_child_radius___get__(o);
}

static int __pyx_setprop_5_soya_13TreeShapifier_max_child_radius(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_13TreeShapifier_16max_child_radius___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_TreeShapifier[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_TreeShapifier[] = {
  {"collapsing_distance", __pyx_getprop_5_soya_13TreeShapifier_collapsing_distance, __pyx_setprop_5_soya_13TreeShapifier_collapsing_distance, 0, 0},
  {"quality", __pyx_getprop_5_soya_13TreeShapifier_quality, __pyx_setprop_5_soya_13TreeShapifier_quality, 0, 0},
  {"max_child_radius", __pyx_getprop_5_soya_13TreeShapifier_max_child_radius, __pyx_setprop_5_soya_13TreeShapifier_max_child_radius, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_TreeShapifier = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_TreeShapifier = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_TreeShapifier = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_TreeShapifier = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_TreeShapifier = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.TreeShapifier", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_TreeShapifier), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_TreeShapifier, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_TreeShapifier, /*tp_as_number*/
  &__pyx_tp_as_sequence_TreeShapifier, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_TreeShapifier, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_TreeShapifier, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "TreeShapifier\n\nShapifier for tree-based Shape. Yields a TreeShape instead of a SimpleShape.\nTreeShape are optimized for big shape with lots of faces, espescially if all the faces\nare not visible at the same time (e.g. a game level). Both rendering and raypicking\nare optimized.\nInternally, the shape is broken down into several hierarchinal nodes, each node grouping\nclose faces.\n\nAttributes are :\n\n - shadow (default 0) : NOT IMPLEMENTED YET for tree\n\n - collapsing_distance (default 0.9) : this parameter tunes how many nodes are created.\n   If a child node\'s radius > parent node\'s radius X collapsing_distance, the child\n   and parent nodes are merged.\n\n - quality (default 0) : set to 1 to compute a slower but slightly more performant tree.\n\n - max_child_radius (default 0.5) : the maximum children node\'s radius, expressed in ratio\n   of the parent node\'s radius. Meaningfull only when quality == 0", /*tp_doc*/
  __pyx_tp_traverse_5_soya_TreeShapifier, /*tp_traverse*/
  __pyx_tp_clear_5_soya_TreeShapifier, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_TreeShapifier, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_TreeShapifier, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_13TreeShapifier___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_TreeShapifier, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_CellShadingShapifier __pyx_vtable_5_soya_CellShadingShapifier;

static PyObject *__pyx_tp_new_5_soya_CellShadingShapifier(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_SimpleShapifier->tp_new(t, a, k);
  struct __pyx_obj_5_soya_CellShadingShapifier *p = (struct __pyx_obj_5_soya_CellShadingShapifier *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_CellShadingShapifier *)__pyx_vtabptr_5_soya_CellShadingShapifier;
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  p->_outline_color = Py_None; Py_INCREF(p->_outline_color);
  return o;
}

static void __pyx_tp_dealloc_5_soya_CellShadingShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_CellShadingShapifier *p = (struct __pyx_obj_5_soya_CellShadingShapifier *)o;
  Py_XDECREF((PyObject *)p->_shader);
  Py_XDECREF(p->_outline_color);
  __pyx_ptype_5_soya_SimpleShapifier->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_CellShadingShapifier(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_CellShadingShapifier *p = (struct __pyx_obj_5_soya_CellShadingShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_traverse(o, v, a);
  if (p->_shader) {
    e = (*v)(((PyObject*)p->_shader), a); if (e) return e;
  }
  if (p->_outline_color) {
    e = (*v)(p->_outline_color, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya_CellShadingShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_CellShadingShapifier *p = (struct __pyx_obj_5_soya_CellShadingShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_clear(o);
  Py_XDECREF((PyObject *)p->_shader);
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  Py_XDECREF(p->_outline_color);
  p->_outline_color = Py_None; Py_INCREF(p->_outline_color);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_20CellShadingShapifier_shader(PyObject *o, void *x) {
  return __pyx_f_5_soya_20CellShadingShapifier_6shader___get__(o);
}

static int __pyx_setprop_5_soya_20CellShadingShapifier_shader(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_20CellShadingShapifier_6shader___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_20CellShadingShapifier_outline_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_20CellShadingShapifier_13outline_color___get__(o);
}

static int __pyx_setprop_5_soya_20CellShadingShapifier_outline_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_20CellShadingShapifier_13outline_color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_20CellShadingShapifier_outline_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_20CellShadingShapifier_13outline_width___get__(o);
}

static int __pyx_setprop_5_soya_20CellShadingShapifier_outline_width(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_20CellShadingShapifier_13outline_width___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_20CellShadingShapifier_outline_attenuation(PyObject *o, void *x) {
  return __pyx_f_5_soya_20CellShadingShapifier_19outline_attenuation___get__(o);
}

static int __pyx_setprop_5_soya_20CellShadingShapifier_outline_attenuation(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_20CellShadingShapifier_19outline_attenuation___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_CellShadingShapifier[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_CellShadingShapifier[] = {
  {"shader", __pyx_getprop_5_soya_20CellShadingShapifier_shader, __pyx_setprop_5_soya_20CellShadingShapifier_shader, 0, 0},
  {"outline_color", __pyx_getprop_5_soya_20CellShadingShapifier_outline_color, __pyx_setprop_5_soya_20CellShadingShapifier_outline_color, 0, 0},
  {"outline_width", __pyx_getprop_5_soya_20CellShadingShapifier_outline_width, __pyx_setprop_5_soya_20CellShadingShapifier_outline_width, 0, 0},
  {"outline_attenuation", __pyx_getprop_5_soya_20CellShadingShapifier_outline_attenuation, __pyx_setprop_5_soya_20CellShadingShapifier_outline_attenuation, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CellShadingShapifier = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_CellShadingShapifier = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_CellShadingShapifier = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CellShadingShapifier = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_CellShadingShapifier = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.CellShadingShapifier", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_CellShadingShapifier), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_CellShadingShapifier, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_CellShadingShapifier, /*tp_as_number*/
  &__pyx_tp_as_sequence_CellShadingShapifier, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CellShadingShapifier, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CellShadingShapifier, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CellShadingShapifier\n\nShapifier for cell-shaded Shape.\n\nAttributes are :\n\n - shadow (default 0) : enable shadows\n\n - shader : the material used for cell-shading lighting\n\n - outline_color (default black) : the color of the outline\n\n - outline_width (default 4.0) : the maximum line width when the cell-shaded shape\n   is very near the camera (set to 0.0 to disable outlines)\n\n - outline_attenuation (default : 0.3) : specify how much the distance affect the\n   outline_width\n", /*tp_doc*/
  __pyx_tp_traverse_5_soya_CellShadingShapifier, /*tp_traverse*/
  __pyx_tp_clear_5_soya_CellShadingShapifier, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_CellShadingShapifier, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_CellShadingShapifier, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_20CellShadingShapifier___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_CellShadingShapifier, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__Cal3dSubMesh __pyx_vtable_5_soya__Cal3dSubMesh;

static PyObject *__pyx_tp_new_5_soya__Cal3dSubMesh(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya__Cal3dSubMesh *p = (struct __pyx_obj_5_soya__Cal3dSubMesh *)o;
  p->__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Cal3dSubMesh *)__pyx_vtabptr_5_soya__Cal3dSubMesh;
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Cal3dSubMesh(PyObject *o) {
  struct __pyx_obj_5_soya__Cal3dSubMesh *p = (struct __pyx_obj_5_soya__Cal3dSubMesh *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_13_Cal3dSubMesh___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_material);
  (*o->ob_type->tp_free)(o);
}

static int __pyx_tp_traverse_5_soya__Cal3dSubMesh(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Cal3dSubMesh *p = (struct __pyx_obj_5_soya__Cal3dSubMesh *)o;
  if (p->_material) {
    e = (*v)(((PyObject*)p->_material), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Cal3dSubMesh(PyObject *o) {
  struct __pyx_obj_5_soya__Cal3dSubMesh *p = (struct __pyx_obj_5_soya__Cal3dSubMesh *)o;
  Py_XDECREF((PyObject *)p->_material);
  p->_material = Py_None; Py_INCREF((PyObject *) p->_material);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__Cal3dSubMesh[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Cal3dSubMesh = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__Cal3dSubMesh = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__Cal3dSubMesh = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Cal3dSubMesh = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Cal3dSubMesh = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Cal3dSubMesh", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Cal3dSubMesh), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Cal3dSubMesh, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Cal3dSubMesh, /*tp_as_number*/
  &__pyx_tp_as_sequence__Cal3dSubMesh, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Cal3dSubMesh, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Cal3dSubMesh, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__Cal3dSubMesh, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Cal3dSubMesh, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Cal3dSubMesh, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Cal3dSubMesh, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__SolidShape __pyx_vtable_5_soya__SolidShape;

static PyObject *__pyx_tp_new_5_soya__SolidShape(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__SimpleShape->tp_new(t, a, k);
  struct __pyx_obj_5_soya__SolidShape *p = (struct __pyx_obj_5_soya__SolidShape *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__SolidShape *)__pyx_vtabptr_5_soya__SolidShape;
  return o;
}

static void __pyx_tp_dealloc_5_soya__SolidShape(PyObject *o) {
  struct __pyx_obj_5_soya__SolidShape *p = (struct __pyx_obj_5_soya__SolidShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__SolidShape(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__SolidShape *p = (struct __pyx_obj_5_soya__SolidShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__SolidShape(PyObject *o) {
  struct __pyx_obj_5_soya__SolidShape *p = (struct __pyx_obj_5_soya__SolidShape *)o;
  __pyx_ptype_5_soya__SimpleShape->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__SolidShape[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SolidShape = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__SolidShape = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__SolidShape = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SolidShape = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__SolidShape = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._SolidShape", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__SolidShape), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__SolidShape, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SolidShape, /*tp_as_number*/
  &__pyx_tp_as_sequence__SolidShape, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SolidShape, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SolidShape, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__SolidShape, /*tp_traverse*/
  __pyx_tp_clear_5_soya__SolidShape, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__SolidShape, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__SolidShape, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__IdleingMaterial __pyx_vtable_5_soya__IdleingMaterial;

static PyObject *__pyx_tp_new_5_soya__IdleingMaterial(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Material->tp_new(t, a, k);
  struct __pyx_obj_5_soya__IdleingMaterial *p = (struct __pyx_obj_5_soya__IdleingMaterial *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__IdleingMaterial *)__pyx_vtabptr_5_soya__IdleingMaterial;
  return o;
}

static void __pyx_tp_dealloc_5_soya__IdleingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__IdleingMaterial *p = (struct __pyx_obj_5_soya__IdleingMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__IdleingMaterial(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__IdleingMaterial *p = (struct __pyx_obj_5_soya__IdleingMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__IdleingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__IdleingMaterial *p = (struct __pyx_obj_5_soya__IdleingMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__IdleingMaterial[] = {
  {"begin_round", (PyCFunction)__pyx_f_5_soya_16_IdleingMaterial_begin_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_16_IdleingMaterial_begin_round},
  {"end_round", (PyCFunction)__pyx_f_5_soya_16_IdleingMaterial_end_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_16_IdleingMaterial_end_round},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_16_IdleingMaterial_advance_time, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_16_IdleingMaterial_advance_time},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__IdleingMaterial = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__IdleingMaterial = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__IdleingMaterial = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__IdleingMaterial = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__IdleingMaterial = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._IdleingMaterial", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__IdleingMaterial), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__IdleingMaterial, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__IdleingMaterial, /*tp_as_number*/
  &__pyx_tp_as_sequence__IdleingMaterial, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__IdleingMaterial, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__IdleingMaterial, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__IdleingMaterial, /*tp_traverse*/
  __pyx_tp_clear_5_soya__IdleingMaterial, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__IdleingMaterial, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_16_IdleingMaterial___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__IdleingMaterial, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya__PythonIdleingMaterial __pyx_vtable_5_soya__PythonIdleingMaterial;

static PyObject *__pyx_tp_new_5_soya__PythonIdleingMaterial(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__IdleingMaterial->tp_new(t, a, k);
  struct __pyx_obj_5_soya__PythonIdleingMaterial *p = (struct __pyx_obj_5_soya__PythonIdleingMaterial *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__PythonIdleingMaterial *)__pyx_vtabptr_5_soya__PythonIdleingMaterial;
  return o;
}

static void __pyx_tp_dealloc_5_soya__PythonIdleingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__PythonIdleingMaterial *p = (struct __pyx_obj_5_soya__PythonIdleingMaterial *)o;
  __pyx_ptype_5_soya__IdleingMaterial->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__PythonIdleingMaterial(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__PythonIdleingMaterial *p = (struct __pyx_obj_5_soya__PythonIdleingMaterial *)o;
  __pyx_ptype_5_soya__IdleingMaterial->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__PythonIdleingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__PythonIdleingMaterial *p = (struct __pyx_obj_5_soya__PythonIdleingMaterial *)o;
  __pyx_ptype_5_soya__IdleingMaterial->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__PythonIdleingMaterial[] = {
  {"init_texture", (PyCFunction)__pyx_f_5_soya_22_PythonIdleingMaterial_init_texture, METH_VARARGS|METH_KEYWORDS, 0},
  {"activated", (PyCFunction)__pyx_f_5_soya_22_PythonIdleingMaterial_activated, METH_VARARGS|METH_KEYWORDS, 0},
  {"inactivated", (PyCFunction)__pyx_f_5_soya_22_PythonIdleingMaterial_inactivated, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__PythonIdleingMaterial = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence__PythonIdleingMaterial = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping__PythonIdleingMaterial = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__PythonIdleingMaterial = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__PythonIdleingMaterial = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._PythonIdleingMaterial", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__PythonIdleingMaterial), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__PythonIdleingMaterial, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__PythonIdleingMaterial, /*tp_as_number*/
  &__pyx_tp_as_sequence__PythonIdleingMaterial, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__PythonIdleingMaterial, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__PythonIdleingMaterial, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "A Material class that can be extended and hacked in Python.\nJust implement the following methods:\n  init_texture()\n  activated()\n  inactivated()\n\nIn addition to PythonMaterial, PythonIdleingMaterial also has begin_round, advance_time and end_round method.", /*tp_doc*/
  __pyx_tp_traverse_5_soya__PythonIdleingMaterial, /*tp_traverse*/
  __pyx_tp_clear_5_soya__PythonIdleingMaterial, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__PythonIdleingMaterial, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__PythonIdleingMaterial, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Fountain __pyx_vtable_5_soya_Fountain;

static PyObject *__pyx_tp_new_5_soya_Fountain(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Particles->tp_new(t, a, k);
  struct __pyx_obj_5_soya_Fountain *p = (struct __pyx_obj_5_soya_Fountain *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Fountain *)__pyx_vtabptr_5_soya_Fountain;
  return o;
}

static void __pyx_tp_dealloc_5_soya_Fountain(PyObject *o) {
  struct __pyx_obj_5_soya_Fountain *p = (struct __pyx_obj_5_soya_Fountain *)o;
  __pyx_ptype_5_soya__Particles->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_Fountain(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Fountain *p = (struct __pyx_obj_5_soya_Fountain *)o;
  __pyx_ptype_5_soya__Particles->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_Fountain(PyObject *o) {
  struct __pyx_obj_5_soya_Fountain *p = (struct __pyx_obj_5_soya_Fountain *)o;
  __pyx_ptype_5_soya__Particles->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Fountain[] = {
  {"generate", (PyCFunction)__pyx_f_5_soya_8Fountain_generate, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Fountain = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Fountain = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Fountain = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Fountain = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Fountain = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Fountain", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Fountain), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Fountain, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Fountain, /*tp_as_number*/
  &__pyx_tp_as_sequence_Fountain, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Fountain, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Fountain, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Fountain, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Fountain, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Fountain, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_8Fountain___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Fountain, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_Smoke __pyx_vtable_5_soya_Smoke;

static PyObject *__pyx_tp_new_5_soya_Smoke(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Particles->tp_new(t, a, k);
  struct __pyx_obj_5_soya_Smoke *p = (struct __pyx_obj_5_soya_Smoke *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_Smoke *)__pyx_vtabptr_5_soya_Smoke;
  return o;
}

static void __pyx_tp_dealloc_5_soya_Smoke(PyObject *o) {
  struct __pyx_obj_5_soya_Smoke *p = (struct __pyx_obj_5_soya_Smoke *)o;
  __pyx_ptype_5_soya__Particles->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_Smoke(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_Smoke *p = (struct __pyx_obj_5_soya_Smoke *)o;
  __pyx_ptype_5_soya__Particles->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_Smoke(PyObject *o) {
  struct __pyx_obj_5_soya_Smoke *p = (struct __pyx_obj_5_soya_Smoke *)o;
  __pyx_ptype_5_soya__Particles->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_Smoke[] = {
  {"generate", (PyCFunction)__pyx_f_5_soya_5Smoke_generate, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Smoke = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_Smoke = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Smoke = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Smoke = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_Smoke = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.Smoke", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_Smoke), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_Smoke, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_Smoke, /*tp_as_number*/
  &__pyx_tp_as_sequence_Smoke, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Smoke, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Smoke, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_Smoke, /*tp_traverse*/
  __pyx_tp_clear_5_soya_Smoke, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_Smoke, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_5Smoke___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_Smoke, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_FlagSubFire __pyx_vtable_5_soya_FlagSubFire;

static PyObject *__pyx_tp_new_5_soya_FlagSubFire(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Particles->tp_new(t, a, k);
  struct __pyx_obj_5_soya_FlagSubFire *p = (struct __pyx_obj_5_soya_FlagSubFire *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_FlagSubFire *)__pyx_vtabptr_5_soya_FlagSubFire;
  return o;
}

static void __pyx_tp_dealloc_5_soya_FlagSubFire(PyObject *o) {
  struct __pyx_obj_5_soya_FlagSubFire *p = (struct __pyx_obj_5_soya_FlagSubFire *)o;
  __pyx_ptype_5_soya__Particles->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_FlagSubFire(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_FlagSubFire *p = (struct __pyx_obj_5_soya_FlagSubFire *)o;
  __pyx_ptype_5_soya__Particles->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_FlagSubFire(PyObject *o) {
  struct __pyx_obj_5_soya_FlagSubFire *p = (struct __pyx_obj_5_soya_FlagSubFire *)o;
  __pyx_ptype_5_soya__Particles->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_FlagSubFire[] = {
  {"generate", (PyCFunction)__pyx_f_5_soya_11FlagSubFire_generate, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_FlagSubFire = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_FlagSubFire = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_FlagSubFire = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_FlagSubFire = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_FlagSubFire = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.FlagSubFire", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_FlagSubFire), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_FlagSubFire, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_FlagSubFire, /*tp_as_number*/
  &__pyx_tp_as_sequence_FlagSubFire, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_FlagSubFire, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_FlagSubFire, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_FlagSubFire, /*tp_traverse*/
  __pyx_tp_clear_5_soya_FlagSubFire, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_FlagSubFire, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_11FlagSubFire___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_FlagSubFire, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};
static struct __pyx_vtabstruct_5_soya_SolidShapifier __pyx_vtable_5_soya_SolidShapifier;

static PyObject *__pyx_tp_new_5_soya_SolidShapifier(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_SimpleShapifier->tp_new(t, a, k);
  struct __pyx_obj_5_soya_SolidShapifier *p = (struct __pyx_obj_5_soya_SolidShapifier *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_SolidShapifier *)__pyx_vtabptr_5_soya_SolidShapifier;
  return o;
}

static void __pyx_tp_dealloc_5_soya_SolidShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_SolidShapifier *p = (struct __pyx_obj_5_soya_SolidShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_SolidShapifier(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_SolidShapifier *p = (struct __pyx_obj_5_soya_SolidShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_SolidShapifier(PyObject *o) {
  struct __pyx_obj_5_soya_SolidShapifier *p = (struct __pyx_obj_5_soya_SolidShapifier *)o;
  __pyx_ptype_5_soya_SimpleShapifier->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_SolidShapifier[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SolidShapifier = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
};

static PySequenceMethods __pyx_tp_as_sequence_SolidShapifier = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_SolidShapifier = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SolidShapifier = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_SolidShapifier = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.SolidShapifier", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_SolidShapifier), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_SolidShapifier, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_SolidShapifier, /*tp_as_number*/
  &__pyx_tp_as_sequence_SolidShapifier, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SolidShapifier, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SolidShapifier, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "SolidShapifier\n", /*tp_doc*/
  __pyx_tp_traverse_5_soya_SolidShapifier, /*tp_traverse*/
  __pyx_tp_clear_5_soya_SolidShapifier, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_SolidShapifier, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_SolidShapifier, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"get_max_texture_size", (PyCFunction)__pyx_f_5_soya_get_max_texture_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"_set_default_material", (PyCFunction)__pyx_f_5_soya__set_default_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"_set_shader_default_material", (PyCFunction)__pyx_f_5_soya__set_shader_default_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"_reconstructor", (PyCFunction)__pyx_f_5_soya__reconstructor, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_quality", (PyCFunction)__pyx_f_5_soya_set_quality, METH_VARARGS|METH_KEYWORDS, 0},
  {"toggle_wireframe", (PyCFunction)__pyx_f_5_soya_toggle_wireframe, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_gamma", (PyCFunction)__pyx_f_5_soya_set_gamma, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_set_gamma},
  {"set_video", (PyCFunction)__pyx_f_5_soya_set_video, METH_VARARGS|METH_KEYWORDS, 0},
  {"init", (PyCFunction)__pyx_f_5_soya_init, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_init},
  {"quit", (PyCFunction)__pyx_f_5_soya_quit, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_use_unicode", (PyCFunction)__pyx_f_5_soya_set_use_unicode, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_set_use_unicode},
  {"process_event", (PyCFunction)__pyx_f_5_soya_process_event, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_mod", (PyCFunction)__pyx_f_5_soya_get_mod, METH_VARARGS|METH_KEYWORDS, 0},
  {"cursor_set_visible", (PyCFunction)__pyx_f_5_soya_cursor_set_visible, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_mouse_pos", (PyCFunction)__pyx_f_5_soya_set_mouse_pos, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_set_mouse_pos},
  {"get_grab_input", (PyCFunction)__pyx_f_5_soya_get_grab_input, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_get_grab_input},
  {"set_grab_input", (PyCFunction)__pyx_f_5_soya_set_grab_input, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_set_grab_input},
  {"clear_events", (PyCFunction)__pyx_f_5_soya_clear_events, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_clear_events},
  {"get_mouse_rel_pos", (PyCFunction)__pyx_f_5_soya_get_mouse_rel_pos, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_get_mouse_rel_pos},
  {"get_renderer", (PyCFunction)__pyx_f_5_soya_get_renderer, METH_VARARGS|METH_KEYWORDS, 0},
  {"check_error", (PyCFunction)__pyx_f_5_soya_check_error, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_root_widget", (PyCFunction)__pyx_f_5_soya_set_root_widget, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_set_root_widget},
  {"render", (PyCFunction)__pyx_f_5_soya_render, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_render},
  {"get_screen_width", (PyCFunction)__pyx_f_5_soya_get_screen_width, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_screen_height", (PyCFunction)__pyx_f_5_soya_get_screen_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"open_image", (PyCFunction)__pyx_f_5_soya_open_image, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_open_image},
  {"image_from_pil", (PyCFunction)__pyx_f_5_soya_image_from_pil, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_image_from_pil},
  {"screenshot", (PyCFunction)__pyx_f_5_soya_screenshot, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_screenshot},
  {"_set_particle_default_material", (PyCFunction)__pyx_f_5_soya__set_particle_default_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"_is_static_light", (PyCFunction)__pyx_f_5_soya__is_static_light, METH_VARARGS|METH_KEYWORDS, 0},
  {"_set_default_shapifier", (PyCFunction)__pyx_f_5_soya__set_default_shapifier, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_raw_image", (PyCFunction)__pyx_f_5_soya_load_raw_image, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_load_raw_image},
  {"parse_cal3d_cfg_file", (PyCFunction)__pyx_f_5_soya_parse_cal3d_cfg_file, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_parse_cal3d_cfg_file},
  {0, 0, 0, 0}
};

DL_EXPORT(void) init_soya(void); /*proto*/
DL_EXPORT(void) init_soya(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  __pyx_m = Py_InitModule4("_soya", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 19; goto __pyx_L1;};
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 19; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 19; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 19; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 19; goto __pyx_L1;};
  __pyx_v_5_soya_renderer = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya_renderer);
  __pyx_v_5_soya__DEFAULT_MATERIAL = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya__DEFAULT_MATERIAL);
  __pyx_v_5_soya__SHADER_DEFAULT_MATERIAL = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya__SHADER_DEFAULT_MATERIAL);
  __pyx_v_5_soya_DRIVER_3D = Py_None; Py_INCREF(__pyx_v_5_soya_DRIVER_3D);
  __pyx_v_5_soya_raypick_data = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya_raypick_data);
  __pyx_v_5_soya_LIGHTS = Py_None; Py_INCREF(__pyx_v_5_soya_LIGHTS);
  __pyx_v_5_soya_LAST_LIGHTS = Py_None; Py_INCREF(__pyx_v_5_soya_LAST_LIGHTS);
  __pyx_v_5_soya__PARTICLE_DEFAULT_MATERIAL = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya__PARTICLE_DEFAULT_MATERIAL);
  __pyx_v_5_soya__DEFAULT_SHAPIFIER = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya__DEFAULT_SHAPIFIER);
  __pyx_vtabptr_5_soya__CObj = &__pyx_vtable_5_soya__CObj;
  __pyx_vtable_5_soya__CObj.__getcstate__ = (void *)__pyx_f_5_soya_5_CObj___getcstate__;
  __pyx_vtable_5_soya__CObj.__setcstate__ = (void *)__pyx_f_5_soya_5_CObj___setcstate__;
  if (PyType_Ready(&__pyx_type_5_soya__CObj) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__CObj.tp_dict, __pyx_vtabptr_5_soya__CObj) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_CObj", (PyObject *)&__pyx_type_5_soya__CObj) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_ptype_5_soya__CObj = &__pyx_type_5_soya__CObj;
  __pyx_vtabptr_5_soya__Image = &__pyx_vtable_5_soya__Image;
  __pyx_vtable_5_soya__Image.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya__Image.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_6_Image___getcstate__;
  __pyx_vtable_5_soya__Image.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_6_Image___setcstate__;
  __pyx_vtable_5_soya__Image.check_for_gl = (void *)__pyx_f_5_soya_6_Image_check_for_gl;
  __pyx_vtable_5_soya__Image.typ = (void *)__pyx_f_5_soya_6_Image_typ;
  __pyx_vtable_5_soya__Image.internal_format = (void *)__pyx_f_5_soya_6_Image_internal_format;
  __pyx_type_5_soya__Image.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya__Image.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Image) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 70; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Image.tp_dict, __pyx_vtabptr_5_soya__Image) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 70; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Image", (PyObject *)&__pyx_type_5_soya__Image) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 70; goto __pyx_L1;}
  __pyx_ptype_5_soya__Image = &__pyx_type_5_soya__Image;
  __pyx_vtabptr_5_soya__Material = &__pyx_vtable_5_soya__Material;
  __pyx_vtable_5_soya__Material.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya__Material.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_9_Material___getcstate__;
  __pyx_vtable_5_soya__Material.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_9_Material___setcstate__;
  __pyx_vtable_5_soya__Material._pack = (void *)__pyx_f_5_soya_9_Material__pack;
  __pyx_vtable_5_soya__Material._init_texture = (void *)__pyx_f_5_soya_9_Material__init_texture;
  __pyx_vtable_5_soya__Material._build_2D_mipmaps = (void *)__pyx_f_5_soya_9_Material__build_2D_mipmaps;
  __pyx_vtable_5_soya__Material._compute_alpha = (void *)__pyx_f_5_soya_9_Material__compute_alpha;
  __pyx_vtable_5_soya__Material._activate = (void *)__pyx_f_5_soya_9_Material__activate;
  __pyx_vtable_5_soya__Material._inactivate = (void *)__pyx_f_5_soya_9_Material__inactivate;
  __pyx_type_5_soya__Material.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya__Material.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Material) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 20; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Material.tp_dict, __pyx_vtabptr_5_soya__Material) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Material", (PyObject *)&__pyx_type_5_soya__Material) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__Material = &__pyx_type_5_soya__Material;
  __pyx_vtabptr_5_soya__Shape = &__pyx_vtable_5_soya__Shape;
  __pyx_vtable_5_soya__Shape.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya__Shape._batch = (void *)__pyx_f_5_soya_6_Shape__batch;
  __pyx_vtable_5_soya__Shape._render = (void *)__pyx_f_5_soya_6_Shape__render;
  __pyx_vtable_5_soya__Shape._shadow = (void *)__pyx_f_5_soya_6_Shape__shadow;
  __pyx_vtable_5_soya__Shape._get_box = (void *)__pyx_f_5_soya_6_Shape__get_box;
  __pyx_vtable_5_soya__Shape._raypick = (void *)__pyx_f_5_soya_6_Shape__raypick;
  __pyx_vtable_5_soya__Shape._raypick_b = (void *)__pyx_f_5_soya_6_Shape__raypick_b;
  __pyx_vtable_5_soya__Shape._collect_raypickables = (void *)__pyx_f_5_soya_6_Shape__collect_raypickables;
  __pyx_type_5_soya__Shape.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya__Shape.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Shape) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Shape.tp_dict, __pyx_vtabptr_5_soya__Shape) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Shape", (PyObject *)&__pyx_type_5_soya__Shape) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__Shape = &__pyx_type_5_soya__Shape;
  __pyx_vtabptr_5_soya__SimpleShape = &__pyx_vtable_5_soya__SimpleShape;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base = *__pyx_vtabptr_5_soya__Shape;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_12_SimpleShape___getcstate__;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_12_SimpleShape___setcstate__;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._batch = (void *)__pyx_f_5_soya_12_SimpleShape__batch;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._render = (void *)__pyx_f_5_soya_12_SimpleShape__render;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._shadow = (void *)__pyx_f_5_soya_12_SimpleShape__shadow;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._get_box = (void *)__pyx_f_5_soya_12_SimpleShape__get_box;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._raypick = (void *)__pyx_f_5_soya_12_SimpleShape__raypick;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_12_SimpleShape__raypick_b;
  __pyx_vtable_5_soya__SimpleShape.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_12_SimpleShape__collect_raypickables;
  __pyx_vtable_5_soya__SimpleShape.__setcstate_data__ = (void *)__pyx_f_5_soya_12_SimpleShape___setcstate_data__;
  __pyx_vtable_5_soya__SimpleShape._register_material = (void *)__pyx_f_5_soya_12_SimpleShape__register_material;
  __pyx_vtable_5_soya__SimpleShape._add_coord = (void *)__pyx_f_5_soya_12_SimpleShape__add_coord;
  __pyx_vtable_5_soya__SimpleShape._register_value = (void *)__pyx_f_5_soya_12_SimpleShape__register_value;
  __pyx_vtable_5_soya__SimpleShape._register_color = (void *)__pyx_f_5_soya_12_SimpleShape__register_color;
  __pyx_vtable_5_soya__SimpleShape._add_face = (void *)__pyx_f_5_soya_12_SimpleShape__add_face;
  __pyx_vtable_5_soya__SimpleShape._add_vertex = (void *)__pyx_f_5_soya_12_SimpleShape__add_vertex;
  __pyx_vtable_5_soya__SimpleShape._identify_vertices = (void *)__pyx_f_5_soya_12_SimpleShape__identify_vertices;
  __pyx_vtable_5_soya__SimpleShape._compute_face_normals = (void *)__pyx_f_5_soya_12_SimpleShape__compute_face_normals;
  __pyx_vtable_5_soya__SimpleShape._compute_vertex_normals = (void *)__pyx_f_5_soya_12_SimpleShape__compute_vertex_normals;
  __pyx_vtable_5_soya__SimpleShape._compute_face_neighbors = (void *)__pyx_f_5_soya_12_SimpleShape__compute_face_neighbors;
  __pyx_vtable_5_soya__SimpleShape._build_sphere = (void *)__pyx_f_5_soya_12_SimpleShape__build_sphere;
  __pyx_vtable_5_soya__SimpleShape._build_display_list = (void *)__pyx_f_5_soya_12_SimpleShape__build_display_list;
  __pyx_vtable_5_soya__SimpleShape._init_display_list = (void *)__pyx_f_5_soya_12_SimpleShape__init_display_list;
  __pyx_vtable_5_soya__SimpleShape._batch_face = (void *)__pyx_f_5_soya_12_SimpleShape__batch_face;
  __pyx_vtable_5_soya__SimpleShape._face_raypick = (void *)__pyx_f_5_soya_12_SimpleShape__face_raypick;
  __pyx_vtable_5_soya__SimpleShape._face_raypick_b = (void *)__pyx_f_5_soya_12_SimpleShape__face_raypick_b;
  __pyx_vtable_5_soya__SimpleShape._render_triangle = (void *)__pyx_f_5_soya_12_SimpleShape__render_triangle;
  __pyx_vtable_5_soya__SimpleShape._render_quad = (void *)__pyx_f_5_soya_12_SimpleShape__render_quad;
  __pyx_vtable_5_soya__SimpleShape._render_vertex = (void *)__pyx_f_5_soya_12_SimpleShape__render_vertex;
  __pyx_type_5_soya__SimpleShape.tp_base = __pyx_ptype_5_soya__Shape;
  __pyx_type_5_soya__SimpleShape.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__SimpleShape) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 74; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__SimpleShape.tp_dict, __pyx_vtabptr_5_soya__SimpleShape) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 74; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SimpleShape", (PyObject *)&__pyx_type_5_soya__SimpleShape) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_ptype_5_soya__SimpleShape = &__pyx_type_5_soya__SimpleShape;
  __pyx_vtabptr_5_soya__CellShadingShape = &__pyx_vtable_5_soya__CellShadingShape;
  __pyx_vtable_5_soya__CellShadingShape.__pyx_base = *__pyx_vtabptr_5_soya__SimpleShape;
  __pyx_vtable_5_soya__CellShadingShape.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_17_CellShadingShape___getcstate__;
  __pyx_vtable_5_soya__CellShadingShape.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_17_CellShadingShape___setcstate__;
  __pyx_vtable_5_soya__CellShadingShape.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_17_CellShadingShape__batch;
  __pyx_vtable_5_soya__CellShadingShape.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_17_CellShadingShape__render;
  __pyx_vtable_5_soya__CellShadingShape._build_cellshading = (void *)__pyx_f_5_soya_17_CellShadingShape__build_cellshading;
  __pyx_vtable_5_soya__CellShadingShape._render_outline = (void *)__pyx_f_5_soya_17_CellShadingShape__render_outline;
  __pyx_vtable_5_soya__CellShadingShape._prepare_cellshading_shades = (void *)__pyx_f_5_soya_17_CellShadingShape__prepare_cellshading_shades;
  __pyx_vtable_5_soya__CellShadingShape._prepare_cellshading = (void *)__pyx_f_5_soya_17_CellShadingShape__prepare_cellshading;
  __pyx_vtable_5_soya__CellShadingShape._vertex_compute_cellshading = (void *)__pyx_f_5_soya_17_CellShadingShape__vertex_compute_cellshading;
  __pyx_vtable_5_soya__CellShadingShape._render_triangle_cellshading = (void *)__pyx_f_5_soya_17_CellShadingShape__render_triangle_cellshading;
  __pyx_vtable_5_soya__CellShadingShape._render_quad_cellshading = (void *)__pyx_f_5_soya_17_CellShadingShape__render_quad_cellshading;
  __pyx_vtable_5_soya__CellShadingShape._render_vertex_cellshading_smoothlit = (void *)__pyx_f_5_soya_17_CellShadingShape__render_vertex_cellshading_smoothlit;
  __pyx_vtable_5_soya__CellShadingShape._render_vertex_cellshading = (void *)__pyx_f_5_soya_17_CellShadingShape__render_vertex_cellshading;
  __pyx_type_5_soya__CellShadingShape.tp_base = __pyx_ptype_5_soya__SimpleShape;
  __pyx_type_5_soya__CellShadingShape.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__CellShadingShape) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 19; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__CellShadingShape.tp_dict, __pyx_vtabptr_5_soya__CellShadingShape) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 19; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_CellShadingShape", (PyObject *)&__pyx_type_5_soya__CellShadingShape) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 19; goto __pyx_L1;}
  __pyx_ptype_5_soya__CellShadingShape = &__pyx_type_5_soya__CellShadingShape;
  __pyx_vtabptr_5_soya__TreeShape = &__pyx_vtable_5_soya__TreeShape;
  __pyx_vtable_5_soya__TreeShape.__pyx_base = *__pyx_vtabptr_5_soya__SimpleShape;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_10_TreeShape___getcstate__;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_10_TreeShape___setcstate__;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_10_TreeShape__batch;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_10_TreeShape__render;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base._raypick = (void *)__pyx_f_5_soya_10_TreeShape__raypick;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_10_TreeShape__raypick_b;
  __pyx_vtable_5_soya__TreeShape.__pyx_base.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_10_TreeShape__collect_raypickables;
  __pyx_vtable_5_soya__TreeShape._node2chunk = (void *)__pyx_f_5_soya_10_TreeShape__node2chunk;
  __pyx_vtable_5_soya__TreeShape._chunk2node = (void *)__pyx_f_5_soya_10_TreeShape__chunk2node;
  __pyx_vtable_5_soya__TreeShape._build_tree = (void *)__pyx_f_5_soya_10_TreeShape__build_tree;
  __pyx_vtable_5_soya__TreeShape._optimize_tree = (void *)__pyx_f_5_soya_10_TreeShape__optimize_tree;
  __pyx_vtable_5_soya__TreeShape.compute_sphere = (void *)__pyx_f_5_soya_10_TreeShape_compute_sphere;
  __pyx_vtable_5_soya__TreeShape._batch_node = (void *)__pyx_f_5_soya_10_TreeShape__batch_node;
  __pyx_vtable_5_soya__TreeShape._node_raypick = (void *)__pyx_f_5_soya_10_TreeShape__node_raypick;
  __pyx_vtable_5_soya__TreeShape._node_raypick_b = (void *)__pyx_f_5_soya_10_TreeShape__node_raypick_b;
  __pyx_vtable_5_soya__TreeShape._raypick_from_context = (void *)__pyx_f_5_soya_10_TreeShape__raypick_from_context;
  __pyx_vtable_5_soya__TreeShape._raypick_from_context_b = (void *)__pyx_f_5_soya_10_TreeShape__raypick_from_context_b;
  __pyx_type_5_soya__TreeShape.tp_base = __pyx_ptype_5_soya__SimpleShape;
  if (PyType_Ready(&__pyx_type_5_soya__TreeShape) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 234; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__TreeShape.tp_dict, __pyx_vtabptr_5_soya__TreeShape) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 234; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_TreeShape", (PyObject *)&__pyx_type_5_soya__TreeShape) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 234; goto __pyx_L1;}
  __pyx_ptype_5_soya__TreeShape = &__pyx_type_5_soya__TreeShape;
  __pyx_vtabptr_5_soya_Position = &__pyx_vtable_5_soya_Position;
  __pyx_vtable_5_soya_Position.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya_Position._into = (void *)__pyx_f_5_soya_8Position__into;
  __pyx_vtable_5_soya_Position._out = (void *)__pyx_f_5_soya_8Position__out;
  __pyx_type_5_soya_Position.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya_Position.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Position) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Position.tp_dict, __pyx_vtabptr_5_soya_Position) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Position", (PyObject *)&__pyx_type_5_soya_Position) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya_Position = &__pyx_type_5_soya_Position;
  __pyx_vtabptr_5_soya__Point = &__pyx_vtable_5_soya__Point;
  __pyx_vtable_5_soya__Point.__pyx_base = *__pyx_vtabptr_5_soya_Position;
  __pyx_vtable_5_soya__Point.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_6_Point___getcstate__;
  __pyx_vtable_5_soya__Point.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_6_Point___setcstate__;
  __pyx_vtable_5_soya__Point.__pyx_base._into = (void *)__pyx_f_5_soya_6_Point__into;
  __pyx_vtable_5_soya__Point.__pyx_base._out = (void *)__pyx_f_5_soya_6_Point__out;
  __pyx_type_5_soya__Point.tp_base = __pyx_ptype_5_soya_Position;
  if (PyType_Ready(&__pyx_type_5_soya__Point) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Point.tp_dict, __pyx_vtabptr_5_soya__Point) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Point", (PyObject *)&__pyx_type_5_soya__Point) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_ptype_5_soya__Point = &__pyx_type_5_soya__Point;
  __pyx_vtabptr_5_soya__Vector = &__pyx_vtable_5_soya__Vector;
  __pyx_vtable_5_soya__Vector.__pyx_base = *__pyx_vtabptr_5_soya__Point;
  __pyx_vtable_5_soya__Vector.__pyx_base.__pyx_base._into = (void *)__pyx_f_5_soya_7_Vector__into;
  __pyx_vtable_5_soya__Vector.__pyx_base.__pyx_base._out = (void *)__pyx_f_5_soya_7_Vector__out;
  __pyx_type_5_soya__Vector.tp_base = __pyx_ptype_5_soya__Point;
  if (PyType_Ready(&__pyx_type_5_soya__Vector) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 288; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Vector.tp_dict, __pyx_vtabptr_5_soya__Vector) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 288; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Vector", (PyObject *)&__pyx_type_5_soya__Vector) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 288; goto __pyx_L1;}
  __pyx_ptype_5_soya__Vector = &__pyx_type_5_soya__Vector;
  __pyx_vtabptr_5_soya__Vertex = &__pyx_vtable_5_soya__Vertex;
  __pyx_vtable_5_soya__Vertex.__pyx_base = *__pyx_vtabptr_5_soya__Point;
  __pyx_vtable_5_soya__Vertex.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_7_Vertex___getcstate__;
  __pyx_vtable_5_soya__Vertex.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_7_Vertex___setcstate__;
  __pyx_vtable_5_soya__Vertex._render = (void *)__pyx_f_5_soya_7_Vertex__render;
  __pyx_vtable_5_soya__Vertex._angle_at = (void *)__pyx_f_5_soya_7_Vertex__angle_at;
  __pyx_type_5_soya__Vertex.tp_base = __pyx_ptype_5_soya__Point;
  __pyx_type_5_soya__Vertex.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Vertex) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Vertex.tp_dict, __pyx_vtabptr_5_soya__Vertex) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Vertex", (PyObject *)&__pyx_type_5_soya__Vertex) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__Vertex = &__pyx_type_5_soya__Vertex;
  __pyx_vtabptr_5_soya_CoordSyst = &__pyx_vtable_5_soya_CoordSyst;
  __pyx_vtable_5_soya_CoordSyst.__pyx_base = *__pyx_vtabptr_5_soya_Position;
  __pyx_vtable_5_soya_CoordSyst.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_9CoordSyst___getcstate__;
  __pyx_vtable_5_soya_CoordSyst.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_9CoordSyst___setcstate__;
  __pyx_vtable_5_soya_CoordSyst.__pyx_base._into = (void *)__pyx_f_5_soya_9CoordSyst__into;
  __pyx_vtable_5_soya_CoordSyst.__pyx_base._out = (void *)__pyx_f_5_soya_9CoordSyst__out;
  __pyx_vtable_5_soya_CoordSyst._batch = (void *)__pyx_f_5_soya_9CoordSyst__batch;
  __pyx_vtable_5_soya_CoordSyst._render = (void *)__pyx_f_5_soya_9CoordSyst__render;
  __pyx_vtable_5_soya_CoordSyst._shadow = (void *)__pyx_f_5_soya_9CoordSyst__shadow;
  __pyx_vtable_5_soya_CoordSyst._raypick = (void *)__pyx_f_5_soya_9CoordSyst__raypick;
  __pyx_vtable_5_soya_CoordSyst._raypick_b = (void *)__pyx_f_5_soya_9CoordSyst__raypick_b;
  __pyx_vtable_5_soya_CoordSyst._collect_raypickables = (void *)__pyx_f_5_soya_9CoordSyst__collect_raypickables;
  __pyx_vtable_5_soya_CoordSyst._contains = (void *)__pyx_f_5_soya_9CoordSyst__contains;
  __pyx_vtable_5_soya_CoordSyst._raypick_data = (void *)__pyx_f_5_soya_9CoordSyst__raypick_data;
  __pyx_vtable_5_soya_CoordSyst._distance_out = (void *)__pyx_f_5_soya_9CoordSyst__distance_out;
  __pyx_vtable_5_soya_CoordSyst._invalidate = (void *)__pyx_f_5_soya_9CoordSyst__invalidate;
  __pyx_vtable_5_soya_CoordSyst.check_lefthanded = (void *)__pyx_f_5_soya_9CoordSyst_check_lefthanded;
  __pyx_vtable_5_soya_CoordSyst._root_matrix = (void *)__pyx_f_5_soya_9CoordSyst__root_matrix;
  __pyx_vtable_5_soya_CoordSyst._inverted_root_matrix = (void *)__pyx_f_5_soya_9CoordSyst__inverted_root_matrix;
  __pyx_vtable_5_soya_CoordSyst._get_root = (void *)__pyx_f_5_soya_9CoordSyst__get_root;
  __pyx_vtable_5_soya_CoordSyst._get_box = (void *)__pyx_f_5_soya_9CoordSyst__get_box;
  __pyx_vtable_5_soya_CoordSyst._get_sphere = (void *)__pyx_f_5_soya_9CoordSyst__get_sphere;
  __pyx_type_5_soya_CoordSyst.tp_base = __pyx_ptype_5_soya_Position;
  if (PyType_Ready(&__pyx_type_5_soya_CoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 71; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_CoordSyst.tp_dict, __pyx_vtabptr_5_soya_CoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "CoordSyst", (PyObject *)&__pyx_type_5_soya_CoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 71; goto __pyx_L1;}
  __pyx_ptype_5_soya_CoordSyst = &__pyx_type_5_soya_CoordSyst;
  __pyx_vtabptr_5_soya__Camera = &__pyx_vtable_5_soya__Camera;
  __pyx_vtable_5_soya__Camera.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Camera.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_7_Camera___getcstate__;
  __pyx_vtable_5_soya__Camera.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_7_Camera___setcstate__;
  __pyx_vtable_5_soya__Camera._init_frustum = (void *)__pyx_f_5_soya_7_Camera__init_frustum;
  __pyx_vtable_5_soya__Camera._subrender_scene = (void *)__pyx_f_5_soya_7_Camera__subrender_scene;
  __pyx_vtable_5_soya__Camera._render_scene = (void *)__pyx_f_5_soya_7_Camera__render_scene;
  __pyx_type_5_soya__Camera.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Camera.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Camera) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Camera.tp_dict, __pyx_vtabptr_5_soya__Camera) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Camera", (PyObject *)&__pyx_type_5_soya__Camera) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__Camera = &__pyx_type_5_soya__Camera;
  __pyx_vtabptr_5_soya__Light = &__pyx_vtable_5_soya__Light;
  __pyx_vtable_5_soya__Light.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Light.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_6_Light___getcstate__;
  __pyx_vtable_5_soya__Light.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_6_Light___setcstate__;
  __pyx_vtable_5_soya__Light.__pyx_base._batch = (void *)__pyx_f_5_soya_6_Light__batch;
  __pyx_vtable_5_soya__Light._shadow_at = (void *)__pyx_f_5_soya_6_Light__shadow_at;
  __pyx_vtable_5_soya__Light._spotlight_at = (void *)__pyx_f_5_soya_6_Light__spotlight_at;
  __pyx_vtable_5_soya__Light._attenuation_at = (void *)__pyx_f_5_soya_6_Light__attenuation_at;
  __pyx_vtable_5_soya__Light._static_light_at = (void *)__pyx_f_5_soya_6_Light__static_light_at;
  __pyx_vtable_5_soya__Light._cast_into = (void *)__pyx_f_5_soya_6_Light__cast_into;
  __pyx_vtable_5_soya__Light._activate = (void *)__pyx_f_5_soya_6_Light__activate;
  __pyx_vtable_5_soya__Light._compute_radius = (void *)__pyx_f_5_soya_6_Light__compute_radius;
  __pyx_type_5_soya__Light.tp_base = __pyx_ptype_5_soya_CoordSyst;
  if (PyType_Ready(&__pyx_type_5_soya__Light) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 22; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Light.tp_dict, __pyx_vtabptr_5_soya__Light) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Light", (PyObject *)&__pyx_type_5_soya__Light) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_ptype_5_soya__Light = &__pyx_type_5_soya__Light;
  __pyx_vtabptr_5_soya__Volume = &__pyx_vtable_5_soya__Volume;
  __pyx_vtable_5_soya__Volume.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Volume.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_7_Volume___getcstate__;
  __pyx_vtable_5_soya__Volume.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_7_Volume___setcstate__;
  __pyx_vtable_5_soya__Volume.__pyx_base._batch = (void *)__pyx_f_5_soya_7_Volume__batch;
  __pyx_vtable_5_soya__Volume.__pyx_base._shadow = (void *)__pyx_f_5_soya_7_Volume__shadow;
  __pyx_vtable_5_soya__Volume.__pyx_base._raypick = (void *)__pyx_f_5_soya_7_Volume__raypick;
  __pyx_vtable_5_soya__Volume.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_7_Volume__raypick_b;
  __pyx_vtable_5_soya__Volume.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_7_Volume__collect_raypickables;
  __pyx_vtable_5_soya__Volume.__pyx_base._contains = (void *)__pyx_f_5_soya_7_Volume__contains;
  __pyx_vtable_5_soya__Volume.__pyx_base._get_box = (void *)__pyx_f_5_soya_7_Volume__get_box;
  __pyx_vtable_5_soya__Volume.__pyx_base._get_sphere = (void *)__pyx_f_5_soya_7_Volume__get_sphere;
  __pyx_type_5_soya__Volume.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Volume.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Volume) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 20; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Volume.tp_dict, __pyx_vtabptr_5_soya__Volume) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Volume", (PyObject *)&__pyx_type_5_soya__Volume) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__Volume = &__pyx_type_5_soya__Volume;
  __pyx_vtabptr_5_soya__World = &__pyx_vtable_5_soya__World;
  __pyx_vtable_5_soya__World.__pyx_base = *__pyx_vtabptr_5_soya__Volume;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_6_World___getcstate__;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_6_World___setcstate__;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_6_World__batch;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._shadow = (void *)__pyx_f_5_soya_6_World__shadow;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._raypick = (void *)__pyx_f_5_soya_6_World__raypick;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_6_World__raypick_b;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_6_World__collect_raypickables;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._contains = (void *)__pyx_f_5_soya_6_World__contains;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._invalidate = (void *)__pyx_f_5_soya_6_World__invalidate;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._get_root = (void *)__pyx_f_5_soya_6_World__get_root;
  __pyx_vtable_5_soya__World.__pyx_base.__pyx_base._get_box = (void *)__pyx_f_5_soya_6_World__get_box;
  __pyx_vtable_5_soya__World._search_all = (void *)__pyx_f_5_soya_6_World__search_all;
  __pyx_type_5_soya__World.tp_base = __pyx_ptype_5_soya__Volume;
  __pyx_type_5_soya__World.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__World) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 20; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__World.tp_dict, __pyx_vtabptr_5_soya__World) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_World", (PyObject *)&__pyx_type_5_soya__World) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__World = &__pyx_type_5_soya__World;
  __pyx_vtabptr_5_soya__Face = &__pyx_vtable_5_soya__Face;
  __pyx_vtable_5_soya__Face.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Face.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_5_Face___getcstate__;
  __pyx_vtable_5_soya__Face.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_5_Face___setcstate__;
  __pyx_vtable_5_soya__Face.__pyx_base._batch = (void *)__pyx_f_5_soya_5_Face__batch;
  __pyx_vtable_5_soya__Face.__pyx_base._render = (void *)__pyx_f_5_soya_5_Face__render;
  __pyx_vtable_5_soya__Face.__pyx_base._raypick = (void *)__pyx_f_5_soya_5_Face__raypick;
  __pyx_vtable_5_soya__Face.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_5_Face__raypick_b;
  __pyx_vtable_5_soya__Face.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_5_Face__collect_raypickables;
  __pyx_vtable_5_soya__Face.__pyx_base._get_box = (void *)__pyx_f_5_soya_5_Face__get_box;
  __pyx_vtable_5_soya__Face._compute_normal = (void *)__pyx_f_5_soya_5_Face__compute_normal;
  __pyx_type_5_soya__Face.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Face.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Face) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 126; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Face.tp_dict, __pyx_vtabptr_5_soya__Face) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 126; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Face", (PyObject *)&__pyx_type_5_soya__Face) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 126; goto __pyx_L1;}
  __pyx_ptype_5_soya__Face = &__pyx_type_5_soya__Face;
  __pyx_vtabptr_5_soya__Cal3dVolume = &__pyx_vtable_5_soya__Cal3dVolume;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_12_Cal3dVolume___getcstate__;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_12_Cal3dVolume___setcstate__;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base._batch = (void *)__pyx_f_5_soya_12_Cal3dVolume__batch;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base._shadow = (void *)__pyx_f_5_soya_12_Cal3dVolume__shadow;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base._raypick = (void *)__pyx_f_5_soya_12_Cal3dVolume__raypick;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_12_Cal3dVolume__raypick_b;
  __pyx_vtable_5_soya__Cal3dVolume.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_12_Cal3dVolume__collect_raypickables;
  __pyx_vtable_5_soya__Cal3dVolume._build_submeshes = (void *)__pyx_f_5_soya_12_Cal3dVolume__build_submeshes;
  __pyx_vtable_5_soya__Cal3dVolume._build_face_planes = (void *)__pyx_f_5_soya_12_Cal3dVolume__build_face_planes;
  __pyx_vtable_5_soya__Cal3dVolume._attach_all = (void *)__pyx_f_5_soya_12_Cal3dVolume__attach_all;
  __pyx_type_5_soya__Cal3dVolume.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Cal3dVolume.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Cal3dVolume) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 19; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Cal3dVolume.tp_dict, __pyx_vtabptr_5_soya__Cal3dVolume) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 19; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Cal3dVolume", (PyObject *)&__pyx_type_5_soya__Cal3dVolume) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 19; goto __pyx_L1;}
  __pyx_ptype_5_soya__Cal3dVolume = &__pyx_type_5_soya__Cal3dVolume;
  __pyx_vtabptr_5_soya__Cal3dShape = &__pyx_vtable_5_soya__Cal3dShape;
  __pyx_vtable_5_soya__Cal3dShape.__pyx_base = *__pyx_vtabptr_5_soya__Shape;
  __pyx_vtable_5_soya__Cal3dShape.__pyx_base._render = (void *)__pyx_f_5_soya_11_Cal3dShape__render;
  __pyx_vtable_5_soya__Cal3dShape.__pyx_base._shadow = (void *)__pyx_f_5_soya_11_Cal3dShape__shadow;
  __pyx_vtable_5_soya__Cal3dShape._build_submeshes = (void *)__pyx_f_5_soya_11_Cal3dShape__build_submeshes;
  __pyx_vtable_5_soya__Cal3dShape._set_face_neighborhood = (void *)__pyx_f_5_soya_11_Cal3dShape__set_face_neighborhood;
  __pyx_vtable_5_soya__Cal3dShape._set_cell_shading = (void *)__pyx_f_5_soya_11_Cal3dShape__set_cell_shading;
  __pyx_vtable_5_soya__Cal3dShape._prepare_cellshading = (void *)__pyx_f_5_soya_11_Cal3dShape__prepare_cellshading;
  __pyx_vtable_5_soya__Cal3dShape._prepare_cellshading_shades = (void *)__pyx_f_5_soya_11_Cal3dShape__prepare_cellshading_shades;
  __pyx_vtable_5_soya__Cal3dShape._render_outline = (void *)__pyx_f_5_soya_11_Cal3dShape__render_outline;
  __pyx_vtable_5_soya__Cal3dShape._get_material_4_cal3d = (void *)__pyx_f_5_soya_11_Cal3dShape__get_material_4_cal3d;
  __pyx_vtable_5_soya__Cal3dShape._create_material_4_cal3d = (void *)__pyx_f_5_soya_11_Cal3dShape__create_material_4_cal3d;
  __pyx_vtable_5_soya__Cal3dShape._set_texture_from_model = (void *)__pyx_f_5_soya_11_Cal3dShape__set_texture_from_model;
  __pyx_vtable_5_soya__Cal3dShape._shadow2 = (void *)__pyx_f_5_soya_11_Cal3dShape__shadow2;
  __pyx_vtable_5_soya__Cal3dShape._build_vertices = (void *)__pyx_f_5_soya_11_Cal3dShape__build_vertices;
  __pyx_type_5_soya__Cal3dShape.tp_base = __pyx_ptype_5_soya__Shape;
  __pyx_type_5_soya__Cal3dShape.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Cal3dShape) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 208; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Cal3dShape.tp_dict, __pyx_vtabptr_5_soya__Cal3dShape) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 208; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Cal3dShape", (PyObject *)&__pyx_type_5_soya__Cal3dShape) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 208; goto __pyx_L1;}
  __pyx_ptype_5_soya__Cal3dShape = &__pyx_type_5_soya__Cal3dShape;
  __pyx_vtabptr_5_soya__Sprite = &__pyx_vtable_5_soya__Sprite;
  __pyx_vtable_5_soya__Sprite.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Sprite.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_7_Sprite___getcstate__;
  __pyx_vtable_5_soya__Sprite.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_7_Sprite___setcstate__;
  __pyx_vtable_5_soya__Sprite.__pyx_base._batch = (void *)__pyx_f_5_soya_7_Sprite__batch;
  __pyx_vtable_5_soya__Sprite.__pyx_base._render = (void *)__pyx_f_5_soya_7_Sprite__render;
  __pyx_vtable_5_soya__Sprite._compute_alpha = (void *)__pyx_f_5_soya_7_Sprite__compute_alpha;
  __pyx_type_5_soya__Sprite.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Sprite.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Sprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 25; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Sprite.tp_dict, __pyx_vtabptr_5_soya__Sprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 25; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Sprite", (PyObject *)&__pyx_type_5_soya__Sprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 25; goto __pyx_L1;}
  __pyx_ptype_5_soya__Sprite = &__pyx_type_5_soya__Sprite;
  __pyx_vtabptr_5_soya__Portal = &__pyx_vtable_5_soya__Portal;
  __pyx_vtable_5_soya__Portal.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Portal.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_7_Portal___getcstate__;
  __pyx_vtable_5_soya__Portal.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_7_Portal___setcstate__;
  __pyx_vtable_5_soya__Portal.__pyx_base._batch = (void *)__pyx_f_5_soya_7_Portal__batch;
  __pyx_vtable_5_soya__Portal.__pyx_base._shadow = (void *)__pyx_f_5_soya_7_Portal__shadow;
  __pyx_vtable_5_soya__Portal.__pyx_base._raypick = (void *)__pyx_f_5_soya_7_Portal__raypick;
  __pyx_vtable_5_soya__Portal.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_7_Portal__raypick_b;
  __pyx_vtable_5_soya__Portal.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_7_Portal__collect_raypickables;
  __pyx_vtable_5_soya__Portal._compute_clipping_planes = (void *)__pyx_f_5_soya_7_Portal__compute_clipping_planes;
  __pyx_vtable_5_soya__Portal._compute_points = (void *)__pyx_f_5_soya_7_Portal__compute_points;
  __pyx_vtable_5_soya__Portal._atmosphere_clear_part = (void *)__pyx_f_5_soya_7_Portal__atmosphere_clear_part;
  __pyx_vtable_5_soya__Portal._draw_fog = (void *)__pyx_f_5_soya_7_Portal__draw_fog;
  __pyx_type_5_soya__Portal.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Portal.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Portal) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Portal.tp_dict, __pyx_vtabptr_5_soya__Portal) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Portal", (PyObject *)&__pyx_type_5_soya__Portal) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__Portal = &__pyx_type_5_soya__Portal;
  __pyx_vtabptr_5_soya__Land = &__pyx_vtable_5_soya__Land;
  __pyx_vtable_5_soya__Land.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Land.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_5_Land___getcstate__;
  __pyx_vtable_5_soya__Land.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_5_Land___setcstate__;
  __pyx_vtable_5_soya__Land.__pyx_base._batch = (void *)__pyx_f_5_soya_5_Land__batch;
  __pyx_vtable_5_soya__Land.__pyx_base._render = (void *)__pyx_f_5_soya_5_Land__render;
  __pyx_vtable_5_soya__Land.__pyx_base._raypick = (void *)__pyx_f_5_soya_5_Land__raypick;
  __pyx_vtable_5_soya__Land.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_5_Land__raypick_b;
  __pyx_vtable_5_soya__Land.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_5_Land__collect_raypickables;
  __pyx_vtable_5_soya__Land._get_vertex = (void *)__pyx_f_5_soya_5_Land__get_vertex;
  __pyx_vtable_5_soya__Land._check_size = (void *)__pyx_f_5_soya_5_Land__check_size;
  __pyx_vtable_5_soya__Land._free_patchs = (void *)__pyx_f_5_soya_5_Land__free_patchs;
  __pyx_vtable_5_soya__Land.__del__ = (void *)__pyx_f_5_soya_5_Land___del__;
  __pyx_vtable_5_soya__Land._add_material = (void *)__pyx_f_5_soya_5_Land__add_material;
  __pyx_vtable_5_soya__Land._get_height = (void *)__pyx_f_5_soya_5_Land__get_height;
  __pyx_vtable_5_soya__Land._set_height = (void *)__pyx_f_5_soya_5_Land__set_height;
  __pyx_vtable_5_soya__Land._init = (void *)__pyx_f_5_soya_5_Land__init;
  __pyx_vtable_5_soya__Land._compute_normal = (void *)__pyx_f_5_soya_5_Land__compute_normal;
  __pyx_vtable_5_soya__Land._compute_normals = (void *)__pyx_f_5_soya_5_Land__compute_normals;
  __pyx_vtable_5_soya__Land._compute_coords = (void *)__pyx_f_5_soya_5_Land__compute_coords;
  __pyx_vtable_5_soya__Land._create_patch = (void *)__pyx_f_5_soya_5_Land__create_patch;
  __pyx_vtable_5_soya__Land._create_patchs = (void *)__pyx_f_5_soya_5_Land__create_patchs;
  __pyx_vtable_5_soya__Land._register_color = (void *)__pyx_f_5_soya_5_Land__register_color;
  __pyx_vtable_5_soya__Land._tri_split = (void *)__pyx_f_5_soya_5_Land__tri_split;
  __pyx_vtable_5_soya__Land._tri_merge_child = (void *)__pyx_f_5_soya_5_Land__tri_merge_child;
  __pyx_vtable_5_soya__Land._tri_set_level = (void *)__pyx_f_5_soya_5_Land__tri_set_level;
  __pyx_vtable_5_soya__Land._patch_set_level = (void *)__pyx_f_5_soya_5_Land__patch_set_level;
  __pyx_vtable_5_soya__Land._patch_update = (void *)__pyx_f_5_soya_5_Land__patch_update;
  __pyx_vtable_5_soya__Land._tri_force_presence = (void *)__pyx_f_5_soya_5_Land__tri_force_presence;
  __pyx_vtable_5_soya__Land._force_presence = (void *)__pyx_f_5_soya_5_Land__force_presence;
  __pyx_vtable_5_soya__Land._tri_batch = (void *)__pyx_f_5_soya_5_Land__tri_batch;
  __pyx_vtable_5_soya__Land._patch_batch = (void *)__pyx_f_5_soya_5_Land__patch_batch;
  __pyx_vtable_5_soya__Land._tri_render_middle = (void *)__pyx_f_5_soya_5_Land__tri_render_middle;
  __pyx_vtable_5_soya__Land._tri_render_secondpass = (void *)__pyx_f_5_soya_5_Land__tri_render_secondpass;
  __pyx_vtable_5_soya__Land._tri_raypick = (void *)__pyx_f_5_soya_5_Land__tri_raypick;
  __pyx_vtable_5_soya__Land._tri_raypick_b = (void *)__pyx_f_5_soya_5_Land__tri_raypick_b;
  __pyx_vtable_5_soya__Land._full_raypick = (void *)__pyx_f_5_soya_5_Land__full_raypick;
  __pyx_vtable_5_soya__Land._full_raypick_rect = (void *)__pyx_f_5_soya_5_Land__full_raypick_rect;
  __pyx_vtable_5_soya__Land._full_raypick_b = (void *)__pyx_f_5_soya_5_Land__full_raypick_b;
  __pyx_vtable_5_soya__Land._full_raypick_rect_b = (void *)__pyx_f_5_soya_5_Land__full_raypick_rect_b;
  __pyx_vtable_5_soya__Land._check_vertex_options = (void *)__pyx_f_5_soya_5_Land__check_vertex_options;
  __pyx_vtable_5_soya__Land._check_color = (void *)__pyx_f_5_soya_5_Land__check_color;
  __pyx_vtable_5_soya__Land._vertex_render_special = (void *)__pyx_f_5_soya_5_Land__vertex_render_special;
  __pyx_type_5_soya__Land.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Land.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Land) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 249; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Land.tp_dict, __pyx_vtabptr_5_soya__Land) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 249; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Land", (PyObject *)&__pyx_type_5_soya__Land) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_ptype_5_soya__Land = &__pyx_type_5_soya__Land;
  __pyx_vtabptr_5_soya__WaterCube = &__pyx_vtable_5_soya__WaterCube;
  __pyx_vtable_5_soya__WaterCube.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__WaterCube._render_watercube = (void *)__pyx_f_5_soya_10_WaterCube__render_watercube;
  __pyx_type_5_soya__WaterCube.tp_base = __pyx_ptype_5_soya_CoordSyst;
  if (PyType_Ready(&__pyx_type_5_soya__WaterCube) < 0) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__WaterCube.tp_dict, __pyx_vtabptr_5_soya__WaterCube) < 0) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_WaterCube", (PyObject *)&__pyx_type_5_soya__WaterCube) < 0) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__WaterCube = &__pyx_type_5_soya__WaterCube;
  __pyx_vtabptr_5_soya__Atmosphere = &__pyx_vtable_5_soya__Atmosphere;
  __pyx_vtable_5_soya__Atmosphere.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya__Atmosphere.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_11_Atmosphere___getcstate__;
  __pyx_vtable_5_soya__Atmosphere.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_11_Atmosphere___setcstate__;
  __pyx_vtable_5_soya__Atmosphere._clear = (void *)__pyx_f_5_soya_11_Atmosphere__clear;
  __pyx_vtable_5_soya__Atmosphere._draw_bg = (void *)__pyx_f_5_soya_11_Atmosphere__draw_bg;
  __pyx_vtable_5_soya__Atmosphere._render = (void *)__pyx_f_5_soya_11_Atmosphere__render;
  __pyx_vtable_5_soya__Atmosphere._fog_factor_at = (void *)__pyx_f_5_soya_11_Atmosphere__fog_factor_at;
  __pyx_type_5_soya__Atmosphere.tp_base = __pyx_ptype_5_soya__CObj;
  if (PyType_Ready(&__pyx_type_5_soya__Atmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Atmosphere.tp_dict, __pyx_vtabptr_5_soya__Atmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Atmosphere", (PyObject *)&__pyx_type_5_soya__Atmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__Atmosphere = &__pyx_type_5_soya__Atmosphere;
  __pyx_vtabptr_5_soya_Renderer = &__pyx_vtable_5_soya_Renderer;
  __pyx_vtable_5_soya_Renderer._frustum = (void *)__pyx_f_5_soya_8Renderer__frustum;
  __pyx_vtable_5_soya_Renderer._context = (void *)__pyx_f_5_soya_8Renderer__context;
  __pyx_vtable_5_soya_Renderer._activate_context_over = (void *)__pyx_f_5_soya_8Renderer__activate_context_over;
  __pyx_vtable_5_soya_Renderer._reset = (void *)__pyx_f_5_soya_8Renderer__reset;
  __pyx_vtable_5_soya_Renderer._batch = (void *)__pyx_f_5_soya_8Renderer__batch;
  __pyx_vtable_5_soya_Renderer._render = (void *)__pyx_f_5_soya_8Renderer__render;
  __pyx_vtable_5_soya_Renderer._render_list = (void *)__pyx_f_5_soya_8Renderer__render_list;
  __pyx_vtable_5_soya_Renderer._clear_screen = (void *)__pyx_f_5_soya_8Renderer__clear_screen;
  __pyx_vtable_5_soya_Renderer._render_shadows = (void *)__pyx_f_5_soya_8Renderer__render_shadows;
  __pyx_type_5_soya_Renderer.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Renderer) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Renderer.tp_dict, __pyx_vtabptr_5_soya_Renderer) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Renderer", (PyObject *)&__pyx_type_5_soya_Renderer) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; goto __pyx_L1;}
  __pyx_ptype_5_soya_Renderer = &__pyx_type_5_soya_Renderer;
  __pyx_type_5_soya_Context.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Context) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_5_soya_Context) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya_Context = &__pyx_type_5_soya_Context;
  __pyx_type_5_soya_RaypickData.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_RaypickData) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 39; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RaypickData", (PyObject *)&__pyx_type_5_soya_RaypickData) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_ptype_5_soya_RaypickData = &__pyx_type_5_soya_RaypickData;
  __pyx_type_5_soya_RaypickContext.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_RaypickContext) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 64; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RaypickContext", (PyObject *)&__pyx_type_5_soya_RaypickContext) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 64; goto __pyx_L1;}
  __pyx_ptype_5_soya_RaypickContext = &__pyx_type_5_soya_RaypickContext;
  __pyx_type_5_soya_Idler.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Idler) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Idler", (PyObject *)&__pyx_type_5_soya_Idler) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; goto __pyx_L1;}
  __pyx_ptype_5_soya_Idler = &__pyx_type_5_soya_Idler;
  __pyx_type_5_soya_Glyph.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Glyph) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 26; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Glyph", (PyObject *)&__pyx_type_5_soya_Glyph) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 26; goto __pyx_L1;}
  __pyx_ptype_5_soya_Glyph = &__pyx_type_5_soya_Glyph;
  __pyx_vtabptr_5_soya_Font = &__pyx_vtable_5_soya_Font;
  __pyx_vtable_5_soya_Font._get_glyph = (void *)__pyx_f_5_soya_4Font__get_glyph;
  __pyx_vtable_5_soya_Font._gen_glyph = (void *)__pyx_f_5_soya_4Font__gen_glyph;
  __pyx_vtable_5_soya_Font._sizeup_pixel = (void *)__pyx_f_5_soya_4Font__sizeup_pixel;
  __pyx_vtable_5_soya_Font._init = (void *)__pyx_f_5_soya_4Font__init;
  __pyx_type_5_soya_Font.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Font) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 37; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Font.tp_dict, __pyx_vtabptr_5_soya_Font) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Font", (PyObject *)&__pyx_type_5_soya_Font) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_ptype_5_soya_Font = &__pyx_type_5_soya_Font;
  __pyx_vtabptr_5_soya_Shapifier = &__pyx_vtable_5_soya_Shapifier;
  __pyx_vtable_5_soya_Shapifier.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya_Shapifier._shapify = (void *)__pyx_f_5_soya_9Shapifier__shapify;
  __pyx_type_5_soya_Shapifier.tp_base = __pyx_ptype_5_soya__CObj;
  if (PyType_Ready(&__pyx_type_5_soya_Shapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 22; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Shapifier.tp_dict, __pyx_vtabptr_5_soya_Shapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Shapifier", (PyObject *)&__pyx_type_5_soya_Shapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_ptype_5_soya_Shapifier = &__pyx_type_5_soya_Shapifier;
  __pyx_vtabptr_5_soya_Traveling = &__pyx_vtable_5_soya_Traveling;
  __pyx_vtable_5_soya_Traveling.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_type_5_soya_Traveling.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya_Traveling.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Traveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 161; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Traveling.tp_dict, __pyx_vtabptr_5_soya_Traveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 161; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Traveling", (PyObject *)&__pyx_type_5_soya_Traveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 161; goto __pyx_L1;}
  __pyx_ptype_5_soya_Traveling = &__pyx_type_5_soya_Traveling;
  __pyx_vtabptr_5_soya__TravelingCamera = &__pyx_vtable_5_soya__TravelingCamera;
  __pyx_vtable_5_soya__TravelingCamera.__pyx_base = *__pyx_vtabptr_5_soya__Camera;
  __pyx_vtable_5_soya__TravelingCamera._traveling_changed = (void *)__pyx_f_5_soya_16_TravelingCamera__traveling_changed;
  __pyx_type_5_soya__TravelingCamera.tp_base = __pyx_ptype_5_soya__Camera;
  __pyx_type_5_soya__TravelingCamera.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__TravelingCamera) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__TravelingCamera.tp_dict, __pyx_vtabptr_5_soya__TravelingCamera) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_TravelingCamera", (PyObject *)&__pyx_type_5_soya__TravelingCamera) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__TravelingCamera = &__pyx_type_5_soya__TravelingCamera;
  __pyx_vtabptr_5_soya__NoBackgroundAtmosphere = &__pyx_vtable_5_soya__NoBackgroundAtmosphere;
  __pyx_vtable_5_soya__NoBackgroundAtmosphere.__pyx_base = *__pyx_vtabptr_5_soya__Atmosphere;
  __pyx_vtable_5_soya__NoBackgroundAtmosphere.__pyx_base._clear = (void *)__pyx_f_5_soya_23_NoBackgroundAtmosphere__clear;
  __pyx_type_5_soya__NoBackgroundAtmosphere.tp_base = __pyx_ptype_5_soya__Atmosphere;
  if (PyType_Ready(&__pyx_type_5_soya__NoBackgroundAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 175; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__NoBackgroundAtmosphere.tp_dict, __pyx_vtabptr_5_soya__NoBackgroundAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 175; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_NoBackgroundAtmosphere", (PyObject *)&__pyx_type_5_soya__NoBackgroundAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 175; goto __pyx_L1;}
  __pyx_ptype_5_soya__NoBackgroundAtmosphere = &__pyx_type_5_soya__NoBackgroundAtmosphere;
  __pyx_vtabptr_5_soya__SkyAtmosphere = &__pyx_vtable_5_soya__SkyAtmosphere;
  __pyx_vtable_5_soya__SkyAtmosphere.__pyx_base = *__pyx_vtabptr_5_soya__Atmosphere;
  __pyx_vtable_5_soya__SkyAtmosphere.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_14_SkyAtmosphere___getcstate__;
  __pyx_vtable_5_soya__SkyAtmosphere.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_14_SkyAtmosphere___setcstate__;
  __pyx_vtable_5_soya__SkyAtmosphere.__pyx_base._draw_bg = (void *)__pyx_f_5_soya_14_SkyAtmosphere__draw_bg;
  __pyx_vtable_5_soya__SkyAtmosphere._draw_sky_plane = (void *)__pyx_f_5_soya_14_SkyAtmosphere__draw_sky_plane;
  __pyx_vtable_5_soya__SkyAtmosphere._draw_sky_box = (void *)__pyx_f_5_soya_14_SkyAtmosphere__draw_sky_box;
  __pyx_type_5_soya__SkyAtmosphere.tp_base = __pyx_ptype_5_soya__Atmosphere;
  __pyx_type_5_soya__SkyAtmosphere.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__SkyAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__SkyAtmosphere.tp_dict, __pyx_vtabptr_5_soya__SkyAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SkyAtmosphere", (PyObject *)&__pyx_type_5_soya__SkyAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; goto __pyx_L1;}
  __pyx_ptype_5_soya__SkyAtmosphere = &__pyx_type_5_soya__SkyAtmosphere;
  __pyx_vtabptr_5_soya_PythonCoordSyst = &__pyx_vtable_5_soya_PythonCoordSyst;
  __pyx_vtable_5_soya_PythonCoordSyst.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya_PythonCoordSyst.__pyx_base._batch = (void *)__pyx_f_5_soya_15PythonCoordSyst__batch;
  __pyx_vtable_5_soya_PythonCoordSyst.__pyx_base._render = (void *)__pyx_f_5_soya_15PythonCoordSyst__render;
  __pyx_vtable_5_soya_PythonCoordSyst.__pyx_base._shadow = (void *)__pyx_f_5_soya_15PythonCoordSyst__shadow;
  __pyx_type_5_soya_PythonCoordSyst.tp_base = __pyx_ptype_5_soya_CoordSyst;
  if (PyType_Ready(&__pyx_type_5_soya_PythonCoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 782; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_PythonCoordSyst.tp_dict, __pyx_vtabptr_5_soya_PythonCoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 782; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "PythonCoordSyst", (PyObject *)&__pyx_type_5_soya_PythonCoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 782; goto __pyx_L1;}
  __pyx_ptype_5_soya_PythonCoordSyst = &__pyx_type_5_soya_PythonCoordSyst;
  __pyx_vtabptr_5_soya_CoordSystState = &__pyx_vtable_5_soya_CoordSystState;
  __pyx_vtable_5_soya_CoordSystState.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya_CoordSystState.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_14CoordSystState___setcstate__;
  __pyx_vtable_5_soya_CoordSystState.__pyx_base._invalidate = (void *)__pyx_f_5_soya_14CoordSystState__invalidate;
  __pyx_vtable_5_soya_CoordSystState._check_state_validity = (void *)__pyx_f_5_soya_14CoordSystState__check_state_validity;
  __pyx_type_5_soya_CoordSystState.tp_base = __pyx_ptype_5_soya_CoordSyst;
  if (PyType_Ready(&__pyx_type_5_soya_CoordSystState) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 742; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_CoordSystState.tp_dict, __pyx_vtabptr_5_soya_CoordSystState) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 742; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "CoordSystState", (PyObject *)&__pyx_type_5_soya_CoordSystState) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 742; goto __pyx_L1;}
  __pyx_ptype_5_soya_CoordSystState = &__pyx_type_5_soya_CoordSystState;
  __pyx_vtabptr_5_soya__FixTraveling = &__pyx_vtable_5_soya__FixTraveling;
  __pyx_vtable_5_soya__FixTraveling.__pyx_base = *__pyx_vtabptr_5_soya_Traveling;
  __pyx_type_5_soya__FixTraveling.tp_base = __pyx_ptype_5_soya_Traveling;
  __pyx_type_5_soya__FixTraveling.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__FixTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 190; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__FixTraveling.tp_dict, __pyx_vtabptr_5_soya__FixTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 190; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_FixTraveling", (PyObject *)&__pyx_type_5_soya__FixTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 190; goto __pyx_L1;}
  __pyx_ptype_5_soya__FixTraveling = &__pyx_type_5_soya__FixTraveling;
  __pyx_vtabptr_5_soya__ThirdPersonTraveling = &__pyx_vtable_5_soya__ThirdPersonTraveling;
  __pyx_vtable_5_soya__ThirdPersonTraveling.__pyx_base = *__pyx_vtabptr_5_soya_Traveling;
  __pyx_vtable_5_soya__ThirdPersonTraveling._check = (void *)__pyx_f_5_soya_21_ThirdPersonTraveling__check;
  __pyx_type_5_soya__ThirdPersonTraveling.tp_base = __pyx_ptype_5_soya_Traveling;
  __pyx_type_5_soya__ThirdPersonTraveling.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__ThirdPersonTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 225; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__ThirdPersonTraveling.tp_dict, __pyx_vtabptr_5_soya__ThirdPersonTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 225; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_ThirdPersonTraveling", (PyObject *)&__pyx_type_5_soya__ThirdPersonTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 225; goto __pyx_L1;}
  __pyx_ptype_5_soya__ThirdPersonTraveling = &__pyx_type_5_soya__ThirdPersonTraveling;
  __pyx_vtabptr_5_soya__PythonMaterial = &__pyx_vtable_5_soya__PythonMaterial;
  __pyx_vtable_5_soya__PythonMaterial.__pyx_base = *__pyx_vtabptr_5_soya__Material;
  __pyx_vtable_5_soya__PythonMaterial.__pyx_base._init_texture = (void *)__pyx_f_5_soya_15_PythonMaterial__init_texture;
  __pyx_vtable_5_soya__PythonMaterial.__pyx_base._activate = (void *)__pyx_f_5_soya_15_PythonMaterial__activate;
  __pyx_vtable_5_soya__PythonMaterial.__pyx_base._inactivate = (void *)__pyx_f_5_soya_15_PythonMaterial__inactivate;
  __pyx_type_5_soya__PythonMaterial.tp_base = __pyx_ptype_5_soya__Material;
  if (PyType_Ready(&__pyx_type_5_soya__PythonMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 405; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__PythonMaterial.tp_dict, __pyx_vtabptr_5_soya__PythonMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 405; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_PythonMaterial", (PyObject *)&__pyx_type_5_soya__PythonMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 405; goto __pyx_L1;}
  __pyx_ptype_5_soya__PythonMaterial = &__pyx_type_5_soya__PythonMaterial;
  __pyx_vtabptr_5_soya__CylinderSprite = &__pyx_vtable_5_soya__CylinderSprite;
  __pyx_vtable_5_soya__CylinderSprite.__pyx_base = *__pyx_vtabptr_5_soya__Sprite;
  __pyx_vtable_5_soya__CylinderSprite.__pyx_base.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_15_CylinderSprite___getcstate__;
  __pyx_vtable_5_soya__CylinderSprite.__pyx_base.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_15_CylinderSprite___setcstate__;
  __pyx_vtable_5_soya__CylinderSprite.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_15_CylinderSprite__render;
  __pyx_type_5_soya__CylinderSprite.tp_base = __pyx_ptype_5_soya__Sprite;
  if (PyType_Ready(&__pyx_type_5_soya__CylinderSprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 138; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__CylinderSprite.tp_dict, __pyx_vtabptr_5_soya__CylinderSprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 138; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_CylinderSprite", (PyObject *)&__pyx_type_5_soya__CylinderSprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 138; goto __pyx_L1;}
  __pyx_ptype_5_soya__CylinderSprite = &__pyx_type_5_soya__CylinderSprite;
  __pyx_vtabptr_5_soya__Bonus = &__pyx_vtable_5_soya__Bonus;
  __pyx_vtable_5_soya__Bonus.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Bonus.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_6_Bonus___getcstate__;
  __pyx_vtable_5_soya__Bonus.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_6_Bonus___setcstate__;
  __pyx_vtable_5_soya__Bonus.__pyx_base._batch = (void *)__pyx_f_5_soya_6_Bonus__batch;
  __pyx_vtable_5_soya__Bonus.__pyx_base._render = (void *)__pyx_f_5_soya_6_Bonus__render;
  __pyx_type_5_soya__Bonus.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Bonus.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Bonus) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 217; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Bonus.tp_dict, __pyx_vtabptr_5_soya__Bonus) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 217; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Bonus", (PyObject *)&__pyx_type_5_soya__Bonus) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 217; goto __pyx_L1;}
  __pyx_ptype_5_soya__Bonus = &__pyx_type_5_soya__Bonus;
  __pyx_vtabptr_5_soya__Particles = &__pyx_vtable_5_soya__Particles;
  __pyx_vtable_5_soya__Particles.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Particles.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_10_Particles___getcstate__;
  __pyx_vtable_5_soya__Particles.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_10_Particles___setcstate__;
  __pyx_vtable_5_soya__Particles.__pyx_base._batch = (void *)__pyx_f_5_soya_10_Particles__batch;
  __pyx_vtable_5_soya__Particles.__pyx_base._render = (void *)__pyx_f_5_soya_10_Particles__render;
  __pyx_vtable_5_soya__Particles._reinit = (void *)__pyx_f_5_soya_10_Particles__reinit;
  __pyx_vtable_5_soya__Particles._advance = (void *)__pyx_f_5_soya_10_Particles__advance;
  __pyx_vtable_5_soya__Particles._compute_alpha = (void *)__pyx_f_5_soya_10_Particles__compute_alpha;
  __pyx_vtable_5_soya__Particles._get_fading_color = (void *)__pyx_f_5_soya_10_Particles__get_fading_color;
  __pyx_vtable_5_soya__Particles._get_size = (void *)__pyx_f_5_soya_10_Particles__get_size;
  __pyx_vtable_5_soya__Particles._generate = (void *)__pyx_f_5_soya_10_Particles__generate;
  __pyx_type_5_soya__Particles.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Particles.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Particles) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 24; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Particles.tp_dict, __pyx_vtabptr_5_soya__Particles) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 24; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Particles", (PyObject *)&__pyx_type_5_soya__Particles) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 24; goto __pyx_L1;}
  __pyx_ptype_5_soya__Particles = &__pyx_type_5_soya__Particles;
  __pyx_vtabptr_5_soya_FlagFirework = &__pyx_vtable_5_soya_FlagFirework;
  __pyx_vtable_5_soya_FlagFirework.__pyx_base = *__pyx_vtabptr_5_soya__Particles;
  __pyx_type_5_soya_FlagFirework.tp_base = __pyx_ptype_5_soya__Particles;
  __pyx_type_5_soya_FlagFirework.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_FlagFirework) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 527; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_FlagFirework.tp_dict, __pyx_vtabptr_5_soya_FlagFirework) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 527; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "FlagFirework", (PyObject *)&__pyx_type_5_soya_FlagFirework) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 527; goto __pyx_L1;}
  __pyx_ptype_5_soya_FlagFirework = &__pyx_type_5_soya_FlagFirework;
  __pyx_vtabptr_5_soya_SimpleShapifier = &__pyx_vtable_5_soya_SimpleShapifier;
  __pyx_vtable_5_soya_SimpleShapifier.__pyx_base = *__pyx_vtabptr_5_soya_Shapifier;
  __pyx_vtable_5_soya_SimpleShapifier.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_15SimpleShapifier___getcstate__;
  __pyx_vtable_5_soya_SimpleShapifier.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_15SimpleShapifier___setcstate__;
  __pyx_vtable_5_soya_SimpleShapifier.__pyx_base._shapify = (void *)__pyx_f_5_soya_15SimpleShapifier__shapify;
  __pyx_type_5_soya_SimpleShapifier.tp_base = __pyx_ptype_5_soya_Shapifier;
  if (PyType_Ready(&__pyx_type_5_soya_SimpleShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 27; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_SimpleShapifier.tp_dict, __pyx_vtabptr_5_soya_SimpleShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 27; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "SimpleShapifier", (PyObject *)&__pyx_type_5_soya_SimpleShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 27; goto __pyx_L1;}
  __pyx_ptype_5_soya_SimpleShapifier = &__pyx_type_5_soya_SimpleShapifier;
  __pyx_vtabptr_5_soya_TreeShapifier = &__pyx_vtable_5_soya_TreeShapifier;
  __pyx_vtable_5_soya_TreeShapifier.__pyx_base = *__pyx_vtabptr_5_soya_SimpleShapifier;
  __pyx_vtable_5_soya_TreeShapifier.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_13TreeShapifier___getcstate__;
  __pyx_vtable_5_soya_TreeShapifier.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_13TreeShapifier___setcstate__;
  __pyx_vtable_5_soya_TreeShapifier.__pyx_base.__pyx_base._shapify = (void *)__pyx_f_5_soya_13TreeShapifier__shapify;
  __pyx_type_5_soya_TreeShapifier.tp_base = __pyx_ptype_5_soya_SimpleShapifier;
  if (PyType_Ready(&__pyx_type_5_soya_TreeShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 95; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_TreeShapifier.tp_dict, __pyx_vtabptr_5_soya_TreeShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 95; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "TreeShapifier", (PyObject *)&__pyx_type_5_soya_TreeShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 95; goto __pyx_L1;}
  __pyx_ptype_5_soya_TreeShapifier = &__pyx_type_5_soya_TreeShapifier;
  __pyx_vtabptr_5_soya_CellShadingShapifier = &__pyx_vtable_5_soya_CellShadingShapifier;
  __pyx_vtable_5_soya_CellShadingShapifier.__pyx_base = *__pyx_vtabptr_5_soya_SimpleShapifier;
  __pyx_vtable_5_soya_CellShadingShapifier.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_20CellShadingShapifier___getcstate__;
  __pyx_vtable_5_soya_CellShadingShapifier.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_20CellShadingShapifier___setcstate__;
  __pyx_vtable_5_soya_CellShadingShapifier.__pyx_base.__pyx_base._shapify = (void *)__pyx_f_5_soya_20CellShadingShapifier__shapify;
  __pyx_type_5_soya_CellShadingShapifier.tp_base = __pyx_ptype_5_soya_SimpleShapifier;
  __pyx_type_5_soya_CellShadingShapifier.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_CellShadingShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 165; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_CellShadingShapifier.tp_dict, __pyx_vtabptr_5_soya_CellShadingShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 165; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "CellShadingShapifier", (PyObject *)&__pyx_type_5_soya_CellShadingShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 165; goto __pyx_L1;}
  __pyx_ptype_5_soya_CellShadingShapifier = &__pyx_type_5_soya_CellShadingShapifier;
  __pyx_vtabptr_5_soya__Cal3dSubMesh = &__pyx_vtable_5_soya__Cal3dSubMesh;
  __pyx_vtable_5_soya__Cal3dSubMesh._build = (void *)__pyx_f_5_soya_13_Cal3dSubMesh__build;
  __pyx_vtable_5_soya__Cal3dSubMesh._build_neighbors = (void *)__pyx_f_5_soya_13_Cal3dSubMesh__build_neighbors;
  __pyx_type_5_soya__Cal3dSubMesh.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Cal3dSubMesh) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 98; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Cal3dSubMesh.tp_dict, __pyx_vtabptr_5_soya__Cal3dSubMesh) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 98; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Cal3dSubMesh", (PyObject *)&__pyx_type_5_soya__Cal3dSubMesh) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 98; goto __pyx_L1;}
  __pyx_ptype_5_soya__Cal3dSubMesh = &__pyx_type_5_soya__Cal3dSubMesh;
  __pyx_vtabptr_5_soya__SolidShape = &__pyx_vtable_5_soya__SolidShape;
  __pyx_vtable_5_soya__SolidShape.__pyx_base = *__pyx_vtabptr_5_soya__SimpleShape;
  __pyx_vtable_5_soya__SolidShape.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_11_SolidShape__render;
  __pyx_vtable_5_soya__SolidShape._render_triangle_solid = (void *)__pyx_f_5_soya_11_SolidShape__render_triangle_solid;
  __pyx_type_5_soya__SolidShape.tp_base = __pyx_ptype_5_soya__SimpleShape;
  if (PyType_Ready(&__pyx_type_5_soya__SolidShape) < 0) {__pyx_filename = __pyx_f[29]; __pyx_lineno = 18; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__SolidShape.tp_dict, __pyx_vtabptr_5_soya__SolidShape) < 0) {__pyx_filename = __pyx_f[29]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SolidShape", (PyObject *)&__pyx_type_5_soya__SolidShape) < 0) {__pyx_filename = __pyx_f[29]; __pyx_lineno = 18; goto __pyx_L1;}
  __pyx_ptype_5_soya__SolidShape = &__pyx_type_5_soya__SolidShape;
  __pyx_vtabptr_5_soya__IdleingMaterial = &__pyx_vtable_5_soya__IdleingMaterial;
  __pyx_vtable_5_soya__IdleingMaterial.__pyx_base = *__pyx_vtabptr_5_soya__Material;
  __pyx_vtable_5_soya__IdleingMaterial.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_16_IdleingMaterial___setcstate__;
  __pyx_type_5_soya__IdleingMaterial.tp_base = __pyx_ptype_5_soya__Material;
  if (PyType_Ready(&__pyx_type_5_soya__IdleingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 375; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__IdleingMaterial.tp_dict, __pyx_vtabptr_5_soya__IdleingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 375; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_IdleingMaterial", (PyObject *)&__pyx_type_5_soya__IdleingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 375; goto __pyx_L1;}
  __pyx_ptype_5_soya__IdleingMaterial = &__pyx_type_5_soya__IdleingMaterial;
  __pyx_vtabptr_5_soya__PythonIdleingMaterial = &__pyx_vtable_5_soya__PythonIdleingMaterial;
  __pyx_vtable_5_soya__PythonIdleingMaterial.__pyx_base = *__pyx_vtabptr_5_soya__IdleingMaterial;
  __pyx_vtable_5_soya__PythonIdleingMaterial.__pyx_base.__pyx_base._init_texture = (void *)__pyx_f_5_soya_22_PythonIdleingMaterial__init_texture;
  __pyx_vtable_5_soya__PythonIdleingMaterial.__pyx_base.__pyx_base._activate = (void *)__pyx_f_5_soya_22_PythonIdleingMaterial__activate;
  __pyx_vtable_5_soya__PythonIdleingMaterial.__pyx_base.__pyx_base._inactivate = (void *)__pyx_f_5_soya_22_PythonIdleingMaterial__inactivate;
  __pyx_type_5_soya__PythonIdleingMaterial.tp_base = __pyx_ptype_5_soya__IdleingMaterial;
  if (PyType_Ready(&__pyx_type_5_soya__PythonIdleingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 433; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__PythonIdleingMaterial.tp_dict, __pyx_vtabptr_5_soya__PythonIdleingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 433; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_PythonIdleingMaterial", (PyObject *)&__pyx_type_5_soya__PythonIdleingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 433; goto __pyx_L1;}
  __pyx_ptype_5_soya__PythonIdleingMaterial = &__pyx_type_5_soya__PythonIdleingMaterial;
  __pyx_vtabptr_5_soya_Fountain = &__pyx_vtable_5_soya_Fountain;
  __pyx_vtable_5_soya_Fountain.__pyx_base = *__pyx_vtabptr_5_soya__Particles;
  __pyx_type_5_soya_Fountain.tp_base = __pyx_ptype_5_soya__Particles;
  if (PyType_Ready(&__pyx_type_5_soya_Fountain) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 470; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Fountain.tp_dict, __pyx_vtabptr_5_soya_Fountain) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 470; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Fountain", (PyObject *)&__pyx_type_5_soya_Fountain) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 470; goto __pyx_L1;}
  __pyx_ptype_5_soya_Fountain = &__pyx_type_5_soya_Fountain;
  __pyx_vtabptr_5_soya_Smoke = &__pyx_vtable_5_soya_Smoke;
  __pyx_vtable_5_soya_Smoke.__pyx_base = *__pyx_vtabptr_5_soya__Particles;
  __pyx_type_5_soya_Smoke.tp_base = __pyx_ptype_5_soya__Particles;
  if (PyType_Ready(&__pyx_type_5_soya_Smoke) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_Smoke.tp_dict, __pyx_vtabptr_5_soya_Smoke) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Smoke", (PyObject *)&__pyx_type_5_soya_Smoke) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_ptype_5_soya_Smoke = &__pyx_type_5_soya_Smoke;
  __pyx_vtabptr_5_soya_FlagSubFire = &__pyx_vtable_5_soya_FlagSubFire;
  __pyx_vtable_5_soya_FlagSubFire.__pyx_base = *__pyx_vtabptr_5_soya__Particles;
  __pyx_type_5_soya_FlagSubFire.tp_base = __pyx_ptype_5_soya__Particles;
  if (PyType_Ready(&__pyx_type_5_soya_FlagSubFire) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 503; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_FlagSubFire.tp_dict, __pyx_vtabptr_5_soya_FlagSubFire) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 503; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "FlagSubFire", (PyObject *)&__pyx_type_5_soya_FlagSubFire) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 503; goto __pyx_L1;}
  __pyx_ptype_5_soya_FlagSubFire = &__pyx_type_5_soya_FlagSubFire;
  __pyx_vtabptr_5_soya_SolidShapifier = &__pyx_vtable_5_soya_SolidShapifier;
  __pyx_vtable_5_soya_SolidShapifier.__pyx_base = *__pyx_vtabptr_5_soya_SimpleShapifier;
  __pyx_vtable_5_soya_SolidShapifier.__pyx_base.__pyx_base._shapify = (void *)__pyx_f_5_soya_14SolidShapifier__shapify;
  __pyx_type_5_soya_SolidShapifier.tp_base = __pyx_ptype_5_soya_SimpleShapifier;
  if (PyType_Ready(&__pyx_type_5_soya_SolidShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 80; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_SolidShapifier.tp_dict, __pyx_vtabptr_5_soya_SolidShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 80; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "SolidShapifier", (PyObject *)&__pyx_type_5_soya_SolidShapifier) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 80; goto __pyx_L1;}
  __pyx_ptype_5_soya_SolidShapifier = &__pyx_type_5_soya_SolidShapifier;

  /* "/home/jiba/src/soya/base.pyx":71 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Image, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Material, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Shape, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SimpleShape, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SolidShape, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_TreeShape, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_CellShadingShape, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Point, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Vector, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Camera, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Light, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Volume, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_World, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Cal3dVolume, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Cal3dShape, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Portal, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_WaterCube, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Face, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Atmosphere, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Particles, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":74 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_VERSION, __pyx_k1p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":158 */
  __pyx_v_5_soya_LIGHT_NULL_ATTENUATION = 0.05;

  /* "/home/jiba/src/soya/base.pyx":275 */
  __pyx_1 = PyFloat_FromDouble(0.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_BLACK, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/base.pyx":276 */
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_WHITE, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/base.pyx":277 */
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_TRANSPARENT, __pyx_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/base.pyx":280 */
  __pyx_v_5_soya_quality = __pyx_e_5_soya_QUALITY_MEDIUM;

  /* "/home/jiba/src/soya/base.pyx":285 */
  __pyx_v_5_soya_CAN_USE_TEX_BORDER = 1;

  /* "/home/jiba/src/soya/base.pyx":299 */
  (__pyx_v_5_soya_white[0]) = 1.0;
  (__pyx_v_5_soya_white[1]) = 1.0;
  (__pyx_v_5_soya_white[2]) = 1.0;
  (__pyx_v_5_soya_white[3]) = 1.0;

  /* "/home/jiba/src/soya/init.pyx":316 */
  Py_INCREF(__pyx_k2p);
  __pyx_k3 = __pyx_k2p;
  __pyx_k4 = 640;
  __pyx_k5 = 480;
  __pyx_k6 = 0;
  __pyx_k7 = 1;
  __pyx_k8 = 1;

  /* "/home/jiba/src/soya/init.pyx":410 */
  __pyx_1 = PyInt_FromLong(4294967295); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SDL_ALLEVENTS, __pyx_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/init.pyx":411 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_SDL_ALLEVENTS); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_ALL_EVENTS, __pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/init.pyx":437 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_ALL_EVENTS); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 437; goto __pyx_L1;}
  __pyx_k9 = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":119 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k10 = Py_None;
  __pyx_k11 = 0.0;
  __pyx_k12 = 0.0;
  __pyx_k13 = 0.0;

  /* "/home/jiba/src/soya/math3d.pyx":306 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 306; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k14 = Py_None;

  /* "/home/jiba/src/soya/renderer.pyx":383 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_root_widget, Py_None) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 383; goto __pyx_L1;}

  /* "/home/jiba/src/soya/renderer.pyx":386 */
  __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 386; goto __pyx_L1;}
  __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_StandardError); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 386; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 386; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_5);
  __pyx_5 = 0;
  __pyx_2 = __Pyx_CreateClass(__pyx_1, __pyx_4, __pyx_n_GLError, "_soya"); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 386; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":387 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_GLError, __pyx_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 386; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":415 */
  __pyx_k16 = 1;

  /* "/home/jiba/src/soya/idler.pyx":18 */
  __pyx_5 = __Pyx_Import(__pyx_n_weakref, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_weakref, __pyx_5) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/idler.pyx":20 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_IDLER, Py_None) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; goto __pyx_L1;}

  /* "/home/jiba/src/soya/idler.pyx":21 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_BEFORE_RENDER, __pyx_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":23 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_weakref); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_WeakKeyDictionary); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_IDLEING_ITEMS, __pyx_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/idler.pyx":92 */
  Py_INCREF(Py_None);
  __pyx_k18 = Py_None;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":234 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 234; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k19 = Py_None;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":55 */
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 55; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_RaypickData), __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 55; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_RaypickData)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 55; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_5_soya_raypick_data));
  __pyx_v_5_soya_raypick_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":75 */
  __pyx_k20 = (-1.0);
  __pyx_k21 = 1;
  __pyx_k22 = 1;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 75; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k23 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 75; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k24 = Py_None;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":114 */
  __pyx_k25 = (-1.0);
  __pyx_k26 = 1;
  __pyx_k27 = 1;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 114; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k28 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 114; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k29 = Py_None;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":84 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 84; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k30 = Py_None;

  /* "/home/jiba/src/soya/soya3d/volume.pyx":23 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 23; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k31 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Shape)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 23; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k32 = Py_None;

  /* "/home/jiba/src/soya/soya3d/world.pyx":38 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k33 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Shape)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k34 = Py_None;

  /* "/home/jiba/src/soya/soya3d/world.pyx":143 */
  __pyx_k35 = (-1.0);
  __pyx_k36 = 1;
  __pyx_k37 = 1;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 143; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k38 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 143; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k39 = Py_None;

  /* "/home/jiba/src/soya/soya3d/world.pyx":194 */
  __pyx_k40 = (-1.0);
  __pyx_k41 = 1;
  __pyx_k42 = 1;

  /* "/home/jiba/src/soya/soya3d/world.pyx":368 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_RaypickContext)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 368; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k43 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k44 = Py_None;

  /* "/home/jiba/src/soya/soya3d/light.pyx":19 */
  __pyx_5 = PyList_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 19; goto __pyx_L1;}
  Py_DECREF(__pyx_v_5_soya_LIGHTS);
  __pyx_v_5_soya_LIGHTS = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":20 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 20; goto __pyx_L1;}
  Py_DECREF(__pyx_v_5_soya_LAST_LIGHTS);
  __pyx_v_5_soya_LAST_LIGHTS = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":35 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k45 = Py_None;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":35 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k46 = Py_None;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":345 */
  __pyx_k47 = (-1.0);
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 345; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k48 = Py_None;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":75 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 75; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k49 = Py_None;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":34 */
  Py_INCREF(Py_None);
  __pyx_k50 = Py_None;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":207 */
  __pyx_k51 = 1;
  __pyx_k52 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":283 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Position)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 283; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k53 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 283; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k54 = Py_None;
  __pyx_k55 = 1;
  __pyx_k56 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":45 */
  Py_INCREF(Py_None);
  __pyx_k57 = Py_None;
  __pyx_k58 = 0;
  __pyx_k59 = 0;
  __pyx_k60 = 0;
  __pyx_k61 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":77 */
  Py_INCREF(Py_None);
  __pyx_k62 = Py_None;
  __pyx_k63 = 0;
  __pyx_k64 = 0;
  __pyx_k65 = 0;

  /* "/home/jiba/src/soya/model/material.pyx":30 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 30; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k66 = Py_None;

  /* "/home/jiba/src/soya/model/material.pyx":376 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 376; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k67 = Py_None;

  /* "/home/jiba/src/soya/model/face.pyx":91 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 91; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k68 = Py_None;
  __pyx_k69 = 0.0;
  __pyx_k70 = 0.0;
  __pyx_k71 = 0.0;
  __pyx_k72 = 0.0;
  __pyx_k73 = 0.0;
  Py_INCREF(Py_None);
  __pyx_k74 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k75 = Py_None;

  /* "/home/jiba/src/soya/model/face.pyx":174 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 174; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k76 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k77 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 174; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k78 = Py_None;

  /* "/home/jiba/src/soya/model/face.pyx":241 */
  __pyx_k79 = 0.005;

  /* "/home/jiba/src/soya/model/sprite.pyx":19 */
  (__pyx_v_5_soya__SPRITE_MATRIX[0]) = 1.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[5]) = 1.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[10]) = 1.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[15]) = 1.0;

  /* "/home/jiba/src/soya/model/sprite.pyx":20 */
  (__pyx_v_5_soya__SPRITE_MATRIX[1]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[2]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[3]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[4]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[6]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[7]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[8]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[9]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[11]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[12]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[13]) = 0.0;
  (__pyx_v_5_soya__SPRITE_MATRIX[14]) = 0.0;

  /* "/home/jiba/src/soya/model/sprite.pyx":22 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[0]) = 1.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) = 1.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10]) = 1.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[15]) = 1.0;

  /* "/home/jiba/src/soya/model/sprite.pyx":23 */
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[1]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[2]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[3]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[6]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[7]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[11]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[12]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[13]) = 0.0;
  (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[14]) = 0.0;

  /* "/home/jiba/src/soya/model/sprite.pyx":61 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k80 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k81 = Py_None;

  /* "/home/jiba/src/soya/model/sprite.pyx":270 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 270; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k82 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 270; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k83 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 270; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k84 = Py_None;

  /* "/home/jiba/src/soya/model/particle.pyx":137 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 137; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k85 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 137; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k86 = Py_None;
  __pyx_k87 = 50;
  __pyx_k88 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":164 */
  __pyx_k89 = (-1);

  /* "/home/jiba/src/soya/model/particle.pyx":355 */
  __pyx_k90 = 0.0;
  __pyx_k91 = 0.0;
  __pyx_k92 = 0.0;

  /* "/home/jiba/src/soya/model/particle.pyx":374 */
  __pyx_k93 = 0.0;
  __pyx_k94 = 0.0;
  __pyx_k95 = 0.0;

  /* "/home/jiba/src/soya/model/particle.pyx":458 */
  __pyx_4 = __Pyx_Import(__pyx_n_random, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 458; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_random, __pyx_4) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 458; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":471 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 471; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k97 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 471; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k98 = Py_None;
  __pyx_k99 = 12;
  __pyx_k100 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":487 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 487; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k101 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 487; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k102 = Py_None;
  __pyx_k103 = 12;
  __pyx_k104 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":504 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 504; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k105 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 504; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k106 = Py_None;
  __pyx_k107 = 12;
  __pyx_k108 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":509 */
  __pyx_k109 = 0.0;
  __pyx_k110 = 0.0;
  __pyx_k111 = 0.0;

  /* "/home/jiba/src/soya/model/particle.pyx":531 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 531; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k112 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 531; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k113 = Py_None;
  __pyx_k114 = 6;
  __pyx_k115 = 0;
  Py_INCREF(Py_None);
  __pyx_k116 = Py_None;
  __pyx_k117 = 8;

  /* "/home/jiba/src/soya/model/particle.pyx":543 */
  __pyx_k118 = (-1);

  /* "/home/jiba/src/soya/model/land.pyx":226 */
  __pyx_v_5_soya_land_drawColor = glColor4fv;

  /* "/home/jiba/src/soya/model/land.pyx":227 */
  __pyx_v_5_soya_land_disableColor = __pyx_f_5_soya_noop;

  /* "/home/jiba/src/soya/model/land.pyx":228 */
  __pyx_v_5_soya_land_enableColor = __pyx_f_5_soya_noop;

  /* "/home/jiba/src/soya/model/land.pyx":339 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 339; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k119 = Py_None;
  __pyx_k120 = 0;
  __pyx_k121 = 0;
  __pyx_k122 = 1.0;

  /* "/home/jiba/src/soya/model/land.pyx":518 */
  __pyx_k123 = 0;
  __pyx_k124 = 0;
  __pyx_k125 = 0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":55 */
  __pyx_k126 = 0;
  __pyx_k127 = 80.0;

  /* "/home/jiba/src/soya/model/shapifier.pyx":139 */
  __pyx_k128 = 0;
  __pyx_k129 = 200.0;
  __pyx_k130 = 0.9;
  __pyx_k131 = 0;
  __pyx_k132 = 0.5;

  /* "/home/jiba/src/soya/model/shapifier.pyx":213 */
  __pyx_k133 = 0;
  __pyx_k134 = 80.0;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 213; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k135 = Py_None;
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_BLACK); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 213; goto __pyx_L1;}
  __pyx_k136 = __pyx_2;
  __pyx_2 = 0;
  __pyx_k137 = 4.0;
  __pyx_k138 = 0.3;

  /* "/home/jiba/src/soya/model/shapifier.pyx":243 */
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 243; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_SimpleShapifier), __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 243; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya_Shapifier)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 243; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__DEFAULT_SHAPIFIER));
  __pyx_v_5_soya__DEFAULT_SHAPIFIER = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":18 */
  __pyx_4 = __Pyx_Import(__pyx_k139p, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 18; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_os, __pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 18; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":23 */
  __pyx_v_5_soya_cal3d_nb_vertices = 0;
  __pyx_v_5_soya_cal3d_nb_faces = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":24 */
  __pyx_v_5_soya_cal3d_texcoords_array = 0;
  __pyx_v_5_soya_cal3d_shades_array = 0;
  __pyx_v_5_soya_cal3d_facesides_array = 0;

  /* "/home/jiba/src/soya/cal3d/shape.pyx":278 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 278; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k140 = Py_None;
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_BLACK); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 278; goto __pyx_L1;}
  __pyx_k141 = __pyx_5;
  __pyx_5 = 0;
  __pyx_k142 = 4.0;
  __pyx_k143 = 0.3;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":69 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 69; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k144 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Cal3dShape)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 69; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k145 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k146 = Py_None;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":93 */
  Py_INCREF(Py_None);
  __pyx_k147 = Py_None;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":228 */
  __pyx_k148 = 1.0;
  __pyx_k149 = 0.2;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":243 */
  __pyx_k150 = 0.2;

  /* "/home/jiba/src/soya/cal3d/volume.pyx":251 */
  __pyx_k151 = 0.2;
  __pyx_k152 = 0.2;

  /* "/home/jiba/src/soya/text/text.pyx":24 */
  __pyx_v_5_soya_library_inited = 0;

  /* "/home/jiba/src/soya/text/text.pyx":57 */
  __pyx_k153 = 20;
  __pyx_k154 = 30;

  /* "/home/jiba/src/soya/text/text.pyx":298 */
  __pyx_k155 = 0.0;
  __pyx_k156 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":388 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya");
}

static char *__pyx_filenames[] = {
  "base.pyx",
  "init.pyx",
  "math3d.pyx",
  "renderer.pyx",
  "idler.pyx",
  "atmosphere.pyx",
  "raypick.pyx",
  "coordsyst.pyx",
  "volume.pyx",
  "world.pyx",
  "light.pyx",
  "camera.pyx",
  "portal.pyx",
  "traveling_camera.pyx",
  "image.pyx",
  "material.pyx",
  "face.pyx",
  "shape.pyx",
  "cellshading.pyx",
  "tree.pyx",
  "sprite.pyx",
  "particle.pyx",
  "land.pyx",
  "shapifier.pyx",
  "shape.pyx",
  "volume.pyx",
  "text.pyx",
  "_soya.pyx",
  "watercube.pyx",
  "solid_shape.pyx",
};
statichere char **__pyx_f = __pyx_filenames;

/* Runtime support code */

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name) {
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if ((none_allowed && obj == Py_None) || PyObject_TypeCheck(obj, type))
        return 1;
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, obj->ob_type->tp_name);
    return 0;
}

static int __Pyx_GetStarArgs(
    PyObject **args, 
    PyObject **kwds,
    char *kwd_list[], 
    int nargs,
    PyObject **args2, 
    PyObject **kwds2)
{
    PyObject *x = 0, *args1 = 0, *kwds1 = 0;
    
    if (args2)
        *args2 = 0;
    if (kwds2)
        *kwds2 = 0;
    
    if (args2) {
        args1 = PyTuple_GetSlice(*args, 0, nargs);
        if (!args1)
            goto bad;
        *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_Size(*args));
        if (!*args2)
            goto bad;
    }
    else {
        args1 = *args;
        Py_INCREF(args1);
    }
    
    if (kwds2) {
        if (*kwds) {
            char **p;
            kwds1 = PyDict_New();
            if (!kwds)
                goto bad;
            *kwds2 = PyDict_Copy(*kwds);
            if (!*kwds2)
                goto bad;
            for (p = kwd_list; *p; p++) {
                x = PyDict_GetItemString(*kwds, *p);
                if (x) {
                    if (PyDict_SetItemString(kwds1, *p, x) < 0)
                        goto bad;
                    if (PyDict_DelItemString(*kwds2, *p) < 0)
                        goto bad;
                }
            }
        }
        else {
            *kwds2 = PyDict_New();
            if (!*kwds2)
                goto bad;
        }
    }
    else {
        kwds1 = *kwds;
        Py_XINCREF(kwds1);
    }
    
    *args = args1;
    *kwds = kwds1;
    return 0;
bad:
    Py_XDECREF(args1);
    Py_XDECREF(kwds1);
    if (*args2)
        Py_XDECREF(*args2);
    if (*kwds2)
        Py_XDECREF(*kwds2);
    return -1;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (obj == Py_None || PyObject_TypeCheck(obj, type))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
        obj->ob_type->tp_name, type->tp_name);
    return 0;
}

static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;
    
    py_modname = PyString_FromString(modname);
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    result = PyClass_New(bases, dict, name);
bad:
    Py_XDECREF(py_modname);
    return result;
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = PyObject_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunction(__import__, "OOOO",
        name, global_dict, empty_dict, list);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static void __Pyx_WriteUnraisable(char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    PyErr_Fetch(&old_exc, &old_val, &old_tb);
    ctx = PyString_FromString(name);
    PyErr_Restore(old_exc, old_val, old_tb);
    if (!ctx)
        ctx = Py_None;
    PyErr_WriteUnraisable(ctx);
}

static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject("stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}

static int __Pyx_PrintItem(PyObject *v) {
    PyObject *f;
    
    if (!(f = __Pyx_GetStdout()))
        return -1;
    if (PyFile_SoftSpace(f, 1)) {
        if (PyFile_WriteString(" ", f) < 0)
            return -1;
    }
    if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
        return -1;
    if (PyString_Check(v)) {
        char *s = PyString_AsString(v);
        int len = PyString_Size(v);
        if (len > 0 &&
            isspace(Py_CHARMASK(s[len-1])) &&
            s[len-1] != ' ')
                PyFile_SoftSpace(f, 0);
    }
    return 0;
}

static int __Pyx_PrintNewline(void) {
    PyObject *f;
    
    if (!(f = __Pyx_GetStdout()))
        return -1;
    if (PyFile_WriteString("\n", f) < 0)
        return -1;
    PyFile_SoftSpace(f, 0);
    return 0;
}

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    /* Next, repeatedly, replace a tuple exception with its first item */
    while (PyTuple_Check(type) && PyTuple_Size(type) > 0) {
        PyObject *tmp = type;
        type = PyTuple_GET_ITEM(type, 0);
        Py_INCREF(type);
        Py_DECREF(tmp);
    }
    if (PyString_Check(type))
        ;
    else if (PyClass_Check(type))
        ; /*PyErr_NormalizeException(&type, &value, &tb);*/
    else if (PyInstance_Check(type)) {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
              "instance exception may not have a separate value");
            goto raise_error;
        }
        else {
            /* Normalize to raise <class>, <instance> */
            Py_DECREF(value);
            value = type;
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
            Py_INCREF(type);
        }
    }
    else {
        /* Not something you can raise.  You get an exception
           anyway, just not what you specified :-) */
        PyErr_Format(PyExc_TypeError,
                 "exceptions must be strings, classes, or "
                 "instances, not %s", type->ob_type->tp_name);
        goto raise_error;
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

static void __Pyx_UnpackError(void) {
    PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size");
}

static PyObject *__Pyx_UnpackItem(PyObject *seq, int i) {
  PyObject *item;
  if (!(item = PySequence_GetItem(seq, i))) {
    if (PyErr_ExceptionMatches(PyExc_IndexError))
    	__Pyx_UnpackError();
  }
  return item;
}

static int __Pyx_EndUnpack(PyObject *seq, int i) {
  PyObject *item;
  if (item = PySequence_GetItem(seq, i)) {
    Py_DECREF(item);
    __Pyx_UnpackError();
    return -1;
  }
  PyErr_Clear();
    return 0;
}

static PyObject *__Pyx_GetExcValue(void) {
    PyObject *type = 0, *value = 0, *tb = 0;
    PyObject *result = 0;
    PyThreadState *tstate = PyThreadState_Get();
    PyErr_Fetch(&type, &value, &tb);
    PyErr_NormalizeException(&type, &value, &tb);
    if (PyErr_Occurred())
        goto bad;
    if (!value) {
        value = Py_None;
        Py_INCREF(value);
    }
    Py_XDECREF(tstate->exc_type);
    Py_XDECREF(tstate->exc_value);
    Py_XDECREF(tstate->exc_traceback);
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    result = value;
    Py_XINCREF(result);
    type = 0;
    value = 0;
    tb = 0;
bad:
    Py_XDECREF(type);
    Py_XDECREF(value);
    Py_XDECREF(tb);
    return result;
}

static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
    while (t->p) {
        *t->p = PyString_InternFromString(t->s);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
    PyObject *pycobj = 0;
    int result;
    
    pycobj = PyCObject_FromVoidPtr(vtable, 0);
    if (!pycobj)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
        goto bad;
    result = 0;
    goto done;

bad:
    result = -1;
done:
    Py_XDECREF(pycobj);
    return result;
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_Get(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
