/* Generated by Pyrex 0.9.3.1 on Tue Jul 18 22:15:19 2006 */

#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#include "stdlib.h"
#include "string.h"
#include "math.h"
#include "stdint.h"
#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 "AL/al.h"
#include "AL/alc.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_LIGHT_INVALID = (1 << 6),
  __pyx_e_5_soya_CAMERA_PARTIAL = (1 << 5),
  __pyx_e_5_soya_CAMERA_ORTHO = (1 << 6),
  __pyx_e_5_soya_CAMERA_NO_LISTENER = (1 << 7),
  __pyx_e_5_soya_SOUND_PLAY_IN_3D = (1 << 6),
  __pyx_e_5_soya_SOUND_AUTO_REMOVE = (1 << 7),
  __pyx_e_5_soya_SOUND_LOOP = (1 << 8),
  __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),
  __pyx_e_5_soya_COORDSYS_STATIC = (1 << 19),
  __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC = (1 << 20),
};

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_MODEL_DIFFUSES = (1 << 5),
  __pyx_e_5_soya_MODEL_EMISSIVES = (1 << 6),
  __pyx_e_5_soya_MODEL_TEXCOORDS = (1 << 8),
  __pyx_e_5_soya_MODEL_VERTEX_OPTIONS = (1 << 10),
  __pyx_e_5_soya_MODEL_CELLSHADING = (1 << 11),
  __pyx_e_5_soya_MODEL_NEVER_LIT = (1 << 12),
  __pyx_e_5_soya_MODEL_PLANE_EQUATION = (1 << 14),
  __pyx_e_5_soya_MODEL_NEIGHBORS = (1 << 15),
  __pyx_e_5_soya_MODEL_INITED = (1 << 16),
  __pyx_e_5_soya_MODEL_TREE = (1 << 17),
  __pyx_e_5_soya_MODEL_DISPLAY_LISTS = (1 << 18),
  __pyx_e_5_soya_MODEL_FACE_LIST = (1 << 19),
  __pyx_e_5_soya_MODEL_HAS_SPHERE = (1 << 20),
  __pyx_e_5_soya_MODEL_SHADOW = (1 << 21),
  __pyx_e_5_soya_MODEL_STATIC_SHADOW = (1 << 22),
  __pyx_e_5_soya_MODEL_STATIC_LIT = (1 << 23),
  __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS = (1 << 24),
  __pyx_e_5_soya_MODEL_SHARED_DATA = (1 << 25),
};

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_TERRAIN_INITED = (1 << 2),
  __pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK = (1 << 3),
  __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS = (1 << 7),
  __pyx_e_5_soya_TERRAIN_COLORED = (1 << 8),
};

enum  {
  __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN = (1 << 0),
  __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA = __pyx_e_5_soya_VERTEX_ALPHA,
  __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID = (1 << 2),
  __pyx_e_5_soya_TERRAIN_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;
  intptr_t 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;
  intptr_t 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_ModelFace;

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_TerrainVertex;

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

struct __pyx_t_5_soya__TerrainPatch {
  float (sphere[4]);
  char level;
  struct __pyx_t_5_soya__TerrainTri (*tri_top);
  struct __pyx_t_5_soya__TerrainTri (*tri_left);
  struct __pyx_t_5_soya__TerrainTri (*tri_right);
  struct __pyx_t_5_soya__TerrainTri (*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__Model;

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

struct __pyx_vtabstruct_5_soya__Model {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  void ((*_instanced)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya__Body *,PyObject *));
  void ((*_batch)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya__Body *));
  void ((*_render)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya__Body *));
  int ((*_shadow)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya__Light *));
  void ((*_get_box)(struct __pyx_obj_5_soya__Model *,float (*),float (*)));
  void ((*_raypick)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_raypick_b)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_collect_raypickables)(struct __pyx_obj_5_soya__Model *,__pyx_t_5_soya_Chunk (*),float (*),float (*),struct __pyx_obj_5_soya_CoordSyst *));
  struct __pyx_obj_5_soya__Model *((*_create_deformed_data)(struct __pyx_obj_5_soya__Model *));
  void ((*_attach)(struct __pyx_obj_5_soya__Model *,PyObject *));
  void ((*_detach)(struct __pyx_obj_5_soya__Model *,PyObject *));
  int ((*_is_attached)(struct __pyx_obj_5_soya__Model *,PyObject *));
  void ((*_attach_to_bone)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya_CoordSyst *,PyObject *));
  void ((*_detach_from_bone)(struct __pyx_obj_5_soya__Model *,struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_advance_time)(struct __pyx_obj_5_soya__Model *,float ));
  void ((*_begin_round)(struct __pyx_obj_5_soya__Model *));
  PyObject *((*_get_attached_meshes)(struct __pyx_obj_5_soya__Model *));
  PyObject *((*_get_attached_coordsysts)(struct __pyx_obj_5_soya__Model *));
  void ((*_animate_blend_cycle)(struct __pyx_obj_5_soya__Model *,PyObject *,float ,float ));
  void ((*_animate_clear_cycle)(struct __pyx_obj_5_soya__Model *,PyObject *,float ));
  void ((*_animate_execute_action)(struct __pyx_obj_5_soya__Model *,PyObject *,float ,float ));
  void ((*_animate_reset)(struct __pyx_obj_5_soya__Model *));
  void ((*_set_lod_level)(struct __pyx_obj_5_soya__Model *,float ));
};
static struct __pyx_vtabstruct_5_soya__Model *__pyx_vtabptr_5_soya__Model;

staticforward PyTypeObject __pyx_type_5_soya__SimpleModel;

struct __pyx_obj_5_soya__SimpleModel {
  struct __pyx_obj_5_soya__Model __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_ModelFace (*_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__SimpleModel {
  struct __pyx_vtabstruct_5_soya__Model __pyx_base;
  void ((*__setcstate_data__)(struct __pyx_obj_5_soya__SimpleModel *,PyObject *));
  void ((*_register_material)(struct __pyx_obj_5_soya__SimpleModel *,struct __pyx_obj_5_soya__Material *));
  void ((*_add_coord)(struct __pyx_obj_5_soya__SimpleModel *,struct __pyx_obj_5_soya__Vertex *));
  int ((*_register_value)(struct __pyx_obj_5_soya__SimpleModel *,float (*),int ));
  int ((*_register_color)(struct __pyx_obj_5_soya__SimpleModel *,float (*)));
  void ((*_add_face)(struct __pyx_obj_5_soya__SimpleModel *,struct __pyx_obj_5_soya__Face *,PyObject *,PyObject *,PyObject *,int ));
  int ((*_add_vertex)(struct __pyx_obj_5_soya__SimpleModel *,struct __pyx_obj_5_soya__Vertex *,PyObject *,PyObject *,PyObject *,int ));
  PyObject *((*_identify_vertices)(struct __pyx_obj_5_soya__SimpleModel *,PyObject *,float ));
  void ((*_compute_face_normals)(struct __pyx_obj_5_soya__SimpleModel *,PyObject *));
  void ((*_compute_vertex_normals)(struct __pyx_obj_5_soya__SimpleModel *,PyObject *,PyObject *,PyObject *));
  void ((*_compute_face_neighbors)(struct __pyx_obj_5_soya__SimpleModel *,PyObject *,PyObject *,PyObject *,int (*),char (*)));
  void ((*_build_sphere)(struct __pyx_obj_5_soya__SimpleModel *));
  void ((*_build_display_list)(struct __pyx_obj_5_soya__SimpleModel *));
  void ((*_init_display_list)(struct __pyx_obj_5_soya__SimpleModel *));
  void ((*_batch_face)(struct __pyx_obj_5_soya__SimpleModel *,__pyx_t_5_soya_ModelFace (*)));
  void ((*_face_raypick)(struct __pyx_obj_5_soya__SimpleModel *,__pyx_t_5_soya_ModelFace (*),float (*),struct __pyx_obj_5_soya_RaypickData *,struct __pyx_obj_5_soya_CoordSyst *));
  int ((*_face_raypick_b)(struct __pyx_obj_5_soya__SimpleModel *,__pyx_t_5_soya_ModelFace (*),float (*),struct __pyx_obj_5_soya_RaypickData *));
  void ((*_render_triangle)(struct __pyx_obj_5_soya__SimpleModel *,__pyx_t_5_soya_ModelFace (*)));
  void ((*_render_quad)(struct __pyx_obj_5_soya__SimpleModel *,__pyx_t_5_soya_ModelFace (*)));
  void ((*_render_vertex)(struct __pyx_obj_5_soya__SimpleModel *,int ,int ));
  int ((*_build_shadow)(struct __pyx_obj_5_soya__SimpleModel *,struct __pyx_obj_5_soya_CoordSyst *,struct __pyx_obj_5_soya__Light *,int ,int ));
};
static struct __pyx_vtabstruct_5_soya__SimpleModel *__pyx_vtabptr_5_soya__SimpleModel;

staticforward PyTypeObject __pyx_type_5_soya__CellShadingModel;

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

struct __pyx_vtabstruct_5_soya__CellShadingModel {
  struct __pyx_vtabstruct_5_soya__SimpleModel __pyx_base;
  void ((*_build_cellshading)(struct __pyx_obj_5_soya__CellShadingModel *,struct __pyx_obj_5_soya__Material *,PyObject *,float ,float ));
  void ((*_render_outline)(struct __pyx_obj_5_soya__CellShadingModel *,__pyx_t_5_soya_Frustum (*)));
  void ((*_prepare_cellshading_shades)(struct __pyx_obj_5_soya__CellShadingModel *,float (*),PyObject *));
  void ((*_prepare_cellshading)(struct __pyx_obj_5_soya__CellShadingModel *,struct __pyx_obj_5_soya_CoordSyst *,float (*)));
  float ((*_vertex_compute_cellshading)(struct __pyx_obj_5_soya__CellShadingModel *,float (*),float (*),PyObject *,float ));
  void ((*_render_triangle_cellshading)(struct __pyx_obj_5_soya__CellShadingModel *,__pyx_t_5_soya_ModelFace (*),float (*)));
  void ((*_render_quad_cellshading)(struct __pyx_obj_5_soya__CellShadingModel *,__pyx_t_5_soya_ModelFace (*),float (*)));
  void ((*_render_vertex_cellshading_smoothlit)(struct __pyx_obj_5_soya__CellShadingModel *,int ,int ,float (*)));
  void ((*_render_vertex_cellshading)(struct __pyx_obj_5_soya__CellShadingModel *,int ,int ,float (*)));
};
static struct __pyx_vtabstruct_5_soya__CellShadingModel *__pyx_vtabptr_5_soya__CellShadingModel;

staticforward PyTypeObject __pyx_type_5_soya__TreeModel;

struct __pyx_obj_5_soya__TreeModel {
  struct __pyx_obj_5_soya__SimpleModel __pyx_base;
  struct __pyx_t_5_soya__Node (*_tree);
};

struct __pyx_vtabstruct_5_soya__TreeModel {
  struct __pyx_vtabstruct_5_soya__SimpleModel __pyx_base;
  PyObject *((*_node2chunk)(struct __pyx_obj_5_soya__TreeModel *,struct __pyx_t_5_soya__Node (*),__pyx_t_5_soya_Chunk (*)));
  struct __pyx_t_5_soya__Node (*((*_chunk2node)(struct __pyx_obj_5_soya__TreeModel *,__pyx_t_5_soya_Chunk (*))));
  void ((*_build_tree)(struct __pyx_obj_5_soya__TreeModel *));
  void ((*_optimize_tree)(struct __pyx_obj_5_soya__TreeModel *,float ,int ,float ));
  void ((*compute_sphere)(struct __pyx_obj_5_soya__TreeModel *,__pyx_t_5_soya_ModelFace (*),float (*)));
  void ((*_batch_node)(struct __pyx_obj_5_soya__TreeModel *,struct __pyx_t_5_soya__Node (*),__pyx_t_5_soya_Frustum (*)));
  void ((*_node_raypick)(struct __pyx_obj_5_soya__TreeModel *,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__TreeModel *,struct __pyx_t_5_soya__Node (*),float (*),struct __pyx_obj_5_soya_RaypickData *));
  void ((*_raypick_from_context)(struct __pyx_obj_5_soya__TreeModel *,struct __pyx_obj_5_soya_RaypickData *,__pyx_t_5_soya_Chunk (*)));
  int ((*_raypick_from_context_b)(struct __pyx_obj_5_soya__TreeModel *,struct __pyx_obj_5_soya_RaypickData *,__pyx_t_5_soya_Chunk (*)));
};
static struct __pyx_vtabstruct_5_soya__TreeModel *__pyx_vtabptr_5_soya__TreeModel;

staticforward PyTypeObject __pyx_type_5_soya__ModelData;

struct __pyx_obj_5_soya__ModelData {
  struct __pyx_obj_5_soya__Model __pyx_base;
};

struct __pyx_vtabstruct_5_soya__ModelData {
  struct __pyx_vtabstruct_5_soya__Model __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__ModelData *__pyx_vtabptr_5_soya__ModelData;

staticforward PyTypeObject __pyx_type_5_soya__AnimatedModelData;

struct __pyx_obj_5_soya__AnimatedModelData {
  struct __pyx_obj_5_soya__ModelData __pyx_base;
  struct __pyx_obj_5_soya__Body *_body;
  struct __pyx_obj_5_soya__AnimatedModel *_model;
  PyObject *_attached_meshes;
  PyObject *_attached_coordsysts;
  struct CalModel (*_cal_model);
  float _delta_time;
  float (*_face_planes);
  float (*_coords);
  float (*_vnormals);
  int _face_plane_ok;
  int _vertex_ok;
};

struct __pyx_vtabstruct_5_soya__AnimatedModelData {
  struct __pyx_vtabstruct_5_soya__ModelData __pyx_base;
  void ((*_build_submeshes)(struct __pyx_obj_5_soya__AnimatedModelData *));
  void ((*_build_face_planes)(struct __pyx_obj_5_soya__AnimatedModelData *));
  void ((*_build_vertices)(struct __pyx_obj_5_soya__AnimatedModelData *,int ));
  void ((*_attach_all)(struct __pyx_obj_5_soya__AnimatedModelData *));
};
static struct __pyx_vtabstruct_5_soya__AnimatedModelData *__pyx_vtabptr_5_soya__AnimatedModelData;

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;
  int _auto_static_count;
};

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 (*)));
  void ((*_go_static)(struct __pyx_obj_5_soya_CoordSyst *));
  void ((*_go_not_static)(struct __pyx_obj_5_soya_CoordSyst *));
};
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 _w;
  float _constant;
  float _linear;
  float _quadratic;
  float _angle;
  float _exponent;
  float (_colors[16]);
  float (_data[3]);
  int _id;
  int _gl_id_enabled;
  PyObject *_static_shadow_displaylists;
};

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__Body;

struct __pyx_obj_5_soya__Body {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__Model *_model;
  struct __pyx_obj_5_soya__Model *_data;
};

struct __pyx_vtabstruct_5_soya__Body {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__Body *__pyx_vtabptr_5_soya__Body;

staticforward PyTypeObject __pyx_type_5_soya__World;

struct __pyx_obj_5_soya__World {
  struct __pyx_obj_5_soya__Body __pyx_base;
  PyObject *children;
  struct __pyx_obj_5_soya__Atmosphere *_atmosphere;
  PyObject *_filename;
  struct __pyx_obj_5_soya_ModelBuilder *_model_builder;
};

struct __pyx_vtabstruct_5_soya__World {
  struct __pyx_vtabstruct_5_soya__Body __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__AnimatedModel;

struct __pyx_obj_5_soya__AnimatedModel {
  struct __pyx_obj_5_soya__Model __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__AnimatedModel {
  struct __pyx_vtabstruct_5_soya__Model __pyx_base;
  void ((*_build_submeshes)(struct __pyx_obj_5_soya__AnimatedModel *));
  void ((*_set_face_neighborhood)(struct __pyx_obj_5_soya__AnimatedModel *,int ,int ,GLfloat (*)));
  void ((*_set_cell_shading)(struct __pyx_obj_5_soya__AnimatedModel *,struct __pyx_obj_5_soya__Material *,GLfloat (*),GLfloat ));
  void ((*_prepare_cellshading)(struct __pyx_obj_5_soya__AnimatedModel *,struct __pyx_obj_5_soya_CoordSyst *,float (*),int ,float (*),float (*)));
  void ((*_prepare_cellshading_shades)(struct __pyx_obj_5_soya__AnimatedModel *,float (*),PyObject *,int ,float (*),float (*)));
  void ((*_render_outline)(struct __pyx_obj_5_soya__AnimatedModel *,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__AnimatedModel *,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__AnimatedModel *,PyObject *,float ,float ,float ,float ,float ,float ,float ,float ,float ));
  void ((*_set_texture_from_model)(struct __pyx_obj_5_soya__AnimatedModel *,struct __pyx_obj_5_soya__Material *,PyObject *));
  int ((*_shadow2)(struct __pyx_obj_5_soya__AnimatedModel *,struct __pyx_obj_5_soya__Cal3dSubMesh *,struct __pyx_obj_5_soya__Body *,struct __pyx_obj_5_soya__Light *,float (*),float (*),float (*)));
  void ((*_build_vertices)(struct __pyx_obj_5_soya__AnimatedModel *,struct __pyx_obj_5_soya__AnimatedModelData *));
};
static struct __pyx_vtabstruct_5_soya__AnimatedModel *__pyx_vtabptr_5_soya__AnimatedModel;

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__Terrain;

struct __pyx_obj_5_soya__Terrain {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  PyObject *_materials;
  __pyx_t_5_soya_TerrainVertex (*_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__TerrainPatch (*_patchs);
};

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

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_MainLoop;

struct __pyx_obj_5_soya_MainLoop {
  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;
  double _last_fps_computation_time;
  int _nb_frame;
};

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_ModelBuilder;

struct __pyx_obj_5_soya_ModelBuilder {
  struct __pyx_obj_5_soya__CObj __pyx_base;
};

struct __pyx_vtabstruct_5_soya_ModelBuilder {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  struct __pyx_obj_5_soya__Model *((*_to_model)(struct __pyx_obj_5_soya_ModelBuilder *,struct __pyx_obj_5_soya__World *));
};
static struct __pyx_vtabstruct_5_soya_ModelBuilder *__pyx_vtabptr_5_soya_ModelBuilder;

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__Deform;

struct __pyx_obj_5_soya__Deform {
  struct __pyx_obj_5_soya__ModelData __pyx_base;
  struct __pyx_obj_5_soya__Model *_model;
  struct __pyx_obj_5_soya__Model *_data;
  int _option;
  float _time;
  float _time_speed;
};

struct __pyx_vtabstruct_5_soya__Deform {
  struct __pyx_vtabstruct_5_soya__ModelData __pyx_base;
  PyObject *((*_set_model)(struct __pyx_obj_5_soya__Deform *,struct __pyx_obj_5_soya__Model *));
  PyObject *((*_deform_points)(struct __pyx_obj_5_soya__Deform *,float (*),float (*),int ));
  PyObject *((*_deform_point)(struct __pyx_obj_5_soya__Deform *,float (*),float (*)));
};
static struct __pyx_vtabstruct_5_soya__Deform *__pyx_vtabptr_5_soya__Deform;

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_SimpleModelBuilder;

struct __pyx_obj_5_soya_SimpleModelBuilder {
  struct __pyx_obj_5_soya_ModelBuilder __pyx_base;
  int _shadow;
  float _max_face_angle;
};

struct __pyx_vtabstruct_5_soya_SimpleModelBuilder {
  struct __pyx_vtabstruct_5_soya_ModelBuilder __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_SimpleModelBuilder *__pyx_vtabptr_5_soya_SimpleModelBuilder;

staticforward PyTypeObject __pyx_type_5_soya_TreeModelBuilder;

struct __pyx_obj_5_soya_TreeModelBuilder {
  struct __pyx_obj_5_soya_SimpleModelBuilder __pyx_base;
  float _collapsing_distance;
  int _quality;
  float _max_child_radius;
};

struct __pyx_vtabstruct_5_soya_TreeModelBuilder {
  struct __pyx_vtabstruct_5_soya_SimpleModelBuilder __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_TreeModelBuilder *__pyx_vtabptr_5_soya_TreeModelBuilder;

staticforward PyTypeObject __pyx_type_5_soya_CellShadingModelBuilder;

struct __pyx_obj_5_soya_CellShadingModelBuilder {
  struct __pyx_obj_5_soya_SimpleModelBuilder __pyx_base;
  struct __pyx_obj_5_soya__Material *_shader;
  PyObject *_outline_color;
  float _outline_width;
  float _outline_attenuation;
};

struct __pyx_vtabstruct_5_soya_CellShadingModelBuilder {
  struct __pyx_vtabstruct_5_soya_SimpleModelBuilder __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_CellShadingModelBuilder *__pyx_vtabptr_5_soya_CellShadingModelBuilder;

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__AnimatedModel *,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__MainLoopingMaterial;

struct __pyx_obj_5_soya__MainLoopingMaterial {
  struct __pyx_obj_5_soya__Material __pyx_base;
};

struct __pyx_vtabstruct_5_soya__MainLoopingMaterial {
  struct __pyx_vtabstruct_5_soya__Material __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__MainLoopingMaterial *__pyx_vtabptr_5_soya__MainLoopingMaterial;

staticforward PyTypeObject __pyx_type_5_soya__PythonMainLoopingMaterial;

struct __pyx_obj_5_soya__PythonMainLoopingMaterial {
  struct __pyx_obj_5_soya__MainLoopingMaterial __pyx_base;
};

struct __pyx_vtabstruct_5_soya__PythonMainLoopingMaterial {
  struct __pyx_vtabstruct_5_soya__MainLoopingMaterial __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__PythonMainLoopingMaterial *__pyx_vtabptr_5_soya__PythonMainLoopingMaterial;

staticforward PyTypeObject __pyx_type_5_soya__SolidModel;

struct __pyx_obj_5_soya__SolidModel {
  struct __pyx_obj_5_soya__SimpleModel __pyx_base;
};

struct __pyx_vtabstruct_5_soya__SolidModel {
  struct __pyx_vtabstruct_5_soya__SimpleModel __pyx_base;
  void ((*_render_triangle_solid)(struct __pyx_obj_5_soya__SolidModel *,__pyx_t_5_soya_ModelFace (*),struct __pyx_obj_5_soya_CoordSyst *,int (*)));
};
static struct __pyx_vtabstruct_5_soya__SolidModel *__pyx_vtabptr_5_soya__SolidModel;

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_SolidModelBuilder;

struct __pyx_obj_5_soya_SolidModelBuilder {
  struct __pyx_obj_5_soya_SimpleModelBuilder __pyx_base;
};

struct __pyx_vtabstruct_5_soya_SolidModelBuilder {
  struct __pyx_vtabstruct_5_soya_SimpleModelBuilder __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_SolidModelBuilder *__pyx_vtabptr_5_soya_SolidModelBuilder;

staticforward PyTypeObject __pyx_type_5_soya__Sound;

struct __pyx_obj_5_soya__Sound {
  struct __pyx_obj_5_soya__CObj __pyx_base;
  PyObject *_filename;
  PyObject *_buffers;
  PyObject *_file;
  int _format;
  int _framerate;
};

struct __pyx_vtabstruct_5_soya__Sound {
  struct __pyx_vtabstruct_5_soya__CObj __pyx_base;
  ALuint ((*_getbuffer)(struct __pyx_obj_5_soya__Sound *,PyObject *));
};
static struct __pyx_vtabstruct_5_soya__Sound *__pyx_vtabptr_5_soya__Sound;

staticforward PyTypeObject __pyx_type_5_soya__WAVSound;

struct __pyx_obj_5_soya__WAVSound {
  struct __pyx_obj_5_soya__Sound __pyx_base;
};

struct __pyx_vtabstruct_5_soya__WAVSound {
  struct __pyx_vtabstruct_5_soya__Sound __pyx_base;
  PyObject *((*_getnextdata)(struct __pyx_obj_5_soya__WAVSound *));
};
static struct __pyx_vtabstruct_5_soya__WAVSound *__pyx_vtabptr_5_soya__WAVSound;

staticforward PyTypeObject __pyx_type_5_soya__OGGVorbisSound;

struct __pyx_obj_5_soya__OGGVorbisSound {
  struct __pyx_obj_5_soya__Sound __pyx_base;
};

struct __pyx_vtabstruct_5_soya__OGGVorbisSound {
  struct __pyx_vtabstruct_5_soya__Sound __pyx_base;
  PyObject *((*_getdata)(struct __pyx_obj_5_soya__OGGVorbisSound *,int ));
};
static struct __pyx_vtabstruct_5_soya__OGGVorbisSound *__pyx_vtabptr_5_soya__OGGVorbisSound;

staticforward PyTypeObject __pyx_type_5_soya__SoundPlayer;

struct __pyx_obj_5_soya__SoundPlayer {
  struct __pyx_obj_5_soya_CoordSyst __pyx_base;
  struct __pyx_obj_5_soya__Sound *_sound;
  ALuint _source;
  ALuint _current_buffer;
  ALuint _pending_buffer;
  int _current_buffer_id;
  float (_old_pos[3]);
};

struct __pyx_vtabstruct_5_soya__SoundPlayer {
  struct __pyx_vtabstruct_5_soya_CoordSyst __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__SoundPlayer *__pyx_vtabptr_5_soya__SoundPlayer;

staticforward PyTypeObject __pyx_type_5_soya__TestDeform;

struct __pyx_obj_5_soya__TestDeform {
  struct __pyx_obj_5_soya__Deform __pyx_base;
};

struct __pyx_vtabstruct_5_soya__TestDeform {
  struct __pyx_vtabstruct_5_soya__Deform __pyx_base;
};
static struct __pyx_vtabstruct_5_soya__TestDeform *__pyx_vtabptr_5_soya__TestDeform;

staticforward PyTypeObject __pyx_type_5_soya_PythonDeform;

struct __pyx_obj_5_soya_PythonDeform {
  struct __pyx_obj_5_soya__Deform __pyx_base;
};

struct __pyx_vtabstruct_5_soya_PythonDeform {
  struct __pyx_vtabstruct_5_soya__Deform __pyx_base;
};
static struct __pyx_vtabstruct_5_soya_PythonDeform *__pyx_vtabptr_5_soya_PythonDeform;

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__Model = 0;
static PyTypeObject *__pyx_ptype_5_soya__SimpleModel = 0;
static PyTypeObject *__pyx_ptype_5_soya__CellShadingModel = 0;
static PyTypeObject *__pyx_ptype_5_soya__TreeModel = 0;
static PyTypeObject *__pyx_ptype_5_soya__ModelData = 0;
static PyTypeObject *__pyx_ptype_5_soya__AnimatedModelData = 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__Body = 0;
static PyTypeObject *__pyx_ptype_5_soya__World = 0;
static PyTypeObject *__pyx_ptype_5_soya__Face = 0;
static PyTypeObject *__pyx_ptype_5_soya__AnimatedModel = 0;
static PyTypeObject *__pyx_ptype_5_soya__Sprite = 0;
static PyTypeObject *__pyx_ptype_5_soya__Portal = 0;
static PyTypeObject *__pyx_ptype_5_soya__Terrain = 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_MainLoop = 0;
static PyTypeObject *__pyx_ptype_5_soya_Glyph = 0;
static PyTypeObject *__pyx_ptype_5_soya__Font = 0;
static PyTypeObject *__pyx_ptype_5_soya_ModelBuilder = 0;
static PyTypeObject *__pyx_ptype_5_soya_Traveling = 0;
static PyTypeObject *__pyx_ptype_5_soya__TravelingCamera = 0;
static PyTypeObject *__pyx_ptype_5_soya__Deform = 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_SimpleModelBuilder = 0;
static PyTypeObject *__pyx_ptype_5_soya_TreeModelBuilder = 0;
static PyTypeObject *__pyx_ptype_5_soya_CellShadingModelBuilder = 0;
static PyTypeObject *__pyx_ptype_5_soya__Cal3dSubMesh = 0;
static PyTypeObject *__pyx_ptype_5_soya__MainLoopingMaterial = 0;
static PyTypeObject *__pyx_ptype_5_soya__PythonMainLoopingMaterial = 0;
static PyTypeObject *__pyx_ptype_5_soya__SolidModel = 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_SolidModelBuilder = 0;
static PyTypeObject *__pyx_ptype_5_soya__Sound = 0;
static PyTypeObject *__pyx_ptype_5_soya__WAVSound = 0;
static PyTypeObject *__pyx_ptype_5_soya__OGGVorbisSound = 0;
static PyTypeObject *__pyx_ptype_5_soya__SoundPlayer = 0;
static PyTypeObject *__pyx_ptype_5_soya__TestDeform = 0;
static PyTypeObject *__pyx_ptype_5_soya_PythonDeform = 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_terrain_drawColor)(float (*)));
static void ((*__pyx_v_5_soya_terrain_disableColor)(void));
static void ((*__pyx_v_5_soya_terrain_enableColor)(void));
static struct __pyx_obj_5_soya_ModelBuilder *__pyx_v_5_soya__DEFAULT_MODEL_BUILDER;
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 int __pyx_v_5_soya__SOUND_INITED;
static ALCdevice (*__pyx_v_5_soya__device);
static ALCcontext (*__pyx_v_5_soya__context);
static ALfloat __pyx_v_5_soya__reference_distance;
static float (__pyx_v_5_soya__ear_old_pos[3]);
static PyObject *__pyx_k4;
static int __pyx_k5;
static int __pyx_k6;
static int __pyx_k7;
static int __pyx_k8;
static int __pyx_k9;
static int __pyx_k10;
static PyObject *__pyx_k12;
static int __pyx_k13;
static float __pyx_k14;
static float __pyx_k15;
static PyObject *__pyx_k16;
static struct __pyx_obj_5_soya_CoordSyst *__pyx_k17;
static float __pyx_k18;
static float __pyx_k19;
static float __pyx_k20;
static struct __pyx_obj_5_soya__Vector *__pyx_k21;
static int __pyx_k23;
static PyObject *__pyx_k25;
static struct __pyx_obj_5_soya__Material *__pyx_k26;
static float __pyx_k27;
static int __pyx_k28;
static int __pyx_k29;
static struct __pyx_obj_5_soya__Point *__pyx_k30;
static struct __pyx_obj_5_soya__Vector *__pyx_k31;
static float __pyx_k32;
static int __pyx_k33;
static int __pyx_k34;
static struct __pyx_obj_5_soya__Point *__pyx_k35;
static struct __pyx_obj_5_soya__Vector *__pyx_k36;
static struct __pyx_obj_5_soya__World *__pyx_k37;
static struct __pyx_obj_5_soya__World *__pyx_k38;
static struct __pyx_obj_5_soya__Model *__pyx_k39;
static PyObject *__pyx_k40;
static PyObject *__pyx_k41;
static float __pyx_k42;
static float __pyx_k43;
static float __pyx_k44;
static float __pyx_k45;
static float __pyx_k46;
static struct __pyx_obj_5_soya__World *__pyx_k47;
static struct __pyx_obj_5_soya__Model *__pyx_k48;
static PyObject *__pyx_k49;
static float __pyx_k50;
static int __pyx_k51;
static int __pyx_k52;
static struct __pyx_obj_5_soya__Point *__pyx_k53;
static struct __pyx_obj_5_soya__Vector *__pyx_k54;
static float __pyx_k55;
static int __pyx_k56;
static int __pyx_k57;
static struct __pyx_obj_5_soya_RaypickContext *__pyx_k58;
static PyObject *__pyx_k59;
static struct __pyx_obj_5_soya__World *__pyx_k61;
static struct __pyx_obj_5_soya__World *__pyx_k62;
static float __pyx_k63;
static struct __pyx_obj_5_soya__Point *__pyx_k64;
static struct __pyx_obj_5_soya__World *__pyx_k65;
static PyObject *__pyx_k66;
static int __pyx_k67;
static int __pyx_k68;
static struct __pyx_obj_5_soya_Position *__pyx_k69;
static struct __pyx_obj_5_soya__Vector *__pyx_k70;
static int __pyx_k71;
static int __pyx_k72;
static PyObject *__pyx_k73;
static int __pyx_k74;
static int __pyx_k75;
static int __pyx_k76;
static int __pyx_k77;
static PyObject *__pyx_k78;
static int __pyx_k79;
static int __pyx_k80;
static int __pyx_k81;
static struct __pyx_obj_5_soya__Image *__pyx_k82;
static struct __pyx_obj_5_soya__Image *__pyx_k83;
static struct __pyx_obj_5_soya_CoordSyst *__pyx_k84;
static float __pyx_k85;
static float __pyx_k86;
static float __pyx_k87;
static float __pyx_k88;
static float __pyx_k89;
static PyObject *__pyx_k90;
static PyObject *__pyx_k91;
static struct __pyx_obj_5_soya__World *__pyx_k92;
static PyObject *__pyx_k93;
static struct __pyx_obj_5_soya__Material *__pyx_k94;
static float __pyx_k95;
static struct __pyx_obj_5_soya__World *__pyx_k96;
static struct __pyx_obj_5_soya__Material *__pyx_k97;
static struct __pyx_obj_5_soya__World *__pyx_k98;
static struct __pyx_obj_5_soya__Material *__pyx_k99;
static struct __pyx_obj_5_soya__Material *__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 int __pyx_k105;
static float __pyx_k106;
static float __pyx_k107;
static float __pyx_k108;
static float __pyx_k109;
static float __pyx_k110;
static float __pyx_k111;
static struct __pyx_obj_5_soya__World *__pyx_k113;
static struct __pyx_obj_5_soya__Material *__pyx_k114;
static int __pyx_k115;
static int __pyx_k116;
static struct __pyx_obj_5_soya__World *__pyx_k117;
static struct __pyx_obj_5_soya__Material *__pyx_k118;
static int __pyx_k119;
static int __pyx_k120;
static struct __pyx_obj_5_soya__World *__pyx_k121;
static struct __pyx_obj_5_soya__Material *__pyx_k122;
static int __pyx_k123;
static int __pyx_k124;
static float __pyx_k125;
static float __pyx_k126;
static float __pyx_k127;
static struct __pyx_obj_5_soya__World *__pyx_k128;
static struct __pyx_obj_5_soya__Material *__pyx_k129;
static int __pyx_k130;
static int __pyx_k131;
static PyObject *__pyx_k132;
static int __pyx_k133;
static int __pyx_k134;
static struct __pyx_obj_5_soya__World *__pyx_k135;
static int __pyx_k136;
static int __pyx_k137;
static float __pyx_k138;
static int __pyx_k139;
static int __pyx_k140;
static int __pyx_k141;
static int __pyx_k142;
static float __pyx_k143;
static int __pyx_k144;
static float __pyx_k145;
static float __pyx_k146;
static int __pyx_k147;
static float __pyx_k148;
static int __pyx_k149;
static float __pyx_k150;
static struct __pyx_obj_5_soya__Material *__pyx_k151;
static PyObject *__pyx_k152;
static float __pyx_k153;
static float __pyx_k154;
static struct __pyx_obj_5_soya__Material *__pyx_k156;
static PyObject *__pyx_k157;
static float __pyx_k158;
static float __pyx_k159;
static PyObject *__pyx_k160;
static int __pyx_k161;
static int __pyx_k162;
static float __pyx_k163;
static int __pyx_k164;
static struct __pyx_obj_5_soya__World *__pyx_k166;
static struct __pyx_obj_5_soya__Sound *__pyx_k167;
static int __pyx_k168;
static int __pyx_k169;
static float __pyx_k170;
static int __pyx_k171;
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_ModelFace (*))); /*proto*/
static void (__pyx_f_5_soya_model_option_activate(int )); /*proto*/
static void (__pyx_f_5_soya_model_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_model_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_terrain_tri_dealloc(struct __pyx_t_5_soya__TerrainTri (*))); /*proto*/
static int (__pyx_f_5_soya_terrain_tri_has_child(struct __pyx_t_5_soya__TerrainTri (*))); /*proto*/
static int (__pyx_f_5_soya_terrain_tri_diamond(struct __pyx_t_5_soya__TerrainTri (*))); /*proto*/
static void (__pyx_f_5_soya_terrain_tri_sphere(float (*),float (*),float (*),float (*))); /*proto*/
static struct __pyx_t_5_soya__TerrainTri (*(__pyx_f_5_soya_terrain_get_tri(void))); /*proto*/
static void (__pyx_f_5_soya_terrain_tri_drop(struct __pyx_t_5_soya__TerrainTri (*))); /*proto*/
static struct __pyx_t_5_soya__TerrainTri (*(__pyx_f_5_soya_terrain_create_tri(__pyx_t_5_soya_TerrainVertex (*),__pyx_t_5_soya_TerrainVertex (*),__pyx_t_5_soya_TerrainVertex (*),struct __pyx_t_5_soya__TerrainPatch (*)))); /*proto*/
static struct __pyx_t_5_soya__TerrainTri (*(__pyx_f_5_soya_terrain_create_child_tri(__pyx_t_5_soya_TerrainVertex (*),__pyx_t_5_soya_TerrainVertex (*),__pyx_t_5_soya_TerrainVertex (*),struct __pyx_t_5_soya__TerrainTri (*)))); /*proto*/
static void (__pyx_f_5_soya_terrain_tri_update_neighbor_after_split(struct __pyx_t_5_soya__TerrainTri (*))); /*proto*/
static void (__pyx_f_5_soya_terrain_tri_force_split(struct __pyx_t_5_soya__TerrainTri (*),__pyx_t_5_soya_TerrainVertex (*))); /*proto*/
static void (__pyx_f_5_soya_terrain_tri_update_neighbor_after_merge(struct __pyx_t_5_soya__TerrainTri (*))); /*proto*/
static void (__pyx_f_5_soya_terrain_get_height_at_factors(__pyx_t_5_soya_TerrainVertex (*),__pyx_t_5_soya_TerrainVertex (*),__pyx_t_5_soya_TerrainVertex (*),float ,float ,float (*),float (*))); /*proto*/
static void (__pyx_f_5_soya_terrain_drawColor_radeon(float (*))); /*proto*/
static void (__pyx_f_5_soya_noop(void)); /*proto*/
static void (__pyx_f_5_soya_terrain_disableColor_radeon(void)); /*proto*/
static void (__pyx_f_5_soya_terrain_enableColor_radeon(void)); /*proto*/
static void (__pyx_f_5_soya_SET_COLOR_OPAQUE(struct __pyx_obj_5_soya__Terrain *,int )); /*proto*/
static void (__pyx_f_5_soya_SET_COLOR_ALPHA(struct __pyx_obj_5_soya__Terrain *,int )); /*proto*/
static void (__pyx_f_5_soya_quit_cal3d(void)); /*proto*/
static void (__pyx_f_5_soya__init_sound(PyObject *,int ,float ,float )); /*proto*/
static void (__pyx_f_5_soya__update_sound_listener_position(struct __pyx_obj_5_soya_CoordSyst *,float )); /*proto*/

/* Implementation of _soya */

static char (__pyx_k1[]) = "0.12";
static char (__pyx_k3[]) = "Soya 3D";
static char (__pyx_k11[]) = "'( ( devices '( native esd sdl alsa arts null ) ) )";
static char (__pyx_k155[]) = "os.path";

static PyObject *__pyx_n_SDL_ALLEVENTS;
static PyObject *__pyx_n_Image;
static PyObject *__pyx_n_Material;
static PyObject *__pyx_n_Model;
static PyObject *__pyx_n_SimpleModel;
static PyObject *__pyx_n_SolidModel;
static PyObject *__pyx_n_TreeModel;
static PyObject *__pyx_n_CellShadingModel;
static PyObject *__pyx_n_Point;
static PyObject *__pyx_n_Vector;
static PyObject *__pyx_n_Camera;
static PyObject *__pyx_n_Light;
static PyObject *__pyx_n_Body;
static PyObject *__pyx_n_World;
static PyObject *__pyx_n_Cal3dBody;
static PyObject *__pyx_n_AnimatedModel;
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_ChunkError;
static PyObject *__pyx_n__chunk_check_error;
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_MAIN_LOOP;
static PyObject *__pyx_n_IDLER;
static PyObject *__pyx_n_BEFORE_RENDER;
static PyObject *__pyx_n_MAIN_LOOP_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_model_builder;
static PyObject *__pyx_n_os;
static PyObject *__pyx_n_load_raw_image;
static PyObject *__pyx_n_parse_cal3d_cfg_file;
static PyObject *__pyx_n_ALError;
static PyObject *__pyx_n_check_al_error;
static PyObject *__pyx_n_set_sound_volume;
static PyObject *__pyx_n_get_sound_volume;
static PyObject *__pyx_n_MemoryError;
static PyObject *__pyx_n_StandardError;
static PyObject *__pyx_n_WeakKeyDictionary;

static PyObject *__pyx_k1p;
static PyObject *__pyx_k3p;
static PyObject *__pyx_k11p;
static PyObject *__pyx_k155p;

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":66 */
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; 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 = 76; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":78 */
  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 = 82; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":84 */
  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":90 */
  __pyx_v_buffer = ((char (*))malloc(__pyx_v_size));

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

  /* "/home/jiba/src/soya/base.pyx":92 */
  __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_f_5_soya__chunk_check_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__chunk_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;

  /* "/home/jiba/src/soya/base.pyx":99 */
  __pyx_1 = chunk_check_error();
  if (__pyx_1) {

    /* "/home/jiba/src/soya/base.pyx":100 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_ChunkError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; goto __pyx_L1;}
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; 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);
  __Pyx_AddTraceback("_soya._chunk_check_error");
  __pyx_r = 0;
  __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":105 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_clazz, __pyx_n___new__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; 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 = 105; 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 = 105; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_obj));
  __pyx_v_obj = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/base.pyx":106 */
  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":110 */

  __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":113 */

  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":116 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_getattr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; 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 = 116; 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 = 116; 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 = 116; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n___dict__); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; 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 = 117; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; 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":120 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; 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":121 */
  __pyx_3 = PyObject_Length(__pyx_v_state); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; 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 = 121; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_state, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; 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 = 121; 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":124 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n__reconstructor); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; 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 = 124; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; 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 = 124; 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":129 */
  __pyx_1 = __Pyx_Import(__pyx_n_copy, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; goto __pyx_L1;}
  Py_DECREF(__pyx_v_copy);
  __pyx_v_copy = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/base.pyx":130 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___new__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; 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 = 130; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; 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 = 130; 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 = 130; 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 = 130; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; 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 = 130; 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 = 130; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/base.pyx":132 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n___getstate__); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; 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":133 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_copy, __pyx_n_deepcopy); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; 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 = 133; 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":134 */
  __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_clone), __pyx_n___setstate__); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; 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 = 134; 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":136 */
  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":140 */
  __pyx_1 = PyString_FromStringAndSize(((char (*))__pyx_v_chunk->content),__pyx_v_chunk->nb); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __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.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":144 */
  __pyx_1 = PyString_FromStringAndSize(((char (*))__pyx_v_chunk->content),__pyx_v_chunk->nb); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; goto __pyx_L1;}
  Py_DECREF(__pyx_v_string);
  __pyx_v_string = __pyx_1;
  __pyx_1 = 0;

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

  /* "/home/jiba/src/soya/base.pyx":146 */
  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":151 */
  __pyx_1 = PyObject_Length(__pyx_v_string); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_v_length = __pyx_1;

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

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

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

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

  /* "/home/jiba/src/soya/base.pyx":156 */
  __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":27 */
  __pyx_v_5_soya_quality = __pyx_v_q;

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

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

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

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

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

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

    /* "/home/jiba/src/soya/init.pyx":34 */
    __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":37 */
    glHint(GL_FOG_HINT,GL_DONT_CARE);

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

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

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

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

    /* "/home/jiba/src/soya/init.pyx":42 */
    __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":45 */
    glHint(GL_FOG_HINT,GL_NICEST);

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

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

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

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

    /* "/home/jiba/src/soya/init.pyx":50 */
    __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":53 */
  __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_WIREFRAME);
  if (__pyx_1) {

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

    /* "/home/jiba/src/soya/init.pyx":55 */
    __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":57 */
    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);

    /* "/home/jiba/src/soya/init.pyx":58 */
    __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_k174p;

static char (__pyx_k174[]) = "\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";

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":61 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_VERSION); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; goto __pyx_L1;}
  __pyx_2 = PyString_FromString(((char (*))glGetString(GL_VERSION))); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 71; goto __pyx_L1;}
  __pyx_3 = PyString_FromString(((char (*))glGetString(GL_RENDERER))); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; goto __pyx_L1;}
  __pyx_4 = PyString_FromString(((char (*))glGetString(GL_VENDOR))); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_5_soya_MAX_LIGHTS); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 74; goto __pyx_L1;}
  __pyx_6 = PyInt_FromLong(__pyx_v_5_soya_MAX_CLIP_PLANES); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 75; goto __pyx_L1;}
  __pyx_7 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURES); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_8 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(8); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 70; 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_k174p, __pyx_9); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; goto __pyx_L1;}
  Py_DECREF(__pyx_9); __pyx_9 = 0;
  if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 61; 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_k175p;
static PyObject *__pyx_k176p;
static PyObject *__pyx_k177p;

static char (__pyx_k175[]) = "";
static char (__pyx_k176[]) = "* Soya 3D * Warning : glGetString returns NULL!";
static char (__pyx_k177[]) = "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":83 */
  glGetIntegerv(GL_MAX_LIGHTS,(&__pyx_v_5_soya_MAX_LIGHTS));

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

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

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

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

    /* "/home/jiba/src/soya/init.pyx":90 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_5_soya_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;

    /* "/home/jiba/src/soya/init.pyx":91 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_5_soya_LAST_LIGHTS, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; 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 = 91; 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":93 */
  glClearDepth(1.0);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "/home/jiba/src/soya/init.pyx":148 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_set_quality); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_5_soya_quality); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; 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 = 148; 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":152 */
  __pyx_v_gl_renderer = ((char (*))glGetString(GL_RENDERER));

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

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

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

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

    /* "/home/jiba/src/soya/init.pyx":158 */
    __pyx_1 = PyString_FromString(((char (*))glGetString(GL_RENDERER))); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 158; 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":159 */
  __pyx_4 = PySequence_Contains(__pyx_v_5_soya_DRIVER_3D, __pyx_k177p); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 159; goto __pyx_L1;}
  if (__pyx_4) {

    /* "/home/jiba/src/soya/init.pyx":169 */
    __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":174 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 174; 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 = 174; 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 = 174; 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_k178p;

static char (__pyx_k178[]) = "* 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":182 */
  if (__Pyx_PrintItem(__pyx_k178p) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 182; goto __pyx_L1;}
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 182; goto __pyx_L1;}

  /* "/home/jiba/src/soya/init.pyx":188 */
  __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 = 188; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 188; 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":195 */
  __pyx_1 = (__pyx_v_5_soya_SHADOW_DISPLAY_LIST != (-1));
  if (__pyx_1) {

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

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

    /* "/home/jiba/src/soya/init.pyx":198 */
    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":209 */
  __pyx_v_5_soya_NB_JOYSTICK = SDL_NumJoysticks();

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

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

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

    /* "/home/jiba/src/soya/init.pyx":214 */
    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_k179p;

static char (__pyx_k179[]) = "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":223 */
  __pyx_v_i = SDL_SetGamma(__pyx_v_r_gamma,__pyx_v_g_gamma,__pyx_v_b_gamma);

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

    /* "/home/jiba/src/soya/init.pyx":225 */
    __pyx_2 = PyString_FromString(SDL_GetError()); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 225; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k179p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 225; 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":226 */
    if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 226; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":227 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 227; 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 = 227; 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 = 227; 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_k180p;
static PyObject *__pyx_k181p;
static PyObject *__pyx_k182p;
static PyObject *__pyx_k183p;
static PyObject *__pyx_k186p;

static char (__pyx_k180[]) = "Video query failed : %s";
static char (__pyx_k181[]) = "Video mode set failed : %s";
static char (__pyx_k182[]) = "* Soya * Failed to set stencil buffer, shadows will be disabled.";
static char (__pyx_k183[]) = "* Soya * Using %i bits stencil buffer";
static char (__pyx_k186[]) = "* 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":233 */
  __pyx_v_5_soya_renderer->screen_width = __pyx_v_width;

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

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

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

    /* "/home/jiba/src/soya/init.pyx":238 */
    __pyx_2 = PyString_FromString(SDL_GetError()); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 238; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k180p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 238; 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":239 */
    if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 239; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 239; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":240 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 240; 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 = 240; 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 = 240; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

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

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

  /* "/home/jiba/src/soya/init.pyx":247 */
  __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":249 */
    __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":250 */
    __pyx_v_flags = (__pyx_v_flags | SDL_FULLSCREEN);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":252 */
  __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":253 */
  __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":257 */
  __pyx_v_stencil = 16;

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

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

    /* "/home/jiba/src/soya/init.pyx":262 */
    __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":263 */
    __pyx_1 = (__pyx_v_5_soya_renderer->screen == 0);
    if (__pyx_1) {
      __pyx_v_stencil = (__pyx_v_stencil >> 1);
      goto __pyx_L8;
    }
    /*else*/ {
      goto __pyx_L7;
    }
    __pyx_L8:;
  }
  __pyx_L7:;

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

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

    /* "/home/jiba/src/soya/init.pyx":268 */
    __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":269 */
    __pyx_1 = (__pyx_v_5_soya_renderer->screen == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/init.pyx":270 */
      __pyx_2 = PyString_FromString(SDL_GetError()); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 270; goto __pyx_L1;}
      __pyx_3 = PyNumber_Remainder(__pyx_k181p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 270; 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":271 */
      if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 271; goto __pyx_L1;}

      /* "/home/jiba/src/soya/init.pyx":272 */
      __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 272; 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 = 272; 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 = 272; goto __pyx_L1;}
      goto __pyx_L10;
    }
    __pyx_L10:;

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

    /* "/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_HAS_STENCIL));

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

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

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

  /* "/home/jiba/src/soya/init.pyx":282 */
  __pyx_3 = PyList_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 282; 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 = 282; 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 = 282; 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":283 */
  for (__pyx_v_i = 0; __pyx_v_i < 10; ++__pyx_v_i) {

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

    /* "/home/jiba/src/soya/init.pyx":285 */
    __pyx_3 = PyFloat_FromDouble(0.1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; 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 = 285; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_L11:;
  }
  /*else*/ {

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

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

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

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

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

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

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

  /* "/home/jiba/src/soya/init.pyx":298 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 298; 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":299 */
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_resize); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; 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 = 299; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; goto __pyx_L1;}
    __pyx_7 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; goto __pyx_L1;}
    __pyx_8 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; goto __pyx_L1;}
    __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 299; 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 = 299; 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_L14;
  }
  __pyx_L14:;

  __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_k189p;
static PyObject *__pyx_k190p;
static PyObject *__pyx_k191p;

static char (__pyx_k189[]) = "* Soya * Initializing for MacOSX...";
static char (__pyx_k190[]) = "soya.macosx";
static char (__pyx_k191[]) = "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":303 */
  __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 303; goto __pyx_L1;}
  Py_DECREF(__pyx_v_sys);
  __pyx_v_sys = __pyx_1;
  __pyx_1 = 0;

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

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

    /* "/home/jiba/src/soya/init.pyx":306 */
    __pyx_1 = __Pyx_Import(__pyx_k190p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 306; 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":309 */
  __pyx_2 = (SDL_Init(((SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) | SDL_INIT_NOPARACHUTE)) < 0);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/init.pyx":310 */
    __pyx_1 = PyString_FromString(SDL_GetError()); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 310; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k191p, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 310; 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":311 */
    if (__Pyx_PrintItem(__pyx_v_s) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 311; goto __pyx_L1;}

    /* "/home/jiba/src/soya/init.pyx":312 */
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 312; 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 = 312; 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 = 312; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/init.pyx":313 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_set_video); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_height); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_fullscreen); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; goto __pyx_L1;}
  __pyx_6 = PyInt_FromLong(__pyx_v_resizable); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 313; 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 = 313; 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":314 */
  __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, sound = 0, sound_device = \"\'( ( devices \'( native esd sdl alsa arts null ) ) )\", sound_frequency = 44100, sound_reference_distance = 1.0, sound_doppler_factor = 0.01)\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.\n\nSet SOUND to true to initialize 3D sound support (default to false for backward compatibility)\nThe following arguments are meaningful only if SOUND is true:\nSOUND_DEVICE is the OpenAL device names, the default value should be nice.\nSOUND_FREQUENCY is the sound frequency.\nSOUND_REFERENCE_DISTANCE is the reference distance for sound attenuation.\nSOUND_DOPPLER_FACTOR can be used to increase or decrease the Doppler effect.";
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;
  int __pyx_v_sound;
  PyObject *__pyx_v_sound_device = 0;
  int __pyx_v_sound_frequency;
  float __pyx_v_sound_reference_distance;
  float __pyx_v_sound_doppler_factor;
  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","sound","sound_device","sound_frequency","sound_reference_distance","sound_doppler_factor",0};
  __pyx_v_title = __pyx_k4;
  __pyx_v_width = __pyx_k5;
  __pyx_v_height = __pyx_k6;
  __pyx_v_fullscreen = __pyx_k7;
  __pyx_v_resizeable = __pyx_k8;
  __pyx_v_create_surface = __pyx_k9;
  __pyx_v_sound = __pyx_k10;
  __pyx_v_sound_device = __pyx_k12;
  __pyx_v_sound_frequency = __pyx_k13;
  __pyx_v_sound_reference_distance = __pyx_k14;
  __pyx_v_sound_doppler_factor = __pyx_k15;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OiiiiiiOiff", __pyx_argnames, &__pyx_v_title, &__pyx_v_width, &__pyx_v_height, &__pyx_v_fullscreen, &__pyx_v_resizeable, &__pyx_v_create_surface, &__pyx_v_sound, &__pyx_v_sound_device, &__pyx_v_sound_frequency, &__pyx_v_sound_reference_distance, &__pyx_v_sound_doppler_factor)) return 0;
  Py_INCREF(__pyx_v_title);
  Py_INCREF(__pyx_v_sound_device);
  __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":334 */
  __pyx_1 = (!(__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_INITED));
  if (__pyx_1) {

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

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

      /* "/home/jiba/src/soya/init.pyx":337 */
      __pyx_2 = PyString_AsString(__pyx_v_title); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 337; 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":338 */
    __pyx_f_5_soya_init_joysticks();

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

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

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

    /* "/home/jiba/src/soya/init.pyx":344 */
    __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":346 */
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 346; 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 = 346; goto __pyx_L1;}
      __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_resize); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 346; 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 = 346; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(0); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 346; goto __pyx_L1;}
      __pyx_7 = PyInt_FromLong(__pyx_v_width); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 346; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_height); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 346; goto __pyx_L1;}
      __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 346; 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 = 346; 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":348 */
    __pyx_6 = __Pyx_Import(__pyx_n_atexit, 0); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 348; goto __pyx_L1;}
    Py_DECREF(__pyx_v_atexit);
    __pyx_v_atexit = __pyx_6;
    __pyx_6 = 0;

    /* "/home/jiba/src/soya/init.pyx":349 */
    __pyx_7 = PyObject_GetAttr(__pyx_v_atexit, __pyx_n_register); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_8 = __Pyx_GetName(__pyx_m, __pyx_n_quit); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 349; 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 = 349; 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":351 */
    __pyx_3 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 351; goto __pyx_L1;}
    Py_DECREF(__pyx_v_soya);
    __pyx_v_soya = __pyx_3;
    __pyx_3 = 0;

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

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

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

    /* "/home/jiba/src/soya/init.pyx":357 */
    __pyx_f_5_soya__init_sound(__pyx_v_sound_device,__pyx_v_sound_frequency,__pyx_v_sound_reference_distance,__pyx_v_sound_doppler_factor);
    goto __pyx_L5;
  }
  __pyx_L5:;

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

  __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);
  Py_DECREF(__pyx_v_sound_device);
  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_v_soya;
  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;
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);

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

  /* "/home/jiba/src/soya/init.pyx":363 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_inited); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 363; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

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

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

    /* "/home/jiba/src/soya/init.pyx":366 */
    __pyx_f_5_soya_quit_cal3d();
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya.quit");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_soya);
  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":374 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_state); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 374; goto __pyx_L1;}
  if (__pyx_1) {

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

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

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

    /* "/home/jiba/src/soya/init.pyx":379 */
    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":389 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 389; goto __pyx_L1;}
  Py_DECREF(__pyx_v_events);
  __pyx_v_events = __pyx_1;
  __pyx_1 = 0;

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

    /* "/home/jiba/src/soya/init.pyx":392 */
    __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":393 */
      __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":394 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_event.key.keysym.sym); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_5 = PyInt_FromLong(__pyx_v_event.key.keysym.mod); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(__pyx_v_event.key.keysym.unicode); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; goto __pyx_L1;}
        __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 394; 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 = 394; 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 = 394; 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":396 */
        __pyx_5 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; goto __pyx_L1;}
        __pyx_7 = PyInt_FromLong(__pyx_v_event.key.keysym.sym); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; goto __pyx_L1;}
        __pyx_1 = PyInt_FromLong(__pyx_v_event.key.keysym.mod); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 396; 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 = 396; 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 = 396; 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":398 */
      __pyx_7 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_1 = PyInt_FromLong(SDL_MOUSEMOTION); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(__pyx_v_event.motion.x); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(__pyx_v_event.motion.y); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_event.motion.xrel); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(__pyx_v_event.motion.yrel); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.motion.state); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; goto __pyx_L1;}
      __pyx_9 = PyTuple_New(6); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 398; 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 = 398; 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 = 398; 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":400 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 400; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 400; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(__pyx_v_event.button.button); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 400; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.button.x); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 400; goto __pyx_L1;}
      __pyx_9 = PyInt_FromLong(__pyx_v_event.button.y); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 400; goto __pyx_L1;}
      __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 400; 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 = 400; 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 = 400; 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":403 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 403; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(SDL_JOYAXISMOTION); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 403; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.jaxis.axis); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 403; goto __pyx_L1;}
      __pyx_9 = PyInt_FromLong(__pyx_v_event.jaxis.value); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 403; goto __pyx_L1;}
      __pyx_7 = PyTuple_New(3); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 403; 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 = 403; 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 = 403; 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":405 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 405; goto __pyx_L1;}
      __pyx_6 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 405; goto __pyx_L1;}
      __pyx_8 = PyInt_FromLong(__pyx_v_event.jbutton.button); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 405; goto __pyx_L1;}
      __pyx_9 = PyTuple_New(2); if (!__pyx_9) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 405; 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 = 405; 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 = 405; 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":408 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 408; goto __pyx_L1;}
      __pyx_1 = PyInt_FromLong(__pyx_v_event.type); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 408; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 408; 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 = 408; 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 = 408; 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":410 */
      __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 = 410; goto __pyx_L1;}
        __pyx_7 = PyInt_FromLong(__pyx_v_event.resize.w); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_event.resize.h); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; goto __pyx_L1;}
        __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 410; 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 = 410; 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 = 411; goto __pyx_L1;}
        __pyx_7 = PyInt_FromLong(__pyx_v_event.resize.w); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; goto __pyx_L1;}
        __pyx_4 = PyInt_FromLong(__pyx_v_event.resize.h); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; goto __pyx_L1;}
        __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; goto __pyx_L1;}
        __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(4); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 411; 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 = 411; 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":413 */
      __pyx_8 = PyObject_GetAttr(__pyx_v_events, __pyx_n_append); if (!__pyx_8) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 413; goto __pyx_L1;}
      __pyx_7 = PyInt_FromLong(SDL_VIDEORESIZE); if (!__pyx_7) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 413; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_event.resize.w); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 413; goto __pyx_L1;}
      __pyx_1 = PyInt_FromLong(__pyx_v_event.resize.h); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 413; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 413; 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 = 413; 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 = 413; 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":415 */
  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":418 */
  __pyx_1 = PyInt_FromLong(SDL_GetModState()); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 418; 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":421 */
  __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":431 */
  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":437 */
  __pyx_1 = (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
  if (__pyx_1) {

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

  /* "/home/jiba/src/soya/init.pyx":440 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 440; 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":447 */
  __pyx_1 = (__pyx_v_mode == 1);
  if (__pyx_1) {

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

    /* "/home/jiba/src/soya/init.pyx":450 */
    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_k16;
  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":461 */
  SDL_PumpEvents();

  /* "/home/jiba/src/soya/init.pyx":463 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyInt_AsLong(__pyx_v_mask); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 463; 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":464 */
  }
  __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":471 */
  SDL_GetRelativeMouseState((&__pyx_v_x),(&__pyx_v_y));

  /* "/home/jiba/src/soya/init.pyx":473 */
  __pyx_1 = PyInt_FromLong(__pyx_v_x); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_y); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 473; 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_k195p;

static char (__pyx_k195[]) = "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":36 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 36; goto __pyx_L1;}
  Py_INCREF(__pyx_k195p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k195p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 36; 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 = 36; 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":39 */

  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":42 */

  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 = 44; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":51 */
  __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":52 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; 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 = 52; 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 = 52; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_p));
  __pyx_v_p = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":53 */
  ((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":54 */
  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":60 */

  __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":69 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 69; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 69; 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 = 69; 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 = 69; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 69; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 69; 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 = 69; 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":70 */
    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":71 */
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; 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":72 */
    __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_Position), __pyx_n___deepcopy__); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 72; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 72; 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 = 72; 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 = 72; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_clone));
    __pyx_v_clone = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/math3d.pyx":73 */
    if (!__Pyx_TypeTest(__pyx_v_parent, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; 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 = 73; 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":74 */
    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 = 75; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 75; 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 = 75; 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":81 */
  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":84 */
  memcpy(__pyx_v_result,__pyx_v_self->_matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":85 */
  __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":86 */
    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":87 */
    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":90 */
  memcpy(__pyx_v_result,__pyx_v_self->_matrix,(3 * (sizeof(float ))));

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

    /* "/home/jiba/src/soya/math3d.pyx":92 */
    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":96 */
  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 = 97; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":98 */
  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 = 100; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":101 */
  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":105 */
  __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 = 105; 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 = 106; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":107 */
  (((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":111 */
  __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 = 111; 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 = 112; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":113 */
  (((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":117 */
  __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 = 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._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 = 118; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":119 */
  (((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_k17;
  __pyx_v_x = __pyx_k18;
  __pyx_v_y = __pyx_k19;
  __pyx_v_z = __pyx_k20;
  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 = 121; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":127 */
  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":128 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = __pyx_v_x;

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

  /* "/home/jiba/src/soya/math3d.pyx":130 */
  (((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":137 */
  __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 = 137; 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 = 137; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 137; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 137; 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":143 */
  (((struct __pyx_obj_5_soya__Point *)__pyx_v_self)->_matrix[0]) = __pyx_v_x;

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

  /* "/home/jiba/src/soya/math3d.pyx":145 */
  (((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 = 147; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":153 */
  ((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 = 155; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 155; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":163 */
  ((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":164 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; 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 = 164; 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 = 164; 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 = 164; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; 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 = 164; 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 = 166; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":173 */
  ((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":174 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; 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 = 174; 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 = 174; 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 = 174; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; 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 = 174; 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":180 */
  (((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":181 */
  (((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":182 */
  (((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 = 184; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":194 */
  ((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":195 */
  (((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":196 */
  (((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":197 */
  (((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":198 */
  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 = 200; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":201 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; 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 = 201; 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 = 203; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":213 */
  ((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":214 */
  (((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":215 */
  (((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":216 */
  (((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":217 */
  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 = 219; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":224 */
  ((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":225 */
  __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 = 225; 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 = 227; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":232 */
  ((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":233 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; 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 = 233; 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 = 233; 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 = 233; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; 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 = 233; 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 = 235; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_soya_Position, 0, "other")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 235; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":236 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_vector_to); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 236; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 236; 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 = 236; 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_k196p;

static char (__pyx_k196[]) = "<%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":239 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; 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 = 239; 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 = 239; 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 = 239; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(5); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; 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_k196p, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; 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":243 */
  __pyx_v_chunk = get_chunk();

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

  /* "/home/jiba/src/soya/math3d.pyx":245 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 245; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 245; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 245; 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":251 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 251; 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 = 251; goto __pyx_L1;}
  if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent, __pyx_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 251; 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 = 251; goto __pyx_L1;}

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

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

  /* "/home/jiba/src/soya/math3d.pyx":254 */
  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 = 259; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":264 */
  ((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":265 */
  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 = 267; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":268 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_convert_to); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 268; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 268; 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 = 268; 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":269 */
  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":275 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 275; 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 = 275; 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 = 275; 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 = 275; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 275; 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 = 275; 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 = 277; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":281 */
  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":282 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; 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":292 */
  memcpy(__pyx_v_result,__pyx_v_self->__pyx_base._matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":293 */
  __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":294 */
    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":295 */
    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":298 */
  memcpy(__pyx_v_result,__pyx_v_self->__pyx_base._matrix,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/math3d.pyx":299 */
  __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":300 */
    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":306 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 306; 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 = 306; 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 = 306; 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 = 306; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 306; 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 = 306; 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_k21;
  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 = 308; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_result), __pyx_ptype_5_soya__Vector, 1, "result")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 308; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":313 */
  ((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":314 */
  __pyx_1 = ((PyObject *)__pyx_v_result) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/math3d.pyx":315 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; 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 = 316; 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 = 317; 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 = 318; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; 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 = 315; 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":321 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n___init__); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 321; 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 = 322; 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 = 323; 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 = 324; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(4); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 321; 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 = 321; 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":326 */
    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 = 328; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":333 */
  ((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":334 */
  __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 = 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._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":340 */
  __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 = 340; 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":348 */
  __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":349 */
  (((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":350 */
  (((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":351 */
  (((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 = 353; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 353; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":360 */
  __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":361 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 361; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 361; 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 = 361; 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 = 361; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_p));
  __pyx_v_p = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":362 */
  ((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":363 */
  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 = 365; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 365; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":372 */
  ((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":373 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 373; 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 = 373; 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 = 373; 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 = 373; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 373; 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 = 373; 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 = 375; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 375; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":376 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 376; 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 = 376; 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 = 376; 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 = 376; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 376; 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 = 376; 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 = 378; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 378; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":379 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 379; 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 = 379; 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 = 379; 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 = 379; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 379; 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 = 379; 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 = 381; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_self), __pyx_ptype_5_soya__Vector, 1, "self")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 381; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":382 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___div__); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 382; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_number); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 382; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 382; 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 = 382; 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 = 384; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":385 */
  (((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":386 */
  (((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":387 */
  (((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":388 */
  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 = 390; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":391 */
  (((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":392 */
  (((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":393 */
  (((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":394 */
  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":397 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 397; 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 = 397; 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 = 397; 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 = 397; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 397; 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 = 397; 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":400 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 400; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_abs); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 400; 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 = 400; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 400; 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 = 400; 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 = 400; 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 = 400; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 400; 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 = 400; 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 = 400; 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 = 400; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 400; 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 = 400; 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 = 400; 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 = 400; 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":407 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_length); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 407; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 407; 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 = 407; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_length = __pyx_4;

  /* "/home/jiba/src/soya/math3d.pyx":408 */
  (((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":409 */
  (((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":410 */
  (((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 = 412; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_end), __pyx_ptype_5_soya_Position, 0, "end")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 412; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":417 */
  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":418 */
  ((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":419 */
  ((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":420 */
  (((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":421 */
  (((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":422 */
  (((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 = 424; goto __pyx_L1;}

  /* "/home/jiba/src/soya/math3d.pyx":429 */
  ((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":430 */
  __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 = 430; 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":28 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 28; 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":72 */
  ((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":73 */
  ((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":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)->top_lights);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->top_lights = __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)->worlds_made);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->worlds_made = __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)->portals);
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->portals = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":77 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; 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":78 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; 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":80 */
  ((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->opaque = get_chunk();

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

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

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

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

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

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

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

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

  /* "/home/jiba/src/soya/renderer.pyx":91 */
  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":94 */
  free(((struct __pyx_obj_5_soya_Renderer *)__pyx_v_self)->root_frustum);

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

  /* "/home/jiba/src/soya/renderer.pyx":96 */
  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":99 */
  __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":100 */
  __pyx_1 = (__pyx_v_coordsyst->_frustum_id == (-1));
  if (__pyx_1) {

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

    /* "/home/jiba/src/soya/renderer.pyx":102 */
    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":103 */
  __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":107 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 107; 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 = 107; 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 = 107; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_context));
  __pyx_v_context = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":108 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->contexts, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; 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 = 108; 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":109 */
  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":114 */
  __pyx_1 = ((PyObject *)__pyx_v_old) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":116 */
    __pyx_3 = PyObject_GetIter(__pyx_v_old->lights); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; 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 = 116; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
      __pyx_v_light = __pyx_4;
      __pyx_4 = 0;

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

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

        /* "/home/jiba/src/soya/renderer.pyx":119 */
        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":120 */
    __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":121 */
      glDisable(GL_CLIP_PLANE0);

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

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

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

      /* "/home/jiba/src/soya/renderer.pyx":125 */
      __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":127 */
  __pyx_2 = ((PyObject *)__pyx_v_new) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/renderer.pyx":128 */
    __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":129 */
    __pyx_4 = PyObject_GetIter(__pyx_v_new->lights); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; 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 = 129; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __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_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":131 */
  __pyx_3 = PyObject_GetIter(__pyx_v_5_soya_renderer->top_lights); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 131; 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 = 131; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 131; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":132 */
    __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 = 132; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; 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 = 132; 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":134 */
  __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":135 */
    glLoadIdentity();

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

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

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

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

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

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

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

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

    /* "/home/jiba/src/soya/renderer.pyx":144 */
    __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":145 */
      glClipPlane(GL_CLIP_PLANE4,(__pyx_v_new->portal->_equation + 16));

      /* "/home/jiba/src/soya/renderer.pyx":146 */
      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":150 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Atmosphere)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 150; 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":151 */
  __pyx_f_5_soya_disable_all_lights();

  /* "/home/jiba/src/soya/renderer.pyx":152 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->worlds_made); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 152; 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 = 152; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 152; 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":153 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->contexts, __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->top_lights, __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->worlds_made, __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_2 = PyObject_GetAttr(__pyx_v_self->portals, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; 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 = 156; 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":157 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->watercubes, __pyx_n___imul__); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 157; 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 = 157; 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":158 */
  __pyx_v_self->opaque->nb = 0;

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

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

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

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

  /* "/home/jiba/src/soya/renderer.pyx":163 */
  __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":166 */
  chunk_add_ptr(__pyx_v_list,((void (*))__pyx_v_obj));

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

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

  /* "/home/jiba/src/soya/renderer.pyx":169 */
  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":178 */
  __pyx_v_5_soya_renderer->frustums->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":181 */
  __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 = 181; 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":182 */
  ((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":186 */
  __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":189 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->portals, __pyx_n_reverse); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 189; 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":190 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->portals); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; 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 = 190; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Portal)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_portal));
    __pyx_v_portal = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":191 */
    __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":193 */
  __pyx_5 = PyObject_GetIter(__pyx_v_self->top_lights); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; 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 = 193; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; 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":195 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 195; 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":199 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_OPAQUE;

  /* "/home/jiba/src/soya/renderer.pyx":200 */
  ((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":203 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_SECONDPASS;

  /* "/home/jiba/src/soya/renderer.pyx":204 */
  ((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":206 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_ALPHA;

  /* "/home/jiba/src/soya/renderer.pyx":207 */
  glEnable(GL_BLEND);

  /* "/home/jiba/src/soya/renderer.pyx":208 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/renderer.pyx":209 */
  ((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":211 */
  ((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":212 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 212; 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":213 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Context)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; 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":216 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->portals); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; 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 = 216; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Portal)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_portal));
    __pyx_v_portal = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":217 */
    __pyx_3 = (__pyx_v_portal->__pyx_base._option & __pyx_e_5_soya_PORTAL_BOUND_ATMOSPHERE);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/renderer.pyx":219 */
      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":220 */
      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":221 */
      __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":222 */
        ((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":225 */
  __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":227 */
  __pyx_v_self->state = __pyx_e_5_soya_RENDERER_STATE_SPECIAL;

  /* "/home/jiba/src/soya/renderer.pyx":228 */
  ((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":233 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/renderer.pyx":234 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/renderer.pyx":235 */
  __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 = 235; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; 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":237 */
  ((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":247 */
  __pyx_v_nb = __pyx_v_list->nb;

  /* "/home/jiba/src/soya/renderer.pyx":248 */
  __pyx_v_list->nb = 0;

  /* "/home/jiba/src/soya/renderer.pyx":249 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_list->nb < __pyx_v_nb);
    if (!__pyx_1) break;

    /* "/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_obj));
    __pyx_v_obj = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":251 */
    __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":252 */
    __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":253 */
    __pyx_v_self->data->nb = chunk_get_int(__pyx_v_list);

    /* "/home/jiba/src/soya/renderer.pyx":256 */
    __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":257 */
      ((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":258 */
      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":261 */
    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":262 */
    __pyx_1 = ((PyObject *)__pyx_v_coordsyst) == Py_None;
    __pyx_3 = (!__pyx_1);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/renderer.pyx":263 */
      glLoadMatrixf(__pyx_v_coordsyst->_render_matrix);

      /* "/home/jiba/src/soya/renderer.pyx":264 */
      __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":266 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 266; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 266; 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__Model));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__Model));
    __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 266; 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 = 266; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_3) {
      if (!__Pyx_TypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya__Body)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 266; goto __pyx_L1;}
      ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_vtab)->_render(((struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_obj)),((struct __pyx_obj_5_soya__Body *)((PyObject *)__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":269 */
    __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":273 */
  __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":274 */
    __pyx_v_size = __pyx_v_self->current_camera->_viewport;

    /* "/home/jiba/src/soya/renderer.pyx":275 */
    glDisable(GL_LIGHTING);

    /* "/home/jiba/src/soya/renderer.pyx":276 */
    glDisable(GL_FOG);

    /* "/home/jiba/src/soya/renderer.pyx":277 */
    glDisable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/renderer.pyx":278 */
    glDisable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/renderer.pyx":279 */
    glDepthMask(GL_FALSE);

    /* "/home/jiba/src/soya/renderer.pyx":280 */
    __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":282 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/renderer.pyx":283 */
    glMatrixMode(GL_PROJECTION);

    /* "/home/jiba/src/soya/renderer.pyx":284 */
    glPushMatrix();

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

    /* "/home/jiba/src/soya/renderer.pyx":286 */
    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":287 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/renderer.pyx":288 */
    glVertex2i(0,0);

    /* "/home/jiba/src/soya/renderer.pyx":289 */
    glVertex2i((__pyx_v_size[2]),0);

    /* "/home/jiba/src/soya/renderer.pyx":290 */
    glVertex2i((__pyx_v_size[2]),(__pyx_v_size[3]));

    /* "/home/jiba/src/soya/renderer.pyx":291 */
    glVertex2i(0,(__pyx_v_size[3]));

    /* "/home/jiba/src/soya/renderer.pyx":292 */
    glEnd();

    /* "/home/jiba/src/soya/renderer.pyx":293 */
    glMatrixMode(GL_PROJECTION);

    /* "/home/jiba/src/soya/renderer.pyx":294 */
    glPopMatrix();

    /* "/home/jiba/src/soya/renderer.pyx":295 */
    glMatrixMode(GL_MODELVIEW);

    /* "/home/jiba/src/soya/renderer.pyx":296 */
    glEnable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/renderer.pyx":297 */
    glEnable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/renderer.pyx":298 */
    glEnable(GL_FOG);

    /* "/home/jiba/src/soya/renderer.pyx":299 */
    glEnable(GL_LIGHTING);

    /* "/home/jiba/src/soya/renderer.pyx":300 */
    glDepthMask(GL_TRUE);

    /* "/home/jiba/src/soya/renderer.pyx":301 */
    glClear(GL_DEPTH_BUFFER_BIT);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/renderer.pyx":303 */
    __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":305 */
    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":311 */
  __pyx_v_ptrf = __pyx_v_self->current_camera->_frustum->points;

  /* "/home/jiba/src/soya/renderer.pyx":317 */
  (__pyx_v_p[0]) = (((__pyx_v_ptrf[0]) + (__pyx_v_ptrf[12])) * 0.5);

  /* "/home/jiba/src/soya/renderer.pyx":318 */
  (__pyx_v_p[1]) = (((__pyx_v_ptrf[1]) + (__pyx_v_ptrf[13])) * 0.5);

  /* "/home/jiba/src/soya/renderer.pyx":319 */
  (__pyx_v_p[2]) = (((__pyx_v_ptrf[2]) + (__pyx_v_ptrf[14])) * 0.5);

  /* "/home/jiba/src/soya/renderer.pyx":320 */
  (__pyx_v_p[3]) = (-(__pyx_v_p[0]));

  /* "/home/jiba/src/soya/renderer.pyx":321 */
  (__pyx_v_p[4]) = (__pyx_v_p[1]);

  /* "/home/jiba/src/soya/renderer.pyx":322 */
  (__pyx_v_p[5]) = (__pyx_v_p[2]);

  /* "/home/jiba/src/soya/renderer.pyx":323 */
  (__pyx_v_p[6]) = (-(__pyx_v_p[0]));

  /* "/home/jiba/src/soya/renderer.pyx":324 */
  (__pyx_v_p[7]) = (-(__pyx_v_p[1]));

  /* "/home/jiba/src/soya/renderer.pyx":325 */
  (__pyx_v_p[8]) = (__pyx_v_p[2]);

  /* "/home/jiba/src/soya/renderer.pyx":326 */
  (__pyx_v_p[9]) = (__pyx_v_p[0]);

  /* "/home/jiba/src/soya/renderer.pyx":327 */
  (__pyx_v_p[10]) = (-(__pyx_v_p[1]));

  /* "/home/jiba/src/soya/renderer.pyx":328 */
  (__pyx_v_p[11]) = (__pyx_v_p[2]);

  /* "/home/jiba/src/soya/renderer.pyx":329 */
  glEnableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/renderer.pyx":330 */
  glVertexPointer(3,GL_FLOAT,0,__pyx_v_p);

  /* "/home/jiba/src/soya/renderer.pyx":331 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/renderer.pyx":332 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/renderer.pyx":333 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/renderer.pyx":334 */
  glDepthFunc(GL_LEQUAL);

  /* "/home/jiba/src/soya/renderer.pyx":335 */
  glPushMatrix();

  /* "/home/jiba/src/soya/renderer.pyx":336 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/renderer.pyx":338 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 338; 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 = 338; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 338; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/renderer.pyx":339 */
    __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":341 */
    glStencilMask(4294967295);

    /* "/home/jiba/src/soya/renderer.pyx":342 */
    glClearStencil(0);

    /* "/home/jiba/src/soya/renderer.pyx":343 */
    glClear(GL_STENCIL_BUFFER_BIT);

    /* "/home/jiba/src/soya/renderer.pyx":344 */
    glEnable(GL_STENCIL_TEST);

    /* "/home/jiba/src/soya/renderer.pyx":345 */
    glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);

    /* "/home/jiba/src/soya/renderer.pyx":348 */
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 348; 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":350 */
      glStencilMask(0);

      /* "/home/jiba/src/soya/renderer.pyx":351 */
      glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

      /* "/home/jiba/src/soya/renderer.pyx":353 */
      glColor4fv((__pyx_v_light->_colors + 12));

      /* "/home/jiba/src/soya/renderer.pyx":354 */
      glStencilFunc(GL_NOTEQUAL,0,4294967295);

      /* "/home/jiba/src/soya/renderer.pyx":355 */
      glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);

      /* "/home/jiba/src/soya/renderer.pyx":356 */
      glDisable(GL_CULL_FACE);

      /* "/home/jiba/src/soya/renderer.pyx":361 */
      glEnable(GL_DEPTH_TEST);

      /* "/home/jiba/src/soya/renderer.pyx":362 */
      glDepthFunc(GL_NOTEQUAL);

      /* "/home/jiba/src/soya/renderer.pyx":363 */
      glDepthRange(1.0,1.0);

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

      /* "/home/jiba/src/soya/renderer.pyx":366 */
      glDrawArrays(GL_QUADS,0,4);

      /* "/home/jiba/src/soya/renderer.pyx":367 */
      glEnable(GL_DEPTH_TEST);

      /* "/home/jiba/src/soya/renderer.pyx":368 */
      glEnable(GL_CULL_FACE);

      /* "/home/jiba/src/soya/renderer.pyx":369 */
      glDepthFunc(GL_LEQUAL);

      /* "/home/jiba/src/soya/renderer.pyx":370 */
      glDepthRange(0.0,1.0);
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/renderer.pyx":372 */
      glStencilMask(0);

      /* "/home/jiba/src/soya/renderer.pyx":373 */
      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":375 */
  glPopMatrix();

  /* "/home/jiba/src/soya/renderer.pyx":376 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/renderer.pyx":377 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/renderer.pyx":378 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/renderer.pyx":379 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/renderer.pyx":380 */
  glDisable(GL_STENCIL_TEST);

  /* "/home/jiba/src/soya/renderer.pyx":381 */
  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":384 */
  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 = 393; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 393; 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_k207p;
static PyObject *__pyx_k208p;

static char (__pyx_k207[]) = "Unknown GL_ERROR";
static char (__pyx_k208[]) = "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":397 */
  __pyx_v_error = glGetError();

  /* "/home/jiba/src/soya/renderer.pyx":398 */
  __pyx_1 = (__pyx_v_error != GL_NO_ERROR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/renderer.pyx":399 */
    __pyx_1 = (__pyx_v_error == GL_INVALID_ENUM);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":399 */
      if (__Pyx_PrintItem(__pyx_n_GL_INVALID_ENUM) < 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_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 = 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_INVALID_OPERATION);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":400 */
      if (__Pyx_PrintItem(__pyx_n_GL_INVALID_OPERATION) < 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_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 = 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;
    }
    __pyx_1 = (__pyx_v_error == GL_STACK_OVERFLOW);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":401 */
      if (__Pyx_PrintItem(__pyx_n_GL_STACK_OVERFLOW) < 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_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 = 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;}
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == GL_STACK_UNDERFLOW);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":402 */
      if (__Pyx_PrintItem(__pyx_n_GL_STACK_UNDERFLOW) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 402; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 402; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":402 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 402; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 402; 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 = 402; 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 = 402; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == GL_OUT_OF_MEMORY);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/renderer.pyx":403 */
      if (__Pyx_PrintItem(__pyx_n_GL_OUT_OF_MEMORY) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 403; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 403; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":403 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 403; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 403; 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 = 403; 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 = 403; goto __pyx_L1;}
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/renderer.pyx":404 */
      if (__Pyx_PrintItem(__pyx_k207p) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 404; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 404; goto __pyx_L1;}

      /* "/home/jiba/src/soya/renderer.pyx":404 */
      __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_GLError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 404; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 404; goto __pyx_L1;}
      Py_INCREF(__pyx_k208p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k208p);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 404; 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 = 404; 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":414 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_root_widget, __pyx_v_widget) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 414; goto __pyx_L1;}

  /* "/home/jiba/src/soya/renderer.pyx":415 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 415; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 415; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":416 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 416; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_resize); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 416; 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 = 416; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 416; goto __pyx_L1;}
    __pyx_5 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 416; goto __pyx_L1;}
    __pyx_6 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_6) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 416; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 416; 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 = 416; 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_k23;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|i", __pyx_argnames, &__pyx_v_swap_buffer)) return 0;

  /* "/home/jiba/src/soya/renderer.pyx":422 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 422; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 422; 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 = 422; goto __pyx_L1;}
  }
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 422; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/renderer.pyx":423 */
    __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 423; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_render); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 423; 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 = 423; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 423; 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":424 */
    __pyx_2 = __pyx_f_5_soya_check_gl_error(); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 424; goto __pyx_L1;}

    /* "/home/jiba/src/soya/renderer.pyx":425 */
    __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 = 427; 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 = 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.get_screen_height");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/main_loop.pyx":71 */
  Py_INCREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes);
  __pyx_r = ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes;
  goto __pyx_L0;

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

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

  /* "/home/jiba/src/soya/main_loop.pyx":75 */
  Py_INCREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks);
  __pyx_r = ((struct __pyx_obj_5_soya_MainLoop *)__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.MainLoop.next_round_tasks.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/main_loop.pyx":79 */
  Py_INCREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_return_value);
  __pyx_r = ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_return_value;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.MainLoop.return_value.__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_8MainLoop___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop___init__[] = "MainLoop(scene1, scene2,...) -> MainLoop\n\nCreates a new main_loop for scenes SCENE1, SCENE2,....";
static int __pyx_f_5_soya_8MainLoop___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/main_loop.pyx":85 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 85; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks);
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":86 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->fps = 0.0;

  /* "/home/jiba/src/soya/main_loop.pyx":87 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->running = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":88 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 88; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 88; 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 = 88; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes);
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":89 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration = 0.030;

  /* "/home/jiba/src/soya/main_loop.pyx":90 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->min_frame_duration = 0.020;

  /* "/home/jiba/src/soya/main_loop.pyx":91 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->will_render = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":93 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":94 */
  if (PyObject_SetAttr(__pyx_v_soya, __pyx_n_MAIN_LOOP, __pyx_v_self) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 94; goto __pyx_L1;}

  /* "/home/jiba/src/soya/main_loop.pyx":95 */
  if (PyObject_SetAttr(__pyx_v_soya, __pyx_n_IDLER, __pyx_v_self) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 95; 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.MainLoop.__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_f_5_soya_8MainLoop_stop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_stop[] = "MainLoop.stop(VALUE = None)\n\nStops the main loop. The stopping may not occur immediately, but at the end of the next iteration.\nMainLoop.stop() causes MainLoop.main_loop() to returns ; VALUE is the (optionnal) value that MainLoop.main_loop() will return.";
static PyObject *__pyx_f_5_soya_8MainLoop_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_k25;
  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/main_loop.pyx":102 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->running = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":103 */
  Py_INCREF(__pyx_v_value);
  Py_DECREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_return_value);
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_return_value = __pyx_v_value;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.MainLoop.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_8MainLoop_reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8MainLoop_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/main_loop.pyx":106 */
  __pyx_1 = __Pyx_Import(__pyx_n_time, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 106; goto __pyx_L1;}
  Py_DECREF(__pyx_v_time);
  __pyx_v_time = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":107 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 107; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 107; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 107; 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 = 107; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  ((struct __pyx_obj_5_soya_MainLoop *)__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.MainLoop.reset");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_time);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_main_loop;

static PyObject *__pyx_f_5_soya_8MainLoop_idle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8MainLoop_idle(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(__pyx_v_self);
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_main_loop); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 109; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 109; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 109; 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.MainLoop.idle");
  __pyx_r = 0;
  __pyx_L0:;
  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_8MainLoop_main_loop(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_main_loop[] = "MainLoop.main_loop()\n\nStarts idling with the current thread. This method never finishes, until you call MainLoop.stop().";
static PyObject *__pyx_f_5_soya_8MainLoop_main_loop(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/main_loop.pyx":115 */
  __pyx_1 = __Pyx_Import(__pyx_n_time, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 115; goto __pyx_L1;}
  Py_DECREF(__pyx_v_time);
  __pyx_v_time = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":120 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->running = 1;

  /* "/home/jiba/src/soya/main_loop.pyx":121 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 121; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 121; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 121; 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 = 121; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time = __pyx_4;
  __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 121; goto __pyx_L1;}
  __pyx_v_last_fps_computation_time = __pyx_4;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":122 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round = 0.0;

  /* "/home/jiba/src/soya/main_loop.pyx":124 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 124; 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/main_loop.pyx":126 */
  while (1) {
    __pyx_L2:;
    __pyx_5 = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->running == 1);
    if (!__pyx_5) break;

    /* "/home/jiba/src/soya/main_loop.pyx":127 */
    __pyx_v_nb_frame = 0;

    /* "/home/jiba/src/soya/main_loop.pyx":128 */
    while (1) {
      __pyx_L4:;
      __pyx_5 = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->running == 1);
      if (__pyx_5) {
        __pyx_5 = (__pyx_v_nb_frame < 80);
      }
      if (!__pyx_5) break;

      /* "/home/jiba/src/soya/main_loop.pyx":129 */
      __pyx_v_nb_frame = (__pyx_v_nb_frame + 1);

      /* "/home/jiba/src/soya/main_loop.pyx":131 */
      while (1) {
        __pyx_L6:;
        __pyx_6 = 1;
        if (!__pyx_6) break;

        /* "/home/jiba/src/soya/main_loop.pyx":132 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; 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 = 132; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_v_current = __pyx_4;

        /* "/home/jiba/src/soya/main_loop.pyx":133 */
        __pyx_v_delta = (__pyx_v_current - ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time);

        /* "/home/jiba/src/soya/main_loop.pyx":134 */
        __pyx_5 = (__pyx_v_delta > ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->min_frame_duration);
        if (__pyx_5) {
          goto __pyx_L7;
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/main_loop.pyx":135 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_sleep); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; goto __pyx_L1;}
        __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->min_frame_duration - __pyx_v_delta)); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; 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 = 135; 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/main_loop.pyx":137 */
      ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time = __pyx_v_current;

      /* "/home/jiba/src/soya/main_loop.pyx":139 */
      while (1) {
        __pyx_L9:;
        __pyx_5 = ((((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round + __pyx_v_delta) > ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration);
        if (!__pyx_5) break;

        /* "/home/jiba/src/soya/main_loop.pyx":140 */
        __pyx_v_spent_time = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration - ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round);

        /* "/home/jiba/src/soya/main_loop.pyx":142 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_advance_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; goto __pyx_L1;}
        __pyx_3 = PyFloat_FromDouble((__pyx_v_spent_time / ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration)); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; 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 = 142; 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/main_loop.pyx":143 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_end_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; 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/main_loop.pyx":144 */
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; 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/main_loop.pyx":146 */
        __pyx_5 = PyObject_IsTrue(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 146; goto __pyx_L1;}
        if (__pyx_5) {

          /* "/home/jiba/src/soya/main_loop.pyx":147 */
          __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; 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 = 147; 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 = 147; goto __pyx_L1;}
            __pyx_2 = PyObject_CallObject(__pyx_v_task, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 147; 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/main_loop.pyx":148 */
          __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 148; goto __pyx_L1;}
          Py_DECREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks);
          ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks = __pyx_3;
          __pyx_3 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/jiba/src/soya/main_loop.pyx":150 */
        __pyx_v_delta = (__pyx_v_delta - __pyx_v_spent_time);

        /* "/home/jiba/src/soya/main_loop.pyx":151 */
        ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round = 0;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/main_loop.pyx":153 */
      ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->will_render = 1;

      /* "/home/jiba/src/soya/main_loop.pyx":154 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_advance_time); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 154; goto __pyx_L1;}
      __pyx_1 = PyFloat_FromDouble((__pyx_v_delta / ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration)); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 154; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 154; 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 = 154; 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/main_loop.pyx":155 */
      ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->will_render = 0;

      /* "/home/jiba/src/soya/main_loop.pyx":156 */
      ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round + __pyx_v_delta);

      /* "/home/jiba/src/soya/main_loop.pyx":158 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_render); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 158; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 158; goto __pyx_L1;}
      __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 158; 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/main_loop.pyx":160 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 160; 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 = 160; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_v_current = __pyx_4;

    /* "/home/jiba/src/soya/main_loop.pyx":161 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->fps = (__pyx_v_nb_frame / (__pyx_v_current - __pyx_v_last_fps_computation_time));

    /* "/home/jiba/src/soya/main_loop.pyx":162 */
    __pyx_v_last_fps_computation_time = __pyx_v_current;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/main_loop.pyx":164 */
  Py_INCREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_return_value);
  __pyx_r = ((struct __pyx_obj_5_soya_MainLoop *)__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.MainLoop.main_loop");
  __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_f_5_soya_8MainLoop_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_update[] = "MainLoop.update()\n\n";
static PyObject *__pyx_f_5_soya_8MainLoop_update(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_time;
  double __pyx_v_current;
  double __pyx_v_delta;
  double __pyx_v_spent_time;
  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;
  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/main_loop.pyx":170 */
  __pyx_1 = __Pyx_Import(__pyx_n_time, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 170; goto __pyx_L1;}
  Py_DECREF(__pyx_v_time);
  __pyx_v_time = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":174 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_time, __pyx_n_time); if (!__pyx_1) {__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_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 174; 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 = 174; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_current = __pyx_4;

  /* "/home/jiba/src/soya/main_loop.pyx":176 */
  __pyx_5 = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_last_fps_computation_time == 0.0);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/main_loop.pyx":177 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time = __pyx_v_current;

    /* "/home/jiba/src/soya/main_loop.pyx":178 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round = 0.0;

    /* "/home/jiba/src/soya/main_loop.pyx":179 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_last_fps_computation_time = __pyx_v_current;

    /* "/home/jiba/src/soya/main_loop.pyx":180 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 180; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 180; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __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;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/main_loop.pyx":182 */
  __pyx_v_delta = (__pyx_v_current - ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time);

  /* "/home/jiba/src/soya/main_loop.pyx":183 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time = __pyx_v_current;

  /* "/home/jiba/src/soya/main_loop.pyx":185 */
  while (1) {
    __pyx_L3:;
    __pyx_5 = ((((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round + __pyx_v_delta) > ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration);
    if (!__pyx_5) break;

    /* "/home/jiba/src/soya/main_loop.pyx":186 */
    __pyx_v_spent_time = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration - ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round);

    /* "/home/jiba/src/soya/main_loop.pyx":188 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_advance_time); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; goto __pyx_L1;}
    __pyx_2 = PyFloat_FromDouble((__pyx_v_spent_time / ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration)); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 188; 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 = 188; 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/main_loop.pyx":189 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_end_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 189; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 189; goto __pyx_L1;}
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 189; 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/main_loop.pyx":190 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 190; 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/main_loop.pyx":192 */
    __pyx_5 = PyObject_IsTrue(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 192; goto __pyx_L1;}
    if (__pyx_5) {

      /* "/home/jiba/src/soya/main_loop.pyx":193 */
      __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
      for (;;) {
        __pyx_L6:;
        __pyx_3 = PyIter_Next(__pyx_1);
        if (!__pyx_3) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
          break;
        }
        Py_DECREF(__pyx_v_task);
        __pyx_v_task = __pyx_3;
        __pyx_3 = 0;
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_v_task, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 193; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
      }
      __pyx_L7:;
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/jiba/src/soya/main_loop.pyx":194 */
      __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 194; goto __pyx_L1;}
      Py_DECREF(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks);
      ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_next_round_tasks = __pyx_2;
      __pyx_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/main_loop.pyx":196 */
    __pyx_v_delta = (__pyx_v_delta - __pyx_v_spent_time);

    /* "/home/jiba/src/soya/main_loop.pyx":197 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/main_loop.pyx":199 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->will_render = 1;

  /* "/home/jiba/src/soya/main_loop.pyx":200 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_advance_time); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 200; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble((__pyx_v_delta / ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->round_duration)); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 200; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 200; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  __pyx_1 = 0;
  __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 200; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":201 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->will_render = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":202 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_time_since_last_round + __pyx_v_delta);

  /* "/home/jiba/src/soya/main_loop.pyx":204 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_render); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 204; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 204; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 204; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":205 */
  ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_nb_frame = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_nb_frame + 1);

  /* "/home/jiba/src/soya/main_loop.pyx":207 */
  __pyx_5 = (((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_nb_frame == 80);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/main_loop.pyx":208 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->fps = (80 / (__pyx_v_current - ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_last_fps_computation_time));

    /* "/home/jiba/src/soya/main_loop.pyx":209 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_last_fps_computation_time = __pyx_v_current;

    /* "/home/jiba/src/soya/main_loop.pyx":210 */
    ((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_nb_frame = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  __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.MainLoop.update");
  __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_8MainLoop_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_begin_round[] = "MainLoop.begin_round()\n\nCalled by MainLoop.main_loop when a new round begins; default implementation delegates to MainLoop.scene.begin_round.";
static PyObject *__pyx_f_5_soya_8MainLoop_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/main_loop.pyx":217 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP_ITEMS); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 217; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 217; 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 = 217; 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 = 217; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 217; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 217; 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/main_loop.pyx":218 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 218; 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 = 218; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 218; 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 = 218; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 218; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 218; 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/main_loop.pyx":219 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 219; goto __pyx_L1;}
  __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 219; 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 = 219; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_widget_begin_round); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 219; 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 = 219; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 219; 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.MainLoop.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_8MainLoop_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_end_round[] = "MainLoop.end_round()\n\nCalled by MainLoop.main_loop when a round is finished; default implementation delegates to MainLoop.scene.end_round.";
static PyObject *__pyx_f_5_soya_8MainLoop_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/main_loop.pyx":226 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP_ITEMS); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 226; 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 = 226; 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 = 226; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 226; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 226; 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/main_loop.pyx":227 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; 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 = 227; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; 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 = 227; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; 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/main_loop.pyx":228 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 228; goto __pyx_L1;}
  __pyx_5 = PyObject_IsTrue(__pyx_4); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 228; 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 = 228; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_widget_end_round); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 228; 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 = 228; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 228; 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/main_loop.pyx":230 */
  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.MainLoop.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_8MainLoop_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_advance_time[] = "MainLoop.advance_time(proportion)\n\nCalled by MainLoop.main_loop when a piece of a round has occured; default implementation delegates to MainLoop.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_8MainLoop_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/main_loop.pyx":238 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP_ITEMS); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 238; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 238; 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 = 238; 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 = 238; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 238; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 238; 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 = 238; 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/main_loop.pyx":239 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya_MainLoop *)__pyx_v_self)->_scenes); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 239; 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 = 239; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 239; 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 = 239; goto __pyx_L1;}
    __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 239; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 239; 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 = 239; 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/main_loop.pyx":240 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_root_widget); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 240; 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 = 240; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_widget_advance_time); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 240; 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 = 240; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 240; 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 = 240; 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.MainLoop.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_8MainLoop_render(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8MainLoop_render[] = "MainLoop.render()\n\nCalled by MainLoop.main_loop when rendering is needed; default implementation calls soya.render.";
static PyObject *__pyx_f_5_soya_8MainLoop_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/main_loop.pyx":246 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_BEFORE_RENDER); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_2 = PyObject_GetIter(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 246; 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 = 246; 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 = 246; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_v_i, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 246; 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/main_loop.pyx":247 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_render); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 247; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 247; 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.MainLoop.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":61 */
  (((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":62 */
  (((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":63 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_type = GL_LINEAR;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":64 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_start = 10.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":65 */
  ((struct __pyx_obj_5_soya__Atmosphere *)__pyx_v_self)->_fog_end = 100.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":66 */
  ((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":71 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":72 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":73 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_type);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":74 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_start);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":75 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_end);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":76 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_density);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":77 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":78 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":79 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":80 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 80; 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":85 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":86 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":87 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_type));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":88 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_start));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":89 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_end));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":90 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fog_density));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":91 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":92 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":93 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":94 */
  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":98 */
  __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 = 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._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":100 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_x); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 100; 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":105 */
  __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 = 105; 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":106 */
  __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 = 106; 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":107 */
  __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 = 107; 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 = 109; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":110 */
  __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":111 */
  __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":112 */
  __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":116 */
  __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 = 116; 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 = 117; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":118 */
  ((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":122 */
  __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 = 122; 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 = 123; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":124 */
  ((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":128 */
  __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 = 128; 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 = 129; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":130 */
  ((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":134 */
  __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 = 134; 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 = 134; 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 = 134; 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 = 134; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; 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":136 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; 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 = 136; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; 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 = 136; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; 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 = 136; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; 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 = 136; 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":140 */
  __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 = 140; 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 = 140; 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 = 140; 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 = 140; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; 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":142 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; 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 = 142; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; 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 = 142; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; 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 = 142; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; 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 = 142; 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":146 */
  __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 = 146; 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 = 146; 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 = 146; 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 = 146; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; 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":148 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; 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 = 148; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; 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 = 148; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; 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 = 148; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; 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 = 148; 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":151 */
  ((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":152 */
  ((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":155 */

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

static char (__pyx_k213[]) = "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":158 */
  __pyx_k213;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":159 */
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT,__pyx_v_self->_ambient);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":160 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_ATMOSPHERE_FOG);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":161 */
    glFogf(GL_FOG_MODE,__pyx_v_self->_fog_type);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":162 */
    glFogf(GL_FOG_START,__pyx_v_self->_fog_start);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":163 */
    glFogf(GL_FOG_END,__pyx_v_self->_fog_end);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":164 */
    glFogf(GL_FOG_DENSITY,__pyx_v_self->_fog_density);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":165 */
    glFogfv(GL_FOG_COLOR,__pyx_v_self->_fog_color);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":166 */
    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":171 */
  __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":172 */
  __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":175 */
  __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":179 */
  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":192 */
  (((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":193 */
  (((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":194 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_type = GL_LINEAR;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":195 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_start = 10.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":196 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_end = 100.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":197 */
  ((struct __pyx_obj_5_soya__SkyAtmosphere *)__pyx_v_self)->__pyx_base._fog_density = 1.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":198 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 198; 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":199 */
  ((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":204 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":205 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":206 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_type);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":207 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_start);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":208 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_end);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":209 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_density);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":210 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":211 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":212 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":213 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sky_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":214 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_cloud_scale);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":215 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; 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":219 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; 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 = 219; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 219; 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 = 219; 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 = 219; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":221 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":222 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":223 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_type));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":224 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_start));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":225 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_end));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":226 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._fog_density));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":227 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._ambient,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":228 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._bg_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":229 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._fog_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":230 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sky_color,4);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":231 */
  __pyx_4 = PyObject_Length(__pyx_v_cstate2); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 231; goto __pyx_L1;}
  __pyx_5 = (__pyx_4 >= 88);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":232 */
    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":234 */
  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_k26;
  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 = 236; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right), __pyx_ptype_5_soya__Material, 1, "right")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 236; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_back), __pyx_ptype_5_soya__Material, 1, "back")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 236; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left), __pyx_ptype_5_soya__Material, 1, "left")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 236; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_bottom), __pyx_ptype_5_soya__Material, 1, "bottom")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 236; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_top), __pyx_ptype_5_soya__Material, 1, "top")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 236; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":242 */
  __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 = 242; 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 = 243; 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":247 */
  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_k214p;

static char (__pyx_k214[]) = "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":249 */
  __pyx_2 = PyObject_Length(__pyx_v_sky_box); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 249; 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 = 249; 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 = 249; goto __pyx_L1;}
      __pyx_1 = (__pyx_2 == 6);
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":250 */
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_front); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_right); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_back); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_left); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_bottom); if (!__pyx_7) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_8 = __Pyx_GetName(__pyx_b, __pyx_n_top); if (!__pyx_8) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_9 = PyTuple_New(6); if (!__pyx_9) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 250; 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 = 251; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 251; goto __pyx_L1;}
    Py_INCREF(__pyx_k214p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k214p);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 251; 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 = 251; 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":255 */
  __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 = 255; 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 = 255; 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 = 255; 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 = 255; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 255; 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":257 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 257; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 257; 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 = 257; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 257; 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 = 257; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 257; 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 = 257; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 257; 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 = 257; 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":261 */
  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 = 262; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":263 */
  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":267 */
  __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 = 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._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 = 268; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":269 */
  ((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":272 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":273 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":274 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":275 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":276 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":277 */
  __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":278 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_self->_sky_box); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 278; 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":279 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":280 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":281 */
  glEnable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":282 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":283 */
  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":290 */
  glLoadMatrixf(__pyx_v_5_soya_renderer->current_camera->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":293 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_5_soya__DEFAULT_MATERIAL), __pyx_n_activate); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 293; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 293; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 293; 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":294 */
  __pyx_v_ptr = __pyx_v_5_soya_renderer->current_camera->_frustum->points;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":295 */
  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":297 */
  __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":298 */
  point_by_matrix(__pyx_v_face1,__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":299 */
  point_by_matrix((__pyx_v_face1 + 3),__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":300 */
  point_by_matrix((__pyx_v_face1 + 6),__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":301 */
  point_by_matrix((__pyx_v_face1 + 9),__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":303 */
  __pyx_v_y = (__pyx_v_5_soya_renderer->current_camera->_back * 0.5);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":304 */
  __pyx_v_h = (__pyx_v_5_soya_renderer->root_frustum->position[1]);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":305 */
  (__pyx_v_plane[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":306 */
  (__pyx_v_plane[1]) = (-1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":307 */
  (__pyx_v_plane[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":308 */
  (__pyx_v_plane[3]) = (__pyx_v_h + __pyx_v_y);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":309 */
  face_intersect_plane(__pyx_v_face1,4,__pyx_v_plane,(&__pyx_v_face2),(&__pyx_v_nb2));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":310 */
  __pyx_4 = (__pyx_v_nb2 > 0);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":311 */
    glColor4fv(__pyx_v_self->_sky_color);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":312 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":313 */
    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":314 */
    glEnd();
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":315 */
  free(__pyx_v_face2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":317 */
  (__pyx_v_plane[1]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":318 */
  (__pyx_v_plane[3]) = (-(__pyx_v_plane[3]));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":319 */
  face_intersect_plane(__pyx_v_face1,4,__pyx_v_plane,(&__pyx_v_face3),(&__pyx_v_nb3));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":320 */
  (__pyx_v_plane[1]) = (-1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":321 */
  (__pyx_v_plane[3]) = (__pyx_v_5_soya_renderer->root_frustum->position[1]);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":322 */
  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":323 */
  free(__pyx_v_face3);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":324 */
  __pyx_4 = (__pyx_v_nb2 > 0);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":325 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":326 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":327 */
    while (1) {
      __pyx_L8:;
      __pyx_4 = (__pyx_v_i < (__pyx_v_nb2 * 3));
      if (!__pyx_4) break;

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":328 */
      __pyx_v_f = (((__pyx_v_face2[(__pyx_v_i + 1)]) - __pyx_v_h) / __pyx_v_y);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":329 */
      __pyx_v_g = (1.0 - __pyx_v_f);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":330 */
      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":334 */
      glVertex3fv((__pyx_v_face2 + __pyx_v_i));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":335 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":336 */
    glEnd();
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":337 */
  free(__pyx_v_face2);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":340 */
  __pyx_4 = ((PyObject *)__pyx_v_self->_cloud) == Py_None;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":341 */
    (__pyx_v_plane[1]) = ((__pyx_v_5_soya_renderer->root_frustum->position[1]) + 5.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":342 */
    __pyx_v_h = (__pyx_v_5_soya_renderer->current_camera->_back * 0.7);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":343 */
    glEnable(GL_BLEND);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":344 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_cloud), __pyx_n_activate); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __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/soya3d/atmosphere.pyx":346 */
    __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":347 */
    (__pyx_v_plane[0]) = (((__pyx_v_ptr[0]) * 0.01) * __pyx_v_self->_cloud_scale);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":348 */
    (__pyx_v_plane[2]) = (((__pyx_v_ptr[2]) * 0.01) * __pyx_v_self->_cloud_scale);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":349 */
    __pyx_v_y = ((__pyx_v_h * 0.1) * __pyx_v_self->_cloud_scale);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":351 */
    __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":352 */
    glTranslatef((__pyx_v_ptr[0]),0.0,(__pyx_v_ptr[2]));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":354 */
    glBegin(GL_TRIANGLE_FAN);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":356 */
    glTexCoord2f((__pyx_v_plane[0]),(__pyx_v_plane[2]));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":357 */
    glVertex3f(0.0,(__pyx_v_plane[1]),0.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":359 */
    __pyx_v_ptr = __pyx_v_self->_cloud->_diffuse;

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":360 */
    glColor4f((__pyx_v_ptr[0]),(__pyx_v_ptr[1]),(__pyx_v_ptr[2]),0.0);

    /* "/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":365 */
    glTexCoord2f(((__pyx_v_plane[0]) - __pyx_v_y),((__pyx_v_plane[2]) + __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":365 */
    glVertex3f((-__pyx_v_h),(__pyx_v_plane[1]),__pyx_v_h);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":366 */
    glTexCoord2f(((__pyx_v_plane[0]) - __pyx_v_y),((__pyx_v_plane[2]) - __pyx_v_y));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":366 */
    glVertex3f((-__pyx_v_h),(__pyx_v_plane[1]),(-__pyx_v_h));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":368 */
    glEnd();

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":369 */
    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":375 */
  __pyx_v_SKY_BOX_DISTANCE = 10.0;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":376 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_sky_box); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 376; goto __pyx_L1;}
  __pyx_v_nb = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":377 */
  __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":378 */
  glLoadMatrixf(__pyx_v_5_soya_renderer->current_camera->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":379 */
  glTranslatef((__pyx_v_ptr[0]),(__pyx_v_ptr[1]),(__pyx_v_ptr[2]));

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":380 */
  __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":383 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 383; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 383; 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 = 383; 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 = 383; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 383; 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":384 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":385 */
  glTexCoord2f(0.0,0.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(1.0,0.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 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":387 */
  glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":388 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":388 */
  glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":389 */
  glEnd();

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":391 */
  __pyx_1 = (__pyx_v_nb > 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":393 */
    __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 393; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 393; 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 = 393; 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 = 393; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 393; 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":394 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":395 */
    glTexCoord2f(0.0,0.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(1.0,0.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 */
    glTexCoord2f(1.0,1.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":397 */
    glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":398 */
    glTexCoord2f(0.0,1.0);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":398 */
    glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":399 */
    glEnd();

    /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":401 */
    __pyx_1 = (__pyx_v_nb > 2);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":403 */
      __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 403; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 403; 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 = 403; 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 = 403; goto __pyx_L1;}
      __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 403; 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":404 */
      glBegin(GL_QUADS);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":405 */
      glTexCoord2f(0.0,0.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(1.0,0.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 */
      glTexCoord2f(1.0,1.0);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":407 */
      glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":408 */
      glTexCoord2f(0.0,1.0);

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":408 */
      glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":409 */
      glEnd();

      /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":411 */
      __pyx_1 = (__pyx_v_nb > 3);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":413 */
        __pyx_3 = PyInt_FromLong(3); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; 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 = 413; 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 = 413; goto __pyx_L1;}
        __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 413; 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":414 */
        glBegin(GL_QUADS);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":415 */
        glTexCoord2f(0.0,0.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(1.0,0.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 */
        glTexCoord2f(1.0,1.0);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":417 */
        glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":418 */
        glTexCoord2f(0.0,1.0);

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":418 */
        glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":419 */
        glEnd();

        /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":421 */
        __pyx_1 = (__pyx_v_nb > 4);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":423 */
          __pyx_2 = PyInt_FromLong(4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 423; goto __pyx_L1;}
          __pyx_3 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 423; 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 = 423; 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 = 423; goto __pyx_L1;}
          __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 423; 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":424 */
          glBegin(GL_QUADS);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":425 */
          glTexCoord2f(0.0,0.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(1.0,0.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 */
          glTexCoord2f(1.0,1.0);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":427 */
          glVertex3f(__pyx_v_SKY_BOX_DISTANCE,(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":428 */
          glTexCoord2f(0.0,1.0);

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":428 */
          glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE),(-__pyx_v_SKY_BOX_DISTANCE));

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":429 */
          glEnd();

          /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":431 */
          __pyx_1 = (__pyx_v_nb > 5);
          if (__pyx_1) {

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":433 */
            __pyx_4 = PyInt_FromLong(5); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 433; goto __pyx_L1;}
            __pyx_2 = PyObject_GetItem(__pyx_v_self->_sky_box, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 433; 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 = 433; 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 = 433; goto __pyx_L1;}
            __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 433; 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":434 */
            glBegin(GL_QUADS);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":435 */
            glTexCoord2f(0.0,0.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(1.0,0.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 */
            glTexCoord2f(1.0,1.0);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":437 */
            glVertex3f(__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":438 */
            glTexCoord2f(0.0,1.0);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":438 */
            glVertex3f((-__pyx_v_SKY_BOX_DISTANCE),__pyx_v_SKY_BOX_DISTANCE,__pyx_v_SKY_BOX_DISTANCE);

            /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":439 */
            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":441 */
  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":25 */
  __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":26 */
  __pyx_1 = ((PyObject *)__pyx_v_p) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":27 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 27; 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 = 27; 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 = 27; 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 = 27; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 27; 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 = 27; 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 = 27; 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":28 */
    __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 28; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 28; 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 = 28; 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 = 28; 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":29 */
    memcpy(__pyx_v_v->__pyx_base._matrix,__pyx_v_normal,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":30 */
    __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 30; 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":32 */
    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":33 */
    (__pyx_v_p->_matrix[0]) = ((__pyx_v_f[0]) + ((__pyx_v_f[3]) * __pyx_v_z));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":34 */
    (__pyx_v_p->_matrix[1]) = ((__pyx_v_f[1]) + ((__pyx_v_f[4]) * __pyx_v_z));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":35 */
    (__pyx_v_p->_matrix[2]) = ((__pyx_v_f[2]) + ((__pyx_v_f[5]) * __pyx_v_z));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":36 */
    memcpy(__pyx_v_v->__pyx_base._matrix,__pyx_v_normal,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":37 */
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 37; 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":49 */
  ((struct __pyx_obj_5_soya_RaypickData *)__pyx_v_self)->raypicked = get_chunk();

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":50 */
  ((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":53 */
  drop_chunk(((struct __pyx_obj_5_soya_RaypickData *)__pyx_v_self)->raypicked);

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":54 */
  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":60 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 60; 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":61 */
  __pyx_v_5_soya_raypick_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":62 */
  __pyx_v_5_soya_raypick_data->raypick_data->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":63 */
  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 = 70; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":71 */
  ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items = get_chunk();

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":72 */
  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":75 */
  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_k27;
  __pyx_v_half_line = __pyx_k28;
  __pyx_v_cull_face = __pyx_k29;
  __pyx_v_p = __pyx_k30;
  __pyx_v_v = __pyx_k31;
  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 = 77; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 77; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya__Point, 1, "p")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 77; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5_soya__Vector, 1, "v")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 77; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":82 */
  __pyx_v_items = ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":83 */
  __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":90 */
  __pyx_2 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 90; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":92 */
  ((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":93 */
  ((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":94 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":95 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":96 */
  __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":98 */
  __pyx_v_max = __pyx_v_items->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":99 */
  __pyx_v_items->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":100 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = (__pyx_v_items->nb < __pyx_v_max);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":101 */
    __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":102 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; 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__TreeModel));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__TreeModel));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; 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 = 102; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__TreeModel *)((struct __pyx_obj_5_soya__TreeModel *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_raypick_from_context(((struct __pyx_obj_5_soya__TreeModel *)((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":105 */
  __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":108 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":109 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":110 */
  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":111 */
    __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":112 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":114 */
  __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 = 114; 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_k32;
  __pyx_v_half_line = __pyx_k33;
  __pyx_v_cull_face = __pyx_k34;
  __pyx_v_p = __pyx_k35;
  __pyx_v_v = __pyx_k36;
  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 = 116; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 116; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya__Point, 1, "p")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 116; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5_soya__Vector, 1, "v")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 116; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":121 */
  __pyx_v_items = ((struct __pyx_obj_5_soya_RaypickContext *)__pyx_v_self)->_items;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":122 */
  __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 = 122; 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":128 */
  __pyx_2 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 128; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":129 */
  ((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":130 */
  ((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":131 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":132 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":133 */
  __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":135 */
  __pyx_v_max = __pyx_v_items->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":136 */
  __pyx_v_items->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":137 */
  while (1) {
    __pyx_L3:;
    __pyx_1 = (__pyx_v_items->nb < __pyx_v_max);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/raypick.pyx":138 */
    __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":139 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 139; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 139; 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__TreeModel));
    PyTuple_SET_ITEM(__pyx_3, 1, ((PyObject*)__pyx_ptype_5_soya__TreeModel));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 139; 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 = 139; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/raypick.pyx":140 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya__TreeModel *)((struct __pyx_obj_5_soya__TreeModel *)((PyObject *)__pyx_v_obj))->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_raypick_from_context_b(((struct __pyx_obj_5_soya__TreeModel *)((PyObject *)__pyx_v_obj)),__pyx_v_data,__pyx_v_items);
      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_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/raypick.pyx":142 */
      __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":142 */
        __pyx_v_result = 1;

        /* "/home/jiba/src/soya/soya3d/raypick.pyx":142 */
        goto __pyx_L4;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L5:;
  }
  /*else*/ {
    __pyx_v_result = 0;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":145 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":146 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":147 */
  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":148 */
    __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":149 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":151 */
  __pyx_3 = PyInt_FromLong(__pyx_v_result); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 151; 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":24 */
  (__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":25 */
  __pyx_1 = (__pyx_v_r == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":27 */
    __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":30 */
  memcpy(__pyx_v_r,__pyx_v_f,(sizeof(__pyx_t_5_soya_Frustum )));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":31 */
  __pyx_1 = (__pyx_v_new != __pyx_v_old);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":33 */
    __pyx_1 = (__pyx_v_old != 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":34 */
      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":35 */
      (__pyx_v_scalefactor[0]) = ((__pyx_v_scalefactor[0]) * (__pyx_v_old[16]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":36 */
      (__pyx_v_scalefactor[1]) = ((__pyx_v_scalefactor[1]) * (__pyx_v_old[17]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":37 */
      (__pyx_v_scalefactor[2]) = ((__pyx_v_scalefactor[2]) * (__pyx_v_old[18]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":38 */
      point_by_matrix(__pyx_v_r->position,__pyx_v_old);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":40 */
    __pyx_1 = (__pyx_v_new != 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":41 */
      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":42 */
      (__pyx_v_scalefactor[0]) = ((__pyx_v_scalefactor[0]) * (__pyx_v_new[16]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":43 */
      (__pyx_v_scalefactor[1]) = ((__pyx_v_scalefactor[1]) * (__pyx_v_new[17]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":44 */
      (__pyx_v_scalefactor[2]) = ((__pyx_v_scalefactor[2]) * (__pyx_v_new[18]));

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":45 */
      point_by_matrix(__pyx_v_r->position,__pyx_v_new);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":48 */
    __pyx_v_scaling = (__pyx_v_scalefactor[0]);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":49 */
    __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":50 */
    __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":51 */
    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":52 */
    vector_set_length(__pyx_v_r->planes,__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":53 */
    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":54 */
    vector_set_length((__pyx_v_r->planes + 4),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":55 */
    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":56 */
    vector_set_length((__pyx_v_r->planes + 8),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":57 */
    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":58 */
    vector_set_length((__pyx_v_r->planes + 12),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":59 */
    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":60 */
    vector_set_length((__pyx_v_r->planes + 16),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":61 */
    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":62 */
    vector_set_length((__pyx_v_r->planes + 20),__pyx_v_scaling);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":64 */
    (__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":65 */
    (__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":66 */
    (__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":67 */
    (__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":68 */
    (__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":69 */
    (__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":70 */
  __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":85 */
  ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__raypick_data = (-1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":86 */
  ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_auto_static_count = 3;

  __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_k37;
  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 = 88; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":92 */
  (((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":93 */
  (((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":94 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 94; 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 = 94; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 94; 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 = 94; 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":99 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":100 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":101 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_matrix,19);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":102 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __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.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":105 */
  __pyx_v_self->_validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":109 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":110 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":111 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_matrix,19);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":112 */
  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":115 */
  memcpy(__pyx_v_result,(__pyx_v_self->_matrix + 12),12);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":116 */
  __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":117 */
    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":118 */
    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":121 */
  memcpy(__pyx_v_result,(__pyx_v_self->_matrix + 12),12);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":122 */
  __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":123 */
    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":126 */

  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":129 */

  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":132 */

  __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":135 */

  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":138 */
  __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":141 */

  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":144 */
  __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;
  int __pyx_1;
  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 = 146; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":151 */
  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);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":152 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC));
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_STATIC);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":153 */
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_go_not_static(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":155 */
    ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_auto_static_count = 3;
  }
  __pyx_L2:;

  __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":158 */
  (__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":166 */
  ((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":167 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_sphere[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_sphere[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_sphere[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; 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 = 167; 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 = 167; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; 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":170 */

  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":178 */
  (__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":179 */
  __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":180 */
  ((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":181 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_box[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_box[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_box[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; 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 = 181; 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 = 181; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_box[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_box[4])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((__pyx_v_box[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; 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 = 181; 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 = 181; 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":189 */
  (__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":190 */
  __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":191 */
  ((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":192 */
  __pyx_2 = PyFloat_FromDouble(((__pyx_v_box[3]) - (__pyx_v_box[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; 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 = 192; 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 = 192; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; 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":200 */
  (__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":201 */
  __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":202 */
  ((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":203 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 203; 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 = 203; 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 = 203; 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 = 203; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 203; 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 = 203; 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":209 */
  __pyx_1 = (__pyx_v_self->__raypick_data == (-1));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":210 */
    __pyx_v_self->__raypick_data = chunk_register(__pyx_v_data->raypick_data,(7 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":211 */
    __pyx_v_rdata = ((float (*))(__pyx_v_data->raypick_data->content + __pyx_v_self->__raypick_data));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":213 */
    __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":214 */
    point_by_matrix_copy(__pyx_v_rdata,__pyx_v_data->root_data,__pyx_v_matrix);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":215 */
    vector_by_matrix_copy((__pyx_v_rdata + 3),(__pyx_v_data->root_data + 3),__pyx_v_matrix);

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":217 */
    __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":219 */
    __pyx_1 = ((__pyx_v_data->root_data[6]) > 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":220 */
      __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":222 */
      __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":224 */
      (__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":228 */
    chunk_add_ptr(__pyx_v_data->raypicked,((void (*))((PyObject *)__pyx_v_self)));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":229 */
    __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":236 */
  __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":237 */
  __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":239 */
  __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":241 */
  __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 MainLoop) 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;
  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/soya3d/coordsyst.pyx":250 */
  __pyx_1 = ((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":251 */
    __pyx_1 = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_auto_static_count == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":252 */
      __pyx_1 = (!(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_STATIC));
      if (__pyx_1) {
        ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_go_static(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":254 */
      ((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_auto_static_count = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_auto_static_count - 1);
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  __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 MainLoop) 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":260 */

  __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 MainLoop) 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":267 */

  __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":271 */
  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":277 */
  __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 = 277; 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 = 278; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":279 */
  __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":284 */
  __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 = 284; 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 = 285; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":286 */
  __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 PyObject *__pyx_f_5_soya_9CoordSyst_6static___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_6static___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":291 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_STATIC)); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __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.CoordSyst.static.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_6static___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_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[7]; __pyx_lineno = 292; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":295 */
  __pyx_1 = (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_STATIC);
  if (__pyx_1) {
    __pyx_1 = (!__pyx_v_x);
  }
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_go_not_static(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_1 = (!(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_STATIC));
  if (__pyx_1) {
    __pyx_1 = __pyx_v_x;
  }
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_go_static(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static PyObject *__pyx_f_5_soya_9CoordSyst_11auto_static___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_9CoordSyst_11auto_static___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":300 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_option & __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC))); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 300; 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.auto_static.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_9CoordSyst_11auto_static___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_9CoordSyst_11auto_static___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 = 301; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":302 */
  __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_COORDSYS_NON_AUTO_STATIC));
    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_COORDSYS_NON_AUTO_STATIC);
  }
  __pyx_L2:;

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

static void __pyx_f_5_soya_9CoordSyst__go_static(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":306 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_COORDSYS_STATIC);

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

static void __pyx_f_5_soya_9CoordSyst__go_not_static(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":309 */
  __pyx_v_self->_option = (__pyx_v_self->_option & (~__pyx_e_5_soya_COORDSYS_STATIC));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":310 */
  __pyx_v_self->_auto_static_count = 3;

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

static void __pyx_f_5_soya_9CoordSyst__invalidate(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":313 */
  __pyx_v_self->_validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":314 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC));
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_COORDSYS_STATIC);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":315 */
    ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_go_not_static(__pyx_v_self);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":317 */
    __pyx_v_self->_auto_static_count = 3;
  }
  __pyx_L2:;

  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":323 */
  __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 = 323; 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 = 324; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":325 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":326 */
  ((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":330 */
  __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 = 330; 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 = 331; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":332 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":333 */
  ((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":337 */
  __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 = 337; 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 = 338; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":339 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":340 */
  ((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":344 */
  __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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; 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 = 344; goto __pyx_L1;}
  __pyx_20 = PyTuple_New(19); if (!__pyx_20) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 344; 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":346 */
  __pyx_1 = PyObject_Length(__pyx_v_matrix); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_2 = (__pyx_1 == 16);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":347 */
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; goto __pyx_L1;}
    __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_8 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_9 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_10 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_11 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_12 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_13 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_14 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_15 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_16 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_17 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_18 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    __pyx_19 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 347; 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 = 347; goto __pyx_L1;}
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":349 */
    __pyx_3 = __Pyx_UnpackItem(__pyx_v_matrix, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; goto __pyx_L1;}
    __pyx_4 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_7 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_8 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_9 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_10 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_11 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_12 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_13 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_14 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_15 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_16 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_17 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_18 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_19 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_20 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_21 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
    __pyx_22 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 349; 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 = 349; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":350 */
  ((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":351 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check_lefthanded(((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":356 */
  __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":357 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_m[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_m[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_m[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_m[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_m[4])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((__pyx_v_m[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_m[6])); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((__pyx_v_m[7])); if (!__pyx_8) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((__pyx_v_m[8])); if (!__pyx_9) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((__pyx_v_m[9])); if (!__pyx_10) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble((__pyx_v_m[10])); if (!__pyx_11) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((__pyx_v_m[11])); if (!__pyx_12) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble((__pyx_v_m[12])); if (!__pyx_13) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_14 = PyFloat_FromDouble((__pyx_v_m[13])); if (!__pyx_14) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_15 = PyFloat_FromDouble((__pyx_v_m[14])); if (!__pyx_15) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_16 = PyFloat_FromDouble((__pyx_v_m[15])); if (!__pyx_16) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_17 = PyFloat_FromDouble((__pyx_v_m[16])); if (!__pyx_17) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_18 = PyFloat_FromDouble((__pyx_v_m[17])); if (!__pyx_18) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_19 = PyFloat_FromDouble((__pyx_v_m[18])); if (!__pyx_19) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; goto __pyx_L1;}
  __pyx_20 = PyTuple_New(19); if (!__pyx_20) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 357; 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":362 */
  __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":363 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_m[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_m[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_m[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_m[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_m[4])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble((__pyx_v_m[5])); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_m[6])); if (!__pyx_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((__pyx_v_m[7])); if (!__pyx_8) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((__pyx_v_m[8])); if (!__pyx_9) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((__pyx_v_m[9])); if (!__pyx_10) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble((__pyx_v_m[10])); if (!__pyx_11) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((__pyx_v_m[11])); if (!__pyx_12) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble((__pyx_v_m[12])); if (!__pyx_13) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_14 = PyFloat_FromDouble((__pyx_v_m[13])); if (!__pyx_14) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_15 = PyFloat_FromDouble((__pyx_v_m[14])); if (!__pyx_15) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_16 = PyFloat_FromDouble((__pyx_v_m[15])); if (!__pyx_16) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_17 = PyFloat_FromDouble((__pyx_v_m[16])); if (!__pyx_17) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_18 = PyFloat_FromDouble((__pyx_v_m[17])); if (!__pyx_18) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_19 = PyFloat_FromDouble((__pyx_v_m[18])); if (!__pyx_19) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; goto __pyx_L1;}
  __pyx_20 = PyTuple_New(19); if (!__pyx_20) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 363; 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":367 */
  __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 = 367; 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":371 */
  __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 = 371; 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 = 372; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":373 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 373; 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 = 373; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 373; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 373; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 373; 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 = 373; 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":377 */
  __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 = 377; 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 = 378; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":379 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; 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 = 379; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 379; 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 = 379; 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":383 */
  __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 = 383; 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 = 384; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":385 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 385; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 385; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 385; 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 = 385; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 385; 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 = 385; 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":391 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_scale); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 391; 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 = 391; 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 = 391; 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 = 391; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 391; 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 = 391; 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 void __pyx_f_5_soya_9CoordSyst__check_lefthanded(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":395 */
  __pyx_1 = ((((__pyx_v_self->_matrix[16]) * (__pyx_v_self->_matrix[17])) * (__pyx_v_self->_matrix[18])) < 0.0);
  if (__pyx_1) {
    __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_LEFTHANDED);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_self->_option = (__pyx_v_self->_option & (~__pyx_e_5_soya_LEFTHANDED));
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __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":399 */
  __pyx_1 = (!(__pyx_v_self->_validity & __pyx_e_5_soya_COORDSYS_ROOT_VALID));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":400 */
    __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":402 */
    __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":403 */
  __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":406 */
  __pyx_1 = (!(__pyx_v_self->_validity & __pyx_e_5_soya_COORDSYS_INVERTED_ROOT_VALID));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":407 */
    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":408 */
  __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":415 */
  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 = 415; 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":416 */
  __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":417 */
  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 = 417; 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 = 417; 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":418 */
  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":422 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_self->__pyx_base._parent), __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 422; 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":423 */
  __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 = 423; 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":424 */
  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 = 424; 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 = 424; 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":425 */
  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 = 427; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":433 */
  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":434 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_parent)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 434; goto __pyx_L1;}
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":435 */
    __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 = 435; 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":436 */
    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":437 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 437; 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":443 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[12]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":444 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[13]) = __pyx_v_y;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":445 */
  (((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix[14]) = __pyx_v_z;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":446 */
  ((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 = 448; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":454 */
  ((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":455 */
  ((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":461 */
  (((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":462 */
  (((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":463 */
  (((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":464 */
  ((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":470 */
  (((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":471 */
  (((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":472 */
  (((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":473 */
  ((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 = 475; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":485 */
  ((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":486 */
  (((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":487 */
  (((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":488 */
  (((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":489 */
  ((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":490 */
  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 = 492; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":497 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 497; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 497; 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 = 497; 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 = 499; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":509 */
  ((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":510 */
  (((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":511 */
  (((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":512 */
  (((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":513 */
  ((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":514 */
  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":521 */
  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":522 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_check_lefthanded(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":523 */
  ((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":529 */
  matrix_set_identity(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":530 */
  ((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":536 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 536; 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 = 536; 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 = 536; 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 = 536; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 536; 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 = 536; 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 = 538; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 538; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":545 */
  ((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":546 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 546; 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 = 546; 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 = 546; 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 = 546; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 546; 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 = 546; 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 = 548; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vector), __pyx_ptype_5_soya__Vector, 0, "vector")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 548; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":555 */
  ((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":556 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 556; 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 = 556; 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 = 556; 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 = 556; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 556; 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 = 556; 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 = 558; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":563 */
  ((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":564 */
  __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 = 564; 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 = 566; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":571 */
  ((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":572 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 572; 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 = 572; 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 = 572; 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 = 572; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 572; 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 = 572; 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 = 574; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":579 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_vector_to); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 579; 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 = 579; 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 = 581; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":586 */
  ((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":587 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 587; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 587; 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 = 587; 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 = 587; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":588 */
    (__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":589 */
    (__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":590 */
    (__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":591 */
  matrix_look_to_Z(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":592 */
  ((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 = 594; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":599 */
  ((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":600 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 600; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 600; 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 = 600; 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 = 600; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":601 */
    (__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":602 */
    (__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":603 */
    (__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":604 */
  matrix_look_to_Y(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":605 */
  ((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 = 607; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":612 */
  ((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":613 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 613; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 613; 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 = 613; 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 = 613; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":614 */
    (__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":615 */
    (__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":616 */
    (__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":617 */
  matrix_look_to_X(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_f);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":618 */
  ((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_y(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_turn_y[] = "CoordSyst.turn_y(angle)\n\nRotate about the *local* Y axis, in degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_turn_y(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":624 */
  matrix_turn_y(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":625 */
  ((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_y");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_turn_x(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_turn_x[] = "CoordSyst.turn_x(angle)\n\nRotate about the *local* X axis, in degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_turn_x(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":631 */
  matrix_turn_x(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":632 */
  ((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_x");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_turn_z(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_turn_z[] = "CoordSyst.turn_z(angle)\n\nRotate about the *local* Z axis, in degrees.";
static PyObject *__pyx_f_5_soya_9CoordSyst_turn_z(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":638 */
  matrix_turn_z(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":639 */
  ((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_z");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  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\nSame as turn_y.";
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":645 */
  matrix_turn_y(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":646 */
  ((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\nSame as turn_x.";
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":652 */
  matrix_turn_x(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":653 */
  ((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\nSame as turn_z.";
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":659 */
  matrix_turn_z(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":660 */
  ((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_y(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_y[] = "CoordSyst.rotate_y(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_y(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":668 */
  matrix_rotate_y(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":669 */
  ((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_y");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_x(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_x[] = "CoordSyst.rotate_x(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_x(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":677 */
  matrix_rotate_x(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":678 */
  ((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_x");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_9CoordSyst_rotate_z(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_z[] = "CoordSyst.rotate_z(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_z(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":686 */
  matrix_rotate_z(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":687 */
  ((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_z");
  __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		\nSame as rotate_y.";
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":693 */
  matrix_rotate_y(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":694 */
  ((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\nSame as rotate_x.";
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":700 */
  matrix_rotate_x(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":701 */
  ((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\nSame as rotate_z.";
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":707 */
  matrix_rotate_z(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,to_radians(__pyx_v_angle));

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":708 */
  ((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[] = "Same as rotate_axis";
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 = 710; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":713 */
  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":715 */
  ((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":716 */
  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":717 */
  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":718 */
  ((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[] = "Same as rotate_axis_xyz";
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":723 */
  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":724 */
  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":725 */
  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":726 */
  ((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_axis(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_axis[] = "CoordSyst.rotate_axis(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_axis(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 = 728; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":734 */
  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":736 */
  ((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":737 */
  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":738 */
  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":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.rotate_axis");
  __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_axis_xyz(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_9CoordSyst_rotate_axis_xyz[] = "CoordSyst.rotate_axis_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_axis_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":746 */
  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":747 */
  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":748 */
  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":749 */
  ((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_axis_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 = 751; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), __pyx_ptype_5_soya_Position, 0, "b")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 751; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":757 */
  ((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":758 */
  ((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":759 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 759; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 759; 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 = 759; 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 = 759; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":760 */
    (__pyx_v_p2[0]) = ((__pyx_v_p2[0]) - (__pyx_v_p1[0]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":761 */
    (__pyx_v_p2[1]) = ((__pyx_v_p2[1]) - (__pyx_v_p1[1]));

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":762 */
    (__pyx_v_p2[2]) = ((__pyx_v_p2[2]) - (__pyx_v_p1[2]));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":763 */
  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":764 */
  ((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":772 */
  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":774 */
  (__pyx_v_p1[0]) = __pyx_v_x1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":775 */
  (__pyx_v_p1[1]) = __pyx_v_y1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":776 */
  (__pyx_v_p1[2]) = __pyx_v_z1;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":777 */
  (__pyx_v_p2[0]) = (__pyx_v_x2 - __pyx_v_x1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":778 */
  (__pyx_v_p2[1]) = (__pyx_v_y2 - __pyx_v_y2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":779 */
  (__pyx_v_p2[2]) = (__pyx_v_z2 - __pyx_v_z2);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":780 */
  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":781 */
  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":782 */
  ((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_k215p;

static char (__pyx_k215[]) = "<%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":785 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 785; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 785; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k215p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 785; 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 = 788; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":791 */
  ((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":792 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 792; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 792; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 792; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 792; 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 = 794; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":797 */
  (__pyx_v_p[0]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":798 */
  (__pyx_v_p[1]) = __pyx_v_y;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":799 */
  (__pyx_v_p[2]) = __pyx_v_z;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":800 */
  __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":801 */
  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":802 */
  __pyx_3 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 802; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 802; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 802; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 802; 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 = 804; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":807 */
  (__pyx_v_p[0]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":808 */
  (__pyx_v_p[1]) = __pyx_v_y;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":809 */
  (__pyx_v_p[2]) = __pyx_v_z;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":810 */
  __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":811 */
  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":812 */
  __pyx_3 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 812; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 812; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 812; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 812; 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 = 815; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state2), __pyx_ptype_5_soya_CoordSystState, 1, "state2")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 815; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":822 */
  ((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":823 */
  ((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":824 */
  __pyx_v_factor1 = (1.0 - __pyx_v_factor);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":829 */
  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":833 */
  matrix_from_quaternion(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self)->_matrix,__pyx_v_q);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":837 */
  (((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":838 */
  (((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":839 */
  (((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":840 */
  (((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":841 */
  (((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":842 */
  (((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":843 */
  __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":844 */
    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":845 */
  ((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 = 858; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":862 */
  __pyx_1 = ((PyObject *)__pyx_v_coord_syst) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":863 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_added_into); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 863; 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 = 863; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 863; 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 = 863; 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":864 */
    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":867 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":868 */
  __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":871 */
  __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":872 */
    __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":873 */
    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":876 */
  __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":877 */
  __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":881 */
  ((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":882 */
  __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 = 882; 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 = 882; 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 = 882; 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 = 882; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 882; 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":884 */
  ((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":885 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_q, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 885; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 885; 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 = 885; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 885; 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 = 885; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 885; 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 = 885; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 885; 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 = 885; 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":894 */
  __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":895 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":899 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_batch); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 899; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 899; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 899; 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 = 899; goto __pyx_L1;}
  __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 899; 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 = 899; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 899; 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 = 899; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 899; 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 = 899; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":900 */
  __pyx_1 = ((PyObject *)__pyx_v_coordsyst) == ((PyObject *)__pyx_v_self);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":901 */
    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":905 */
  __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":910 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_render); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 910; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 910; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 910; 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":913 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 913; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 913; 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 = 913; 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 = 913; 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":929 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 929; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 929; 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 = 936; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_light), __pyx_ptype_5_soya__Light, 1, "light")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 936; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":937 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 937; 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_5_Body___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_5_Body___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__Model *__pyx_v_model = 0;
  PyObject *__pyx_v_opt = 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[] = {"parent","model","opt",0};
  __pyx_v_parent = __pyx_k38;
  __pyx_v_model = __pyx_k39;
  __pyx_v_opt = __pyx_k40;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_model, &__pyx_v_opt)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_model);
  Py_INCREF(__pyx_v_opt);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Model, 1, "model")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":27 */
  __pyx_1 = ((PyObject *)__pyx_v_model) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":28 */
    Py_INCREF(((PyObject *)__pyx_v_model));
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model));
    ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model = ((PyObject *)__pyx_v_model);

    /* "/home/jiba/src/soya/soya3d/body.pyx":29 */
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_model->__pyx_base.__pyx_vtab)->_instanced(__pyx_v_model,((struct __pyx_obj_5_soya__Body *)__pyx_v_self),__pyx_v_opt);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":30 */
  __pyx_3 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 30; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 30; 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));
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 30; 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_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Body.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF(__pyx_v_opt);
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/soya3d/body.pyx":34 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model);
  goto __pyx_L0;

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

static int __pyx_f_5_soya_5_Body_5model___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_model); /*proto*/
static int __pyx_f_5_soya_5_Body_5model___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_model) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_model);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Model, 1, "model")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 35; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":36 */
  Py_INCREF(__pyx_v_model);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model));
  ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model = __pyx_v_model;

  /* "/home/jiba/src/soya/soya3d/body.pyx":37 */
  __pyx_1 = __pyx_v_model == Py_None;
  if (__pyx_1) {
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
    ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data = Py_None;
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Model *)__pyx_v_model)->__pyx_base.__pyx_vtab)->_instanced(((struct __pyx_obj_5_soya__Model *)__pyx_v_model),((struct __pyx_obj_5_soya__Body *)__pyx_v_self),Py_None);
  }
  __pyx_L2:;

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

static PyObject *__pyx_f_5_soya_5_Body_set_model(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_set_model(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Model *__pyx_v_model = 0;
  PyObject *__pyx_v_opt = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  static char *__pyx_argnames[] = {"model","opt",0};
  __pyx_v_opt = __pyx_k41;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|O", __pyx_argnames, &__pyx_v_model, &__pyx_v_opt)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_model);
  Py_INCREF(__pyx_v_opt);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Model, 1, "model")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 40; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":41 */
  Py_INCREF(((PyObject *)__pyx_v_model));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model));
  ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model = ((PyObject *)__pyx_v_model);

  /* "/home/jiba/src/soya/soya3d/body.pyx":42 */
  __pyx_1 = ((PyObject *)__pyx_v_model) == Py_None;
  if (__pyx_1) {
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 42; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
    ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data = Py_None;
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_model->__pyx_base.__pyx_vtab)->_instanced(__pyx_v_model,((struct __pyx_obj_5_soya__Body *)__pyx_v_self),__pyx_v_opt);
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Body.set_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF(__pyx_v_opt);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Body___getcstate__(struct __pyx_obj_5_soya__Body *__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/body.pyx":46 */
  __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 = 46; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 46; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_model));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_model));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_data));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_self->_data));
  __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._Body.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Body___setcstate__(struct __pyx_obj_5_soya__Body *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_attached_coordsysts;
  PyObject *__pyx_v_coordsyst;
  PyObject *__pyx_v_bone_id;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  PyObject *__pyx_6 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_attached_coordsysts = Py_None; Py_INCREF(__pyx_v_attached_coordsysts);
  __pyx_v_coordsyst = Py_None; Py_INCREF(__pyx_v_coordsyst);
  __pyx_v_bone_id = Py_None; Py_INCREF(__pyx_v_bone_id);

  /* "/home/jiba/src/soya/soya3d/body.pyx":49 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 49; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 49; 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/body.pyx":50 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 50; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_model));
  __pyx_v_self->_model = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/body.pyx":51 */
  __pyx_3 = PyObject_Length(__pyx_v_cstate); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_4 = (__pyx_3 > 2);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":52 */
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    __pyx_5 = PyObject_GetItem(__pyx_v_cstate, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
    PyTuple_SET_ITEM(__pyx_6, 1, __pyx_2);
    __pyx_5 = 0;
    __pyx_2 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_6); __pyx_6 = 0;
    __pyx_3 = PyObject_IsTrue(__pyx_5); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 52; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/body.pyx":53 */
      __pyx_2 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__AnimatedModelData), __pyx_n___new__); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 53; goto __pyx_L1;}
      __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 53; goto __pyx_L1;}
      Py_INCREF(((PyObject*)__pyx_ptype_5_soya__AnimatedModelData));
      PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject*)__pyx_ptype_5_soya__AnimatedModelData));
      __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 53; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      if (!__Pyx_TypeTest(__pyx_6, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 53; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_data));
      __pyx_v_self->_data = __pyx_6;
      __pyx_6 = 0;

      /* "/home/jiba/src/soya/soya3d/body.pyx":54 */
      __pyx_5 = PyList_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 54; goto __pyx_L1;}
      Py_DECREF(__pyx_v_attached_coordsysts);
      __pyx_v_attached_coordsysts = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/soya3d/body.pyx":55 */
      __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_cstate, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_6 = PyObject_GetIter(__pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      for (;;) {
        __pyx_L4:;
        __pyx_5 = PyIter_Next(__pyx_6);
        if (!__pyx_5) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
          break;
        }
        __pyx_2 = __Pyx_UnpackItem(__pyx_5, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        Py_DECREF(__pyx_v_coordsyst);
        __pyx_v_coordsyst = __pyx_2;
        __pyx_2 = 0;
        __pyx_1 = __Pyx_UnpackItem(__pyx_5, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        Py_DECREF(__pyx_v_bone_id);
        __pyx_v_bone_id = __pyx_1;
        __pyx_1 = 0;
        if (__Pyx_EndUnpack(__pyx_5, 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        __pyx_5 = PyObject_GetAttr(__pyx_v_attached_coordsysts, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        Py_INCREF(__pyx_v_coordsyst);
        PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_coordsyst);
        Py_INCREF(__pyx_v_bone_id);
        PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_bone_id);
        PyTuple_SET_ITEM(__pyx_1, 2, __pyx_2);
        __pyx_2 = 0;
        __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
        __pyx_1 = 0;
        __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 55; goto __pyx_L1;}
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_1); __pyx_1 = 0;
      }
      __pyx_L5:;
      Py_DECREF(__pyx_6); __pyx_6 = 0;

      /* "/home/jiba/src/soya/soya3d/body.pyx":56 */
      __pyx_5 = PyInt_FromLong(2); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 56; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 56; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_1 = PyTuple_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 56; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_self));
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_model));
      PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_self->_model));
      PyTuple_SET_ITEM(__pyx_1, 2, __pyx_2);
      Py_INCREF(__pyx_v_attached_coordsysts);
      PyTuple_SET_ITEM(__pyx_1, 3, __pyx_v_attached_coordsysts);
      __pyx_2 = 0;
      ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self->_data),__pyx_1);
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/body.pyx":59 */
      __pyx_6 = PyInt_FromLong(2); if (!__pyx_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 59; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_v_cstate, __pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 59; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 59; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_data));
      __pyx_v_self->_data = __pyx_5;
      __pyx_5 = 0;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":60 */
  __pyx_4 = ((PyObject *)__pyx_v_self->_data) == Py_None;
  if (__pyx_4) {
    Py_INCREF(((PyObject *)__pyx_v_self->_model));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_data));
    __pyx_v_self->_data = ((PyObject *)__pyx_v_self->_model);
    goto __pyx_L6;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya._Body.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_attached_coordsysts);
  Py_DECREF(__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_bone_id);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_5_Body__batch(struct __pyx_obj_5_soya__Body *__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/body.pyx":64 */
  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/body.pyx":65 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/body.pyx":67 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_batch(__pyx_v_self->_data,__pyx_v_self);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static int __pyx_f_5_soya_5_Body__shadow(struct __pyx_obj_5_soya__Body *__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/body.pyx":71 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_r = ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_shadow(__pyx_v_self->_data,((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/body.pyx":72 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Body._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_5_Body__raypick(struct __pyx_obj_5_soya__Body *__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/body.pyx":77 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data) == 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/body.pyx":78 */
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_raypick(__pyx_v_self->_data,__pyx_v_raypick_data,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Body._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_Body__raypick_b(struct __pyx_obj_5_soya__Body *__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/body.pyx":83 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data) == 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/body.pyx":84 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_raypick_b(__pyx_v_self->_data,__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._Body._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_Body__collect_raypickables(struct __pyx_obj_5_soya__Body *__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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/soya3d/body.pyx":88 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data) == 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/body.pyx":94 */
  __pyx_v_matrix = ((struct __pyx_vtabstruct_5_soya__Body *)__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/body.pyx":95 */
  point_by_matrix_copy(__pyx_v_s,__pyx_v_rsphere,__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/body.pyx":96 */
  (__pyx_v_s[3]) = length_by_matrix((__pyx_v_rsphere[3]),__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/body.pyx":99 */
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_collect_raypickables(__pyx_v_self->_data,__pyx_v_items,__pyx_v_rsphere,__pyx_v_s,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

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

static int __pyx_f_5_soya_5_Body__contains(struct __pyx_obj_5_soya__Body *__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/body.pyx":102 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_model) == ((PyObject *)__pyx_v_obj);
  if (__pyx_1) {
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":103 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Body._contains");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_obj);
  return __pyx_r;
}

static void __pyx_f_5_soya_5_Body__get_box(struct __pyx_obj_5_soya__Body *__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/body.pyx":109 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":110 */
    __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/body.pyx":114 */
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_get_box(__pyx_v_self->_data,__pyx_v_box,__pyx_v_matrix2);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static void __pyx_f_5_soya_5_Body__get_sphere(struct __pyx_obj_5_soya__Body *__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/body.pyx":119 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_data);
  Py_INCREF((PyObject *)__pyx_1);
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 119; 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 = 119; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 119; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_data));
    PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_self->_data));
    Py_INCREF(((PyObject*)__pyx_ptype_5_soya__SimpleModel));
    PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__SimpleModel));
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 119; 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 = 119; goto __pyx_L1;}
    if (__pyx_2) {
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)((PyObject *)__pyx_v_self->_data))->_option & __pyx_e_5_soya_MODEL_HAS_SPHERE)); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 119; goto __pyx_L1;}
    }
  }
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 119; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":120 */
    memcpy(__pyx_v_sphere,((struct __pyx_obj_5_soya__SimpleModel *)((PyObject *)__pyx_v_self->_data))->_sphere,(4 * (sizeof(float ))));
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/body.pyx":122 */
    (__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._Body._get_sphere");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k216p;

static char (__pyx_k216[]) = "<%s, model=%s>";

static PyObject *__pyx_f_5_soya_5_Body___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body___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/body.pyx":125 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 125; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 125; 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 = 125; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_model));
  __pyx_2 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k216p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 125; 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._Body.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k217p;

static char (__pyx_k217[]) = "This Deform object is already used by another Body! Please create a new Deform!";

static PyObject *__pyx_f_5_soya_5_Body_add_deform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_add_deform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Deform *__pyx_v_deform = 0;
  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[] = {"deform",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_deform)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_deform);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_deform), __pyx_ptype_5_soya__Deform, 1, "deform")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 127; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":128 */
  __pyx_1 = ((PyObject *)__pyx_v_deform->_model) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":129 */
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 129; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 129; goto __pyx_L1;}
    Py_INCREF(__pyx_k217p);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k217p);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 129; 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[8]; __pyx_lineno = 129; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":131 */
  __pyx_3 = ((struct __pyx_vtabstruct_5_soya__Deform *)__pyx_v_deform->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_set_model(__pyx_v_deform,((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 131; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/body.pyx":132 */
  Py_INCREF(((PyObject *)__pyx_v_deform));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
  ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data = ((PyObject *)__pyx_v_deform);

  __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._Body.add_deform");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_deform);
  return __pyx_r;
}

static PyObject *__pyx_k218p;

static char (__pyx_k218[]) = "Cannot remove deform: this deform hasn't been added.";

static PyObject *__pyx_f_5_soya_5_Body_remove_deform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_remove_deform(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Deform *__pyx_v_deform = 0;
  struct __pyx_obj_5_soya__Model *__pyx_v_model;
  struct __pyx_obj_5_soya__Deform *__pyx_v_previous;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"deform",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_deform)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_deform);
  __pyx_v_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);
  __pyx_v_previous = Py_None; Py_INCREF((PyObject *) __pyx_v_previous);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_deform), __pyx_ptype_5_soya__Deform, 1, "deform")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 134; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":138 */
  __pyx_1 = ((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data) == ((PyObject *)__pyx_v_deform);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":139 */
    Py_INCREF(((PyObject *)__pyx_v_deform->_model));
    Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
    ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data = ((PyObject *)__pyx_v_deform->_model);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/body.pyx":141 */
    Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
    __pyx_v_model = ((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data);

    /* "/home/jiba/src/soya/soya3d/body.pyx":142 */
    if (!__Pyx_TypeTest(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data), __pyx_ptype_5_soya__Deform)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 142; goto __pyx_L1;}
    Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_previous));
    __pyx_v_previous = ((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data);

    /* "/home/jiba/src/soya/soya3d/body.pyx":143 */
    while (1) {
      __pyx_L3:;
      __pyx_2 = ((PyObject *)__pyx_v_model);
      Py_INCREF((PyObject *)__pyx_2);
      __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 143; goto __pyx_L1;}
      if (__pyx_1) {
        Py_DECREF((PyObject *)__pyx_2); __pyx_2 = 0;
        __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 143; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 143; goto __pyx_L1;}
        Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
        PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_model));
        Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Deform));
        PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__Deform));
        __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 143; 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[8]; __pyx_lineno = 143; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/soya3d/body.pyx":144 */
      __pyx_1 = ((PyObject *)__pyx_v_model) == ((PyObject *)__pyx_v_deform);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/body.pyx":145 */
        __pyx_3 = ((struct __pyx_vtabstruct_5_soya__Deform *)__pyx_v_previous->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_set_model(__pyx_v_previous,__pyx_v_deform->_model); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 145; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;

        /* "/home/jiba/src/soya/soya3d/body.pyx":146 */
        goto __pyx_L4;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/body.pyx":148 */
      if (!__Pyx_TypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Deform)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 148; goto __pyx_L1;}
      Py_INCREF(((PyObject *)__pyx_v_model));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_previous));
      __pyx_v_previous = ((PyObject *)__pyx_v_model);

      /* "/home/jiba/src/soya/soya3d/body.pyx":149 */
      Py_INCREF(((PyObject *)__pyx_v_previous->_model));
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
      __pyx_v_model = ((PyObject *)__pyx_v_previous->_model);
    }
    /*else*/ {
      __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 150; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 150; goto __pyx_L1;}
      Py_INCREF(__pyx_k218p);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k218p);
      __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 150; 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[8]; __pyx_lineno = 150; goto __pyx_L1;}
    }
    __pyx_L4:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":152 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 152; goto __pyx_L1;}
  __pyx_4 = ((struct __pyx_vtabstruct_5_soya__Deform *)__pyx_v_deform->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_set_model(__pyx_v_deform,((struct __pyx_obj_5_soya__Model *)Py_None)); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 152; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 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);
  __Pyx_AddTraceback("_soya._Body.remove_deform");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF((PyObject *)__pyx_v_previous);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_deform);
  return __pyx_r;
}

static PyObject *__pyx_n_insert;

static PyObject *__pyx_f_5_soya_5_Body_7deforms___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_7deforms___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_v_deforms;
  struct __pyx_obj_5_soya__Model *__pyx_v_model;
  struct __pyx_obj_5_soya__Deform *__pyx_v_deform;
  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_deforms = Py_None; Py_INCREF(__pyx_v_deforms);
  __pyx_v_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);
  __pyx_v_deform = Py_None; Py_INCREF((PyObject *) __pyx_v_deform);

  /* "/home/jiba/src/soya/soya3d/body.pyx":156 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 156; goto __pyx_L1;}
  Py_DECREF(__pyx_v_deforms);
  __pyx_v_deforms = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/body.pyx":160 */
  Py_INCREF(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_v_model = ((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data);

  /* "/home/jiba/src/soya/soya3d/body.pyx":161 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = ((PyObject *)__pyx_v_model);
    Py_INCREF((PyObject *)__pyx_1);
    __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 161; 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 = 161; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 161; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
      PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_model));
      Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Deform));
      PyTuple_SET_ITEM(__pyx_4, 1, ((PyObject*)__pyx_ptype_5_soya__Deform));
      __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 161; 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 = 161; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/soya3d/body.pyx":162 */
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Deform)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 162; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_model));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_deform));
    __pyx_v_deform = ((PyObject *)__pyx_v_model);

    /* "/home/jiba/src/soya/soya3d/body.pyx":163 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_deforms, __pyx_n_insert); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 163; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 163; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 163; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4);
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_deform));
    PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_deform));
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 163; 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/soya3d/body.pyx":164 */
    Py_INCREF(((PyObject *)__pyx_v_deform->_model));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
    __pyx_v_model = ((PyObject *)__pyx_v_deform->_model);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":165 */
  Py_INCREF(__pyx_v_deforms);
  __pyx_r = __pyx_v_deforms;
  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._Body.deforms.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_deforms);
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF((PyObject *)__pyx_v_deform);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_TypeError;

static PyObject *__pyx_k219p;

static char (__pyx_k219[]) = "This type of model doesn't support attach!";

static PyObject *__pyx_f_5_soya_5_Body_attach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_attach[] = "Body.attach(mesh_name_1, ...)\n\nOnly for Body associated with a AnimatedModel.\n\nAttaches new meshes named MESH_NAME_1, ... to the body.\nSee body.model.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_5_Body_attach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mesh_names = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 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);

  /* "/home/jiba/src/soya/soya3d/body.pyx":177 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 177; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_attach(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_mesh_names);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 178; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 178; goto __pyx_L1;}
    Py_INCREF(__pyx_k219p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k219p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 178; 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[8]; __pyx_lineno = 178; goto __pyx_L1;}
  }
  __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._Body.attach");
  __pyx_r = 0;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_mesh_names);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_k220p;

static char (__pyx_k220[]) = "This type of model doesn't support detach!";

static PyObject *__pyx_f_5_soya_5_Body_detach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_detach[] = "Cal3DBody.detach(mesh_name_1, ...)\n\nOnly for Body associated with a AnimatedModel.\n\nDetaches meshes named MESH_NAME_1, ... to the body.\nDetaching several meshes at the same time can be faster.";
static PyObject *__pyx_f_5_soya_5_Body_detach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mesh_names = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 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);

  /* "/home/jiba/src/soya/soya3d/body.pyx":187 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 187; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_detach(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_mesh_names);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 188; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 188; goto __pyx_L1;}
    Py_INCREF(__pyx_k220p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k220p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 188; 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[8]; __pyx_lineno = 188; goto __pyx_L1;}
  }
  __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._Body.detach");
  __pyx_r = 0;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_mesh_names);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static PyObject *__pyx_n_mesh_names;

static PyObject *__pyx_f_5_soya_5_Body_is_attached(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_is_attached[] = "Cal3DBody.is_attached(mesh_name)\n\nOnly for Body associated with a AnimatedModel.\n\nChecks if the mesh called MESH_NAME is attached to the body.";
static PyObject *__pyx_f_5_soya_5_Body_is_attached(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_mesh_name = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 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/soya3d/body.pyx":196 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 196; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_mesh_names); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 196; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_is_attached(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_2)); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 196; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":197 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 197; 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);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_soya._Body.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_k221p;

static char (__pyx_k221[]) = "This type of model doesn't support attach_to_bone!";

static PyObject *__pyx_f_5_soya_5_Body_attach_to_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_attach_to_bone[] = "Cal3DBody.attach_to_bone(coordsyst, bone_name)\n\nOnly for Body associated with a AnimatedModel.\n\nAttaches COORDSYST to the bone named BONE_NAME.\nAs the bone moved (because of animation), COORDSYST will be moved too.\nSee tutorial character-animation-2.py.\n\nXXX this method should be moved to World.\nXXX attaching a coordsyst X to bone of object Y will works well ONLY if Y is a world and X is a direct child of Y!";
static PyObject *__pyx_f_5_soya_5_Body_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;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 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[8]; __pyx_lineno = 199; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":210 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 210; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_attach_to_bone(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_coordsyst,__pyx_v_bone_name);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 211; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 211; goto __pyx_L1;}
    Py_INCREF(__pyx_k221p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k221p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 211; 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[8]; __pyx_lineno = 211; goto __pyx_L1;}
  }
  __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._Body.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_k222p;

static char (__pyx_k222[]) = "This type of model doesn't support detach_from_bone!";

static PyObject *__pyx_f_5_soya_5_Body_detach_from_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_detach_from_bone[] = "Cal3DBody.detach_from_bone(coordsyst)\n\nOnly for Body associated with a AnimatedModel.\n\nDetaches COORDSYST from the bone it has been attached to.\n\nXXX this method should be moved to World.";
static PyObject *__pyx_f_5_soya_5_Body_detach_from_bone(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst = 0;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 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);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya_CoordSyst, 1, "coordsyst")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 213; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/body.pyx":221 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 221; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_detach_from_bone(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_coordsyst);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 222; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 222; goto __pyx_L1;}
    Py_INCREF(__pyx_k222p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k222p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 222; 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[8]; __pyx_lineno = 222; goto __pyx_L1;}
  }
  __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._Body.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_f_5_soya_5_Body_15attached_meshes___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_15attached_meshes___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/body.pyx":226 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 226; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_get_attached_meshes(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 226; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":227 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 227; 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._Body.attached_meshes.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Body_19attached_coordsysts___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_19attached_coordsysts___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/body.pyx":231 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 231; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_get_attached_coordsysts(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 231; goto __pyx_L1;}
    __pyx_r = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":232 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 232; 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._Body.attached_coordsysts.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k223p;

static char (__pyx_k223[]) = "This type of model doesn't support animation!";

static PyObject *__pyx_f_5_soya_5_Body_animate_blend_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_animate_blend_cycle[] = "Body.animate_blend_cycle(animation_name, weight = 1.0, fade_in = 0.2)\n\nOnly for Body associated with a AnimatedModel.\n\nPlays animation ANIMATION_NAME in cycle.\nSee body.model.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_5_Body_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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"animation_name","weight","fade_in",0};
  __pyx_v_weight = __pyx_k42;
  __pyx_v_fade_in = __pyx_k43;
  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/soya3d/body.pyx":249 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 249; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_animate_blend_cycle(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_animation_name,__pyx_v_weight,__pyx_v_fade_in);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 250; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 250; goto __pyx_L1;}
    Py_INCREF(__pyx_k223p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k223p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 250; 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[8]; __pyx_lineno = 250; goto __pyx_L1;}
  }
  __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._Body.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_k224p;

static char (__pyx_k224[]) = "This type of model doesn't support animation!";

static PyObject *__pyx_f_5_soya_5_Body_animate_clear_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_animate_clear_cycle[] = "Body.animate_clear_cycle(animation_name, fade_out = 0.2)\n\nOnly for Body associated with a AnimatedModel.\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_5_Body_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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"animation_name","fade_out",0};
  __pyx_v_fade_out = __pyx_k44;
  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/soya3d/body.pyx":260 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 260; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_animate_clear_cycle(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_animation_name,__pyx_v_fade_out);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 261; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 261; goto __pyx_L1;}
    Py_INCREF(__pyx_k224p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k224p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 261; 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[8]; __pyx_lineno = 261; goto __pyx_L1;}
  }
  __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._Body.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_k225p;

static char (__pyx_k225[]) = "This type of model doesn't support animation!";

static PyObject *__pyx_f_5_soya_5_Body_animate_execute_action(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_animate_execute_action[] = "Body.animate_execute_action(animation_name, fade_in = 0.2, fade_out = 0.2)\n\nOnly for Body associated with a AnimatedModel.\n\nPlays animation ANIMATION_NAME once.\nSee body.model.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_5_Body_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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"animation_name","fade_in","fade_out",0};
  __pyx_v_fade_in = __pyx_k45;
  __pyx_v_fade_out = __pyx_k46;
  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/soya3d/body.pyx":272 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 272; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_animate_execute_action(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_animation_name,__pyx_v_fade_in,__pyx_v_fade_out);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; goto __pyx_L1;}
    Py_INCREF(__pyx_k225p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k225p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; 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[8]; __pyx_lineno = 273; goto __pyx_L1;}
  }
  __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._Body.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_k226p;

static char (__pyx_k226[]) = "This type of model doesn't support animation!";

static PyObject *__pyx_f_5_soya_5_Body_animate_reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Body_animate_reset[] = "Body.animate_reset()\n\nOnly for Body associated with a AnimatedModel.\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_5_Body_animate_reset(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/soya3d/body.pyx":282 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 282; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_animate_reset(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 283; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 283; goto __pyx_L1;}
    Py_INCREF(__pyx_k226p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k226p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 283; 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[8]; __pyx_lineno = 283; goto __pyx_L1;}
  }
  __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._Body.animate_reset");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k227p;

static char (__pyx_k227[]) = "This type of model doesn't support LOD!";

static PyObject *__pyx_f_5_soya_5_Body_set_lod_level(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_set_lod_level(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_lod_level;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  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/soya3d/body.pyx":286 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 286; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_set_lod_level(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_lod_level);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 287; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 287; goto __pyx_L1;}
    Py_INCREF(__pyx_k227p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k227p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 287; 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[8]; __pyx_lineno = 287; goto __pyx_L1;}
  }
  __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._Body.set_lod_level");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_5_Body_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_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/soya3d/body.pyx":293 */
  __pyx_1 = ((((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/body.pyx":294 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->__pyx_base._auto_static_count == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/body.pyx":295 */
      __pyx_1 = (!(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_COORDSYS_STATIC));
      if (__pyx_1) {
        ((struct __pyx_vtabstruct_5_soya__Body *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._go_static(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)));
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/body.pyx":297 */
      ((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->__pyx_base._auto_static_count = (((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->__pyx_base._auto_static_count - 1);
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/body.pyx":299 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 299; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_begin_round(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data);
    goto __pyx_L5;
  }
  __pyx_L5:;

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

static PyObject *__pyx_f_5_soya_5_Body_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Body_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_r;
  int __pyx_1;
  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/body.pyx":302 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 302; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data->__pyx_base.__pyx_vtab)->_advance_time(((struct __pyx_obj_5_soya__Body *)__pyx_v_self)->_data,__pyx_v_proportion);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

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

  /* "/home/jiba/src/soya/soya3d/world.pyx":30 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_model_builder));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_model_builder);
  goto __pyx_L0;

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

static int __pyx_f_5_soya_6_World_13model_builder___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_arg); /*proto*/
static int __pyx_f_5_soya_6_World_13model_builder___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_ModelBuilder, 1, "arg")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 31; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":32 */
  Py_INCREF(__pyx_v_arg);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_model_builder));
  ((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_model_builder = __pyx_v_arg;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._World.model_builder.__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":36 */
  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 = 37; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":38 */
  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__Model *__pyx_v_model = 0;
  PyObject *__pyx_v_opt = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"parent","model","opt",0};
  __pyx_v_parent = __pyx_k47;
  __pyx_v_model = __pyx_k48;
  __pyx_v_opt = __pyx_k49;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOO", __pyx_argnames, &__pyx_v_parent, &__pyx_v_model, &__pyx_v_opt)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_model);
  Py_INCREF(__pyx_v_opt);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Model, 1, "model")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":41 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 41; 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":42 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Body), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; 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_model));
  PyTuple_SET_ITEM(__pyx_2, 2, ((PyObject *)__pyx_v_model));
  Py_INCREF(__pyx_v_opt);
  PyTuple_SET_ITEM(__pyx_2, 3, __pyx_v_opt);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; 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_model);
  Py_DECREF(__pyx_v_opt);
  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":45 */
  __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 = 45; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(7); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 45; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base._model));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->__pyx_base._model));
  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->_model_builder));
  PyTuple_SET_ITEM(__pyx_2, 5, ((PyObject *)__pyx_v_self->_model_builder));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->__pyx_base._data));
  PyTuple_SET_ITEM(__pyx_2, 6, ((PyObject *)__pyx_v_self->__pyx_base._data));
  __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_data;
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_child;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);
  __pyx_v_data = Py_None; Py_INCREF(__pyx_v_data);
  __pyx_v_child = Py_None; Py_INCREF((PyObject *) __pyx_v_child);

  /* "/home/jiba/src/soya/soya3d/world.pyx":59 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 59; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->_filename);
  __pyx_v_self->_filename = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":60 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 60; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 60; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_self->children);
  __pyx_v_self->children = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":61 */
  __pyx_1 = PyInt_FromLong(4); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Atmosphere)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 61; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_atmosphere));
  __pyx_v_self->_atmosphere = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":62 */
  __pyx_1 = PyInt_FromLong(5); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 62; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_ModelBuilder)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 62; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_model_builder));
  __pyx_v_self->_model_builder = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":64 */
  __pyx_3 = PyObject_Length(__pyx_v_cstate); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 64; goto __pyx_L1;}
  __pyx_4 = (__pyx_3 == 6);
  if (__pyx_4) {
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_data);
    __pyx_v_data = Py_None;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_1 = PyInt_FromLong(6); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 65; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 65; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_v_data);
    __pyx_v_data = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":66 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 66; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_5 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 66; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 66; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_5);
  Py_INCREF(__pyx_v_data);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_data);
  __pyx_2 = 0;
  __pyx_5 = 0;
  __pyx_vtabptr_5_soya__Body->__pyx_base.__pyx_base.__pyx_base.__setcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self),__pyx_1);
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":69 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 69; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_5 = PyIter_Next(__pyx_2);
    if (!__pyx_5) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 69; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 69; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_5;
    __pyx_5 = 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_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._World.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  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":73 */
  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":74 */
  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 = 74; 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 = 74; 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":75 */
  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":79 */
  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":80 */
  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 = 80; 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 = 80; 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":81 */
  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":84 */
  __pyx_vtabptr_5_soya_CoordSyst->_invalidate(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self));

  /* "/home/jiba/src/soya/soya3d/world.pyx":86 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 86; 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 = 86; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 86; 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":91 */
  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":92 */
  __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":94 */
  __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":95 */
  __pyx_v_self->__pyx_base.__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/world.pyx":97 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_atmosphere) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":98 */
    __pyx_1 = ((PyObject *)__pyx_v_5_soya_renderer->root_atmosphere) == Py_None;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":99 */
      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":101 */
      __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":102 */
        __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 = 102; 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":103 */
        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":104 */
        __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 = 104; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 104; 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 = 104; 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":106 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._model) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->__pyx_base._model->__pyx_base.__pyx_vtab)->_batch(__pyx_v_self->__pyx_base._model,((struct __pyx_obj_5_soya__Body *)__pyx_v_self));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":108 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 108; 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 = 108; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 108; 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":110 */
  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":115 */
  __pyx_v_result = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":116 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._model) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    __pyx_v_result = ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->__pyx_base._model->__pyx_base.__pyx_vtab)->_shadow(__pyx_v_self->__pyx_base._model,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_self),__pyx_v_light);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":117 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 117; 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 = 117; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 117; 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":118 */
  __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":123 */
  __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":124 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._model) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->__pyx_base._model->__pyx_base.__pyx_vtab)->_raypick(__pyx_v_self->__pyx_base._model,__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":125 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 125; 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 = 125; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __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_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":129 */
  __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":130 */
  __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base._model) == Py_None;
  __pyx_1 = (!__pyx_2);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->__pyx_base._model->__pyx_base.__pyx_vtab)->_raypick_b(__pyx_v_self->__pyx_base._model,__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":131 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 131; 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 = 131; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 131; 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":132 */
    __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":133 */
  __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_model;

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":137 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 137; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 137; 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 = 137; 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 = 137; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":138 */
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_obj), __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 138; 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":139 */
    while (1) {
      __pyx_L3:;
      __pyx_4 = PyObject_IsTrue(((PyObject *)__pyx_v_child)); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 139; goto __pyx_L1;}
      if (!__pyx_4) break;

      /* "/home/jiba/src/soya/soya3d/world.pyx":140 */
      __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":141 */
      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":143 */
    __pyx_4 = ((PyObject *)__pyx_v_self->__pyx_base._model) == ((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":144 */
    __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 144; 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 = 144; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 144; 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":145 */
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_model); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 145; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__CObj)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 145; 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":146 */
  __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":154 */
  __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":157 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._model) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->__pyx_base._model->__pyx_base.__pyx_vtab)->_get_box(__pyx_v_self->__pyx_base._model,__pyx_v_box,__pyx_v_matrix2);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":160 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 160; 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 = 160; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 160; 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_k50;
  __pyx_v_half_line = __pyx_k51;
  __pyx_v_cull_face = __pyx_k52;
  __pyx_v_p = __pyx_k53;
  __pyx_v_v = __pyx_k54;
  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 = 162; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 162; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p), __pyx_ptype_5_soya__Point, 1, "p")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 162; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5_soya__Vector, 1, "v")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 162; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":194 */
  __pyx_1 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 194; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":195 */
  ((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":196 */
  ((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":197 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/world.pyx":198 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/world.pyx":199 */
  __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":201 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 201; 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":202 */
  __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":206 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/world.pyx":207 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":208 */
  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":209 */
    __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":210 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":211 */
  __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 = 211; 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_k55;
  __pyx_v_half_line = __pyx_k56;
  __pyx_v_cull_face = __pyx_k57;
  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 = 213; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 0, "direction")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 213; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":239 */
  __pyx_1 = ((PyObject *)__pyx_f_5_soya_get_raypick_data()); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 239; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":240 */
  ((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":241 */
  ((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":242 */
  vector_normalize((__pyx_v_data->root_data + 3));

  /* "/home/jiba/src/soya/soya3d/world.pyx":243 */
  (__pyx_v_data->root_data[6]) = __pyx_v_distance;

  /* "/home/jiba/src/soya/soya3d/world.pyx":244 */
  __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":246 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 246; 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":249 */
  __pyx_v_max = __pyx_v_data->raypicked->nb;

  /* "/home/jiba/src/soya/soya3d/world.pyx":250 */
  __pyx_v_data->raypicked->nb = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":251 */
  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":252 */
    __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":253 */
    __pyx_v_coordsyst->__raypick_data = (-1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":254 */
  __pyx_1 = PyInt_FromLong(__pyx_v_result); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 254; 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_k228p;

static char (__pyx_k228[]) = "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 = 256; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":264 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 264; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 264; 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 = 264; 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 = 264; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":265 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_is_inside); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 265; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 265; 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 = 265; 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 = 265; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":266 */
      __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 266; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 266; goto __pyx_L1;}
      Py_INCREF(__pyx_k228p);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k228p);
      __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 266; 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 = 266; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":270 */
  __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":271 */
    __pyx_v_m = ((float (*))malloc((19 * (sizeof(float )))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":272 */
    __pyx_v_p = ((float (*))malloc((3 * (sizeof(float )))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":273 */
    ((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":274 */
    matrix_copy(__pyx_v_m,__pyx_v_child->_matrix);

    /* "/home/jiba/src/soya/soya3d/world.pyx":274 */
    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":275 */
    matrix_copy(__pyx_v_m,__pyx_v_child->_matrix);

    /* "/home/jiba/src/soya/soya3d/world.pyx":275 */
    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":276 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_child->__pyx_base._parent), __pyx_n_remove); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 276; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 276; 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 = 276; 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":277 */
    memcpy((__pyx_v_child->_matrix + 12),__pyx_v_p,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/soya3d/world.pyx":278 */
    free(__pyx_v_m);

    /* "/home/jiba/src/soya/soya3d/world.pyx":279 */
    free(__pyx_v_p);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":280 */
  __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 = 280; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 280; 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 = 280; 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":281 */
  ((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":283 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_added_into); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 283; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 283; 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 = 283; 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 = 285; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":290 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add); 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((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 = 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.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":293 */
  __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 = 293; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 293; 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 = 293; 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 = 293; 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_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 = 295; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":300 */
  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":301 */
  __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 = 301; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 301; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 301; 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 = 301; 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 = 303; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":308 */
  __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 = 308; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 308; 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 = 308; 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":309 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_added_into); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 309; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 309; 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 = 309; 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":317 */
  __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 = 317; goto __pyx_L1;}
  Py_DECREF(__pyx_v_recursive);
  __pyx_v_recursive = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":318 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 318; 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 = 318; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 318; 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":319 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 319; 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 = 319; 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 = 319; 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 = 319; 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 = 319; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 319; goto __pyx_L1;}
      __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 319; 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 = 319; 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 = 319; 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":320 */
  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":324 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_iter); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 324; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 324; 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 = 324; 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_k230p;

static char (__pyx_k230[]) = "";

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":329 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 329; 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 = 329; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 329; 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":330 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_getattr); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 330; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 330; 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_k230p);
    PyTuple_SET_ITEM(__pyx_3, 2, __pyx_k230p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 330; 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 = 330; 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":331 */
  __pyx_2 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 331; 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 = 331; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 331; 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":332 */
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 332; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 332; 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 = 332; 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 = 332; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_5) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":333 */
      __pyx_4 = PyObject_GetItem(((PyObject *)__pyx_v_item), __pyx_v_name); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 333; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 333; 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":334 */
      __pyx_5 = PyObject_IsTrue(((PyObject *)__pyx_v_i)); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 334; 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_k231p;

static char (__pyx_k231[]) = ".";

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) -> CoordSyst\n\nReturns the CoordSyst 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":343 */
  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":344 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_namepath, __pyx_n_split); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 344; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 344; goto __pyx_L1;}
  Py_INCREF(__pyx_k231p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k231p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 344; 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 = 344; 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 = 344; 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 = 344; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 344; 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":345 */
  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":353 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 353; 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 = 353; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 353; 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":354 */
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 354; 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 = 354; 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 = 354; 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":355 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 355; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 355; 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 = 355; 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 = 355; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":356 */
      __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_item), __pyx_n_search); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 356; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 356; 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 = 356; 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":357 */
      __pyx_4 = PyObject_IsTrue(__pyx_v_subresult); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 357; 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":358 */
  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_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;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  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);

  /* "/home/jiba/src/soya/soya3d/world.pyx":364 */
  __pyx_1 = PyObject_GetItem(__pyx_v_self, __pyx_v_name); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 364; 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.search_name");
  __pyx_r = 0;
  __pyx_L0:;
  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":371 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 371; goto __pyx_L1;}
  Py_DECREF(__pyx_v_result);
  __pyx_v_result = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/world.pyx":372 */
  ((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":373 */
  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":377 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 377; 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":378 */
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 378; 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 = 378; 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 = 378; 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 = 378; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 378; 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 = 378; 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":379 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 379; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 379; 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 = 379; 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 = 379; 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_k58;
  __pyx_v_items = __pyx_k59;
  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 = 381; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rc), __pyx_ptype_5_soya_RaypickContext, 1, "rc")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 381; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/world.pyx":401 */
  __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 = 401; 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":402 */
  __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 = 402; 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 = 402; 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 = 402; 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":404 */
    __pyx_v_rc->_items->nb = 0;

    /* "/home/jiba/src/soya/soya3d/world.pyx":405 */
    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":406 */
  ((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":407 */
  (__pyx_v_sphere[3]) = __pyx_v_radius;

  /* "/home/jiba/src/soya/soya3d/world.pyx":409 */
  __pyx_2 = __pyx_v_items == Py_None;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":410 */
    ((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":412 */
    __pyx_1 = PyObject_GetIter(__pyx_v_items); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 412; 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 = 412; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__CObj)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 412; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_item));
      __pyx_v_item = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/soya3d/world.pyx":413 */
      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":415 */
  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":418 */
  __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":425 */
  __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":426 */
  point_by_matrix_copy(__pyx_v_s,__pyx_v_rsphere,__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/world.pyx":427 */
  (__pyx_v_s[3]) = length_by_matrix((__pyx_v_rsphere[3]),__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/world.pyx":428 */
  __pyx_1 = ((PyObject *)__pyx_v_self->__pyx_base._model) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {
    ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->__pyx_base._model->__pyx_base.__pyx_vtab)->_collect_raypickables(__pyx_v_self->__pyx_base._model,__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":429 */
  __pyx_3 = PyObject_GetIter(__pyx_v_self->children); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 429; 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 = 429; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 429; 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":430 */
    ((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 main_loop) 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;
  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 (!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":440 */
  __pyx_1 = ((((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base._option & __pyx_e_5_soya_COORDSYS_NON_AUTO_STATIC) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/world.pyx":441 */
    __pyx_1 = (((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base._auto_static_count == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/world.pyx":442 */
      __pyx_1 = (!(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base._option & __pyx_e_5_soya_COORDSYS_STATIC));
      if (__pyx_1) {
        ((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._go_static(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)));
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/world.pyx":444 */
      ((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base._auto_static_count = (((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base.__pyx_base._auto_static_count - 1);
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":446 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base._data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 446; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base._data->__pyx_base.__pyx_vtab)->_begin_round(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base._data);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":449 */
  __pyx_2 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; goto __pyx_L1;}
  for (;;) {
    __pyx_L6:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_begin_round); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; goto __pyx_L1;}
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 449; 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_L7:;
  Py_DECREF(__pyx_2); __pyx_2 = 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);
  __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 main_loop) 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":456 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 456; 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 = 456; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 456; 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 = 456; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 456; goto __pyx_L1;}
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 456; 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 main_loop) 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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 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":467 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base._data)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 467; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Model *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base._data->__pyx_base.__pyx_vtab)->_advance_time(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->__pyx_base._data,__pyx_v_proportion);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/world.pyx":469 */
  __pyx_2 = PyObject_GetIter(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->children); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 469; goto __pyx_L1;}
  for (;;) {
    __pyx_L3:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 469; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 469; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_child));
    __pyx_v_child = __pyx_3;
    __pyx_3 = 0;
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_child), __pyx_n_advance_time); if (!__pyx_3) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 469; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_4) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 469; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 469; 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[9]; __pyx_lineno = 469; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
  }
  __pyx_L4:;
  Py_DECREF(__pyx_2); __pyx_2 = 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);
  __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_model_builder;

static PyObject *__pyx_f_5_soya_6_World_to_model(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_World_to_model[] = "World.to_model() -> Model\n\nTurns the world into a Model (a solid optimized / compiled model).\nSee World.model_builder and ModelBuilder if you want to customize this process (e.g. for using\ntrees, cell-shading or shadow).";
static PyObject *__pyx_f_5_soya_6_World_to_model(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":477 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_model_builder); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 477; 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_ModelBuilder *)__pyx_v_5_soya__DEFAULT_MODEL_BUILDER->__pyx_base.__pyx_vtab)->_to_model(__pyx_v_5_soya__DEFAULT_MODEL_BUILDER,((struct __pyx_obj_5_soya__World *)__pyx_v_self))); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 477; 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_ModelBuilder *)((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_model_builder->__pyx_base.__pyx_vtab)->_to_model(((struct __pyx_obj_5_soya__World *)__pyx_v_self)->_model_builder,((struct __pyx_obj_5_soya__World *)__pyx_v_self))); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 478; 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.to_model");
  __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;
  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_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":37 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->__pyx_base.__raypick_data = (-1);

  /* "/home/jiba/src/soya/soya3d/light.pyx":38 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_id = (-1);

  /* "/home/jiba/src/soya/soya3d/light.pyx":39 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_weakref); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_WeakKeyDictionary); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 39; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_static_shadow_displaylists);
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_static_shadow_displaylists = __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._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 PyObject *__pyx_n_values;

static void __pyx_f_5_soya_6_Light___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_6_Light___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_v_displaylist;
  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/soya3d/light.pyx":43 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_static_shadow_displaylists, __pyx_n_values); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 43; 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[10]; __pyx_lineno = 43; 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[10]; __pyx_lineno = 43; goto __pyx_L1;}
      break;
    }
    __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 43; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_v_displaylist = __pyx_4;

    /* "/home/jiba/src/soya/soya3d/light.pyx":44 */
    glDeleteLists(__pyx_v_displaylist,1);
  }
  __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);
  __Pyx_AddTraceback("_soya._Light.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

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_k61;
  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 = 46; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":47 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 47; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 47; 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 = 47; 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":48 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_w = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":49 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_constant = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":50 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_angle = 180.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":51 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":52 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[1]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":53 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":54 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[3]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":55 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[4]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":56 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[5]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":57 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[6]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":58 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[7]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":59 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[8]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":60 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[9]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":61 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[10]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":62 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[11]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":63 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[12]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":64 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[13]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":65 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[14]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":66 */
  (((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_colors[15]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/light.pyx":67 */
  ((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":68 */
  ((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":72 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/light.pyx":73 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/soya3d/light.pyx":74 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/light.pyx":75 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->radius);

  /* "/home/jiba/src/soya/soya3d/light.pyx":76 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_angle);

  /* "/home/jiba/src/soya/soya3d/light.pyx":77 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_exponent);

  /* "/home/jiba/src/soya/soya3d/light.pyx":78 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_linear);

  /* "/home/jiba/src/soya/soya3d/light.pyx":79 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_constant);

  /* "/home/jiba/src/soya/soya3d/light.pyx":80 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_quadratic);

  /* "/home/jiba/src/soya/soya3d/light.pyx":81 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_w);

  /* "/home/jiba/src/soya/soya3d/light.pyx":82 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,16);

  /* "/home/jiba/src/soya/soya3d/light.pyx":83 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 83; 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);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/light.pyx":86 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/light.pyx":88 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/soya3d/light.pyx":89 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/soya3d/light.pyx":90 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/light.pyx":91 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->radius));

  /* "/home/jiba/src/soya/soya3d/light.pyx":92 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_angle));

  /* "/home/jiba/src/soya/soya3d/light.pyx":93 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_exponent));

  /* "/home/jiba/src/soya/soya3d/light.pyx":94 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_linear));

  /* "/home/jiba/src/soya/soya3d/light.pyx":95 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_constant));

  /* "/home/jiba/src/soya/soya3d/light.pyx":96 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_quadratic));

  /* "/home/jiba/src/soya/soya3d/light.pyx":97 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_w));

  /* "/home/jiba/src/soya/soya3d/light.pyx":98 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,16);

  /* "/home/jiba/src/soya/soya3d/light.pyx":99 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/soya3d/light.pyx":101 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LIGHT_STATIC);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":102 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_LIGHT_STATIC));

    /* "/home/jiba/src/soya/soya3d/light.pyx":103 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_COORDSYS_STATIC);
    goto __pyx_L2;
  }
  __pyx_L2:;

  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_5angle___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_5angle___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":107 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_angle); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __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._Light.angle.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_5angle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_5angle___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 = 108; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":109 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_angle = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":110 */
  ((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_INVALID);

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

static PyObject *__pyx_f_5_soya_6_Light_8exponent___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Light_8exponent___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":114 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_exponent); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __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._Light.exponent.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_6_Light_8exponent___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_6_Light_8exponent___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 = 115; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":116 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_exponent = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":117 */
  ((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_INVALID);

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

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":121 */
  __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 = 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._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 = 122; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":123 */
  __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":128 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_constant); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 128; 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 = 129; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":130 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_constant = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":131 */
  ((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));

  /* "/home/jiba/src/soya/soya3d/light.pyx":132 */
  ((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_INVALID);

  __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":136 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_linear); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 136; 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 = 137; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":138 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_linear = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":139 */
  ((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));

  /* "/home/jiba/src/soya/soya3d/light.pyx":140 */
  ((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_INVALID);

  __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":144 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_quadratic); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 144; 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 = 145; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":146 */
  ((struct __pyx_obj_5_soya__Light *)__pyx_v_self)->_quadratic = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/light.pyx":147 */
  ((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));

  /* "/home/jiba/src/soya/soya3d/light.pyx":148 */
  ((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_INVALID);

  __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":152 */
  __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 = 152; 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 = 153; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":154 */
  __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":159 */
  __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 = 159; 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 = 160; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":161 */
  __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_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":166 */
  __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 = 166; 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 = 166; 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 = 166; 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 = 166; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 166; 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":168 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 168; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 168; 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 = 168; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 168; 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 = 168; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 168; 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 = 168; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 168; 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 = 168; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":169 */
  ((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_INVALID);

  __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":173 */
  __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 = 173; 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 = 173; 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 = 173; 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 = 173; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 173; 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":175 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 175; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 175; 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 = 175; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 175; 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 = 175; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 175; 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 = 175; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 175; 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 = 175; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":176 */
  ((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_INVALID);

  __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":180 */
  __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 = 180; 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 = 180; 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 = 180; 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 = 180; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; 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":182 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; 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 = 182; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; 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 = 182; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; 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 = 182; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; 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 = 182; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/light.pyx":183 */
  ((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_INVALID);

  __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":187 */
  __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 = 187; 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 = 187; 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 = 187; 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 = 187; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 187; 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":189 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_color, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; 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 = 189; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; 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 = 189; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; 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 = 189; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; 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 = 189; 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":195 */
  __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 = 195; 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":196 */
  __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":197 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 197; 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 = 197; 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 = 197; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":198 */
  __pyx_v_rdata = __pyx_v_data->root_data;

  /* "/home/jiba/src/soya/soya3d/light.pyx":199 */
  __pyx_2 = (__pyx_v_self->_w == 0.0);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":200 */
    (__pyx_v_rdata[3]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":201 */
    (__pyx_v_rdata[4]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":202 */
    (__pyx_v_rdata[5]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/light.pyx":203 */
    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":204 */
    vector_normalize((__pyx_v_rdata + 3));

    /* "/home/jiba/src/soya/soya3d/light.pyx":205 */
    (__pyx_v_rdata[6]) = 100.0;

    /* "/home/jiba/src/soya/soya3d/light.pyx":206 */
    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":207 */
    (__pyx_v_rdata[0]) = ((__pyx_v_rdata[0]) - ((__pyx_v_rdata[3]) * (__pyx_v_rdata[6])));

    /* "/home/jiba/src/soya/soya3d/light.pyx":208 */
    (__pyx_v_rdata[1]) = ((__pyx_v_rdata[1]) - ((__pyx_v_rdata[4]) * (__pyx_v_rdata[6])));

    /* "/home/jiba/src/soya/soya3d/light.pyx":209 */
    (__pyx_v_rdata[2]) = ((__pyx_v_rdata[2]) - ((__pyx_v_rdata[5]) * (__pyx_v_rdata[6])));

    /* "/home/jiba/src/soya/soya3d/light.pyx":210 */
    (__pyx_v_rdata[6]) = ((__pyx_v_rdata[6]) - 1.0);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/light.pyx":212 */
    vector_from_points((__pyx_v_rdata + 3),(__pyx_v_self->__pyx_base._matrix + 12),__pyx_v_position);

    /* "/home/jiba/src/soya/soya3d/light.pyx":213 */
    __pyx_2 = ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base._parent) == Py_None;
    if (__pyx_2) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":214 */
      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":216 */
      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":217 */
      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":218 */
    (__pyx_v_rdata[6]) = (vector_length((__pyx_v_rdata + 3)) - 1.0);

    /* "/home/jiba/src/soya/soya3d/light.pyx":219 */
    vector_normalize((__pyx_v_rdata + 3));
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":220 */
  __pyx_v_data->option = __pyx_e_5_soya_RAYPICK_HALF_LINE;

  /* "/home/jiba/src/soya/soya3d/light.pyx":221 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 221; 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":226 */
  __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":227 */
    __pyx_r = 1.0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":228 */
  (__pyx_v_v[0]) = ((__pyx_v_position[0]) - (__pyx_v_self->__pyx_base._matrix[12]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":229 */
  (__pyx_v_v[1]) = ((__pyx_v_position[1]) - (__pyx_v_self->__pyx_base._matrix[13]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":230 */
  (__pyx_v_v[2]) = ((__pyx_v_position[2]) - (__pyx_v_self->__pyx_base._matrix[14]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":231 */
  (__pyx_v_w[0]) = (-(__pyx_v_self->__pyx_base._matrix[8]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":232 */
  (__pyx_v_w[1]) = (-(__pyx_v_self->__pyx_base._matrix[9]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":233 */
  (__pyx_v_w[2]) = (-(__pyx_v_self->__pyx_base._matrix[10]));

  /* "/home/jiba/src/soya/soya3d/light.pyx":234 */
  __pyx_v_m = vector_dot_product(__pyx_v_v,__pyx_v_w);

  /* "/home/jiba/src/soya/soya3d/light.pyx":235 */
  __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":236 */
  __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":241 */
  __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":242 */
  __pyx_v_d = point_distance_to((__pyx_v_self->__pyx_base._matrix + 12),__pyx_v_position);

  /* "/home/jiba/src/soya/soya3d/light.pyx":243 */
  __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":248 */
  __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":249 */
  __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":250 */
  __pyx_v_f = (__pyx_v_attenuation * __pyx_v_spotlight);

  /* "/home/jiba/src/soya/soya3d/light.pyx":252 */
  __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":253 */
  __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":255 */
    __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":257 */
      memcpy(__pyx_v_n,__pyx_v_normal,(sizeof(__pyx_v_n)));

      /* "/home/jiba/src/soya/soya3d/light.pyx":258 */
      vector_normalize(__pyx_v_n);

      /* "/home/jiba/src/soya/soya3d/light.pyx":259 */
      __pyx_1 = (__pyx_v_self->_w == 0.0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/light.pyx":260 */
        (__pyx_v_v[0]) = 0.0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":261 */
        (__pyx_v_v[1]) = 0.0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":262 */
        (__pyx_v_v[2]) = 1.0;

        /* "/home/jiba/src/soya/soya3d/light.pyx":263 */
        vector_by_matrix(__pyx_v_v,__pyx_v_self->__pyx_base._matrix);
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/soya3d/light.pyx":265 */
        vector_from_points(__pyx_v_v,(__pyx_v_self->__pyx_base._matrix + 12),__pyx_v_position);

        /* "/home/jiba/src/soya/soya3d/light.pyx":266 */
        vector_normalize(__pyx_v_v);
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/light.pyx":267 */
      __pyx_v_angle = vector_dot_product(__pyx_v_n,__pyx_v_v);

      /* "/home/jiba/src/soya/soya3d/light.pyx":269 */
      __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":271 */
    __pyx_v_g = __pyx_v_angle;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/light.pyx":273 */
  (__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":274 */
  (__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":275 */
  (__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":279 */
  __pyx_1 = (__pyx_v_self->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":280 */
    (__pyx_v_self->_data[0]) = (-(__pyx_v_self->__pyx_base._matrix[8]));

    /* "/home/jiba/src/soya/soya3d/light.pyx":281 */
    (__pyx_v_self->_data[1]) = (-(__pyx_v_self->__pyx_base._matrix[9]));

    /* "/home/jiba/src/soya/soya3d/light.pyx":282 */
    (__pyx_v_self->_data[2]) = (-(__pyx_v_self->__pyx_base._matrix[10]));

    /* "/home/jiba/src/soya/soya3d/light.pyx":283 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 283; 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 = 283; 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":284 */
      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":285 */
      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":286 */
      vector_normalize(__pyx_v_self->_data);
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/light.pyx":288 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_parent); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 288; 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 = 288; 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":289 */
      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":291 */
      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":292 */
      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":296 */
  __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":298 */
  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":306 */
  __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 = 306; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 306; 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 = 306; 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 = 307; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 307; 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 = 307; 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_k232p;

static char (__pyx_k232[]) = "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":315 */
  (__pyx_v_p[3]) = __pyx_v_self->_w;

  /* "/home/jiba/src/soya/soya3d/light.pyx":316 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_HIDDEN));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":317 */
    glLoadMatrixf(__pyx_v_self->__pyx_base._render_matrix);

    /* "/home/jiba/src/soya/soya3d/light.pyx":318 */
    __pyx_1 = (__pyx_v_self->_id == (-1));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":319 */
      __pyx_v_id = 0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":320 */
      __pyx_2 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 320; 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 = 320; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 320; 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":321 */
        __pyx_1 = ((PyObject *)__pyx_v_light) == Py_None;
        if (__pyx_1) {

          /* "/home/jiba/src/soya/soya3d/light.pyx":322 */
          __pyx_v_self->_id = __pyx_v_id;

          /* "/home/jiba/src/soya/soya3d/light.pyx":323 */
          __pyx_3 = PyInt_FromLong(__pyx_v_id); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 323; 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 = 323; goto __pyx_L1;}
          Py_DECREF(__pyx_3); __pyx_3 = 0;

          /* "/home/jiba/src/soya/soya3d/light.pyx":324 */
          goto __pyx_L5;
          goto __pyx_L6;
        }
        __pyx_L6:;

        /* "/home/jiba/src/soya/soya3d/light.pyx":325 */
        __pyx_v_id = (__pyx_v_id + 1);
      }
      /*else*/ {

        /* "/home/jiba/src/soya/soya3d/light.pyx":327 */
        if (__Pyx_PrintItem(__pyx_k232p) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 327; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 327; goto __pyx_L1;}

        /* "/home/jiba/src/soya/soya3d/light.pyx":329 */
        goto __pyx_L0;
      }
      __pyx_L5:;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":331 */
    __pyx_v_id = (GL_LIGHT0 + __pyx_v_self->_id);

    /* "/home/jiba/src/soya/soya3d/light.pyx":333 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_LIGHT_INVALID);
    if (!__pyx_1) {
      __pyx_3 = PyInt_FromLong(__pyx_v_self->_id); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 333; 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 = 333; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_4 = ((PyObject *)__pyx_v_self) == __pyx_2;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      __pyx_1 = (!__pyx_4);
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":334 */
      __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_LIGHT_INVALID));

      /* "/home/jiba/src/soya/soya3d/light.pyx":335 */
      __pyx_3 = PyInt_FromLong(__pyx_v_self->_id); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 335; 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 = 335; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":337 */
      glLightf(__pyx_v_id,GL_SPOT_EXPONENT,__pyx_v_self->_exponent);

      /* "/home/jiba/src/soya/soya3d/light.pyx":338 */
      glLightf(__pyx_v_id,GL_SPOT_CUTOFF,__pyx_v_self->_angle);

      /* "/home/jiba/src/soya/soya3d/light.pyx":339 */
      glLightfv(__pyx_v_id,GL_AMBIENT,__pyx_v_self->_colors);

      /* "/home/jiba/src/soya/soya3d/light.pyx":340 */
      glLightfv(__pyx_v_id,GL_DIFFUSE,(__pyx_v_self->_colors + 4));

      /* "/home/jiba/src/soya/soya3d/light.pyx":341 */
      glLightfv(__pyx_v_id,GL_SPECULAR,(__pyx_v_self->_colors + 8));

      /* "/home/jiba/src/soya/soya3d/light.pyx":342 */
      glLightf(__pyx_v_id,GL_CONSTANT_ATTENUATION,__pyx_v_self->_constant);

      /* "/home/jiba/src/soya/soya3d/light.pyx":343 */
      glLightf(__pyx_v_id,GL_LINEAR_ATTENUATION,__pyx_v_self->_linear);

      /* "/home/jiba/src/soya/soya3d/light.pyx":344 */
      glLightf(__pyx_v_id,GL_QUADRATIC_ATTENUATION,__pyx_v_self->_quadratic);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":346 */
    __pyx_4 = (__pyx_v_self->_w == 0.0);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":347 */
      (__pyx_v_p[0]) = 0.0;
      (__pyx_v_p[1]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":348 */
      (__pyx_v_p[2]) = 1.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":349 */
      glLightfv(__pyx_v_id,GL_POSITION,__pyx_v_p);
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/soya3d/light.pyx":351 */
      (__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":352 */
      (__pyx_v_q[0]) = 0.0;
      (__pyx_v_q[1]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":353 */
      (__pyx_v_q[2]) = (-1.0);

      /* "/home/jiba/src/soya/soya3d/light.pyx":354 */
      glLightfv(__pyx_v_id,GL_POSITION,__pyx_v_p);

      /* "/home/jiba/src/soya/soya3d/light.pyx":355 */
      glLightfv(__pyx_v_id,GL_SPOT_DIRECTION,__pyx_v_q);
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/soya3d/light.pyx":356 */
    glEnable(__pyx_v_id);

    /* "/home/jiba/src/soya/soya3d/light.pyx":357 */
    __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":361 */
  __pyx_1 = (__pyx_v_self->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/light.pyx":362 */
    __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":364 */
    __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":366 */
    __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":369 */
    __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_k233[]) = "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":373 */
  __pyx_k233;

  /* "/home/jiba/src/soya/soya3d/light.pyx":375 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 375; 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 = 375; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 375; 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":376 */
    __pyx_3 = ((PyObject *)__pyx_v_light) == Py_None;
    __pyx_4 = (!__pyx_3);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":377 */
      __pyx_3 = __pyx_v_light->_gl_id_enabled;
      if (__pyx_3) {

        /* "/home/jiba/src/soya/soya3d/light.pyx":378 */
        glDisable((GL_LIGHT0 + __pyx_v_light->_id));

        /* "/home/jiba/src/soya/soya3d/light.pyx":379 */
        __pyx_v_light->_gl_id_enabled = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/soya3d/light.pyx":380 */
      __pyx_2 = PyInt_FromLong(__pyx_v_light->_id); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 380; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_5_soya_LIGHTS, __pyx_2, Py_None) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 380; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/soya3d/light.pyx":381 */
      __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_k234[]) = "Disable all static lights. Static lights are disabled when rendering static lit\nmodel (Soya assume the effect of static lights was already taken into account at the\nmodel 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":384 */
  __pyx_k234;

  /* "/home/jiba/src/soya/soya3d/light.pyx":388 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 388; 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 = 388; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 388; 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":389 */
    __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_COORDSYS_STATIC);
      }
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":390 */
      glDisable((GL_LIGHT0 + __pyx_v_light->_id));

      /* "/home/jiba/src/soya/soya3d/light.pyx":391 */
      __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_k235[]) = "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\nmodel 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":394 */
  __pyx_k235;

  /* "/home/jiba/src/soya/soya3d/light.pyx":398 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 398; 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 = 398; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 398; 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":399 */
    __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_COORDSYS_STATIC);
      }
    }
    if (__pyx_3) {

      /* "/home/jiba/src/soya/soya3d/light.pyx":400 */
      glEnable((GL_LIGHT0 + __pyx_v_light->_id));

      /* "/home/jiba/src/soya/soya3d/light.pyx":401 */
      __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_k236[]) = "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":404 */
  __pyx_k236;

  /* "/home/jiba/src/soya/soya3d/light.pyx":406 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_LIGHTS); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 406; 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 = 406; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 406; 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":407 */
    __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":408 */
      __pyx_2 = PyInt_FromLong(GL_LIGHT0); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 408; goto __pyx_L1;}
      __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_i); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 408; goto __pyx_L1;}
      __pyx_6 = PyNumber_Add(__pyx_2, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 408; 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 = 408; goto __pyx_L1;}
      Py_DECREF(__pyx_6); __pyx_6 = 0;
      glDisable(__pyx_7);

      /* "/home/jiba/src/soya/soya3d/light.pyx":409 */
      __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":29 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base.__raypick_data = (-1);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":30 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._render_matrix[15]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":31 */
  ((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":32 */
  (((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":33 */
  (((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":36 */
  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_k62;
  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 = 38; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":39 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 39; 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 = 39; 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":40 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov = 60.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":41 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_front = 0.1;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":42 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_back = 100.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":43 */
  ((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":48 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":49 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":50 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":51 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_front);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":52 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_back);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":53 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_fov);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":54 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 54; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 54; 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":57 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":59 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 59; 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 = 59; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 59; 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 = 59; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":62 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":63 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":64 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":65 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_front));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":66 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_back));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":67 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_fov));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":68 */
  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":72 */
  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":74 */
  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":78 */
  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 = 79; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":80 */
  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":84 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_front); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 84; 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 = 85; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":86 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_front = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":87 */
  ((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":91 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_back); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 91; 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 = 92; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":93 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_back = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":94 */
  ((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":98 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __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._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 = 99; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":100 */
  ((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_fov = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":101 */
  ((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":105 */
  __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 = 105; 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 = 106; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":107 */
  (((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":111 */
  __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 = 111; 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 = 112; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":113 */
  (((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":117 */
  __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 = 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._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 = 118; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":119 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":120 */
  ((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":124 */
  __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 = 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._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 = 125; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":126 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_x;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":127 */
  ((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_12listen_sound___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_12listen_sound___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":131 */
  __pyx_1 = PyInt_FromLong((!(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_CAMERA_NO_LISTENER))); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __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._Camera.listen_sound.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Camera_12listen_sound___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Camera_12listen_sound___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 = 132; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":133 */
  __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_NO_LISTENER));
    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_NO_LISTENER);
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.listen_sound.__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":141 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[0]) = __pyx_v_left;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":142 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[1]) = __pyx_v_top;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":143 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_width;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":144 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_height;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":145 */
  ((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":149 */
  __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 = 149; 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 = 150; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":151 */
  __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":156 */
  __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 = 156; 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 = 157; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":158 */
  __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":160 */
  ((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":163 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[0]) = __pyx_v_left;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":164 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[1]) = __pyx_v_top;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":165 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[2]) = __pyx_v_width;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":166 */
  (((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->_viewport[3]) = __pyx_v_height;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":167 */
  ((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":173 */
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_width); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __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._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":178 */
  __pyx_1 = PyInt_FromLong(__pyx_v_5_soya_renderer->screen_height); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 178; 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":183 */
  __pyx_v_f = __pyx_v_self->_frustum;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":184 */
  (__pyx_v_f->position[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":185 */
  (__pyx_v_f->position[1]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":186 */
  (__pyx_v_f->position[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":187 */
  __pyx_v_ratio = (((float )(__pyx_v_self->_viewport[3])) / ((float )(__pyx_v_self->_viewport[2])));

  /* "/home/jiba/src/soya/soya3d/camera.pyx":189 */
  __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":190 */
  __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":191 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":192 */
    __pyx_v_l = (__pyx_v_self->_fov / 20.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":193 */
    __pyx_v_ratio = (__pyx_v_l * __pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":194 */
    (__pyx_v_f->points[0]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":194 */
    (__pyx_v_f->points[1]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":195 */
    (__pyx_v_f->points[3]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":195 */
    (__pyx_v_f->points[4]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":196 */
    (__pyx_v_f->points[6]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":196 */
    (__pyx_v_f->points[7]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":197 */
    (__pyx_v_f->points[9]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":197 */
    (__pyx_v_f->points[10]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":198 */
    (__pyx_v_f->points[12]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":198 */
    (__pyx_v_f->points[13]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":199 */
    (__pyx_v_f->points[15]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":199 */
    (__pyx_v_f->points[16]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":200 */
    (__pyx_v_f->points[18]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":200 */
    (__pyx_v_f->points[19]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":201 */
    (__pyx_v_f->points[21]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":201 */
    (__pyx_v_f->points[22]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":202 */
    (__pyx_v_f->planes[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":202 */
    (__pyx_v_f->planes[1]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":202 */
    (__pyx_v_f->planes[2]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":202 */
    (__pyx_v_f->planes[3]) = (-__pyx_v_self->_front);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":203 */
    (__pyx_v_f->planes[4]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":203 */
    (__pyx_v_f->planes[5]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":203 */
    (__pyx_v_f->planes[6]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":203 */
    (__pyx_v_f->planes[7]) = __pyx_v_ratio;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":204 */
    (__pyx_v_f->planes[8]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":204 */
    (__pyx_v_f->planes[9]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":204 */
    (__pyx_v_f->planes[10]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":204 */
    (__pyx_v_f->planes[11]) = (-__pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":205 */
    (__pyx_v_f->planes[12]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":205 */
    (__pyx_v_f->planes[13]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":205 */
    (__pyx_v_f->planes[14]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":205 */
    (__pyx_v_f->planes[15]) = __pyx_v_l;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[16]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[17]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[18]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":206 */
    (__pyx_v_f->planes[19]) = (-__pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":207 */
    (__pyx_v_f->planes[20]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":207 */
    (__pyx_v_f->planes[21]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":207 */
    (__pyx_v_f->planes[22]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":207 */
    (__pyx_v_f->planes[23]) = (-__pyx_v_self->_back);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":209 */
    __pyx_v_l = tan((to_radians(__pyx_v_self->_fov) / 2.0));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":210 */
    __pyx_v_y = (__pyx_v_self->_back * __pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":211 */
    __pyx_v_x = (__pyx_v_y / __pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":212 */
    (__pyx_v_f->points[12]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":212 */
    (__pyx_v_f->points[13]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":213 */
    (__pyx_v_f->points[15]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":213 */
    (__pyx_v_f->points[16]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":214 */
    (__pyx_v_f->points[18]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":214 */
    (__pyx_v_f->points[19]) = (-__pyx_v_y);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":215 */
    (__pyx_v_f->points[21]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":215 */
    (__pyx_v_f->points[22]) = (-__pyx_v_y);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":216 */
    (__pyx_v_f->planes[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":216 */
    (__pyx_v_f->planes[1]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":216 */
    (__pyx_v_f->planes[2]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":216 */
    (__pyx_v_f->planes[3]) = (-__pyx_v_self->_front);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":217 */
    __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":218 */
    (__pyx_v_f->planes[4]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":218 */
    (__pyx_v_f->planes[5]) = (__pyx_v_self->_back / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":218 */
    (__pyx_v_f->planes[6]) = (__pyx_v_y / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":218 */
    (__pyx_v_f->planes[7]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":219 */
    (__pyx_v_f->planes[8]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":219 */
    (__pyx_v_f->planes[9]) = (-(__pyx_v_f->planes[5]));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":219 */
    (__pyx_v_f->planes[10]) = (__pyx_v_f->planes[6]);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":219 */
    (__pyx_v_f->planes[11]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":220 */
    __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":221 */
    (__pyx_v_f->planes[12]) = (__pyx_v_self->_back / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":221 */
    (__pyx_v_f->planes[13]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":221 */
    (__pyx_v_f->planes[14]) = (__pyx_v_x / __pyx_v_ff);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":221 */
    (__pyx_v_f->planes[15]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":222 */
    (__pyx_v_f->planes[16]) = (-(__pyx_v_f->planes[12]));

    /* "/home/jiba/src/soya/soya3d/camera.pyx":222 */
    (__pyx_v_f->planes[17]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":222 */
    (__pyx_v_f->planes[18]) = (__pyx_v_f->planes[14]);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":222 */
    (__pyx_v_f->planes[19]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":223 */
    (__pyx_v_f->planes[20]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":223 */
    (__pyx_v_f->planes[21]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":223 */
    (__pyx_v_f->planes[22]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":223 */
    (__pyx_v_f->planes[23]) = (-__pyx_v_self->_back);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":224 */
    __pyx_v_y = (__pyx_v_self->_front * __pyx_v_l);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":225 */
    __pyx_v_x = (__pyx_v_y / __pyx_v_ratio);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":226 */
    (__pyx_v_f->points[0]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":226 */
    (__pyx_v_f->points[1]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":227 */
    (__pyx_v_f->points[3]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":227 */
    (__pyx_v_f->points[4]) = __pyx_v_y;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":228 */
    (__pyx_v_f->points[6]) = (-__pyx_v_x);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":228 */
    (__pyx_v_f->points[7]) = (-__pyx_v_y);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":229 */
    (__pyx_v_f->points[9]) = __pyx_v_x;

    /* "/home/jiba/src/soya/soya3d/camera.pyx":229 */
    (__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":236 */
  __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":237 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":239 */
  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":241 */
  __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":242 */
  __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":248 */
  __pyx_v_p = __pyx_v_self->__pyx_base._render_matrix;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":249 */
  (__pyx_v_p[0]) = (__pyx_v_m[0]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":250 */
  (__pyx_v_p[4]) = (__pyx_v_m[4]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":251 */
  (__pyx_v_p[8]) = (__pyx_v_m[8]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":252 */
  (__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":253 */
  (__pyx_v_p[1]) = (__pyx_v_m[1]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":254 */
  (__pyx_v_p[5]) = (__pyx_v_m[5]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":255 */
  (__pyx_v_p[9]) = (__pyx_v_m[9]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":256 */
  (__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":257 */
  (__pyx_v_p[2]) = (__pyx_v_m[2]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":258 */
  (__pyx_v_p[6]) = (__pyx_v_m[6]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":259 */
  (__pyx_v_p[10]) = (__pyx_v_m[10]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":260 */
  (__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":261 */
  (__pyx_v_p[16]) = (__pyx_v_m[16]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":262 */
  (__pyx_v_p[17]) = (__pyx_v_m[17]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":263 */
  (__pyx_v_p[18]) = (__pyx_v_m[18]);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":267 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":268 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":269 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_CAMERA_ORTHO);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":270 */
    __pyx_v_v1 = (__pyx_v_self->_fov / 20.0);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":271 */
    __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":272 */
    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":275 */
    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":276 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":279 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_to_render); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 279; 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":280 */
    __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 = 280; 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":281 */
    __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 = 282; 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 = 283; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 283; 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":285 */
  __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":287 */
  ((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":290 */
  glPushAttrib(GL_VIEWPORT);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":291 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":292 */
  glPushMatrix();

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

  /* "/home/jiba/src/soya/soya3d/camera.pyx":294 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":295 */
  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":296 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":297 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":298 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":299 */
  glEnable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":301 */
  ((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":303 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":304 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":305 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":306 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":307 */
  glPopAttrib();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":308 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":309 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":310 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":311 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":312 */
  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":315 */
  ((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 = 317; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":325 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_mat), __pyx_n_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 325; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_width); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 325; 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 = 325; 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 = 325; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_height); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 325; 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 = 325; 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":327 */
  glPushAttrib(GL_VIEWPORT_BIT);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":328 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":329 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":330 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":331 */
  glPushMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":332 */
  glViewport(0,0,__pyx_v_w,__pyx_v_h);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":333 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":334 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":335 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":336 */
  glEnable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":338 */
  ((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":340 */
  glBindTexture(GL_TEXTURE_2D,__pyx_v_mat->_id);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":342 */
  glCopyTexImage2D(GL_TEXTURE_2D,0,__pyx_v_what,0,0,__pyx_v_w,__pyx_v_h,0);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":344 */
  glBindTexture(GL_TEXTURE_2D,0);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":346 */
  glMatrixMode(GL_PROJECTION);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":347 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":348 */
  glMatrixMode(GL_MODELVIEW);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":349 */
  glPopMatrix();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":350 */
  glPopAttrib();

  /* "/home/jiba/src/soya/soya3d/camera.pyx":351 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":352 */
  glDisable(GL_DEPTH_TEST);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":353 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":354 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":355 */
  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_k63;
  __pyx_v_result = __pyx_k64;
  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 = 358; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":367 */
  __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 = 367; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 367; 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 = 367; 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 = 367; 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":368 */
  __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":369 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_set_xyz); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 369; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_x); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; 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 = 370; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_3 = PyNumber_Subtract(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_3 = PyNumber_Multiply(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 370; goto __pyx_L1;}
    __pyx_3 = PyNumber_Multiply(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 370; 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 = 371; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_y); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 371; 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 = 371; 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 = 371; goto __pyx_L1;}
    __pyx_4 = PyNumber_Divide(__pyx_5, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 371; goto __pyx_L1;}
    __pyx_6 = PyNumber_Add(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 371; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 371; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_5, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 371; goto __pyx_L1;}
    __pyx_6 = PyNumber_Divide(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 371; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 371; 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 = 372; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 369; 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 = 369; 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":375 */
    __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":376 */
    __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_set_xyz); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 376; goto __pyx_L1;}
    __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(__pyx_v_x); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; 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 = 377; 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 = 377; goto __pyx_L1;}
    __pyx_4 = PyNumber_Divide(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
    __pyx_2 = PyNumber_Add(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
    __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 377; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 377; 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 = 378; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(__pyx_v_y); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; 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 = 378; 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 = 378; goto __pyx_L1;}
    __pyx_6 = PyNumber_Divide(__pyx_2, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; 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 = 378; goto __pyx_L1;}
    __pyx_3 = PyNumber_Subtract(__pyx_6, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; 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 = 378; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_3, __pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; 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 = 378; goto __pyx_L1;}
    __pyx_6 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; 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 = 378; goto __pyx_L1;}
    __pyx_3 = PyNumber_Multiply(__pyx_6, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 378; 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 = 379; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 376; 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 = 376; 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":381 */
  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 = 383; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":389 */
  ((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":390 */
  __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":391 */
    __pyx_2 = PyFloat_FromDouble((-(__pyx_v_f[0]))); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; 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 = 392; goto __pyx_L1;}
    __pyx_5 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; 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 = 392; goto __pyx_L1;}
    __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; goto __pyx_L1;}
    __pyx_2 = PyNumber_Divide(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; goto __pyx_L1;}
    __pyx_4 = PyNumber_Add(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 392; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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 = 393; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; 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":396 */
    __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":397 */
    __pyx_3 = PyFloat_FromDouble((-(__pyx_v_f[0]))); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; goto __pyx_L1;}
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; 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 = 398; goto __pyx_L1;}
    __pyx_4 = PyNumber_Divide(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; goto __pyx_L1;}
    __pyx_2 = PyNumber_Multiply(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; goto __pyx_L1;}
    __pyx_4 = PyNumber_Multiply(__pyx_5, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; 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 = 398; goto __pyx_L1;}
    __pyx_3 = PyNumber_Add(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 398; goto __pyx_L1;}
    __pyx_5 = PyNumber_Multiply(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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 = 399; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; 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_f_5_soya_7_Camera_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_7_Camera_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  PyObject *__pyx_r;
  int __pyx_1;
  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/camera.pyx":407 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_CAMERA_NO_LISTENER));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":408 */
    __pyx_f_5_soya__update_sound_listener_position(((struct __pyx_obj_5_soya_CoordSyst *)((struct __pyx_obj_5_soya__Camera *)__pyx_v_self)),__pyx_v_proportion);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Camera.advance_time");
  __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 = 410; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/camera.pyx":414 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_World); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; 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 = 414; 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 = 414; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/camera.pyx":416 */
    __pyx_vtabptr_5_soya__Body->__pyx_base._get_sphere(__pyx_v_coordsyst,__pyx_v_sphere);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":417 */
    __pyx_v_coordsyst->_frustum_id = (-1);

    /* "/home/jiba/src/soya/soya3d/camera.pyx":418 */
    __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 = 418; 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":420 */
    __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 = 420; 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 = 420; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 420; 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":421 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_is_in_frustum); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 421; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 421; 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 = 421; 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 = 421; 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 = 421; 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":422 */
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __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/soya3d/camera.pyx":424 */
  ((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":425 */
  __pyx_v_coordsyst->_frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/camera.pyx":440 */
  __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 = 440; 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":31 */
  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_k237p;

static char (__pyx_k237[]) = "";

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 = 32; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":33 */
  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":34 */
  __pyx_1 = __pyx_v_beyond == Py_None;
  if (__pyx_1) {
    Py_INCREF(__pyx_k237p);
    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_k237p;
    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":39 */
  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":41 */
  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":45 */
  __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 = 45; 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":46 */
  __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 = 46; 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":47 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 47; 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 = 48; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":49 */
  __pyx_1 = (__pyx_v_x == 4);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":50 */
    ((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":51 */
    ((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":52 */
    ((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":54 */
    ((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":55 */
    ((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":56 */
    ((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":58 */
    ((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":59 */
    ((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":60 */
    free(((struct __pyx_obj_5_soya__Portal *)__pyx_v_self)->_equation);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":61 */
    ((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":72 */
  __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 = 72; 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 = 73; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":74 */
  __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_k65;
  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 = 77; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":78 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 78; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __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[12]; __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/soya3d/portal.pyx":79 */
  ((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":80 */
  ((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":86 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_beyond_name); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 86; goto __pyx_L1;}
  __pyx_2 = PyObject_IsTrue(__pyx_1); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 86; 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 = 86; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 86; 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 = 86; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 86; 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 = 86; 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":87 */
  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":93 */

  __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":100 */
  __pyx_1 = (-0.5);
  (__pyx_v_p1[0]) = __pyx_1;
  (__pyx_v_p1[1]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":101 */
  (__pyx_v_p1[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":102 */
  (__pyx_v_p2[0]) = 0.5;
  (__pyx_v_p2[1]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":103 */
  (__pyx_v_p2[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":104 */
  (__pyx_v_v1[0]) = 0.0;
  (__pyx_v_v1[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":105 */
  (__pyx_v_v1[1]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":106 */
  (__pyx_v_v2[1]) = 0.0;
  (__pyx_v_v2[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":107 */
  (__pyx_v_v2[0]) = 1.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":109 */
  __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":110 */
  point_by_matrix(__pyx_v_p1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":111 */
  point_by_matrix(__pyx_v_p2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":112 */
  vector_by_matrix(__pyx_v_v1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":113 */
  vector_by_matrix(__pyx_v_v2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":115 */
  __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":116 */
  point_by_matrix(__pyx_v_p1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":117 */
  point_by_matrix(__pyx_v_p2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":118 */
  vector_by_matrix(__pyx_v_v1,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":119 */
  vector_by_matrix(__pyx_v_v2,__pyx_v_m);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":122 */
  (__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":123 */
  (__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":124 */
  (__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":125 */
  (__pyx_v_self->_equation[3]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":126 */
  (__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":127 */
  (__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":128 */
  (__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":129 */
  (__pyx_v_self->_equation[7]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":130 */
  (__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":131 */
  (__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":132 */
  (__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":133 */
  (__pyx_v_self->_equation[11]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":134 */
  (__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":135 */
  (__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":136 */
  (__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":137 */
  (__pyx_v_self->_equation[15]) = ((double )0.0);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":138 */
  __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":139 */
    (__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":140 */
    (__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":141 */
    (__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":142 */
    (__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":153 */
  __pyx_1 = (-0.5);
  (__pyx_v_p[0]) = __pyx_1;
  (__pyx_v_p[1]) = __pyx_1;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":154 */
  (__pyx_v_p[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":155 */
  (__pyx_v_p[3]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":156 */
  (__pyx_v_p[4]) = (-0.5);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":157 */
  (__pyx_v_p[5]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":158 */
  (__pyx_v_p[6]) = 0.5;
  (__pyx_v_p[7]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":159 */
  (__pyx_v_p[8]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":160 */
  (__pyx_v_p[9]) = (-0.5);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":161 */
  (__pyx_v_p[10]) = 0.5;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":162 */
  (__pyx_v_p[11]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":165 */
  point_by_matrix(__pyx_v_p,__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":166 */
  point_by_matrix((__pyx_v_p + 3),__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":167 */
  point_by_matrix((__pyx_v_p + 6),__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":168 */
  point_by_matrix((__pyx_v_p + 9),__pyx_v_self->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":171 */
  free(__pyx_v_self->_coords);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":172 */
  __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":174 */
    __pyx_v_frustum = __pyx_v_5_soya_renderer->current_camera->_frustum;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":175 */
    __pyx_v_p2 = ((float (*))malloc((4 * (sizeof(float )))));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":176 */
    (__pyx_v_p2[0]) = (-(__pyx_v_frustum->planes[0]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":177 */
    (__pyx_v_p2[1]) = (-(__pyx_v_frustum->planes[1]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":178 */
    (__pyx_v_p2[2]) = (-(__pyx_v_frustum->planes[2]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":179 */
    (__pyx_v_p2[3]) = (__pyx_v_frustum->planes[3]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":180 */
    face_intersect_plane(__pyx_v_p,4,__pyx_v_p2,(&__pyx_v_p1),(&__pyx_v_nb));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":181 */
    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 + 4),(&__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 + 8),(&__pyx_v_p1),(&__pyx_v_nb));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":184 */
    free(__pyx_v_p2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":185 */
    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":185 */
    free(__pyx_v_p1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":186 */
    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":187 */
    free(__pyx_v_p2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":192 */
    __pyx_v_p1 = __pyx_v_self->_coords;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":193 */
    __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":194 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":195 */
    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":196 */
      __pyx_v_v = (__pyx_v_f / (__pyx_v_p1[(__pyx_v_i + 2)]));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":197 */
      (__pyx_v_p1[__pyx_v_i]) = (__pyx_v_v * (__pyx_v_p1[__pyx_v_i]));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":198 */
      (__pyx_v_p1[(__pyx_v_i + 1)]) = (__pyx_v_v * (__pyx_v_p1[(__pyx_v_i + 1)]));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":199 */
      (__pyx_v_p1[(__pyx_v_i + 2)]) = __pyx_v_f;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":200 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":202 */
    __pyx_v_self->_coords = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":203 */
    __pyx_v_self->_nb_vertices = 0;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":205 */
  __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":206 */
  __pyx_v_nb = (__pyx_v_self->_nb_vertices * 3);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":207 */
  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":217 */
  __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":218 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":221 */
  __pyx_v_ptr = __pyx_v_5_soya_renderer->root_frustum->position;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":222 */
  __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":223 */
  __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":224 */
  __pyx_1 = (__pyx_v_p < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":225 */
    __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 = 225; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 225; goto __pyx_L1;}
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 225; 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":226 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":230 */
  __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":231 */
    __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":232 */
    (__pyx_v_sphere[0]) = (__pyx_v_self->__pyx_base._matrix[12]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":233 */
    (__pyx_v_sphere[1]) = (__pyx_v_self->__pyx_base._matrix[13]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":234 */
    (__pyx_v_sphere[2]) = (__pyx_v_self->__pyx_base._matrix[14]);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":235 */
    __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":237 */
    __pyx_1 = (sphere_in_frustum(__pyx_v_f,__pyx_v_sphere) == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/portal.pyx":238 */
      __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 = 238; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 238; goto __pyx_L1;}
        __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 238; 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":239 */
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":241 */
    __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":242 */
    __pyx_v_i = 2;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":243 */
    while (1) {
      __pyx_L9:;
      __pyx_2 = (__pyx_v_i < 24);
      if (!__pyx_2) break;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":244 */
      __pyx_1 = ((__pyx_v_f->points[__pyx_v_i]) <= 0.0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/soya3d/portal.pyx":245 */
        __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 = 245; goto __pyx_L1;}
          __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 245; goto __pyx_L1;}
          __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 245; 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":246 */
        goto __pyx_L0;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/soya3d/portal.pyx":247 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L10:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":250 */
  __pyx_2 = ((PyObject *)__pyx_v_self->_beyond) == Py_None;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":251 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_load_beyond); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 251; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 251; goto __pyx_L1;}
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 251; 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 = 251; 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":252 */
    __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":255 */
  __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":256 */
  __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":259 */
    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":260 */
    ((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":262 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_5_soya_renderer->portals, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 262; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 262; 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 = 262; 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":264 */
  __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":265 */
  __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 = 265; 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":266 */
    __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 = 266; 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":270 */
  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":271 */
  __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 = 271; 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":272 */
  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":273 */
  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":274 */
  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":275 */
  __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":276 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_5_soya_renderer->worlds_made, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 276; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 276; 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 = 276; 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":277 */
  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":278 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 278; 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":279 */
  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":282 */
  __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":283 */
    __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":284 */
  __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":290 */
  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":293 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":294 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":295 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":296 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":297 */
  glDepthMask(GL_FALSE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":298 */
  glColor4fv(__pyx_v_atmosphere->_bg_color);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":299 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":300 */
  __pyx_v_ptr = (__pyx_v_self->_coords + (__pyx_v_self->_nb_vertices * 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":301 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":302 */
  glVertex3fv(__pyx_v_ptr);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":303 */
  glVertex3fv((__pyx_v_ptr + 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":304 */
  glVertex3fv((__pyx_v_ptr + 6));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":305 */
  glVertex3fv((__pyx_v_ptr + 9));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":306 */
  glEnd();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":309 */
  __pyx_1 = (__pyx_v_self->_nb_vertices > 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":310 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":311 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":312 */
    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":313 */
      glVertex3fv((__pyx_v_self->_coords + __pyx_v_i));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":314 */
      __pyx_v_i = (__pyx_v_i + 3);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/soya3d/portal.pyx":315 */
    glEnd();
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":318 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 318; 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 = 318; 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 = 318; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":320 */
    __pyx_1 = (__pyx_v_self->_equation == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/soya3d/portal.pyx":321 */
      __pyx_v_self->_equation = ((double (*))malloc((16 * (sizeof(double )))));

      /* "/home/jiba/src/soya/soya3d/portal.pyx":322 */
      ((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":323 */
    glClipPlane(GL_CLIP_PLANE0,__pyx_v_self->_equation);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":324 */
    glClipPlane(GL_CLIP_PLANE1,(__pyx_v_self->_equation + 4));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":325 */
    glClipPlane(GL_CLIP_PLANE2,(__pyx_v_self->_equation + 8));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":326 */
    glClipPlane(GL_CLIP_PLANE3,(__pyx_v_self->_equation + 12));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":327 */
    glEnable(GL_CLIP_PLANE0);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":328 */
    glEnable(GL_CLIP_PLANE1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":329 */
    glEnable(GL_CLIP_PLANE2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":330 */
    glEnable(GL_CLIP_PLANE3);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":331 */
    ((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":332 */
    glDisable(GL_CLIP_PLANE0);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":333 */
    glDisable(GL_CLIP_PLANE1);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":334 */
    glDisable(GL_CLIP_PLANE2);

    /* "/home/jiba/src/soya/soya3d/portal.pyx":335 */
    glDisable(GL_CLIP_PLANE3);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":337 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":338 */
  glDepthMask(GL_TRUE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":339 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":340 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":341 */
  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":348 */
  glDisable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":349 */
  glDisable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":350 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":352 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":354 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":355 */
  __pyx_v_ptr = (__pyx_v_self->_coords + (__pyx_v_self->_nb_vertices * 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":356 */
  glBegin(GL_QUADS);

  /* "/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));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":357 */
  glVertex3fv(__pyx_v_ptr);

  /* "/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 + 3)));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":358 */
  glVertex3fv((__pyx_v_ptr + 3));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":359 */
  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":359 */
  glVertex3fv((__pyx_v_ptr + 6));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":360 */
  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":360 */
  glVertex3fv((__pyx_v_ptr + 9));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":361 */
  glEnd();

  /* "/home/jiba/src/soya/soya3d/portal.pyx":369 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":371 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":372 */
  glEnable(GL_FOG);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":373 */
  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":376 */
  ((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":379 */
  __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":382 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->__pyx_base._option); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 382; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OBJECT_NON_SOLID); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 382; goto __pyx_L1;}
  __pyx_3 = PyNumber_And(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 382; 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 = 382; 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":389 */
  __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":390 */
  point_by_matrix_copy(__pyx_v_s,__pyx_v_rsphere,__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":391 */
  (__pyx_v_s[3]) = length_by_matrix((__pyx_v_rsphere[3]),__pyx_v_matrix);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":393 */
  __pyx_4 = (vector_length(__pyx_v_s) < ((__pyx_v_s[3]) + 0.5));
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":394 */
    ((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 = 397; 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 = 397; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/portal.pyx":402 */
  __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 = 402; 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":406 */
  ((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":407 */
  ((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":408 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 408; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 408; 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 = 408; 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 = 408; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/portal.pyx":409 */
    (__pyx_v_new[0]) = ((__pyx_v_old[0]) + (__pyx_v_new[0]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":410 */
    (__pyx_v_new[1]) = ((__pyx_v_old[1]) + (__pyx_v_new[1]));

    /* "/home/jiba/src/soya/soya3d/portal.pyx":411 */
    (__pyx_v_new[2]) = ((__pyx_v_old[2]) + (__pyx_v_new[2]));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":413 */
  __pyx_v_f = ((__pyx_v_old[2]) * (__pyx_v_new[2]));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":414 */
  __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 = 414; 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":415 */
  __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 = 415; 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":416 */
  __pyx_v_f1 = ((__pyx_v_old[2]) / ((__pyx_v_old[2]) + (__pyx_v_new[2])));

  /* "/home/jiba/src/soya/soya3d/portal.pyx":417 */
  __pyx_v_f2 = (1.0 - __pyx_v_f1);

  /* "/home/jiba/src/soya/soya3d/portal.pyx":418 */
  __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 = 418; 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":425 */
  __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 = 425; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 425; 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":428 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 428; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 428; 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":429 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 429; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 429; 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 = 33; 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 = 34; 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_k66;
  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":37 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Camera), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 37; 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 = 37; 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":39 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 39; 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":40 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Traveling)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; 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":41 */
  ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value = 0.3;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":42 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; 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 = 42; 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 = 44; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":45 */
  __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 = 45; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 45; 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 = 45; 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":46 */
  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":47 */
  ((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":50 */
  __pyx_1 = PyInt_FromLong((-1)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 50; 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 = 50; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":51 */
  __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 51; 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 = 51; 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 = 51; 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":52 */
  ((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 = 54; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":55 */
  __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 = 55; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 55; 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 = 55; 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":56 */
  __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":57 */
    __pyx_1 = PyInt_FromLong((-1)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 57; 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 = 57; 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 = 57; 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":58 */
    ((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":64 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_traveling->_incline_as) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":65 */
    (__pyx_v_v[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":66 */
    (__pyx_v_v[1]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":67 */
    (__pyx_v_v[2]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":68 */
    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":70 */
    __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":71 */
      (__pyx_v_up[0]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":72 */
      (__pyx_v_up[1]) = 1.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":73 */
      (__pyx_v_up[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":74 */
      (__pyx_v_v[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":76 */
      __pyx_v_angle = vector_angle(__pyx_v_up,__pyx_v_v);

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":77 */
      __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 = 77; goto __pyx_L1;}
        __pyx_3 = PyFloat_FromDouble((-__pyx_v_angle)); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; 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 = 77; 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 = 78; goto __pyx_L1;}
        __pyx_4 = PyFloat_FromDouble(__pyx_v_angle); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 78; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 78; 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 = 78; 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;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  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":86 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Camera), __pyx_n_advance_time); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 86; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 86; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 86; goto __pyx_L1;}
  Py_INCREF((PyObject *)__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
  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[13]; __pyx_lineno = 86; 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":88 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":89 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_MAIN_LOOP); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_will_render); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 89; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 89; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 89; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":90 */
    ((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":91 */
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":93 */
  __pyx_v_proportion = (__pyx_v_proportion + ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_proportion);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":99 */
  __pyx_4 = ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_smooth_move;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":100 */
    while (1) {
      __pyx_L4:;
      __pyx_4 = (__pyx_v_proportion > 1.0);
      if (!__pyx_4) break;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":101 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed), __pyx_n_set_start_end); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; 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 = 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_5 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
      Py_INCREF((PyObject *)__pyx_v_self);
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
      PyTuple_SET_ITEM(__pyx_2, 1, __pyx_5);
      __pyx_5 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":102 */
      __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_mul_vector); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
      __pyx_3 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_2, 0, __pyx_3);
      Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
      PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed));
      __pyx_3 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 102; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":103 */
      __pyx_v_proportion = (__pyx_v_proportion - 1.0);
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":105 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed), __pyx_n_set_start_end); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; 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 = 105; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_5 = PyTuple_New(2); 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);
    PyTuple_SET_ITEM(__pyx_5, 1, __pyx_1);
    __pyx_1 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":106 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_add_mul_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 106; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((__pyx_v_proportion * ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value)); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 106; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 106; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3);
    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_3 = 0;
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 106; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":109 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_move); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; 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 = 109; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_self);
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; 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[13]; __pyx_lineno = 109; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
    __pyx_2 = 0;
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":111 */
  __pyx_4 = ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_smooth_rotation;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":112 */
    __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 = 112; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_self);
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":113 */
    __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 113; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 113; goto __pyx_L1;}
    Py_INCREF(__pyx_v_r);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_r);
    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_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 113; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 113; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {
      if (!__Pyx_TypeTest(__pyx_v_r, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 113; 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_1 = PyNumber_Rshift(__pyx_v_self, __pyx_v_r); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 114; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 114; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_direction));
      __pyx_v_direction = __pyx_1;
      __pyx_1 = 0;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":115 */
    __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_convert_to); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 115; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 115; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
    __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 115; 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/soya3d/traveling_camera.pyx":116 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_normalize); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 116; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 116; goto __pyx_L1;}
    __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 116; 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":117 */
    __pyx_4 = ((__pyx_v_direction->__pyx_base._matrix[0]) < (-0.02));
    if (__pyx_4) {
      (__pyx_v_direction->__pyx_base._matrix[0]) = (-0.02);
      goto __pyx_L8;
    }
    __pyx_4 = ((__pyx_v_direction->__pyx_base._matrix[0]) > 0.02);
    if (__pyx_4) {
      (__pyx_v_direction->__pyx_base._matrix[0]) = 0.02;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":119 */
    __pyx_4 = ((__pyx_v_direction->__pyx_base._matrix[1]) < (-0.02));
    if (__pyx_4) {
      (__pyx_v_direction->__pyx_base._matrix[1]) = (-0.02);
      goto __pyx_L9;
    }
    __pyx_4 = ((__pyx_v_direction->__pyx_base._matrix[1]) > 0.02);
    if (__pyx_4) {
      (__pyx_v_direction->__pyx_base._matrix[1]) = 0.02;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":121 */
    (__pyx_v_direction->__pyx_base._matrix[2]) = (-1.0);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":122 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_look_at); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 122; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 122; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_direction));
    PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_direction));
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 122; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":125 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_look_at); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 125; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling), __pyx_n_best_direction); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 125; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 125; goto __pyx_L1;}
    Py_INCREF((PyObject *)__pyx_v_self);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
    __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 125; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 125; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
    __pyx_5 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 125; 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_L6:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":139 */
  __pyx_4 = ((PyObject *)((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_traveling->_incline_as) == Py_None;
  __pyx_6 = (!__pyx_4);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":140 */
    (__pyx_v_v[0]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":141 */
    (__pyx_v_v[1]) = 1.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":142 */
    (__pyx_v_v[2]) = 0.0;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":143 */
    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":144 */
    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":146 */
    __pyx_4 = ((__pyx_v_v[0]) != 0.0);
    if (!__pyx_4) {
      __pyx_4 = ((__pyx_v_v[1]) != 0.0);
    }
    if (__pyx_4) {

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":147 */
      (__pyx_v_up[0]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":148 */
      (__pyx_v_up[1]) = 1.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":149 */
      (__pyx_v_up[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":150 */
      (__pyx_v_v[2]) = 0.0;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":152 */
      __pyx_v_angle = vector_angle(__pyx_v_up,__pyx_v_v);

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":153 */
      __pyx_5 = __Pyx_GetName(__pyx_b, __pyx_n_min); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      __pyx_2 = PyFloat_FromDouble((2.0 * ((struct __pyx_obj_5_soya__TravelingCamera *)__pyx_v_self)->_speed_value)); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      __pyx_3 = PyFloat_FromDouble(__pyx_v_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3);
      __pyx_2 = 0;
      __pyx_3 = 0;
      __pyx_2 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      __pyx_3 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      __pyx_5 = PyNumber_Multiply(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_7 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 153; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __pyx_v_angle = __pyx_7;

      /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":154 */
      __pyx_6 = ((__pyx_v_v[0]) > 0);
      if (__pyx_6) {
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_turn_incline); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 154; goto __pyx_L1;}
        __pyx_2 = PyFloat_FromDouble((-__pyx_v_angle)); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 154; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 154; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
        __pyx_2 = 0;
        __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 154; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;
        goto __pyx_L12;
      }
      /*else*/ {
        __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_turn_incline); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 155; goto __pyx_L1;}
        __pyx_1 = PyFloat_FromDouble(__pyx_v_angle); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 155; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 155; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
        __pyx_1 = 0;
        __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 155; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 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":157 */
  ((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_3);
  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":161 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_move); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 161; 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 = 161; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 161; 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 = 161; 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 = 161; 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 = 161; 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":162 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_look_at); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 162; 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 = 162; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 162; 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 = 162; 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 = 162; 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 = 162; 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":171 */
  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 = 172; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":173 */
  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":177 */
  __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 = 177; 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 = 178; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":179 */
  ((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":183 */
  __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 = 183; 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 = 184; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":185 */
  ((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 = 187; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":188 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NotImplementedError); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 188; goto __pyx_L1;}
  __Pyx_Raise(__pyx_1, 0, 0);
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  {__pyx_filename = __pyx_f[13]; __pyx_lineno = 188; 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 = 190; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":191 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NotImplementedError); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 191; goto __pyx_L1;}
  __Pyx_Raise(__pyx_1, 0, 0);
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  {__pyx_filename = __pyx_f[13]; __pyx_lineno = 191; 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":201 */
  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 = 202; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":203 */
  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":207 */
  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 = 208; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":209 */
  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_k67;
  __pyx_v_smooth_rotation = __pyx_k68;
  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 = 211; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya_Position, 1, "direction")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 211; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":217 */
  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":218 */
  __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 = 218; 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 = 218; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 218; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(0.0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 218; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((-1.0)); if (!__pyx_6) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 218; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 218; 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 = 218; 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 = 218; 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":219 */
  ((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":220 */
  ((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 = 222; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":223 */
  __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 = 223; 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 = 225; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":226 */
  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":241 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 241; 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 = 242; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":243 */
  ((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":247 */
  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 = 248; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":249 */
  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":253 */
  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 = 254; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":255 */
  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":259 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 259; 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 = 260; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":261 */
  ((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":265 */
  __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 = 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._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 = 266; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":267 */
  ((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":271 */
  __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 = 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._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 = 272; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":273 */
  ((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":277 */
  __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 = 277; 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 = 278; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":279 */
  ((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":283 */
  __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 = 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._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":285 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 285; 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_k69;
  __pyx_v_direction = __pyx_k70;
  __pyx_v_smooth_move = __pyx_k71;
  __pyx_v_smooth_rotation = __pyx_k72;
  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 = 287; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_direction), __pyx_ptype_5_soya__Vector, 1, "direction")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":288 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_target), __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 288; 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":289 */
  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":290 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 290; 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 = 290; 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":291 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 291; 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 = 291; 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":292 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 292; 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 = 292; 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":293 */
  __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 = 293; 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 = 293; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 293; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 293; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble(2.0); if (!__pyx_6) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 293; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 293; 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 = 293; 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 = 293; 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":294 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 294; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 294; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 294; 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 = 294; 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":295 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(0); if (!__pyx_7) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 295; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_7); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 295; 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 = 295; 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":296 */
  ((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":297 */
  ((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":298 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_distance = 5.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":299 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y = 1.5;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":300 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y2 = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":301 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":302 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_top_view = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":303 */
  ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_speed = 1.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":304 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_RaypickContext)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 304; 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 = 306; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":314 */
  __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 = 314; 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":315 */
  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":316 */
  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":317 */
  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":318 */
  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":320 */
  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 = 320; 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":321 */
  (__pyx_v_target->_matrix[0]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":322 */
  (__pyx_v_target->_matrix[1]) = ((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_offset_y;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":323 */
  (__pyx_v_target->_matrix[2]) = 0.0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":324 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_target), __pyx_n_convert_to); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 324; 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 = 324; 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":326 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); 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_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 = 326; 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":327 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_add_mul_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 327; 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 = 327; 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":328 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_root), __pyx_n_RaypickContext); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 328; 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 = 328; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 328; 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 = 328; 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 = 328; 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":330 */
  __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 = 330; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 330; 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 = 330; 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 = 330; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 330; 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 = 330; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 330; 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 = 330; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 330; 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 = 330; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":332 */
  __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":333 */
    __pyx_v_c = cos(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":334 */
    __pyx_v_s = sin(((struct __pyx_obj_5_soya__ThirdPersonTraveling *)__pyx_v_self)->_lateral_angle);

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":335 */
    __pyx_v_a = __pyx_v_px;

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":336 */
    __pyx_v_px = ((__pyx_v_c * __pyx_v_px) + (__pyx_v_s * __pyx_v_pz));

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":337 */
    __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":339 */
  __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":341 */
  __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 = 342; goto __pyx_L1;}
    __pyx_1 = PyFloat_FromDouble(__pyx_v_px); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 342; goto __pyx_L1;}
    __pyx_8 = PyTuple_New(2); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 342; 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 = 342; 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 = 342; 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 = 342; 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":343 */
  __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 = 344; goto __pyx_L1;}
    __pyx_8 = PyFloat_FromDouble(__pyx_v_py); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_1 = PyFloat_FromDouble(3.0); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 344; 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 = 344; 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 = 344; 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 = 344; 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":346 */
  __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":347 */
  __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 = 348; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 348; 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 = 348; 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":350 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_convert_to); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 350; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 350; 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 = 350; 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":352 */
  __pyx_v_old_dirx = (__pyx_v_direction->__pyx_base._matrix[0]);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":353 */
  __pyx_v_old_diry = (__pyx_v_direction->__pyx_base._matrix[1]);

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":356 */
  (__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":357 */
  __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":358 */
  __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":360 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":360 */
    __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 360; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 360; 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 = 360; 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":360 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":362 */
  (__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":363 */
  __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":364 */
  __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":366 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":366 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 366; goto __pyx_L1;}
    __pyx_8 = PyTuple_New(1); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 366; 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 = 366; 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":366 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":369 */
  (__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":370 */
  __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":371 */
  __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":373 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":373 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 373; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 373; 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 = 373; 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":373 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":375 */
  (__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":376 */
  __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":377 */
  __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":379 */
  __pyx_7 = (__pyx_v_dist > __pyx_v_best_dist);
  if (__pyx_7) {

    /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":379 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_best), __pyx_n_clone); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 379; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 379; 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 = 379; 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":379 */
    __pyx_v_best_dist = __pyx_v_dist;
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":381 */
  __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_set_start_end); if (!__pyx_8) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 381; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 381; 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 = 381; 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":383 */
  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 = 385; goto __pyx_L1;}

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":387 */
  __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 = 387; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 387; 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 = 387; 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":388 */
  (((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":389 */
  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":394 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_root), __pyx_n_raypick); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 394; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->_distance); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 394; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 394; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 394; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(7); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 394; 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 = 394; 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 = 394; 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":395 */
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_direction), __pyx_n_set_length); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 395; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(__pyx_v_self->_distance); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 395; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 395; 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 = 395; 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":396 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_clone); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 396; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 396; 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 = 396; 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":397 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_add_vector); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 397; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 397; 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 = 397; 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":398 */
    __pyx_r = __pyx_v_self->_distance;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":400 */
  __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_result), __pyx_n_distance_to); if (!__pyx_4) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 400; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 400; 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 = 400; 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 = 400; 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_k239p;

static char (__pyx_k239[]) = "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":27 */
  __pyx_1 = __Pyx_Import(__pyx_k239p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 27; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":28 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_image_from_pil); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 28; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 28; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_open); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 28; 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 = 28; 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 = 28; 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 = 28; 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 = 28; 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 = 28; 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":29 */
  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":30 */
  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_RGBA;
static PyObject *__pyx_n_RGB;
static PyObject *__pyx_n_L;
static PyObject *__pyx_n_P;
static PyObject *__pyx_n_palette;
static PyObject *__pyx_n_tostring;
static PyObject *__pyx_n_pixels;

static PyObject *__pyx_k244p;

static char (__pyx_k244[]) = "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":37 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 37; 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 = 37; 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":38 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_size); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_2 = __Pyx_UnpackItem(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_4 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 38; 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 = 38; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 38; 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 = 38; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":39 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 39; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_n_RGBA, &__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {
    __pyx_v_image->nb_color = 4;
    goto __pyx_L2;
  }
  __pyx_3 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 40; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_3, __pyx_n_RGB, &__pyx_5) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_5 = __pyx_5 == 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_5) {
    __pyx_v_image->nb_color = 3;
    goto __pyx_L2;
  }
  __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;}
  if (PyObject_Cmp(__pyx_1, __pyx_n_L, &__pyx_4) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 41; 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 = 42; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_n_P, &__pyx_5) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_5 = __pyx_5 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/image.pyx":43 */
    __pyx_v_image->nb_color = 1;

    /* "/home/jiba/src/soya/model/image.pyx":44 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_palette); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 44; goto __pyx_L1;}
    __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_palette); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 44; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (PyObject_SetAttr(((PyObject *)__pyx_v_image), __pyx_n_palette, __pyx_1) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 44; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 45; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_mode); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 45; goto __pyx_L1;}
    __pyx_1 = PyNumber_Remainder(__pyx_k244p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 45; 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 = 45; 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[14]; __pyx_lineno = 45; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __Pyx_Raise(__pyx_1, 0, 0);
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    {__pyx_filename = __pyx_f[14]; __pyx_lineno = 45; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/image.pyx":46 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_pil_image, __pyx_n_tostring); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (PyObject_SetAttr(((PyObject *)__pyx_v_image), __pyx_n_pixels, __pyx_1) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":47 */
  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_k245p;

static char (__pyx_k245[]) = "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 MainLoop).";
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_k73;
  __pyx_v_x = __pyx_k74;
  __pyx_v_y = __pyx_k75;
  __pyx_v_width = __pyx_k76;
  __pyx_v_height = __pyx_k77;
  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":56 */
  __pyx_1 = __Pyx_Import(__pyx_k245p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 56; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":59 */
  __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":60 */
  __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":61 */
  __pyx_v_size = ((3 * __pyx_v_width) * __pyx_v_height);

  /* "/home/jiba/src/soya/model/image.pyx":62 */
  __pyx_v_pixels = ((GLubyte (*))malloc((__pyx_v_size * (sizeof(GLubyte )))));

  /* "/home/jiba/src/soya/model/image.pyx":63 */
  glReadBuffer(GL_FRONT);

  /* "/home/jiba/src/soya/model/image.pyx":64 */
  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":65 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 65; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 65; 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 = 65; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_height); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 65; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 65; 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 = 65; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 65; 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 = 65; 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":66 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_image, __pyx_n_transpose); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_FLIP_TOP_BOTTOM); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 66; 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 = 66; 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 = 66; 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":67 */
  free(__pyx_v_pixels);

  /* "/home/jiba/src/soya/model/image.pyx":68 */
  __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 = 68; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 68; 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 = 68; 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":69 */
  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_k78;
  __pyx_v_width = __pyx_k79;
  __pyx_v_height = __pyx_k80;
  __pyx_v_nb_color = __pyx_k81;
  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":89 */
  __pyx_1 = (__pyx_v_nb_color == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/image.pyx":90 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_pixels = 0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/image.pyx":92 */
    __pyx_1 = __pyx_v_pixels == Py_None;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/image.pyx":93 */
      ((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":95 */
      ((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":96 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->width = __pyx_v_width;

    /* "/home/jiba/src/soya/model/image.pyx":97 */
    ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height = __pyx_v_height;

    /* "/home/jiba/src/soya/model/image.pyx":98 */
    ((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":101 */
  __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":106 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/image.pyx":107 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->nb_color);

  /* "/home/jiba/src/soya/model/image.pyx":108 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->width);

  /* "/home/jiba/src/soya/model/image.pyx":109 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->height);

  /* "/home/jiba/src/soya/model/image.pyx":110 */
  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":111 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 111; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 111; 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":116 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 116; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 116; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 116; 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 = 116; 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 = 116; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/image.pyx":117 */
    __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 117; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 117; 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":118 */
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 118; goto __pyx_L1;}
    __pyx_1 = PyObject_GetItem(__pyx_v_cstate, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 118; 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":120 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/image.pyx":121 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->nb_color));

  /* "/home/jiba/src/soya/model/image.pyx":122 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->width));

  /* "/home/jiba/src/soya/model/image.pyx":123 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->height));

  /* "/home/jiba/src/soya/model/image.pyx":124 */
  __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":125 */
  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":126 */
  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":130 */
  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":134 */
  __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 = 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.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":136 */
  ((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 = 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._Image.has_border");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static char (__pyx_k247[]) = "_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":141 */
  __pyx_k247;

  /* "/home/jiba/src/soya/model/image.pyx":146 */
  __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":147 */
  __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":148 */
  __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_k249p;

static char (__pyx_k248[]) = "_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_k249[]) = "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":162 */
  __pyx_k248;

  /* "/home/jiba/src/soya/model/image.pyx":166 */
  __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":169 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 169; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_self->nb_color); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 169; goto __pyx_L1;}
  __pyx_4 = PyNumber_Remainder(__pyx_k249p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 169; 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 = 169; 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 = 169; 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 = 169; 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_k251p;

static char (__pyx_k250[]) = "_Image.internal_format() -> GLuint\n\nReturns the image internal format, depending on the number of color channels and the\nrendering quality.";
static char (__pyx_k251[]) = "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":172 */
  __pyx_k250;

  /* "/home/jiba/src/soya/model/image.pyx":176 */
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_LOW);
  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_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":181 */
    __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":185 */
    __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":188 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 188; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_self->nb_color); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 188; goto __pyx_L1;}
  __pyx_4 = PyNumber_Remainder(__pyx_k251p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 188; 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 = 188; 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 = 188; 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 = 188; 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_k252p;

static char (__pyx_k252[]) = "<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_k252p, ((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 190; 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_n_putpalette;

static PyObject *__pyx_k253p;

static char (__pyx_k253[]) = "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_v_pimage;
  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);
  __pyx_v_pimage = Py_None; Py_INCREF(__pyx_v_pimage);

  /* "/home/jiba/src/soya/model/image.pyx":193 */
  __pyx_1 = __Pyx_Import(__pyx_k253p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 193; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":194 */
  __pyx_2 = (((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->nb_color == 4);
  if (__pyx_2) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 194; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 194; 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 = 194; 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 = 194; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 194; 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 = 194; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 194; goto __pyx_L1;}
    Py_INCREF(__pyx_n_RGBA);
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_RGBA);
    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 = 194; 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 = 195; goto __pyx_L1;}
    __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 195; 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 = 195; 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 = 195; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 195; 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 = 195; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 195; 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 = 195; 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 == 1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/image.pyx":197 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_palette); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_4, Py_None, &__pyx_2) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
    __pyx_2 = __pyx_2 == 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_2) {
      __pyx_3 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
      __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_fromstring); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 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 = 197; 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 = 197; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
      PyTuple_SET_ITEM(__pyx_3, 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 = 197; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
      Py_INCREF(__pyx_n_L);
      PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_L);
      PyTuple_SET_ITEM(__pyx_4, 1, __pyx_3);
      PyTuple_SET_ITEM(__pyx_4, 2, __pyx_1);
      __pyx_3 = 0;
      __pyx_1 = 0;
      __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 197; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_r = __pyx_3;
      __pyx_3 = 0;
      goto __pyx_L0;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/image.pyx":199 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; goto __pyx_L1;}
      __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_fromstring); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; 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 = 199; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(((struct __pyx_obj_5_soya__Image *)__pyx_v_self)->height); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; goto __pyx_L1;}
      __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4);
      PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3);
      __pyx_4 = 0;
      __pyx_3 = 0;
      __pyx_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_pixels); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; goto __pyx_L1;}
      Py_INCREF(__pyx_n_P);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_P);
      PyTuple_SET_ITEM(__pyx_3, 1, __pyx_1);
      PyTuple_SET_ITEM(__pyx_3, 2, __pyx_4);
      __pyx_1 = 0;
      __pyx_4 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 199; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_v_pimage);
      __pyx_v_pimage = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/image.pyx":200 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_pimage, __pyx_n_putpalette); if (!__pyx_4) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 200; goto __pyx_L1;}
      __pyx_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_palette); if (!__pyx_5) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 200; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 200; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_5);
      __pyx_5 = 0;
      __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 200; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_1); __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/image.pyx":201 */
      Py_INCREF(__pyx_v_pimage);
      __pyx_r = __pyx_v_pimage;
      goto __pyx_L0;
    }
    __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);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._Image.to_pil");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_PIL);
  Py_DECREF(__pyx_v_pimage);
  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":204 */
  __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":205 */
  __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":206 */
  __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":207 */
  __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":208 */
  __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":209 */
  __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":210 */
  __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":211 */
  __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":212 */
  __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":213 */
  __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":214 */
  __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":215 */
  __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":216 */
  __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_k258[]) = "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":219 */
  __pyx_k258;

  /* "/home/jiba/src/soya/model/image.pyx":228 */
  __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":229 */
    __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":230 */
    __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":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":232 */
    __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":233 */
      __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":234 */
        for (__pyx_v_m = 0; __pyx_v_m < __pyx_v_nb_color; ++__pyx_v_m) {

          /* "/home/jiba/src/soya/model/image.pyx":235 */
          (__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":237 */
    (__pyx_v_w[0]) = ((__pyx_v_w[0]) >> 1);

    /* "/home/jiba/src/soya/model/image.pyx":238 */
    (__pyx_v_h[0]) = ((__pyx_v_h[0]) >> 1);

    /* "/home/jiba/src/soya/model/image.pyx":239 */
    __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":242 */
    __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":243 */
      __pyx_v_y = (2 * __pyx_v_j);

      /* "/home/jiba/src/soya/model/image.pyx":244 */
      __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":245 */
        __pyx_v_x = (2 * __pyx_v_i);

        /* "/home/jiba/src/soya/model/image.pyx":246 */
        for (__pyx_v_m = 0; __pyx_v_m < __pyx_v_nb_color; ++__pyx_v_m) {

          /* "/home/jiba/src/soya/model/image.pyx":247 */
          (__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":253 */
  __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_k259p;
static PyObject *__pyx_k260p;

static char (__pyx_k259[]) = "";
static char (__pyx_k260[]) = "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_k82;
  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 = 32; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":36 */
  ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->shininess = 128.0;

  /* "/home/jiba/src/soya/model/material.pyx":37 */
  (((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":38 */
  Py_INCREF(__pyx_k259p);
  Py_DECREF(((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_filename);
  ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_filename = __pyx_k259p;

  /* "/home/jiba/src/soya/model/material.pyx":39 */
  __pyx_1 = ((PyObject *)__pyx_v_texture) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/material.pyx":40 */
    __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 = 40; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_texture->width); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 40; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(__pyx_v_texture->height); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 40; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 40; 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_k260p, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 40; 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 = 40; 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 = 40; 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 = 40; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/material.pyx":41 */
    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":42 */
    ((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":43 */
    ((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":46 */
  __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":51 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/material.pyx":52 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/material.pyx":53 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->shininess);

  /* "/home/jiba/src/soya/model/material.pyx":54 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_diffuse,4);

  /* "/home/jiba/src/soya/model/material.pyx":55 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_specular,4);

  /* "/home/jiba/src/soya/model/material.pyx":56 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_emissive,4);

  /* "/home/jiba/src/soya/model/material.pyx":57 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 57; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 57; 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":64 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 64; 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 = 64; 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 = 64; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 64; 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 = 64; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":65 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/material.pyx":66 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/model/material.pyx":67 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->shininess));

  /* "/home/jiba/src/soya/model/material.pyx":68 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_diffuse,4);

  /* "/home/jiba/src/soya/model/material.pyx":69 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_specular,4);

  /* "/home/jiba/src/soya/model/material.pyx":70 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_emissive,4);

  /* "/home/jiba/src/soya/model/material.pyx":71 */
  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_k261[]) = "_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;
  intptr_t __pyx_6;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/material.pyx":79 */
  __pyx_k261;

  /* "/home/jiba/src/soya/model/material.pyx":88 */
  __pyx_v_opt = (__pyx_v_option & __pyx_e_5_soya_PACK_OPTIONS);

  /* "/home/jiba/src/soya/model/material.pyx":90 */
  __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":91 */
    __pyx_v_pack = (__pyx_v_self->_packs[__pyx_v_i]);

    /* "/home/jiba/src/soya/model/material.pyx":92 */
    __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":94 */
  __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))malloc((sizeof(struct __pyx_t_5_soya__Pack ))));

  /* "/home/jiba/src/soya/model/material.pyx":95 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 95; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 95; 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 = 95; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_6 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 95; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_v_pack->material_id = __pyx_6;

  /* "/home/jiba/src/soya/model/material.pyx":96 */
  __pyx_v_pack->option = __pyx_v_opt;

  /* "/home/jiba/src/soya/model/material.pyx":98 */
  __pyx_v_pack->batched_faces = 0;

  /* "/home/jiba/src/soya/model/material.pyx":99 */
  __pyx_v_pack->secondpass = 0;
  __pyx_v_pack->alpha = 0;

  /* "/home/jiba/src/soya/model/material.pyx":100 */
  __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":101 */
  (__pyx_v_self->_packs[__pyx_v_self->_nb_packs]) = __pyx_v_pack;

  /* "/home/jiba/src/soya/model/material.pyx":102 */
  __pyx_v_self->_nb_packs = (__pyx_v_self->_nb_packs + 1);

  /* "/home/jiba/src/soya/model/material.pyx":103 */
  __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_k262[]) = "_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":106 */
  __pyx_k262;

  /* "/home/jiba/src/soya/model/material.pyx":112 */
  __pyx_1 = (__pyx_v_5_soya_renderer->engine_option & __pyx_e_5_soya_INITED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":113 */
    __pyx_1 = ((PyObject *)__pyx_v_self->_texture) == Py_None;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/material.pyx":114 */
      __pyx_1 = (__pyx_v_self->_id != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":115 */
        glDeleteTextures(1,(&__pyx_v_self->_id));

        /* "/home/jiba/src/soya/model/material.pyx":116 */
        __pyx_v_self->_id = 0;
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/material.pyx":119 */
      __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":120 */
      glPushAttrib(GL_TEXTURE_BIT);

      /* "/home/jiba/src/soya/model/material.pyx":121 */
      glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_id);

      /* "/home/jiba/src/soya/model/material.pyx":122 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":123 */
        glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/material.pyx":125 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_CLAMP);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/material.pyx":126 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);

        /* "/home/jiba/src/soya/model/material.pyx":127 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);
        goto __pyx_L7;
      }
      /*else*/ {

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

        /* "/home/jiba/src/soya/model/material.pyx":130 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
      }
      __pyx_L7:;

      /* "/home/jiba/src/soya/model/material.pyx":132 */
      __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":135 */
      __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":136 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);

        /* "/home/jiba/src/soya/model/material.pyx":137 */
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

        /* "/home/jiba/src/soya/model/material.pyx":138 */
        ((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":140 */
        __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":142 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

          /* "/home/jiba/src/soya/model/material.pyx":143 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
          goto __pyx_L10;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/material.pyx":145 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

          /* "/home/jiba/src/soya/model/material.pyx":146 */
          glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/model/material.pyx":148 */
        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":153 */
      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_k263[]) = "_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":157 */
  __pyx_k263;

  /* "/home/jiba/src/soya/model/material.pyx":166 */
  __pyx_v_w = (__pyx_v_self->_texture->width - (2 * __pyx_v_border));

  /* "/home/jiba/src/soya/model/material.pyx":167 */
  __pyx_v_h = (__pyx_v_self->_texture->height - (2 * __pyx_v_border));

  /* "/home/jiba/src/soya/model/material.pyx":168 */
  __pyx_v_level = 0;

  /* "/home/jiba/src/soya/model/material.pyx":169 */
  __pyx_v_pixels = __pyx_v_self->_texture->_pixels;

  /* "/home/jiba/src/soya/model/material.pyx":170 */
  __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":171 */
  __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":173 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/material.pyx":174 */
    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":175 */
    __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":177 */
    __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":178 */
    __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":179 */
    __pyx_v_pixels = __pyx_v_new_pixels;

    /* "/home/jiba/src/soya/model/material.pyx":181 */
    __pyx_v_level = (__pyx_v_level + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/material.pyx":183 */
  __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_k264[]) = "_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":186 */
  __pyx_k264;

  /* "/home/jiba/src/soya/model/material.pyx":192 */
  __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":193 */
  __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":194 */
    __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":197 */
    __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":198 */
      __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":199 */
        __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MATERIAL_ALPHA);

        /* "/home/jiba/src/soya/model/material.pyx":200 */
        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_k265[]) = "_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":204 */
  __pyx_k265;

  /* "/home/jiba/src/soya/model/material.pyx":211 */
  __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":212 */
    ((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":213 */
    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":214 */
    __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":216 */
      __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":217 */
      glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_id);
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/material.pyx":219 */
    __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":221 */
    glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,__pyx_v_self->shininess);

    /* "/home/jiba/src/soya/model/material.pyx":222 */
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,__pyx_v_self->_specular);

    /* "/home/jiba/src/soya/model/material.pyx":223 */
    __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_MASK);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/material.pyx":224 */
      glDisable(GL_ALPHA_TEST);

      /* "/home/jiba/src/soya/model/material.pyx":225 */
      glAlphaFunc(GL_NOTEQUAL,0.0);

      /* "/home/jiba/src/soya/model/material.pyx":226 */
      glEnable(GL_ALPHA_TEST);

      /* "/home/jiba/src/soya/model/material.pyx":227 */
      glDepthMask(GL_TRUE);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/material.pyx":228 */
    __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/material.pyx":229 */
      glBlendFunc(GL_SRC_ALPHA,GL_ONE);

      /* "/home/jiba/src/soya/model/material.pyx":232 */
      glPushAttrib(GL_FOG_BIT);

      /* "/home/jiba/src/soya/model/material.pyx":233 */
      glDisable(GL_FOG);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/material.pyx":234 */
    __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/material.pyx":235 */
      glEnable(GL_TEXTURE_GEN_S);

      /* "/home/jiba/src/soya/model/material.pyx":236 */
      glEnable(GL_TEXTURE_GEN_T);

      /* "/home/jiba/src/soya/model/material.pyx":237 */
      glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);

      /* "/home/jiba/src/soya/model/material.pyx":238 */
      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":243 */
  glColor4fv(__pyx_v_self->_diffuse);

  /* "/home/jiba/src/soya/model/material.pyx":244 */
  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_k266[]) = "_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":248 */
  __pyx_k266;

  /* "/home/jiba/src/soya/model/material.pyx":254 */
  glBindTexture(GL_TEXTURE_2D,0);

  /* "/home/jiba/src/soya/model/material.pyx":255 */
  __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":256 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_MASK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":257 */
    glDisable(GL_ALPHA_TEST);

    /* "/home/jiba/src/soya/model/material.pyx":258 */
    __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":259 */
  __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":260 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ADDITIVE_BLENDING);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":261 */
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    /* "/home/jiba/src/soya/model/material.pyx":262 */
    glPopAttrib();
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/material.pyx":263 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MATERIAL_ENVIRONMENT_MAPPING);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":264 */
    glDisable(GL_TEXTURE_GEN_S);

    /* "/home/jiba/src/soya/model/material.pyx":265 */
    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":274 */
  ((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":280 */
  ((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":281 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 281; 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":285 */
  __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 = 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._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":289 */
  __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 = 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._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":293 */
  __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 = 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._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 = 294; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":295 */
  __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":300 */
  __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 = 300; 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 = 301; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":302 */
  __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":304 */
  ((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":308 */
  __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 = 308; 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 = 309; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":310 */
  __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":312 */
  ((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":316 */
  __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 = 316; 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 = 317; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":318 */
  __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":320 */
  ((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":324 */
  __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 = 324; 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 = 325; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":326 */
  __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":328 */
  ((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":332 */
  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_k267p;

static char (__pyx_k267[]) = "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 = 333; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":335 */
  __pyx_1 = __pyx_v_image == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/material.pyx":336 */
    __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":337 */
    __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 = 339; 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 = 339; 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 = 339; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 339; 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_k267p, __pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 339; 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 = 339; 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 = 339; 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 = 339; goto __pyx_L1;}
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":340 */
  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":341 */
  ((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":342 */
  ((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":347 */
  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":351 */
  __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 = 351; 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 = 351; 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 = 351; 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 = 351; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 351; 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":353 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 353; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 353; 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 = 353; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 353; 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 = 353; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 353; 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 = 353; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 353; 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 = 353; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":354 */
  ((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":358 */
  __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 = 358; 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 = 358; 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 = 358; 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 = 358; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 358; 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":360 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 360; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 360; 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 = 360; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 360; 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 = 360; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 360; 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 = 360; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 360; 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 = 360; 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":364 */
  __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 = 364; 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 = 364; 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 = 364; 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 = 364; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 364; 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":366 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 366; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 366; 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 = 366; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 366; 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 = 366; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 366; 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 = 366; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 366; 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 = 366; 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":370 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_id); 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.opengl_id.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k268p;

static char (__pyx_k268[]) = "<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_k268p, ((struct __pyx_obj_5_soya__Material *)__pyx_v_self)->_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 372; 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_20_MainLoopingMaterial___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_20_MainLoopingMaterial___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_k83;
  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 = 378; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/material.pyx":379 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Material), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 379; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 379; 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 = 379; 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":380 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 380; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP_ITEMS); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 380; goto __pyx_L1;}
  if (PyObject_SetItem(__pyx_2, __pyx_v_self, __pyx_1) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 380; 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._MainLoopingMaterial.__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_20_MainLoopingMaterial___setcstate__(struct __pyx_obj_5_soya__MainLoopingMaterial *__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":383 */
  __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":384 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 384; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP_ITEMS); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 384; goto __pyx_L1;}
  if (PyObject_SetItem(__pyx_2, ((PyObject *)__pyx_v_self), __pyx_1) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 384; 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._MainLoopingMaterial.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static PyObject *__pyx_f_5_soya_20_MainLoopingMaterial_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_20_MainLoopingMaterial_begin_round[] = "_IdleingMaterial.begin_round()\n\nCalled by the MainLoop when a new round begins; default implementation does nothing.";
static PyObject *__pyx_f_5_soya_20_MainLoopingMaterial_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":390 */

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

static PyObject *__pyx_f_5_soya_20_MainLoopingMaterial_end_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_20_MainLoopingMaterial_end_round[] = "_IdleingMaterial.end_round()\n\nCalled by the MainLoop when a round is finished; default implementation does nothing.";
static PyObject *__pyx_f_5_soya_20_MainLoopingMaterial_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":396 */

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

static PyObject *__pyx_f_5_soya_20_MainLoopingMaterial_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_20_MainLoopingMaterial_advance_time[] = "_IdleingMaterial.advance_time(proportion)\n\nCalled by the MainLoop 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_20_MainLoopingMaterial_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":403 */

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._MainLoopingMaterial.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":414 */
  __pyx_vtabptr_5_soya__Material->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":415 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_init_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 415; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 415; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 415; 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":418 */

  __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":421 */
  __pyx_vtabptr_5_soya__Material->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":422 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_activated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 422; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 422; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 422; 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":425 */

  __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":428 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_inactivated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 428; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 428; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 428; 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":429 */
  __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":432 */

  __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_26_PythonMainLoopingMaterial__init_texture(struct __pyx_obj_5_soya__PythonMainLoopingMaterial *__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":444 */
  __pyx_vtabptr_5_soya__Material->_init_texture(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":445 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_init_texture); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 445; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 445; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 445; 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._PythonMainLoopingMaterial._init_texture");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_26_PythonMainLoopingMaterial_init_texture(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_26_PythonMainLoopingMaterial_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":448 */

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

static void __pyx_f_5_soya_26_PythonMainLoopingMaterial__activate(struct __pyx_obj_5_soya__PythonMainLoopingMaterial *__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":451 */
  __pyx_vtabptr_5_soya__Material->_activate(((struct __pyx_obj_5_soya__Material *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/material.pyx":452 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_activated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 452; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 452; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 452; 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._PythonMainLoopingMaterial._activate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_26_PythonMainLoopingMaterial_activated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_26_PythonMainLoopingMaterial_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":455 */

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

static void __pyx_f_5_soya_26_PythonMainLoopingMaterial__inactivate(struct __pyx_obj_5_soya__PythonMainLoopingMaterial *__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":458 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_inactivated); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 458; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 458; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 458; 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":459 */
  __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._PythonMainLoopingMaterial._inactivate");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_26_PythonMainLoopingMaterial_inactivated(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_26_PythonMainLoopingMaterial_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":462 */

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

static char (__pyx_k269[]) = "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":498 */
  __pyx_k269;

  /* "/home/jiba/src/soya/model/material.pyx":504 */
  __pyx_1 = (__pyx_v_pack->alpha == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":505 */
    __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":506 */
    __pyx_v_pack->alpha->material_id = __pyx_v_pack->material_id;

    /* "/home/jiba/src/soya/model/material.pyx":507 */
    __pyx_v_pack->alpha->option = (__pyx_v_pack->option | __pyx_e_5_soya_FACE_ALPHA);

    /* "/home/jiba/src/soya/model/material.pyx":509 */
    __pyx_v_pack->alpha->batched_faces = 0;

    /* "/home/jiba/src/soya/model/material.pyx":510 */
    __pyx_v_pack->alpha->secondpass = 0;
    __pyx_v_pack->alpha->alpha = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":511 */
  __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_k270[]) = "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":514 */
  __pyx_k270;

  /* "/home/jiba/src/soya/model/material.pyx":520 */
  __pyx_1 = (__pyx_v_pack->secondpass == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":521 */
    __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":522 */
    __pyx_v_pack->secondpass->material_id = __pyx_v_pack->material_id;

    /* "/home/jiba/src/soya/model/material.pyx":523 */
    __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":526 */
    __pyx_v_pack->secondpass->batched_faces = 0;

    /* "/home/jiba/src/soya/model/material.pyx":527 */
    __pyx_v_pack->secondpass->secondpass = 0;
    __pyx_v_pack->secondpass->alpha = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":528 */
  __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_k271[]) = "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":532 */
  __pyx_k271;

  /* "/home/jiba/src/soya/model/material.pyx":536 */
  __pyx_1 = (__pyx_v_pack->batched_faces == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":537 */
    __pyx_v_pack->batched_faces = get_chunk();

    /* "/home/jiba/src/soya/model/material.pyx":538 */
    __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":541 */
  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":548 */
  __pyx_1 = __pyx_v_5_soya_renderer->used_opaque_packs->nb;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":549 */
    ((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":550 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->used_opaque_packs,0);

    /* "/home/jiba/src/soya/model/material.pyx":551 */
    __pyx_v_5_soya_renderer->used_opaque_packs->nb = 0;

    /* "/home/jiba/src/soya/model/material.pyx":552 */
    __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":553 */
    while (1) {
      __pyx_L3:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/material.pyx":554 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,__pyx_v_pack);

      /* "/home/jiba/src/soya/model/material.pyx":555 */
      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":556 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

      /* "/home/jiba/src/soya/model/material.pyx":557 */
      drop_chunk(__pyx_v_pack->batched_faces);

      /* "/home/jiba/src/soya/model/material.pyx":557 */
      __pyx_v_pack->batched_faces = 0;

      /* "/home/jiba/src/soya/model/material.pyx":558 */
      __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":559 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

    /* "/home/jiba/src/soya/model/material.pyx":560 */
    __pyx_v_5_soya_renderer->used_opaque_packs->nb = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/material.pyx":562 */
  __pyx_1 = __pyx_v_5_soya_renderer->used_alpha_packs->nb;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":563 */
    ((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":564 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->used_alpha_packs,0);

    /* "/home/jiba/src/soya/model/material.pyx":565 */
    __pyx_v_5_soya_renderer->used_alpha_packs->nb = 0;

    /* "/home/jiba/src/soya/model/material.pyx":566 */
    __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":567 */
    while (1) {
      __pyx_L6:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/material.pyx":568 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,__pyx_v_pack);

      /* "/home/jiba/src/soya/model/material.pyx":569 */
      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":570 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

      /* "/home/jiba/src/soya/model/material.pyx":571 */
      drop_chunk(__pyx_v_pack->batched_faces);

      /* "/home/jiba/src/soya/model/material.pyx":571 */
      __pyx_v_pack->batched_faces = 0;

      /* "/home/jiba/src/soya/model/material.pyx":572 */
      __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":573 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

    /* "/home/jiba/src/soya/model/material.pyx":574 */
    __pyx_v_5_soya_renderer->used_alpha_packs->nb = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/material.pyx":576 */
  __pyx_1 = __pyx_v_5_soya_renderer->used_secondpass_packs->nb;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/material.pyx":577 */
    ((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":578 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->used_secondpass_packs,0);

    /* "/home/jiba/src/soya/model/material.pyx":579 */
    __pyx_v_5_soya_renderer->used_secondpass_packs->nb = 0;

    /* "/home/jiba/src/soya/model/material.pyx":580 */
    __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":581 */
    while (1) {
      __pyx_L9:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/material.pyx":582 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,__pyx_v_pack);

      /* "/home/jiba/src/soya/model/material.pyx":583 */
      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":584 */
      chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

      /* "/home/jiba/src/soya/model/material.pyx":585 */
      drop_chunk(__pyx_v_pack->batched_faces);

      /* "/home/jiba/src/soya/model/material.pyx":585 */
      __pyx_v_pack->batched_faces = 0;

      /* "/home/jiba/src/soya/model/material.pyx":586 */
      __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":587 */
    chunk_add_ptr(__pyx_v_5_soya_renderer->data,0);

    /* "/home/jiba/src/soya/model/material.pyx":588 */
    __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":29 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/face.pyx":30 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,3);

  /* "/home/jiba/src/soya/model/face.pyx":33 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_x),1);

  /* "/home/jiba/src/soya/model/face.pyx":34 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_y),1);

  /* "/home/jiba/src/soya/model/face.pyx":35 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 35; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 35; 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":38 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 38; 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 = 38; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 38; 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 = 38; 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 = 38; 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 = 38; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":43 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/face.pyx":44 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,3);

  /* "/home/jiba/src/soya/model/face.pyx":47 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_x));

  /* "/home/jiba/src/soya/model/face.pyx":48 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_tex_y));

  /* "/home/jiba/src/soya/model/face.pyx":49 */
  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":61 */
  __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 = 61; 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 = 62; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":63 */
  ((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":67 */
  __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 = 67; 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 = 68; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":69 */
  ((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":73 */
  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":75 */
  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":79 */
  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":81 */
  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":85 */
  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":87 */
  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":91 */
  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_k84;
  __pyx_v_x = __pyx_k85;
  __pyx_v_y = __pyx_k86;
  __pyx_v_z = __pyx_k87;
  __pyx_v_tex_x = __pyx_k88;
  __pyx_v_tex_y = __pyx_k89;
  __pyx_v_diffuse = __pyx_k90;
  __pyx_v_emissive = __pyx_k91;
  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 = 93; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":98 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Point); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 98; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___init__); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 98; 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 = 98; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_y); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 98; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 98; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(5); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 98; 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 = 98; 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":99 */
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_x = __pyx_v_tex_x;

  /* "/home/jiba/src/soya/model/face.pyx":100 */
  ((struct __pyx_obj_5_soya__Vertex *)__pyx_v_self)->_tex_y = __pyx_v_tex_y;

  /* "/home/jiba/src/soya/model/face.pyx":101 */
  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":102 */
  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":106 */
  glTexCoord2f(__pyx_v_self->_tex_x,__pyx_v_self->_tex_y);

  /* "/home/jiba/src/soya/model/face.pyx":107 */
  __pyx_1 = __pyx_v_self->_diffuse == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/face.pyx":111 */
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 111; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 111; 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 = 111; 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 = 111; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 111; 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 = 111; 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 = 111; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 111; 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 = 111; 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 = 111; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_diffuse, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 111; 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 = 111; 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":112 */
  __pyx_1 = __pyx_v_self->_emissive == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/face.pyx":113 */
    glMaterialfv(GL_FRONT,GL_EMISSION,((float (*))__pyx_v_self->_emissive));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/face.pyx":114 */
  __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":116 */
    ((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":117 */
    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":122 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_face->_vertices, __pyx_n_index); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 122; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 122; 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 = 122; 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 = 122; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_index = __pyx_4;

  /* "/home/jiba/src/soya/model/face.pyx":123 */
  __pyx_4 = PyObject_Length(__pyx_v_self->_face->_vertices); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 123; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(((__pyx_v_index + 1) % __pyx_4)); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 123; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_self->_face->_vertices, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 123; 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":124 */
  __pyx_3 = PyInt_FromLong((__pyx_v_index - 1)); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 124; goto __pyx_L1;}
  __pyx_1 = PyObject_GetItem(__pyx_v_self->_face->_vertices, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 124; 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":125 */
  __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":135 */
  __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 = 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._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 = 136; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":137 */
  __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":142 */
  __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 = 142; 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 = 143; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":144 */
  __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":149 */
  __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 = 149; 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 = 150; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":151 */
  __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":156 */
  __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 = 156; 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 = 157; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":158 */
  __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":163 */
  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 = 164; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":165 */
  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":169 */
  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":173 */
  ((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":174 */
  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_k92;
  __pyx_v_vertices = __pyx_k93;
  __pyx_v_material = __pyx_k94;
  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 = 176; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 176; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":182 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 182; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 182; 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 = 182; 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":183 */
  __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 = 183; 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 = 183; 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":184 */
  __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 = 184; 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 = 184; 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":185 */
  ((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":186 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; goto __pyx_L1;}
  __pyx_1 = PyObject_GetIter(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; 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 = 186; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 186; 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":191 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/face.pyx":192 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/face.pyx":193 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/face.pyx":194 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 194; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 194; 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":197 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 197; 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 = 197; 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 = 197; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 197; 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 = 197; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":200 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 200; 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 = 200; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 200; 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":203 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/face.pyx":204 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/face.pyx":205 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/face.pyx":206 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/face.pyx":207 */
  __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 = 209; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":213 */
  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":214 */
  __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 = 214; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 214; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 214; 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 = 214; 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 = 216; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":220 */
  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":221 */
  __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 = 221; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 221; 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 = 221; 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 = 223; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/face.pyx":227 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 227; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 227; 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 = 227; 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":232 */
  (__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":233 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 233; goto __pyx_L1;}
  __pyx_2 = (__pyx_1 > 2);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/face.pyx":234 */
    __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 = 234; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 234; 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 = 234; 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 = 234; 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":236 */
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 236; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 236; 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":237 */
    __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 237; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 237; 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":238 */
    __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 238; goto __pyx_L1;}
    __pyx_5 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 238; 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":239 */
    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":240 */
    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 = 241; 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_k95;
  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":248 */
  __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 = 248; 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 = 248; 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":252 */
  ((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":253 */
  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":254 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 254; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 254; 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 = 254; 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 = 254; 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":257 */
  __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 257; 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 = 257; 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":258 */
  __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 258; 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 = 258; 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":260 */
  __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 = 260; goto __pyx_L1;}
  __pyx_5 = PyObject_GetIter(__pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 260; 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 = 260; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 260; 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":261 */
    ((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":262 */
    face_normal(__pyx_v_n2->__pyx_base._matrix,__pyx_v_a,__pyx_v_b,__pyx_v_c);

    /* "/home/jiba/src/soya/model/face.pyx":263 */
    vector_normalize(__pyx_v_n2->__pyx_base._matrix);

    /* "/home/jiba/src/soya/model/face.pyx":265 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_n1), __pyx_n_distance_to); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 265; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 265; 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 = 265; 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 = 265; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_6, __pyx_4, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 265; 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 = 265; 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":266 */
  __pyx_6 = PyInt_FromLong(1); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 266; 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":273 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 273; 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 = 273; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 273; 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":274 */
    __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 = 274; 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":275 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 275; 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":281 */
  __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 = 281; 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 = 281; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 281; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 281; 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 = 281; 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 = 281; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 281; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 281; 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":288 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__Face *)__pyx_v_self)->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 288; 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 = 288; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 288; 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":289 */
    __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 = 289; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 289; 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 = 289; goto __pyx_L1;}
      if (PyObject_Cmp(__pyx_5, __pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 289; 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 = 289; 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":290 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 290; 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":293 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_is_alpha); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 293; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 293; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 293; 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 = 293; 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":300 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 300; goto __pyx_L1;}
  __pyx_v_i = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":301 */
  __pyx_1 = (__pyx_v_i == 0);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":303 */
  ((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":305 */
  __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":306 */
  __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":307 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/face.pyx":308 */
    glDisable(GL_CULL_FACE);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/face.pyx":310 */
  ((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":311 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_normal) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/face.pyx":312 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 312; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 312; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 312; goto __pyx_L1;}
    __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 312; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 312; 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 = 312; 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 = 312; 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":313 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_at_camera), __pyx_n_convert_to); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 313; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 313; 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 = 313; 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":314 */
    glNormal3fv(__pyx_v_at_camera->__pyx_base._matrix);
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/face.pyx":316 */
    glNormal3fv(__pyx_v_self->_normal->__pyx_base._matrix);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/face.pyx":318 */
  __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":324 */
  __pyx_6 = PyObject_GetIter(__pyx_v_self->_vertices); if (!__pyx_6) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 324; 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 = 324; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 324; 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":325 */
  glEnd();

  /* "/home/jiba/src/soya/model/face.pyx":327 */
  __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":328 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);

    /* "/home/jiba/src/soya/model/face.pyx":329 */
    glEnable(GL_CULL_FACE);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/face.pyx":331 */
  __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":334 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_iter); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 334; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 334; 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 = 334; 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":336 */
  __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 = 336; 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":341 */
  __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 = 341; 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_k272p;
static PyObject *__pyx_k273p;
static PyObject *__pyx_k274p;
static PyObject *__pyx_k275p;
static PyObject *__pyx_k276p;
static PyObject *__pyx_k277p;
static PyObject *__pyx_k278p;

static char (__pyx_k272[]) = "<Plot";
static char (__pyx_k273[]) = "<Line";
static char (__pyx_k274[]) = "<Triangle";
static char (__pyx_k275[]) = "<Quad";
static char (__pyx_k276[]) = "<Polygon";
static char (__pyx_k277[]) = ", material %s";
static char (__pyx_k278[]) = ">";

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":345 */
  __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 = 345; goto __pyx_L1;}
  __pyx_v_i = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":346 */
  __pyx_1 = (__pyx_v_i == 1);
  if (__pyx_1) {
    Py_INCREF(__pyx_k272p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k272p;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_i == 2);
  if (__pyx_1) {
    Py_INCREF(__pyx_k273p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k273p;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_i == 3);
  if (__pyx_1) {
    Py_INCREF(__pyx_k274p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k274p;
    goto __pyx_L2;
  }
  __pyx_1 = (__pyx_v_i == 4);
  if (__pyx_1) {
    Py_INCREF(__pyx_k275p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k275p;
    goto __pyx_L2;
  }
  /*else*/ {
    Py_INCREF(__pyx_k276p);
    Py_DECREF(__pyx_v_r);
    __pyx_v_r = __pyx_k276p;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/face.pyx":351 */
  __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 = 351; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k277p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 351; 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 = 351; 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":352 */
  __pyx_4 = PyNumber_Add(__pyx_v_r, __pyx_k278p); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 352; 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":358 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 358; 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 = 358; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 358; 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":359 */
    __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":362 */
    __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":363 */
    __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":364 */
    __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":365 */
    __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":366 */
    __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":367 */
    __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_k279p;

static char (__pyx_k279[]) = "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":373 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 373; goto __pyx_L1;}
  __pyx_v_nb_vertices = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":374 */
  __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":375 */
  __pyx_v_option = __pyx_v_data->option;

  /* "/home/jiba/src/soya/model/face.pyx":376 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_double_sided); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 376; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 376; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 376; 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":379 */
  __pyx_v_p = ((float (*))malloc(((__pyx_v_nb_vertices * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/face.pyx":380 */
  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 = 380; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 380; 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":382 */
  face_normal(__pyx_v_normal,__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6));

  /* "/home/jiba/src/soya/model/face.pyx":383 */
  vector_normalize(__pyx_v_normal);

  /* "/home/jiba/src/soya/model/face.pyx":384 */
  __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 = 386; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 386; goto __pyx_L1;}
    Py_INCREF(__pyx_k279p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k279p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 386; 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 = 386; goto __pyx_L1;}
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/face.pyx":388 */
  __pyx_1 = (__pyx_v_i != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/face.pyx":389 */
    __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":390 */
    __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":391 */
      __pyx_1 = (__pyx_v_i == __pyx_e_5_soya_RAYPICK_DIRECT);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/face.pyx":392 */
        __pyx_v_data->result = __pyx_v_r;

        /* "/home/jiba/src/soya/model/face.pyx":393 */
        __pyx_v_data->root_result = __pyx_v_root_r;

        /* "/home/jiba/src/soya/model/face.pyx":394 */
        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":395 */
        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":397 */
        __pyx_v_data->result = __pyx_v_r;

        /* "/home/jiba/src/soya/model/face.pyx":398 */
        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":399 */
        __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_double_sided); if (!__pyx_2) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 399; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 399; goto __pyx_L1;}
        if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 399; 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":400 */
          (__pyx_v_data->normal[0]) = (-(__pyx_v_normal[0]));

          /* "/home/jiba/src/soya/model/face.pyx":401 */
          (__pyx_v_data->normal[1]) = (-(__pyx_v_normal[1]));

          /* "/home/jiba/src/soya/model/face.pyx":402 */
          (__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":405 */
  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_k280p;

static char (__pyx_k280[]) = "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":412 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 412; goto __pyx_L1;}
  __pyx_v_nb_vertices = __pyx_1;

  /* "/home/jiba/src/soya/model/face.pyx":413 */
  __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":414 */
  __pyx_v_option = __pyx_v_data->option;

  /* "/home/jiba/src/soya/model/face.pyx":415 */
  __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 = 415; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 415; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 415; 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":418 */
  __pyx_v_p = ((float (*))malloc(((__pyx_v_nb_vertices * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/face.pyx":419 */
  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 = 419; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 419; 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":421 */
  face_normal(__pyx_v_normal,__pyx_v_p,(__pyx_v_p + 3),(__pyx_v_p + 6));

  /* "/home/jiba/src/soya/model/face.pyx":422 */
  vector_normalize(__pyx_v_normal);

  /* "/home/jiba/src/soya/model/face.pyx":423 */
  __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 = 425; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 425; goto __pyx_L1;}
    Py_INCREF(__pyx_k280p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k280p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 425; 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 = 425; goto __pyx_L1;}
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/face.pyx":427 */
  free(__pyx_v_p);

  /* "/home/jiba/src/soya/model/face.pyx":428 */
  __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":431 */
  __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":434 */
  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_k281p;

static char (__pyx_k281[]) = "<%s %s>";

static PyObject *__pyx_f_5_soya_6_Model___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Model___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/model.pyx":24 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 24; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 24; 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 = 24; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  Py_INCREF(((struct __pyx_obj_5_soya__Model *)__pyx_v_self)->_filename);
  PyTuple_SET_ITEM(__pyx_1, 1, ((struct __pyx_obj_5_soya__Model *)__pyx_v_self)->_filename);
  __pyx_2 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k281p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 24; 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._Model.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_6_Model__batch(struct __pyx_obj_5_soya__Model *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_6_Model__render(struct __pyx_obj_5_soya__Model *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static int __pyx_f_5_soya_6_Model__shadow(struct __pyx_obj_5_soya__Model *__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);
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._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_Model__get_box(struct __pyx_obj_5_soya__Model *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  Py_INCREF((PyObject *)__pyx_v_self);

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

static void __pyx_f_5_soya_6_Model__raypick(struct __pyx_obj_5_soya__Model *__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);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._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_Model__raypick_b(struct __pyx_obj_5_soya__Model *__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);
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._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_Model__collect_raypickables(struct __pyx_obj_5_soya__Model *__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);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static PyObject *__pyx_k282p;

static char (__pyx_k282[]) = "This type of model doesn't support attach!";

static void __pyx_f_5_soya_6_Model__attach(struct __pyx_obj_5_soya__Model *__pyx_v_self,PyObject *__pyx_v_mesh_names) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_mesh_names);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 34; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 34; goto __pyx_L1;}
  Py_INCREF(__pyx_k282p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k282p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __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[17]; __pyx_lineno = 34; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._attach");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_names);
}

static PyObject *__pyx_k283p;

static char (__pyx_k283[]) = "This type of model doesn't support detach!";

static void __pyx_f_5_soya_6_Model__detach(struct __pyx_obj_5_soya__Model *__pyx_v_self,PyObject *__pyx_v_mesh_names) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_mesh_names);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 35; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_INCREF(__pyx_k283p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k283p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 35; 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[17]; __pyx_lineno = 35; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._detach");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_names);
}

static int __pyx_f_5_soya_6_Model__is_attached(struct __pyx_obj_5_soya__Model *__pyx_v_self,PyObject *__pyx_v_mesh_name) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_mesh_name);
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._is_attached");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_name);
  return __pyx_r;
}

static PyObject *__pyx_k284p;

static char (__pyx_k284[]) = "This type of model doesn't support attach_to_bone!";

static void __pyx_f_5_soya_6_Model__attach_to_bone(struct __pyx_obj_5_soya__Model *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,PyObject *__pyx_v_bone_name) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coordsyst);
  Py_INCREF(__pyx_v_bone_name);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 37; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 37; goto __pyx_L1;}
  Py_INCREF(__pyx_k284p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k284p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 37; 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[17]; __pyx_lineno = 37; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._attach_to_bone");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_bone_name);
}

static PyObject *__pyx_k285p;

static char (__pyx_k285[]) = "This type of model doesn't support detach_from_bone!";

static void __pyx_f_5_soya_6_Model__detach_from_bone(struct __pyx_obj_5_soya__Model *__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);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_INCREF(__pyx_k285p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k285p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 38; 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[17]; __pyx_lineno = 38; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._detach_from_bone");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_f_5_soya_6_Model__get_attached_meshes(struct __pyx_obj_5_soya__Model *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 39; 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._Model._get_attached_meshes");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Model__get_attached_coordsysts(struct __pyx_obj_5_soya__Model *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 40; 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._Model._get_attached_coordsysts");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k286p;

static char (__pyx_k286[]) = "This type of model doesn't support animation!";

static void __pyx_f_5_soya_6_Model__animate_blend_cycle(struct __pyx_obj_5_soya__Model *__pyx_v_self,PyObject *__pyx_v_animation_name,float __pyx_v_weight,float __pyx_v_fade_in) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 41; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 41; goto __pyx_L1;}
  Py_INCREF(__pyx_k286p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k286p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 41; 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[17]; __pyx_lineno = 41; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._animate_blend_cycle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
}

static PyObject *__pyx_k287p;

static char (__pyx_k287[]) = "This type of model doesn't support animation!";

static void __pyx_f_5_soya_6_Model__animate_clear_cycle(struct __pyx_obj_5_soya__Model *__pyx_v_self,PyObject *__pyx_v_animation_name,float __pyx_v_fade_out) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 42; goto __pyx_L1;}
  Py_INCREF(__pyx_k287p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k287p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 42; 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[17]; __pyx_lineno = 42; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._animate_clear_cycle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
}

static PyObject *__pyx_k288p;

static char (__pyx_k288[]) = "This type of model doesn't support animation!";

static void __pyx_f_5_soya_6_Model__animate_execute_action(struct __pyx_obj_5_soya__Model *__pyx_v_self,PyObject *__pyx_v_animation_name,float __pyx_v_fade_in,float __pyx_v_fade_out) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_INCREF(__pyx_k288p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k288p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 43; 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[17]; __pyx_lineno = 43; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Model._animate_execute_action");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
}

static void __pyx_f_5_soya_6_Model__animate_reset(struct __pyx_obj_5_soya__Model *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

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

static PyObject *__pyx_k289p;

static char (__pyx_k289[]) = "This type of model doesn't support LOD!";

static void __pyx_f_5_soya_6_Model__set_lod_level(struct __pyx_obj_5_soya__Model *__pyx_v_self,float __pyx_v_lod_level) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_TypeError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 45; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 45; goto __pyx_L1;}
  Py_INCREF(__pyx_k289p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k289p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 45; 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[17]; __pyx_lineno = 45; goto __pyx_L1;}

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

static void __pyx_f_5_soya_6_Model__begin_round(struct __pyx_obj_5_soya__Model *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

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

static void __pyx_f_5_soya_6_Model__advance_time(struct __pyx_obj_5_soya__Model *__pyx_v_self,float __pyx_v_proportion) {
  Py_INCREF((PyObject *)__pyx_v_self);

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

static void __pyx_f_5_soya_6_Model__instanced(struct __pyx_obj_5_soya__Model *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body,PyObject *__pyx_v_opt) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  Py_INCREF(__pyx_v_opt);

  /* "/home/jiba/src/soya/model/model.pyx":50 */
  Py_INCREF(((PyObject *)__pyx_v_self));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_body->_data));
  __pyx_v_body->_data = ((PyObject *)__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Model._instanced");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF(__pyx_v_opt);
}

static struct __pyx_obj_5_soya__Model *__pyx_f_5_soya_6_Model__create_deformed_data(struct __pyx_obj_5_soya__Model *__pyx_v_self) {
  struct __pyx_obj_5_soya__Model *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 52; goto __pyx_L1;}
  Py_INCREF((PyObject *)Py_None);
  __pyx_r = (struct __pyx_obj_5_soya__Model *)Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Model._create_deformed_data");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya_6_Model___deepcopy__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_6_Model___deepcopy__[] = "Models are immutable.";
static PyObject *__pyx_f_5_soya_6_Model___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/model.pyx":57 */
  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._Model.__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_ModelFace (*__pyx_v_self)) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/model.pyx":79 */
  __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/model.pyx":81 */
  __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 PyObject *__pyx_n_base_model;

static struct __pyx_obj_5_soya__Model *__pyx_f_5_soya_12_SimpleModel__create_deformed_data(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self) {
  struct __pyx_obj_5_soya__SimpleModel *__pyx_v_data;
  struct __pyx_obj_5_soya__Model *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);

  /* "/home/jiba/src/soya/model/model.pyx":99 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 99; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___new__); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 99; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 99; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 99; 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[17]; __pyx_lineno = 99; 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__SimpleModel)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 99; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_data));
  __pyx_v_data = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":100 */
  if (PyObject_SetAttr(((PyObject *)__pyx_v_data), __pyx_n_base_model, ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 100; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model.pyx":102 */
  Py_INCREF(__pyx_v_self->_materials);
  Py_DECREF(__pyx_v_data->_materials);
  __pyx_v_data->_materials = __pyx_v_self->_materials;

  /* "/home/jiba/src/soya/model/model.pyx":103 */
  __pyx_v_data->_option = __pyx_v_self->_option;

  /* "/home/jiba/src/soya/model/model.pyx":104 */
  __pyx_v_data->_nb_vertices = __pyx_v_self->_nb_vertices;

  /* "/home/jiba/src/soya/model/model.pyx":105 */
  __pyx_v_data->_nb_coords = __pyx_v_self->_nb_coords;

  /* "/home/jiba/src/soya/model/model.pyx":106 */
  __pyx_v_data->_nb_vnormals = __pyx_v_self->_nb_vnormals;

  /* "/home/jiba/src/soya/model/model.pyx":107 */
  __pyx_v_data->_nb_colors = __pyx_v_self->_nb_colors;

  /* "/home/jiba/src/soya/model/model.pyx":108 */
  __pyx_v_data->_nb_values = __pyx_v_self->_nb_values;

  /* "/home/jiba/src/soya/model/model.pyx":109 */
  __pyx_v_data->_nb_faces = __pyx_v_self->_nb_faces;

  /* "/home/jiba/src/soya/model/model.pyx":111 */
  __pyx_v_data->_faces = __pyx_v_self->_faces;

  /* "/home/jiba/src/soya/model/model.pyx":112 */
  __pyx_v_data->_coords = ((float (*))malloc(((3 * __pyx_v_data->_nb_coords) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":113 */
  __pyx_v_data->_vnormals = __pyx_v_self->_vnormals;

  /* "/home/jiba/src/soya/model/model.pyx":114 */
  __pyx_v_data->_colors = __pyx_v_self->_colors;

  /* "/home/jiba/src/soya/model/model.pyx":115 */
  __pyx_v_data->_values = __pyx_v_self->_values;

  /* "/home/jiba/src/soya/model/model.pyx":116 */
  __pyx_v_data->_vertex_coords = __pyx_v_self->_vertex_coords;

  /* "/home/jiba/src/soya/model/model.pyx":118 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
  if (__pyx_4) {
    __pyx_v_data->_vertex_options = __pyx_v_self->_vertex_options;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":119 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_4) {
    __pyx_v_data->_vertex_texcoords = __pyx_v_self->_vertex_texcoords;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":120 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
  if (__pyx_4) {
    __pyx_v_data->_vertex_diffuses = __pyx_v_self->_vertex_diffuses;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/model.pyx":121 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_4) {
    __pyx_v_data->_vertex_emissives = __pyx_v_self->_vertex_emissives;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/model.pyx":122 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_HAS_SPHERE);
  if (__pyx_4) {
    __pyx_v_data->_sphere = __pyx_v_self->_sphere;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/model.pyx":124 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_NEIGHBORS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":125 */
    __pyx_v_data->_neighbors = __pyx_v_self->_neighbors;

    /* "/home/jiba/src/soya/model/model.pyx":126 */
    __pyx_v_data->_neighbors_side = __pyx_v_self->_neighbors_side;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/model.pyx":128 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":129 */
    __pyx_v_data->_simple_neighbors = __pyx_v_self->_simple_neighbors;

    /* "/home/jiba/src/soya/model/model.pyx":130 */
    __pyx_v_data->_simple_neighbors_side = __pyx_v_self->_simple_neighbors_side;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/model.pyx":132 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_data->__pyx_base.__pyx_base.__pyx_vtab)->_build_display_list(__pyx_v_data);

  /* "/home/jiba/src/soya/model/model.pyx":134 */
  __pyx_v_data->_option = (__pyx_v_data->_option & (~__pyx_e_5_soya_MODEL_DISPLAY_LISTS));

  /* "/home/jiba/src/soya/model/model.pyx":135 */
  __pyx_v_data->_option = (__pyx_v_data->_option & (~__pyx_e_5_soya_MODEL_INITED));

  /* "/home/jiba/src/soya/model/model.pyx":136 */
  __pyx_v_data->_option = (__pyx_v_data->_option | __pyx_e_5_soya_MODEL_SHARED_DATA);

  /* "/home/jiba/src/soya/model/model.pyx":137 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_data));
  __pyx_r = (struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_data);
  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._SimpleModel._create_deformed_data");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_self);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

static void __pyx_f_5_soya_12_SimpleModel__get_box(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":143 */
  __pyx_v_coord = __pyx_v_self->_coords;

  /* "/home/jiba/src/soya/model/model.pyx":144 */
  __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 = 144; goto __pyx_L1;}
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":145 */
    point_by_matrix_copy(__pyx_v_coord2,__pyx_v_coord,__pyx_v_matrix);

    /* "/home/jiba/src/soya/model/model.pyx":147 */
    __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/model.pyx":148 */
    __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/model.pyx":149 */
    __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/model.pyx":150 */
    __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/model.pyx":151 */
    __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/model.pyx":152 */
    __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/model.pyx":154 */
    __pyx_v_coord = (__pyx_v_coord + 3);
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SimpleModel._get_box");
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_12_SimpleModel___getcstate__(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  int __pyx_v_i;
  __pyx_t_5_soya_ModelFace (*__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/model.pyx":161 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 161; goto __pyx_L1;}
  Py_DECREF(__pyx_v_material_id2index);
  __pyx_v_material_id2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":162 */
  __pyx_2 = PyObject_Length(__pyx_v_self->_materials); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 162; 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 = 162; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 162; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 162; goto __pyx_L1;}
    __pyx_5 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 162; 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 = 162; 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 = 162; 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 = 162; 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/model.pyx":164 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/model.pyx":165 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/model.pyx":166 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vertices);

  /* "/home/jiba/src/soya/model/model.pyx":167 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_coords);

  /* "/home/jiba/src/soya/model/model.pyx":168 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vnormals);

  /* "/home/jiba/src/soya/model/model.pyx":169 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_colors);

  /* "/home/jiba/src/soya/model/model.pyx":170 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_values);

  /* "/home/jiba/src/soya/model/model.pyx":171 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_faces);

  /* "/home/jiba/src/soya/model/model.pyx":173 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_coords,(3 * __pyx_v_self->_nb_coords));

  /* "/home/jiba/src/soya/model/model.pyx":174 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_vnormals,(3 * __pyx_v_self->_nb_vnormals));

  /* "/home/jiba/src/soya/model/model.pyx":175 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/model.pyx":176 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_values,__pyx_v_self->_nb_values);

  /* "/home/jiba/src/soya/model/model.pyx":178 */
  chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_coords,__pyx_v_self->_nb_vertices);

  /* "/home/jiba/src/soya/model/model.pyx":179 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":180 */
    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/model.pyx":181 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":182 */
    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/model.pyx":183 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":184 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":185 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":187 */
  __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/model.pyx":188 */
    __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/model.pyx":189 */
    chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_face->option);

    /* "/home/jiba/src/soya/model/model.pyx":190 */
    __pyx_3 = PyInt_FromLong(__pyx_v_face->pack->material_id); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 190; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_material_id2index, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 190; 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 = 190; 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/model.pyx":191 */
    chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_face->normal);

    /* "/home/jiba/src/soya/model/model.pyx":192 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_face->v,4);
    __pyx_L9:;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/model.pyx":194 */
  __pyx_6 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_NEIGHBORS);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/model/model.pyx":195 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/model.pyx":196 */
    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/model.pyx":198 */
  __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":199 */
    chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_simple_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/model.pyx":200 */
    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/model.pyx":202 */
  __pyx_5 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 202; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 202; 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._SimpleModel.__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_SimpleModel___setcstate_data__(struct __pyx_obj_5_soya__SimpleModel *__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_ModelFace (*__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/model.pyx":209 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 209; 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 = 209; 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 = 209; 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 = 209; goto __pyx_L1;}

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

  /* "/home/jiba/src/soya/model/model.pyx":212 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/model/model.pyx":213 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vertices));

  /* "/home/jiba/src/soya/model/model.pyx":214 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_coords));

  /* "/home/jiba/src/soya/model/model.pyx":215 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vnormals));

  /* "/home/jiba/src/soya/model/model.pyx":216 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/model.pyx":217 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_values));

  /* "/home/jiba/src/soya/model/model.pyx":218 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_faces));

  /* "/home/jiba/src/soya/model/model.pyx":220 */
  __pyx_v_self->_faces = ((__pyx_t_5_soya_ModelFace (*))malloc((__pyx_v_self->_nb_faces * (sizeof(__pyx_t_5_soya_ModelFace )))));

  /* "/home/jiba/src/soya/model/model.pyx":221 */
  __pyx_v_self->_coords = ((float (*))malloc(((3 * __pyx_v_self->_nb_coords) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":222 */
  __pyx_v_self->_vnormals = ((float (*))malloc(((3 * __pyx_v_self->_nb_vnormals) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":223 */
  __pyx_v_self->_colors = ((float (*))malloc(((4 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":224 */
  __pyx_v_self->_values = ((float (*))malloc((__pyx_v_self->_nb_values * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":226 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_coords,(3 * __pyx_v_self->_nb_coords));

  /* "/home/jiba/src/soya/model/model.pyx":227 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_vnormals,(3 * __pyx_v_self->_nb_vnormals));

  /* "/home/jiba/src/soya/model/model.pyx":228 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/model.pyx":229 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_values,__pyx_v_self->_nb_values);

  /* "/home/jiba/src/soya/model/model.pyx":231 */
  __pyx_v_self->_vertex_coords = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/model.pyx":232 */
  chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_vertex_coords,__pyx_v_self->_nb_vertices);

  /* "/home/jiba/src/soya/model/model.pyx":233 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":233 */
    __pyx_v_self->_vertex_options = ((char (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/model.pyx":233 */
    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/model.pyx":234 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":234 */
    __pyx_v_self->_vertex_texcoords = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":234 */
    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/model.pyx":235 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":235 */
    __pyx_v_self->_vertex_diffuses = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":235 */
    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/model.pyx":236 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":236 */
    __pyx_v_self->_vertex_emissives = ((int (*))malloc((__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":236 */
    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/model.pyx":237 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_HAS_SPHERE);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":237 */
    __pyx_v_self->_sphere = ((float (*))malloc((4 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/model.pyx":237 */
    chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_sphere,4);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/model.pyx":239 */
  __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/model.pyx":240 */
    __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/model.pyx":241 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_face->option));

    /* "/home/jiba/src/soya/model/model.pyx":242 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_temp));

    /* "/home/jiba/src/soya/model/model.pyx":243 */
    __pyx_1 = PyInt_FromLong(__pyx_v_temp); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 243; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 243; 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/model.pyx":244 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/model.pyx":245 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[0])));

    /* "/home/jiba/src/soya/model/model.pyx":246 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[1])));

    /* "/home/jiba/src/soya/model/model.pyx":247 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[2])));

    /* "/home/jiba/src/soya/model/model.pyx":248 */
    chunk_get_int_endian_safe(__pyx_v_chunk,(&(__pyx_v_face->v[3])));
    __pyx_L7:;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/model.pyx":250 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_NEIGHBORS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":251 */
    __pyx_v_self->_neighbors = ((int (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":252 */
    __pyx_v_self->_neighbors_side = ((char (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/model.pyx":253 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/model.pyx":254 */
    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/model.pyx":256 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":257 */
    __pyx_v_self->_simple_neighbors = ((int (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":258 */
    __pyx_v_self->_simple_neighbors_side = ((char (*))malloc(((__pyx_v_self->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/model.pyx":259 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_simple_neighbors,(__pyx_v_self->_nb_faces * 4));

    /* "/home/jiba/src/soya/model/model.pyx":260 */
    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/model.pyx":262 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/model.pyx":264 */
  __pyx_v_self->_option = (__pyx_v_self->_option & (~__pyx_e_5_soya_MODEL_INITED));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._SimpleModel.__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_SimpleModel___setcstate__(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,PyObject *__pyx_v_cstate) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/model.pyx":267 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__setcstate_data__(__pyx_v_self,__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/model.pyx":268 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_build_display_list(__pyx_v_self);

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

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

  /* "/home/jiba/src/soya/model/model.pyx":272 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 272; 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._SimpleModel.option.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/model/model.pyx":276 */
  Py_INCREF(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials);
  __pyx_r = ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials;
  goto __pyx_L0;

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

static PyObject *__pyx_f_5_soya_12_SimpleModel_9nb_coords___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":280 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_coords); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 280; 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._SimpleModel.nb_coords.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_11nb_vertices___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":284 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 284; 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._SimpleModel.nb_vertices.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_8nb_faces___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":288 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 288; 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._SimpleModel.nb_faces.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_get_face(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_SimpleModel_get_face[] = "Debugging functions";
static PyObject *__pyx_f_5_soya_12_SimpleModel_get_face(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_index;
  __pyx_t_5_soya_ModelFace (*__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/model.pyx":293 */
  __pyx_v_face = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_faces + __pyx_v_index);

  /* "/home/jiba/src/soya/model/model.pyx":294 */
  __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 = 294; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((__pyx_v_face->v[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 294; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((__pyx_v_face->v[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 294; goto __pyx_L1;}
    __pyx_5 = PyInt_FromLong((__pyx_v_face->v[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 294; goto __pyx_L1;}
    __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 294; 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 = 295; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((__pyx_v_face->v[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 295; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((__pyx_v_face->v[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 295; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 295; 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._SimpleModel.get_face");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_get_vertex_index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_SimpleModel_get_vertex_index[] = "Debugging functions";
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":299 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_coords[__pyx_v_index])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 299; goto __pyx_L1;}
  __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 299; 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/model.pyx":300 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_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 = 300; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_options[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 300; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 300; 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 = 300; 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 = 301; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 301; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 301; 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 = 301; 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/model.pyx":302 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 302; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_texcoords[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 302; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 302; 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 = 302; 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 = 303; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 303; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 303; 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 = 303; 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/model.pyx":304 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 304; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 304; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 304; 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 = 304; 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 = 305; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 305; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 305; 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 = 305; 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/model.pyx":306 */
  __pyx_3 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_3) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 306; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_emissives[__pyx_v_index])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 306; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 306; 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 = 306; 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 = 307; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong((-1)); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 307; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 307; 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 = 307; 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/model.pyx":308 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 308; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 308; 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 = 308; 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._SimpleModel.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_SimpleModel_get_vertex(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_12_SimpleModel_get_vertex[] = "Debugging functions";
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":312 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_coords[(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_coords[__pyx_v_index])])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_coords[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_coords[__pyx_v_index]) + 1)])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_coords[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_coords[__pyx_v_index]) + 2)])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 312; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 312; 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 = 312; 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/model.pyx":313 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_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 = 313; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_options[__pyx_v_index])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 313; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 313; 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 = 313; 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 = 314; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 314; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 314; 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 = 314; 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/model.pyx":315 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_5) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_values[(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_texcoords[__pyx_v_index])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_values[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_texcoords[__pyx_v_index]) + 1)])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 315; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 315; 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 = 315; 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 = 315; 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 = 316; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong((-1)); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 316; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 316; 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 = 316; 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/model.pyx":317 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
  if (__pyx_5) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; goto __pyx_L1;}
    __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index])])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index]) + 1)])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index]) + 2)])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_diffuses[__pyx_v_index]) + 3)])); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 317; 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 = 317; 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 = 317; 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 = 318; goto __pyx_L1;}
    __pyx_6 = PyInt_FromLong((-1)); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 318; goto __pyx_L1;}
    __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 318; 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 = 318; 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/model.pyx":319 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_5) {
    __pyx_1 = PyObject_GetAttr(__pyx_v_l, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_emissives[__pyx_v_index])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_6 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_emissives[__pyx_v_index]) + 1)])); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_emissives[__pyx_v_index]) + 2)])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_7 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors[((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_emissives[__pyx_v_index]) + 3)])); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 319; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 319; 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 = 319; 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 = 319; 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 = 320; goto __pyx_L1;}
    __pyx_7 = PyInt_FromLong((-1)); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 320; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 320; 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 = 320; 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/model.pyx":321 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 321; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 321; 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 = 321; 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._SimpleModel.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_SimpleModel_get_neighbor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":324 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_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/model.pyx":326 */
  __pyx_v_neighbor = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_neighbors + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/model.pyx":327 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 327; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 327; 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._SimpleModel.get_neighbor");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_get_neighbor_side(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":330 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_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/model.pyx":332 */
  __pyx_v_neighbor_side = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_neighbors_side + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/model.pyx":333 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor_side[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 333; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor_side[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 333; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor_side[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 333; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor_side[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 333; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 333; 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._SimpleModel.get_neighbor_side");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_get_simple_neighbor(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":336 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_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/model.pyx":338 */
  __pyx_v_neighbor = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_simple_neighbors + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/model.pyx":339 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 339; 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._SimpleModel.get_simple_neighbor");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SimpleModel_get_simple_neighbor_side(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":342 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_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/model.pyx":344 */
  __pyx_v_neighbor_side = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_simple_neighbors_side + (4 * __pyx_v_index));

  /* "/home/jiba/src/soya/model/model.pyx":345 */
  __pyx_2 = PyInt_FromLong((__pyx_v_neighbor_side[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 345; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_neighbor_side[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 345; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((__pyx_v_neighbor_side[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 345; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong((__pyx_v_neighbor_side[3])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 345; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 345; 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._SimpleModel.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_SimpleModel_6sphere___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SimpleModel_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/model.pyx":349 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_sphere[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_sphere[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_sphere[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_sphere[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 349; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __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._SimpleModel.sphere.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SimpleModel__register_material(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":352 */
  __pyx_1 = PySequence_Contains(__pyx_v_self->_materials, ((PyObject *)__pyx_v_material)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 352; goto __pyx_L1;}
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":353 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 353; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 353; 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 = 353; 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._SimpleModel._register_material");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
}

static void __pyx_f_5_soya_12_SimpleModel__add_coord(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":356 */
  ((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/model.pyx":357 */
  __pyx_v_self->_nb_coords = (__pyx_v_self->_nb_coords + 1);

  /* "/home/jiba/src/soya/model/model.pyx":358 */
  __pyx_1 = ((PyObject *)__pyx_v_vertex->_normal) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":359 */
    ((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/model.pyx":360 */
    vector_normalize((__pyx_v_self->_vnormals + (3 * __pyx_v_self->_nb_vnormals)));

    /* "/home/jiba/src/soya/model/model.pyx":361 */
    __pyx_v_self->_nb_vnormals = (__pyx_v_self->_nb_vnormals + 1);
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._add_coord");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_vertex);
}

static int __pyx_f_5_soya_12_SimpleModel__register_value(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":365 */
  __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/model.pyx":366 */
    __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/model.pyx":367 */
  __pyx_v_r = __pyx_v_self->_nb_values;

  /* "/home/jiba/src/soya/model/model.pyx":368 */
  __pyx_v_self->_nb_values = (__pyx_v_self->_nb_values + __pyx_v_nb);

  /* "/home/jiba/src/soya/model/model.pyx":369 */
  __pyx_v_self->_values = ((float (*))realloc(__pyx_v_self->_values,(__pyx_v_self->_nb_values * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":370 */
  memcpy((__pyx_v_self->_values + __pyx_v_r),__pyx_v_value,(__pyx_v_nb * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/model.pyx":371 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._register_value");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_SimpleModel__register_color(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":376 */
  __pyx_v_ptr = __pyx_v_self->_colors;

  /* "/home/jiba/src/soya/model/model.pyx":377 */
  __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/model.pyx":378 */
    __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/model.pyx":382 */
    __pyx_v_ptr = (__pyx_v_ptr + 4);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":384 */
  __pyx_v_i = (__pyx_v_self->_nb_colors * 4);

  /* "/home/jiba/src/soya/model/model.pyx":385 */
  __pyx_v_self->_nb_colors = (__pyx_v_self->_nb_colors + 1);

  /* "/home/jiba/src/soya/model/model.pyx":386 */
  __pyx_v_self->_colors = ((float (*))realloc(__pyx_v_self->_colors,((__pyx_v_self->_nb_colors * 4) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":387 */
  memcpy((__pyx_v_self->_colors + __pyx_v_i),__pyx_v_color,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/model.pyx":388 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._register_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k290p;

static char (__pyx_k290[]) = "Face with %s vertices are not supported in model.";

static void __pyx_f_5_soya_12_SimpleModel__add_face(struct __pyx_obj_5_soya__SimpleModel *__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_ModelFace (*__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/model.pyx":395 */
  __pyx_v_sf = (__pyx_v_self->_faces + __pyx_v_self->_nb_faces);

  /* "/home/jiba/src/soya/model/model.pyx":397 */
  __pyx_v_sf->option = 0;

  /* "/home/jiba/src/soya/model/model.pyx":398 */
  (__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/model.pyx":399 */
  __pyx_1 = PyObject_Length(__pyx_v_face->_vertices); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 399; goto __pyx_L1;}
  __pyx_v_nb_vertices = __pyx_1;

  /* "/home/jiba/src/soya/model/model.pyx":400 */
  __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 = 402; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_nb_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 402; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k290p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 402; 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 = 402; 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 = 402; 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 = 402; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":403 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_is_alpha); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 403; 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 = 403; 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/model.pyx":404 */
  __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/model.pyx":405 */
  __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/model.pyx":406 */
  __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/model.pyx":407 */
  __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/model.pyx":411 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 411; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 411; 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 = 411; goto __pyx_L1;}
  (__pyx_v_sf->v[0]) = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":412 */
  __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 412; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 412; 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 = 412; goto __pyx_L1;}
  (__pyx_v_sf->v[1]) = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":413 */
  __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 413; goto __pyx_L1;}
  __pyx_4 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 413; 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 = 413; goto __pyx_L1;}
  (__pyx_v_sf->v[2]) = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":414 */
  __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 = 414; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_face->_vertices, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 414; 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 = 414; goto __pyx_L1;}
    (__pyx_v_sf->v[3]) = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":416 */
  ((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/model.pyx":417 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_PLANE_EQUATION);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":418 */
    __pyx_v_p = (__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[(__pyx_v_sf->v[0])]));

    /* "/home/jiba/src/soya/model/model.pyx":419 */
    (__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/model.pyx":420 */
    plane_vector_normalize(__pyx_v_n);

    /* "/home/jiba/src/soya/model/model.pyx":421 */
    __pyx_v_sf->normal = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":423 */
    vector_normalize(__pyx_v_n);

    /* "/home/jiba/src/soya/model/model.pyx":424 */
    __pyx_v_sf->normal = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":427 */
  __pyx_1 = PySequence_Contains(__pyx_v_self->_materials, ((PyObject *)__pyx_v_face->_material)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 427; 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 = 427; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 427; 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 = 427; 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/model.pyx":428 */
  __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/model.pyx":430 */
  __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._SimpleModel._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_SimpleModel__add_vertex(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":437 */
  __pyx_1 = PyObject_GetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex)); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 437; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 437; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
  __pyx_v_ivertex = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":439 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 439; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex)); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 439; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_ivertex2index, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 439; 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 = 439; 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 = 439; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_coord = __pyx_4;

  /* "/home/jiba/src/soya/model/model.pyx":441 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":442 */
    (__pyx_v_value[0]) = __pyx_v_vertex->_tex_x;

    /* "/home/jiba/src/soya/model/model.pyx":443 */
    (__pyx_v_value[1]) = __pyx_v_vertex->_tex_y;

    /* "/home/jiba/src/soya/model/model.pyx":444 */
    __pyx_v_texcoord = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":447 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":448 */
    __pyx_4 = __pyx_v_vertex->_diffuse == Py_None;
    __pyx_5 = (!__pyx_4);
    if (__pyx_5) {

      /* "/home/jiba/src/soya/model/model.pyx":449 */
      __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 449; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 449; 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 = 449; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (__pyx_v_value[0]) = __pyx_6;

      /* "/home/jiba/src/soya/model/model.pyx":450 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 450; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 450; 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 = 450; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      (__pyx_v_value[1]) = __pyx_6;

      /* "/home/jiba/src/soya/model/model.pyx":451 */
      __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 451; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 451; 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 = 451; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      (__pyx_v_value[2]) = __pyx_6;

      /* "/home/jiba/src/soya/model/model.pyx":452 */
      __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 452; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_vertex->_diffuse, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 452; 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 = 452; 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/model.pyx":454 */
      memcpy(__pyx_v_value,__pyx_v_vertex->_face->_material->_diffuse,(4 * (sizeof(float ))));
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/model.pyx":455 */
    __pyx_v_diffuse = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":458 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":459 */
    __pyx_5 = __pyx_v_vertex->_emissive == Py_None;
    __pyx_4 = (!__pyx_5);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/model/model.pyx":460 */
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 460; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 460; 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 = 460; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      (__pyx_v_value[0]) = __pyx_6;

      /* "/home/jiba/src/soya/model/model.pyx":461 */
      __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 461; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 461; 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 = 461; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      (__pyx_v_value[1]) = __pyx_6;

      /* "/home/jiba/src/soya/model/model.pyx":462 */
      __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 462; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 462; 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 = 462; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      (__pyx_v_value[2]) = __pyx_6;

      /* "/home/jiba/src/soya/model/model.pyx":463 */
      __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 463; goto __pyx_L1;}
      __pyx_1 = PyObject_GetItem(__pyx_v_vertex->_emissive, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 463; 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 = 463; 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/model.pyx":465 */
      (__pyx_v_value[0]) = 0.0;
      (__pyx_v_value[1]) = 0.0;
      (__pyx_v_value[2]) = 0.0;

      /* "/home/jiba/src/soya/model/model.pyx":466 */
      (__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 = 468; goto __pyx_L1;}
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/model.pyx":469 */
    (__pyx_v_value[0]) = 0.0;
    (__pyx_v_value[1]) = 0.0;
    (__pyx_v_value[2]) = 0.0;

    /* "/home/jiba/src/soya/model/model.pyx":470 */
    (__pyx_v_value[3]) = 1.0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/model.pyx":472 */
  __pyx_4 = PyObject_IsTrue(__pyx_v_lights); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 472; goto __pyx_L1;}
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":473 */
    __pyx_3 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 473; 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 = 473; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 473; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
      __pyx_v_light = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":474 */
      ((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/model.pyx":475 */
      __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/model.pyx":477 */
      ((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/model.pyx":478 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_4) {
    __pyx_v_emissive = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":482 */
  __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/model.pyx":483 */
    __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/model.pyx":488 */
  __pyx_v_i = __pyx_v_self->_nb_vertices;

  /* "/home/jiba/src/soya/model/model.pyx":489 */
  __pyx_v_self->_nb_vertices = (__pyx_v_self->_nb_vertices + 1);

  /* "/home/jiba/src/soya/model/model.pyx":490 */
  __pyx_v_self->_vertex_coords = ((int (*))realloc(__pyx_v_self->_vertex_coords,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/model.pyx":491 */
  (__pyx_v_self->_vertex_coords[__pyx_v_i]) = __pyx_v_coord;

  /* "/home/jiba/src/soya/model/model.pyx":493 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":493 */
    __pyx_v_self->_vertex_texcoords = ((int (*))realloc(__pyx_v_self->_vertex_texcoords,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":493 */
    (__pyx_v_self->_vertex_texcoords[__pyx_v_i]) = __pyx_v_texcoord;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/model/model.pyx":494 */
  __pyx_5 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/model.pyx":494 */
    __pyx_v_self->_vertex_diffuses = ((int (*))realloc(__pyx_v_self->_vertex_diffuses,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":494 */
    (__pyx_v_self->_vertex_diffuses[__pyx_v_i]) = __pyx_v_diffuse;
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/jiba/src/soya/model/model.pyx":495 */
  __pyx_4 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/model.pyx":495 */
    __pyx_v_self->_vertex_emissives = ((int (*))realloc(__pyx_v_self->_vertex_emissives,(__pyx_v_self->_nb_vertices * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":495 */
    (__pyx_v_self->_vertex_emissives[__pyx_v_i]) = __pyx_v_emissive;
    goto __pyx_L17;
  }
  __pyx_L17:;

  /* "/home/jiba/src/soya/model/model.pyx":496 */
  __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._SimpleModel._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_face;
static PyObject *__pyx_n_normal;
static PyObject *__pyx_n_angle_to;
static PyObject *__pyx_n_sort;

static char (__pyx_k291[]) = "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_SimpleModel__identify_vertices(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":510 */
  __pyx_k291;

  /* "/home/jiba/src/soya/model/model.pyx":520 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 520; goto __pyx_L1;}
  Py_DECREF(__pyx_v_vertex2ivertex);
  __pyx_v_vertex2ivertex = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":521 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 521; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2vertices);
  __pyx_v_ivertex2vertices = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":522 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 522; goto __pyx_L1;}
  Py_DECREF(__pyx_v_hashcube);
  __pyx_v_hashcube = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":523 */
  __pyx_1 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 523; 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 = 523; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 523; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":524 */
    __pyx_2 = PyObject_GetIter(__pyx_v_face->_vertices); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 524; 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 = 524; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 524; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":525 */
      ((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/model.pyx":526 */
      (__pyx_v_p[0]) = (((float )((int )((__pyx_v_p[0]) / EPSILON))) * EPSILON);

      /* "/home/jiba/src/soya/model/model.pyx":527 */
      (__pyx_v_p[1]) = (((float )((int )((__pyx_v_p[1]) / EPSILON))) * EPSILON);

      /* "/home/jiba/src/soya/model/model.pyx":528 */
      (__pyx_v_p[2]) = (((float )((int )((__pyx_v_p[2]) / EPSILON))) * EPSILON);

      /* "/home/jiba/src/soya/model/model.pyx":530 */
      __pyx_3 = PyFloat_FromDouble((__pyx_v_p[0])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 530; goto __pyx_L1;}
      __pyx_4 = PyFloat_FromDouble((__pyx_v_p[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 530; goto __pyx_L1;}
      __pyx_5 = PyFloat_FromDouble((__pyx_v_p[2])); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 530; goto __pyx_L1;}
      __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 530; 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/model.pyx":531 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_hashcube, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 531; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 531; 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 = 531; 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 = 531; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
      __pyx_v_ivertex = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":532 */
      __pyx_7 = ((PyObject *)__pyx_v_ivertex) == Py_None;
      if (__pyx_7) {

        /* "/home/jiba/src/soya/model/model.pyx":533 */
        if (PyObject_SetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex), ((PyObject *)__pyx_v_vertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 533; goto __pyx_L1;}
        if (PyObject_SetItem(__pyx_v_hashcube, __pyx_v_hash, ((PyObject *)__pyx_v_vertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 533; 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/model.pyx":534 */
        __pyx_6 = PyList_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 534; 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 = 534; goto __pyx_L1;}
        Py_DECREF(__pyx_6); __pyx_6 = 0;
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/model.pyx":536 */
        if (PyObject_SetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_vertex), ((PyObject *)__pyx_v_ivertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 536; goto __pyx_L1;}

        /* "/home/jiba/src/soya/model/model.pyx":537 */
        __pyx_3 = PyObject_GetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_ivertex)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 537; goto __pyx_L1;}
        __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 537; 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 = 537; 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 = 537; 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/model.pyx":539 */
  __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 = 539; 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/model.pyx":586 */
  __pyx_4 = PyDict_New(); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 586; goto __pyx_L1;}
  Py_DECREF(__pyx_v_vertex2ivertex2);
  __pyx_v_vertex2ivertex2 = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":587 */
  __pyx_5 = PyDict_New(); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 587; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2vertices2);
  __pyx_v_ivertex2vertices2 = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":588 */
  __pyx_6 = PyList_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 588; 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 = 588; 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 = 588; 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/model.pyx":589 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_values); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 589; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 589; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 589; 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 = 589; 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 = 589; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_vertices);
    __pyx_v_vertices = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":590 */
    __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 590; goto __pyx_L1;}
    Py_DECREF(__pyx_v_couples);
    __pyx_v_couples = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":591 */
    __pyx_7 = PyObject_Length(__pyx_v_vertices); if (__pyx_7 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 591; goto __pyx_L1;}
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_7; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/model.pyx":592 */
      __pyx_8 = PyObject_Length(__pyx_v_vertices); if (__pyx_8 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 592; goto __pyx_L1;}
      for (__pyx_v_j = (__pyx_v_i + 1); __pyx_v_j < __pyx_8; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/model.pyx":593 */
        __pyx_3 = PyObject_GetAttr(__pyx_v_couples, __pyx_n_append); if (!__pyx_3) {__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_v_vertices, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; 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 = 593; 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 = 593; 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 = 593; 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 = 593; goto __pyx_L1;}
        __pyx_2 = PyObject_GetItem(__pyx_v_vertices, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; 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 = 593; 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 = 593; 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 = 593; 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 = 593; 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 = 593; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_v_vertices, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; 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 = 593; goto __pyx_L1;}
        __pyx_5 = PyObject_GetItem(__pyx_v_vertices, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 593; 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 = 593; 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 = 593; 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 = 593; 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/model.pyx":595 */
    __pyx_5 = PyObject_GetAttr(__pyx_v_couples, __pyx_n_sort); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 595; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 595; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_5, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 595; 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/model.pyx":597 */
    __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 597; goto __pyx_L1;}
    Py_DECREF(__pyx_v_shared_vertices);
    __pyx_v_shared_vertices = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":598 */
    __pyx_4 = PyObject_GetIter(__pyx_v_vertices); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 598; 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 = 598; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 598; 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 = 598; 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 = 598; 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 = 598; 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 = 598; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
    }
    __pyx_L15:;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":600 */
    __pyx_5 = PyObject_GetIter(__pyx_v_couples); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 600; 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 = 600; goto __pyx_L1;}
        break;
      }
      __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 600; goto __pyx_L1;}
      __pyx_9 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 600; 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 = 600; 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 = 600; goto __pyx_L1;}
      if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 600; 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 = 600; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":601 */
      __pyx_8 = (__pyx_v_a > __pyx_v_angle);
      if (__pyx_8) {
        goto __pyx_L17;
        goto __pyx_L18;
      }
      __pyx_L18:;

      /* "/home/jiba/src/soya/model/model.pyx":602 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_shared_vertices, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 602; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 602; 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 = 602; 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/model.pyx":603 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_shared_vertices, __pyx_n_get); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 603; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 603; 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 = 603; 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/model.pyx":604 */
      __pyx_1 = PyNumber_Or(__pyx_v_shared_vertex1, __pyx_v_shared_vertex2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 604; goto __pyx_L1;}
      Py_DECREF(__pyx_v_shared_vertex);
      __pyx_v_shared_vertex = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":605 */
      __pyx_4 = PyObject_GetIter(__pyx_v_shared_vertex); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 605; 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 = 605; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 605; 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 = 605; 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/model.pyx":607 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_shared_vertices, __pyx_n_values); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 607; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 607; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 607; 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 = 607; 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 = 607; 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 = 607; 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 = 607; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_shared_vertex);
      __pyx_v_shared_vertex = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":608 */
      __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_list); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 608; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 608; 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 = 608; 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/model.pyx":609 */
      __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_shared_vertex, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 609; 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 = 609; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
      __pyx_v_ivertex = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":610 */
      if (PyObject_SetItem(__pyx_v_ivertex2vertices2, ((PyObject *)__pyx_v_ivertex), __pyx_v_shared_vertex) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 610; goto __pyx_L1;}

      /* "/home/jiba/src/soya/model/model.pyx":611 */
      __pyx_4 = PyObject_GetIter(__pyx_v_shared_vertex); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 611; 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 = 611; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 611; goto __pyx_L1;}
        Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
        __pyx_v_vertex = __pyx_5;
        __pyx_5 = 0;

        /* "/home/jiba/src/soya/model/model.pyx":612 */
        if (PyObject_SetItem(__pyx_v_vertex2ivertex2, ((PyObject *)__pyx_v_vertex), ((PyObject *)__pyx_v_ivertex)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 612; 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/model.pyx":614 */
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 614; 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._SimpleModel._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_SimpleModel__compute_face_normals(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":618 */
  __pyx_1 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 618; 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 = 618; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 618; 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._SimpleModel._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_SimpleModel__compute_vertex_normals(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":622 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_keys); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 622; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 622; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 622; 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 = 622; 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 = 622; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 622; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":623 */
    __pyx_3 = PyObject_GetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_ivertex)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 623; goto __pyx_L1;}
    __pyx_2 = PyObject_GetIter(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 623; 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 = 623; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 623; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":624 */
      __pyx_4 = (__pyx_v_vertex->_face->__pyx_base._option & __pyx_e_5_soya_FACE2_SMOOTH_LIT);
      if (__pyx_4) {

        /* "/home/jiba/src/soya/model/model.pyx":625 */
        __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 = 625; 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 = 625; goto __pyx_L1;}
          __pyx_6 = PyTuple_New(0); if (!__pyx_6) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 625; goto __pyx_L1;}
          __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_6); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 625; 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 = 625; 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 = 625; 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 = 625; 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/model.pyx":626 */
        ((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/model.pyx":627 */
        __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_ivertex->_normal), __pyx_n_add_mul_vector); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 627; 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 = 627; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 627; 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 = 627; 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._SimpleModel._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_SimpleModel__compute_face_neighbors(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":636 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/model.pyx":637 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 637; goto __pyx_L1;}
  Py_DECREF(__pyx_v_face2index);
  __pyx_v_face2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":638 */
  __pyx_1 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; 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 = 638; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 638; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":639 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    if (PyObject_SetItem(__pyx_v_face2index, ((PyObject *)__pyx_v_face), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 639; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":640 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":642 */
  __pyx_2 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 642; 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 = 642; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 642; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":643 */
    __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 643; goto __pyx_L1;}
    __pyx_3 = PyObject_Length(__pyx_1); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 643; 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/model.pyx":644 */
      (__pyx_v_neighbor[__pyx_v_i]) = (-1);

      /* "/home/jiba/src/soya/model/model.pyx":646 */
      __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 646; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 646; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 646; 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 = 646; 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 = 646; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_v1));
      __pyx_v_v1 = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":647 */
      __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; goto __pyx_L1;}
      __pyx_6 = PyObject_Length(__pyx_5); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; 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 = 647; goto __pyx_L1;}
      __pyx_6 = PyObject_IsTrue(__pyx_4); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; 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 = 647; goto __pyx_L1;}
        __pyx_5 = PyInt_FromLong((__pyx_v_i + 1)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; 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 = 647; 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 = 647; goto __pyx_L1;}
        __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; goto __pyx_L1;}
        __pyx_4 = PyObject_GetItem(__pyx_1, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 647; 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 = 647; 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 = 647; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_v2));
      __pyx_v_v2 = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":649 */
      __pyx_5 = PyObject_GetItem(__pyx_v_ivertex2vertices, ((PyObject *)__pyx_v_v1)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 649; goto __pyx_L1;}
      __pyx_4 = PyObject_GetIter(__pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 649; 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 = 649; goto __pyx_L1;}
          break;
        }
        if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 649; 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/model.pyx":653 */
        __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/model.pyx":655 */
        __pyx_6 = ((PyObject *)__pyx_v_v1_neighbor->_face) == ((PyObject *)__pyx_v_face);
        __pyx_7 = (!__pyx_6);
        if (__pyx_7) {

          /* "/home/jiba/src/soya/model/model.pyx":656 */
          __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_v1_neighbor->_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 656; goto __pyx_L1;}
          __pyx_1 = PyObject_GetIter(__pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 656; 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 = 656; goto __pyx_L1;}
              break;
            }
            if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 656; 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/model.pyx":657 */
            __pyx_5 = PyObject_GetItem(__pyx_v_vertex2ivertex, ((PyObject *)__pyx_v_v2_neighbor)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 657; 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/model.pyx":659 */
              __pyx_5 = PyObject_GetItem(__pyx_v_face2index, ((PyObject *)__pyx_v_v1_neighbor->_face)); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
              __pyx_7 = PyInt_AsLong(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 659; goto __pyx_L1;}
              Py_DECREF(__pyx_5); __pyx_5 = 0;
              (__pyx_v_neighbor[__pyx_v_i]) = __pyx_7;

              /* "/home/jiba/src/soya/model/model.pyx":661 */
              __pyx_6 = (__pyx_v_face->__pyx_base._option & __pyx_e_5_soya_FACE2_DOUBLE_SIDED);
              if (__pyx_6) {

                /* "/home/jiba/src/soya/model/model.pyx":662 */
                __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_v1_neighbor->_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 662; goto __pyx_L1;}
                __pyx_8 = PyObject_GetAttr(__pyx_5, __pyx_n_index); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 662; 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 = 662; 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 = 662; 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 = 662; goto __pyx_L1;}
                Py_DECREF(__pyx_9); __pyx_9 = 0;
                __pyx_v_v1_neighbor_index = __pyx_7;

                /* "/home/jiba/src/soya/model/model.pyx":663 */
                __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_v1_neighbor->_face), __pyx_n_vertices); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 663; goto __pyx_L1;}
                __pyx_5 = PyObject_GetAttr(__pyx_8, __pyx_n_index); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 663; 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 = 663; 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 = 663; 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 = 663; goto __pyx_L1;}
                Py_DECREF(__pyx_8); __pyx_8 = 0;
                __pyx_v_v2_neighbor_index = __pyx_6;

                /* "/home/jiba/src/soya/model/model.pyx":664 */
                __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/model.pyx":665 */
                  (__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/model.pyx":669 */
              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/model.pyx":671 */
          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/model.pyx":673 */
    __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_face), __pyx_n_vertices); if (!__pyx_5) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 673; goto __pyx_L1;}
    __pyx_6 = PyObject_Length(__pyx_5); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 673; 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/model.pyx":674 */
    __pyx_v_neighbor = (__pyx_v_neighbor + 4);

    /* "/home/jiba/src/soya/model/model.pyx":675 */
    __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._SimpleModel._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_SimpleModel___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_12_SimpleModel___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 = 677; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model.pyx":684 */
  __pyx_v_chunk = chunk_new();

  /* "/home/jiba/src/soya/model/model.pyx":686 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 686; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":690 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 690; goto __pyx_L1;}
  Py_DECREF(__pyx_v_faces);
  __pyx_v_faces = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":691 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_world), __pyx_n_recursive); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 691; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 691; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 691; 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 = 691; 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 = 691; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 691; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_coordsyst));
    __pyx_v_coordsyst = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":692 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 692; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 692; 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 = 692; 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 = 692; 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 = 692; goto __pyx_L1;}
    }
    __pyx_5 = PyObject_IsTrue(__pyx_3); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 692; 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 = 692; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 692; 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 = 692; 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/model.pyx":695 */
  ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option | __pyx_v_option);

  /* "/home/jiba/src/soya/model/model.pyx":696 */
  __pyx_5 = PyObject_IsTrue(__pyx_v_lights); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 696; goto __pyx_L1;}
  if (__pyx_5) {
    ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option | (__pyx_e_5_soya_MODEL_STATIC_LIT + __pyx_e_5_soya_MODEL_EMISSIVES));
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/model.pyx":698 */
  __pyx_2 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 698; 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 = 698; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 698; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":699 */
    __pyx_3 = PyObject_GetIter(__pyx_v_face->_vertices); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 699; 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 = 699; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 699; goto __pyx_L1;}
      Py_DECREF((PyObject *)((PyObject *)__pyx_v_vertex));
      __pyx_v_vertex = __pyx_1;
      __pyx_1 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":700 */
      __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__SimpleModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option | __pyx_e_5_soya_MODEL_TEXCOORDS);
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/model/model.pyx":701 */
      __pyx_6 = __pyx_v_vertex->_diffuse == Py_None;
      __pyx_5 = (!__pyx_6);
      if (__pyx_5) {
        ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option | __pyx_e_5_soya_MODEL_DIFFUSES);
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/model/model.pyx":702 */
      __pyx_6 = __pyx_v_vertex->_emissive == Py_None;
      __pyx_5 = (!__pyx_6);
      if (__pyx_5) {
        ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option | __pyx_e_5_soya_MODEL_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/model.pyx":704 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_face_normals(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_faces);

  /* "/home/jiba/src/soya/model/model.pyx":705 */
  __pyx_4 = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_identify_vertices(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_faces,__pyx_v_angle); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 705; goto __pyx_L1;}
  __pyx_1 = __Pyx_UnpackItem(__pyx_4, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 705; 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 = 705; 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 = 705; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":706 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_vertex_normals(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_faces,__pyx_v_vertex2ivertex,__pyx_v_ivertex2vertices);

  /* "/home/jiba/src/soya/model/model.pyx":709 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/model.pyx":710 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 710; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertices);
  __pyx_v_ivertices = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":711 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 711; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ivertex2index);
  __pyx_v_ivertex2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":712 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_keys); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 712; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 712; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 712; 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 = 712; 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 = 712; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 712; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":713 */
    __pyx_6 = ((PyObject *)__pyx_v_ivertex->_normal) == Py_None;
    __pyx_5 = (!__pyx_6);
    if (__pyx_5) {

      /* "/home/jiba/src/soya/model/model.pyx":714 */
      __pyx_4 = PyObject_GetAttr(__pyx_v_ivertices, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 714; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 714; 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 = 714; 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/model.pyx":715 */
      __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 715; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_ivertex2index, ((PyObject *)__pyx_v_ivertex), __pyx_4) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 715; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":716 */
      __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/model.pyx":717 */
  __pyx_6 = PyObject_Length(__pyx_v_ivertices); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 717; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vnormals = ((float (*))malloc(((__pyx_6 * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":718 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_ivertex2vertices, __pyx_n_keys); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 718; 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 = 718; 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 = 718; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 718; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":719 */
    __pyx_5 = ((PyObject *)__pyx_v_ivertex->_normal) == Py_None;
    if (__pyx_5) {

      /* "/home/jiba/src/soya/model/model.pyx":720 */
      __pyx_3 = PyObject_GetAttr(__pyx_v_ivertices, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 720; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 720; 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 = 720; 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/model.pyx":721 */
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 721; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_ivertex2index, ((PyObject *)__pyx_v_ivertex), __pyx_3) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 721; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/jiba/src/soya/model/model.pyx":722 */
      __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/model.pyx":723 */
  __pyx_6 = PyObject_Length(__pyx_v_ivertices); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 723; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_coords = ((float (*))malloc(((__pyx_6 * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/model.pyx":724 */
  __pyx_4 = PyObject_GetIter(__pyx_v_ivertices); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 724; 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 = 724; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Vertex)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 724; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_ivertex));
    __pyx_v_ivertex = __pyx_2;
    __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_add_coord(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_ivertex);
  }
  __pyx_L20:;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":727 */
  __pyx_5 = PyObject_Length(__pyx_v_faces); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 727; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_faces = ((__pyx_t_5_soya_ModelFace (*))malloc((__pyx_5 * (sizeof(__pyx_t_5_soya_ModelFace )))));

  /* "/home/jiba/src/soya/model/model.pyx":728 */
  __pyx_3 = PyObject_GetIter(__pyx_v_faces); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 728; 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 = 728; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Face)) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 728; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_face));
    __pyx_v_face = __pyx_1;
    __pyx_1 = 0;
    ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_add_face(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_face,__pyx_v_vertex2ivertex,__pyx_v_ivertex2index,__pyx_v_lights,(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_STATIC_SHADOW));
  }
  __pyx_L22:;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":731 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_tuple); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 731; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 731; goto __pyx_L1;}
  Py_INCREF(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials);
  PyTuple_SET_ITEM(__pyx_4, 0, ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials);
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 731; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/model.pyx":734 */
  __pyx_6 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_NEIGHBORS);
  if (__pyx_6) {

    /* "/home/jiba/src/soya/model/model.pyx":735 */
    ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_neighbors = ((int (*))malloc(((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":736 */
    ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_neighbors_side = ((char (*))malloc(((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/model.pyx":737 */
    ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_face_neighbors(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_faces,__pyx_v_vertex2ivertex,__pyx_v_ivertex2vertices,((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_neighbors,((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_neighbors_side);
    goto __pyx_L23;
  }
  __pyx_L23:;

  /* "/home/jiba/src/soya/model/model.pyx":740 */
  __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/model.pyx":742 */
    __pyx_3 = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_identify_vertices(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_faces,360.0); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 742; goto __pyx_L1;}
    __pyx_2 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 742; 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 = 742; 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 = 742; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":743 */
    ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_simple_neighbors = ((int (*))malloc(((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_faces * 4) * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/model.pyx":744 */
    ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_simple_neighbors_side = ((char (*))malloc(((((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_nb_faces * 4) * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/model.pyx":745 */
    ((struct __pyx_vtabstruct_5_soya__SimpleModel *)((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_compute_face_neighbors(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_faces,__pyx_v_vertex2ivertex,__pyx_v_ivertex2vertices,((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_simple_neighbors,((struct __pyx_obj_5_soya__SimpleModel *)__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._SimpleModel.__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_SimpleModel__build_sphere(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/model.pyx":751 */
  __pyx_1 = (__pyx_v_self->_nb_coords > 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":752 */
    __pyx_v_self->_sphere = ((float (*))malloc((4 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/model.pyx":753 */
    sphere_from_points(__pyx_v_self->_sphere,__pyx_v_self->_coords,__pyx_v_self->_nb_coords);

    /* "/home/jiba/src/soya/model/model.pyx":754 */
    __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MODEL_HAS_SPHERE);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static void __pyx_f_5_soya_12_SimpleModel__build_display_list(struct __pyx_obj_5_soya__SimpleModel *__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_ModelFace (*__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/model.pyx":764 */
  __pyx_v_display_lists = ((__pyx_t_5_soya_DisplayLists (*))malloc((sizeof(__pyx_t_5_soya_DisplayLists ))));

  /* "/home/jiba/src/soya/model/model.pyx":765 */
  __pyx_v_display_lists->nb_opaque_list = 0;
  __pyx_v_display_lists->nb_alpha_list = 0;

  /* "/home/jiba/src/soya/model/model.pyx":766 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/model.pyx":767 */
  __pyx_v_display_lists->display_lists = 0;

  /* "/home/jiba/src/soya/model/model.pyx":768 */
  for (__pyx_v_k = 0; __pyx_v_k < 2; ++__pyx_v_k) {

    /* "/home/jiba/src/soya/model/model.pyx":769 */
    __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/model.pyx":770 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_j);

      /* "/home/jiba/src/soya/model/model.pyx":771 */
      __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/model.pyx":772 */
        for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

          /* "/home/jiba/src/soya/model/model.pyx":773 */
          __pyx_v_display_list = (__pyx_v_display_lists->display_lists + __pyx_v_i);

          /* "/home/jiba/src/soya/model/model.pyx":774 */
          __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/model.pyx":775 */
            chunk_add_int(__pyx_v_display_list->chunk,__pyx_v_j);

            /* "/home/jiba/src/soya/model/model.pyx":776 */
            goto __pyx_L8;
            goto __pyx_L9;
          }
          __pyx_L9:;
          __pyx_L7:;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/model.pyx":778 */
          __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/model.pyx":779 */
          __pyx_v_display_list = (__pyx_v_display_lists->display_lists + __pyx_v_nb);

          /* "/home/jiba/src/soya/model/model.pyx":780 */
          __pyx_v_display_list->material_id = __pyx_v_face->pack->material_id;

          /* "/home/jiba/src/soya/model/model.pyx":781 */
          __pyx_v_display_list->option = (__pyx_v_face->option & __pyx_e_5_soya_DISPLAY_LIST_OPTIONS);

          /* "/home/jiba/src/soya/model/model.pyx":782 */
          __pyx_v_display_list->chunk = chunk_new();

          /* "/home/jiba/src/soya/model/model.pyx":783 */
          chunk_add_int(__pyx_v_display_list->chunk,__pyx_v_j);

          /* "/home/jiba/src/soya/model/model.pyx":784 */
          __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/model.pyx":786 */
          __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/model.pyx":788 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/model.pyx":789 */
    __pyx_v_display_list = (__pyx_v_display_lists->display_lists + __pyx_v_i);

    /* "/home/jiba/src/soya/model/model.pyx":790 */
    chunk_add_int(__pyx_v_display_list->chunk,(-1));

    /* "/home/jiba/src/soya/model/model.pyx":791 */
    __pyx_v_display_list->faces_id = ((int (*))__pyx_v_display_list->chunk->content);

    /* "/home/jiba/src/soya/model/model.pyx":792 */
    free(__pyx_v_display_list->chunk);
    __pyx_L11:;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/model/model.pyx":796 */
  __pyx_v_self->_display_lists = __pyx_v_display_lists;

  /* "/home/jiba/src/soya/model/model.pyx":797 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MODEL_DISPLAY_LISTS);

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

static PyObject *__pyx_k294p;
static PyObject *__pyx_k295p;

static char (__pyx_k294[]) = "Model supports only triangle or quad faces !";
static char (__pyx_k295[]) = "Model supports only triangle or quad faces !";

static void __pyx_f_5_soya_12_SimpleModel__init_display_list(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self) {
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  __pyx_t_5_soya_ModelFace (*__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/model.pyx":804 */
  __pyx_v_nb = (__pyx_v_self->_display_lists->nb_opaque_list + __pyx_v_self->_display_lists->nb_alpha_list);

  /* "/home/jiba/src/soya/model/model.pyx":805 */
  __pyx_v_display_list = __pyx_v_self->_display_lists->display_lists;

  /* "/home/jiba/src/soya/model/model.pyx":807 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/model.pyx":808 */
    __pyx_v_display_list = (__pyx_v_self->_display_lists->display_lists + __pyx_v_i);

    /* "/home/jiba/src/soya/model/model.pyx":809 */
    __pyx_v_display_list->id = glGenLists(1);

    /* "/home/jiba/src/soya/model/model.pyx":810 */
    __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/model.pyx":811 */
    __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

    /* "/home/jiba/src/soya/model/model.pyx":812 */
    glNewList(__pyx_v_display_list->id,GL_COMPILE);

    /* "/home/jiba/src/soya/model/model.pyx":814 */
    __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/model.pyx":817 */
      if (__Pyx_PrintItem(__pyx_k294p) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 817; goto __pyx_L1;}
      if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 817; goto __pyx_L1;}

      /* "/home/jiba/src/soya/model/model.pyx":818 */
      __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_1) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 818; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 818; goto __pyx_L1;}
      Py_INCREF(__pyx_k295p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k295p);
      __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 818; 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 = 818; goto __pyx_L1;}
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/model.pyx":820 */
    __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/model.pyx":821 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_j);

      /* "/home/jiba/src/soya/model/model.pyx":822 */
      __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/model.pyx":823 */
        __pyx_5 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
        if (__pyx_5) {
          ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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__SimpleModel *)__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/model.pyx":826 */
    glEnd();

    /* "/home/jiba/src/soya/model/model.pyx":827 */
    glEndList();

    /* "/home/jiba/src/soya/model/model.pyx":828 */
    __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":830 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_MODEL_INITED);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleModel._init_display_list");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_option;

static void __pyx_f_5_soya_12_SimpleModel___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_12_SimpleModel___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;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/model.pyx":836 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_DISPLAY_LISTS);
  if (__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_INITED);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":837 */
    __pyx_v_nb = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_display_lists->nb_opaque_list + ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_display_lists->nb_alpha_list);

    /* "/home/jiba/src/soya/model/model.pyx":838 */
    __pyx_v_display_list = ((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_display_lists->display_lists;

    /* "/home/jiba/src/soya/model/model.pyx":839 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/model.pyx":840 */
      __pyx_v_display_list = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":841 */
      glDeleteLists(__pyx_v_display_list->id,1);
      __pyx_L3:;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":843 */
  free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_coords);

  /* "/home/jiba/src/soya/model/model.pyx":845 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_option); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 845; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_e_5_soya_MODEL_SHARED_DATA); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 845; goto __pyx_L1;}
  __pyx_4 = PyNumber_And(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 845; 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 = 845; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_5 = (!__pyx_1);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/model/model.pyx":846 */
    free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_faces);

    /* "/home/jiba/src/soya/model/model.pyx":847 */
    free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vnormals);

    /* "/home/jiba/src/soya/model/model.pyx":848 */
    free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_colors);

    /* "/home/jiba/src/soya/model/model.pyx":849 */
    free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_values);

    /* "/home/jiba/src/soya/model/model.pyx":850 */
    free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_coords);

    /* "/home/jiba/src/soya/model/model.pyx":851 */
    __pyx_1 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
    if (__pyx_1) {
      free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_options);
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/model.pyx":852 */
    __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_TEXCOORDS);
    if (__pyx_5) {
      free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_texcoords);
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/model.pyx":853 */
    __pyx_1 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_DIFFUSES);
    if (__pyx_1) {
      free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_diffuses);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/model.pyx":854 */
    __pyx_5 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_EMISSIVES);
    if (__pyx_5) {
      free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_vertex_emissives);
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/home/jiba/src/soya/model/model.pyx":855 */
    __pyx_1 = (((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_option & __pyx_e_5_soya_MODEL_HAS_SPHERE);
    if (__pyx_1) {
      free(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self)->_sphere);
      goto __pyx_L10;
    }
    __pyx_L10:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._SimpleModel.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleModel__batch(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  float (__pyx_v_sphere[4]);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  /* "/home/jiba/src/soya/model/model.pyx":858 */
  __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":864 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_HAS_SPHERE);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":865 */
    sphere_by_matrix_copy(__pyx_v_sphere,__pyx_v_self->_sphere,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

    /* "/home/jiba/src/soya/model/model.pyx":866 */
    __pyx_1 = (sphere_in_frustum(__pyx_v_5_soya_renderer->root_frustum,__pyx_v_sphere) == 0);
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":868 */
  __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),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/model.pyx":869 */
  __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),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
    goto __pyx_L6;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static PyObject *__pyx_n_P3_VERTEX_ALPHA;

static void __pyx_f_5_soya_12_SimpleModel__batch_face(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__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/model.pyx":876 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":877 */
    __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/model.pyx":881 */
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/model.pyx":883 */
    __pyx_3 = PyInt_FromLong((__pyx_v_self->_vertex_options[(__pyx_v_face->v[0])])); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 883; goto __pyx_L1;}
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_P3_VERTEX_ALPHA); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 883; goto __pyx_L1;}
    __pyx_2 = PyNumber_And(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 883; 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 = 883; 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 = 884; goto __pyx_L1;}
      __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_P3_VERTEX_ALPHA); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 884; goto __pyx_L1;}
      __pyx_2 = PyNumber_And(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 884; 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 = 884; 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 = 885; goto __pyx_L1;}
        __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_P3_VERTEX_ALPHA); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 885; goto __pyx_L1;}
        __pyx_2 = PyNumber_And(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 885; 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 = 885; 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 = 886; goto __pyx_L1;}
        }
      }
    }
    __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 883; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":888 */
      __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/model.pyx":889 */
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":891 */
  __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._SimpleModel._batch_face");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k296p;
static PyObject *__pyx_k297p;

static char (__pyx_k296[]) = "Model supports only triangle or quad faces !";
static char (__pyx_k297[]) = "Model supports only triangle or quad faces !";

static void __pyx_f_5_soya_12_SimpleModel__render(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  __pyx_t_5_soya_DisplayList (*__pyx_v_display_list);
  __pyx_t_5_soya_ModelFace (*__pyx_v_face);
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_start;
  int __pyx_v_end;
  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_body);

  /* "/home/jiba/src/soya/model/model.pyx":898 */
  __pyx_f_5_soya_model_option_activate(__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/model.pyx":899 */
  __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
  if (__pyx_1) {
    glFrontFace(GL_CW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":901 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_DISPLAY_LISTS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":902 */
    __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_MODEL_INITED));
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_init_display_list(__pyx_v_self);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/model.pyx":903 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":904 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/model.pyx":905 */
      __pyx_v_end = __pyx_v_self->_display_lists->nb_opaque_list;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/model.pyx":907 */
      __pyx_v_start = __pyx_v_self->_display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/model.pyx":908 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->_display_lists->nb_alpha_list);
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/model.pyx":909 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/model.pyx":910 */
      __pyx_v_display_list = (__pyx_v_self->_display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":911 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/model.pyx":912 */
      __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/model.pyx":913 */
      glCallList(__pyx_v_display_list->id);

      /* "/home/jiba/src/soya/model/model.pyx":914 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L6:;
    }
    __pyx_L7:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/model.pyx":917 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":918 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/model.pyx":919 */
      __pyx_v_end = __pyx_v_self->_display_lists->nb_opaque_list;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/model.pyx":921 */
      __pyx_v_start = __pyx_v_self->_display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/model.pyx":922 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->_display_lists->nb_alpha_list);
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/model.pyx":923 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/model.pyx":924 */
      __pyx_v_display_list = (__pyx_v_self->_display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":925 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/model.pyx":926 */
      __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/model.pyx":928 */
      __pyx_1 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_TRIANGLE);
      if (__pyx_1) {
        glBegin(GL_TRIANGLES);
        goto __pyx_L11;
      }
      __pyx_1 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_QUAD);
      if (__pyx_1) {
        glBegin(GL_QUADS);
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/model.pyx":931 */
        if (__Pyx_PrintItem(__pyx_k296p) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 931; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 931; goto __pyx_L1;}

        /* "/home/jiba/src/soya/model/model.pyx":932 */
        __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 932; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 932; goto __pyx_L1;}
        Py_INCREF(__pyx_k297p);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k297p);
        __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 932; 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 = 932; goto __pyx_L1;}
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/model/model.pyx":934 */
      __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/model.pyx":935 */
        __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_j);

        /* "/home/jiba/src/soya/model/model.pyx":936 */
        __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/model.pyx":937 */
          __pyx_5 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
          if (__pyx_5) {
            ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_quad(__pyx_v_self,__pyx_v_face);
            goto __pyx_L15;
          }
          /*else*/ {
            ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle(__pyx_v_self,__pyx_v_face);
          }
          __pyx_L15:;
          goto __pyx_L14;
        }
        __pyx_L14:;
        __pyx_L12:;
      }
      __pyx_L13:;

      /* "/home/jiba/src/soya/model/model.pyx":940 */
      glEnd();

      /* "/home/jiba/src/soya/model/model.pyx":942 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L9:;
    }
    __pyx_L10:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":944 */
  __pyx_5 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
  if (__pyx_5) {
    glFrontFace(GL_CCW);
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/jiba/src/soya/model/model.pyx":945 */
  __pyx_f_5_soya_model_option_inactivate(__pyx_v_self->_option);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleModel._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_12_SimpleModel__raypick(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":950 */
  __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/model.pyx":951 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":952 */
  __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/model.pyx":953 */
    ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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._SimpleModel._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_SimpleModel__raypick_b(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":958 */
  __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/model.pyx":959 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":960 */
  __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/model.pyx":961 */
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":962 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._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_SimpleModel__face_raypick(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__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/model.pyx":969 */
  __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/model.pyx":970 */
  __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/model.pyx":971 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":972 */
    __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/model.pyx":974 */
    __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/model.pyx":976 */
  __pyx_1 = (__pyx_v_r != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":977 */
    __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/model.pyx":978 */
    __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/model.pyx":979 */
      __pyx_v_data->result = __pyx_v_z;

      /* "/home/jiba/src/soya/model/model.pyx":980 */
      __pyx_v_data->root_result = __pyx_v_root_z;

      /* "/home/jiba/src/soya/model/model.pyx":981 */
      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/model.pyx":982 */
      __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/model.pyx":984 */
        __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/model.pyx":985 */
          (__pyx_v_data->normal[0]) = (-((__pyx_v_self->_values + __pyx_v_face->normal)[0]));

          /* "/home/jiba/src/soya/model/model.pyx":986 */
          (__pyx_v_data->normal[1]) = (-((__pyx_v_self->_values + __pyx_v_face->normal)[1]));

          /* "/home/jiba/src/soya/model/model.pyx":987 */
          (__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._SimpleModel._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_SimpleModel__face_raypick_b(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__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/model.pyx":994 */
  __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/model.pyx":995 */
  __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/model.pyx":996 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":997 */
    __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/model.pyx":999 */
    __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/model.pyx":1000 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._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_SimpleModel__collect_raypickables(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":1003 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":1004 */
    chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_parent)));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._SimpleModel._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static void __pyx_f_5_soya_12_SimpleModel__render_triangle(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__pyx_v_face)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/model.pyx":1007 */
  __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/model.pyx":1008 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":1009 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":1010 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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._SimpleModel._render_triangle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleModel__render_quad(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__pyx_v_face)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/model.pyx":1013 */
  __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/model.pyx":1014 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":1015 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":1016 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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/model.pyx":1017 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__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._SimpleModel._render_quad");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_12_SimpleModel__render_vertex(struct __pyx_obj_5_soya__SimpleModel *__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/model.pyx":1020 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":1021 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":1022 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_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/model.pyx":1023 */
  __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/model.pyx":1024 */
  glVertex3fv((__pyx_v_self->_coords + (__pyx_v_self->_vertex_coords[__pyx_v_index])));

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

static int __pyx_f_5_soya_12_SimpleModel__shadow(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst,struct __pyx_obj_5_soya__Light *__pyx_v_light) {
  int __pyx_v_displaylist;
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  float (__pyx_v_coord[4]);
  float (__pyx_v_cone[9]);
  float __pyx_v_b;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  GLuint __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_coord_syst);
  Py_INCREF((PyObject *)__pyx_v_light);

  /* "/home/jiba/src/soya/model/model.pyx":1033 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_MODEL_SHADOW));
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":1041 */
  __pyx_v_b = __pyx_v_5_soya_renderer->current_camera->_back;

  /* "/home/jiba/src/soya/model/model.pyx":1042 */
  ((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/model.pyx":1043 */
  __pyx_1 = (__pyx_v_light->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1044 */
    cone_from_sphere_and_vector(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/model.pyx":1046 */
    __pyx_1 = (cone_from_sphere_and_origin(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b) == 0);
    if (__pyx_1) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":1048 */
  __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/model.pyx":1049 */
  (__pyx_v_coord[0]) = (0.5 * ((__pyx_v_frustum->points[0]) + (__pyx_v_frustum->points[6])));

  /* "/home/jiba/src/soya/model/model.pyx":1050 */
  (__pyx_v_coord[1]) = (0.5 * ((__pyx_v_frustum->points[1]) + (__pyx_v_frustum->points[7])));

  /* "/home/jiba/src/soya/model/model.pyx":1051 */
  (__pyx_v_coord[2]) = (0.5 * ((__pyx_v_frustum->points[2]) + (__pyx_v_frustum->points[8])));

  /* "/home/jiba/src/soya/model/model.pyx":1052 */
  (__pyx_v_coord[3]) = point_distance_to(__pyx_v_coord,__pyx_v_frustum->points);

  /* "/home/jiba/src/soya/model/model.pyx":1054 */
  __pyx_1 = (__pyx_v_coord_syst->_option & __pyx_e_5_soya_COORDSYS_STATIC);
  if (__pyx_1) {
    __pyx_1 = (__pyx_v_light->__pyx_base._option & __pyx_e_5_soya_COORDSYS_STATIC);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1056 */
    __pyx_1 = sphere_is_in_cone(__pyx_v_coord,__pyx_v_cone);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":1057 */
      __pyx_r = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_build_shadow(__pyx_v_self,__pyx_v_coord_syst,__pyx_v_light,1,__pyx_v_5_soya_SHADOW_DISPLAY_LIST);
      goto __pyx_L0;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/model.pyx":1060 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_light->_static_shadow_displaylists, __pyx_n_get); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1060; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong((-1)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1060; goto __pyx_L1;}
      __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1060; goto __pyx_L1;}
      Py_INCREF((PyObject *)((PyObject *)__pyx_v_coord_syst));
      PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_coord_syst));
      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[17]; __pyx_lineno = 1060; 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[17]; __pyx_lineno = 1060; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_v_displaylist = __pyx_1;

      /* "/home/jiba/src/soya/model/model.pyx":1061 */
      __pyx_1 = (__pyx_v_displaylist == (-1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1062 */
        __pyx_5 = glGenLists(1);
        __pyx_v_displaylist = __pyx_5;
        __pyx_2 = PyInt_FromLong(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1062; goto __pyx_L1;}
        if (PyObject_SetItem(__pyx_v_light->_static_shadow_displaylists, ((PyObject *)__pyx_v_coord_syst), __pyx_2) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1062; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;

        /* "/home/jiba/src/soya/model/model.pyx":1065 */
        ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_build_shadow(__pyx_v_self,__pyx_v_coord_syst,__pyx_v_light,0,__pyx_v_displaylist);
        goto __pyx_L7;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/model.pyx":1069 */
        glStencilFunc(GL_ALWAYS,1,4294967295);

        /* "/home/jiba/src/soya/model/model.pyx":1070 */
        glFrontFace(GL_CW);

        /* "/home/jiba/src/soya/model/model.pyx":1071 */
        glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);

        /* "/home/jiba/src/soya/model/model.pyx":1072 */
        glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

        /* "/home/jiba/src/soya/model/model.pyx":1073 */
        glCallList(__pyx_v_displaylist);

        /* "/home/jiba/src/soya/model/model.pyx":1075 */
        glFrontFace(GL_CCW);

        /* "/home/jiba/src/soya/model/model.pyx":1076 */
        glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

        /* "/home/jiba/src/soya/model/model.pyx":1077 */
        glCallList(__pyx_v_displaylist);
      }
      __pyx_L7:;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/model.pyx":1079 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/model.pyx":1082 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_light->_static_shadow_displaylists, __pyx_n_get); if (!__pyx_4) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1082; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong((-1)); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1082; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1082; goto __pyx_L1;}
    Py_INCREF((PyObject *)((PyObject *)__pyx_v_coord_syst));
    PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_coord_syst));
    PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1082; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_1 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1082; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_displaylist = __pyx_1;

    /* "/home/jiba/src/soya/model/model.pyx":1083 */
    __pyx_1 = (__pyx_v_displaylist != (-1));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":1084 */
      if (PyObject_DelItem(__pyx_v_light->_static_shadow_displaylists, ((PyObject *)__pyx_v_coord_syst)) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1084; goto __pyx_L1;}
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/model.pyx":1086 */
    __pyx_r = ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_build_shadow(__pyx_v_self,__pyx_v_coord_syst,__pyx_v_light,sphere_is_in_cone(__pyx_v_coord,__pyx_v_cone),__pyx_v_5_soya_SHADOW_DISPLAY_LIST);
    goto __pyx_L0;
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._SimpleModel._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 PyObject *__pyx_n_has_key;

static PyObject *__pyx_k298p;

static char (__pyx_k298[]) = "* Soya * warning : drawing shadow for non-closed model (can't join segments)!";

static int __pyx_f_5_soya_12_SimpleModel__build_shadow(struct __pyx_obj_5_soya__SimpleModel *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coord_syst,struct __pyx_obj_5_soya__Light *__pyx_v_light,int __pyx_v_camera_inside_shadow,int __pyx_v_displaylist) {
  __pyx_t_5_soya_ModelFace (*__pyx_v_face);
  __pyx_t_5_soya_ModelFace (*__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_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/model.pyx":1090 */
  __pyx_1 = (!(__pyx_v_self->_option & __pyx_e_5_soya_MODEL_SHADOW));
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":1109 */
  __pyx_v_b = __pyx_v_5_soya_renderer->current_camera->_back;

  /* "/home/jiba/src/soya/model/model.pyx":1114 */
  __pyx_1 = (__pyx_v_light->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1116 */
    __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/model.pyx":1117 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":1118 */
      __pyx_2 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/model.pyx":1119 */
        __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/model.pyx":1123 */
          goto __pyx_L4;
          goto __pyx_L7;
        }
        __pyx_L7:;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/model.pyx":1125 */
      __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/model.pyx":1126 */
        __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/model.pyx":1128 */
        __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/model.pyx":1132 */
    __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/model.pyx":1133 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":1134 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_MODEL_VERTEX_OPTIONS);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1135 */
        __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/model.pyx":1139 */
          goto __pyx_L9;
          goto __pyx_L12;
        }
        __pyx_L12:;
        goto __pyx_L11;
      }
      __pyx_L11:;

      /* "/home/jiba/src/soya/model/model.pyx":1141 */
      __pyx_v_normal = (__pyx_v_self->_values + __pyx_v_face->normal);

      /* "/home/jiba/src/soya/model/model.pyx":1142 */
      __pyx_1 = ((((((__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_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1143 */
        __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_LIGHT_BACK)) | __pyx_e_5_soya_FACE_LIGHT_FRONT);
        goto __pyx_L13;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/model.pyx":1145 */
        __pyx_v_face->option = ((__pyx_v_face->option & (~__pyx_e_5_soya_FACE_LIGHT_FRONT)) | __pyx_e_5_soya_FACE_LIGHT_BACK);
      }
      __pyx_L13:;
      __pyx_L9:;
    }
    __pyx_L10:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/model.pyx":1148 */
  glStencilFunc(GL_ALWAYS,1,4294967295);

  /* "/home/jiba/src/soya/model/model.pyx":1149 */
  glFrontFace(GL_CW);

  /* "/home/jiba/src/soya/model/model.pyx":1150 */
  glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);

  /* "/home/jiba/src/soya/model/model.pyx":1151 */
  glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

  /* "/home/jiba/src/soya/model/model.pyx":1152 */
  glNewList(__pyx_v_displaylist,GL_COMPILE_AND_EXECUTE);

  /* "/home/jiba/src/soya/model/model.pyx":1161 */
  __pyx_1 = (__pyx_v_camera_inside_shadow == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1165 */
    __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/model.pyx":1167 */
    __pyx_v_chunk = get_chunk();

    /* "/home/jiba/src/soya/model/model.pyx":1168 */
    __pyx_v_chunk2 = get_chunk();

    /* "/home/jiba/src/soya/model/model.pyx":1169 */
    __pyx_v_nb_inter = 0;
    __pyx_v_nb_segment = 0;

    /* "/home/jiba/src/soya/model/model.pyx":1172 */
    __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/model.pyx":1173 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":1175 */
      __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1177 */
        __pyx_v_neighbors = (__pyx_v_self->_simple_neighbors + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/model.pyx":1178 */
        __pyx_v_neighbors_side = (__pyx_v_self->_simple_neighbors_side + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/model.pyx":1179 */
        __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
        if (__pyx_1) {
          __pyx_v_nbv = 4;
          goto __pyx_L18;
        }
        /*else*/ {
          __pyx_v_nbv = 3;
        }
        __pyx_L18:;

        /* "/home/jiba/src/soya/model/model.pyx":1182 */
        for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nbv; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/model/model.pyx":1183 */
          __pyx_v_neighbor_face = (__pyx_v_self->_faces + (__pyx_v_neighbors[__pyx_v_k]));

          /* "/home/jiba/src/soya/model/model.pyx":1185 */
          __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED));
          if (__pyx_1) {
            __pyx_1 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
            if (!__pyx_1) {
              __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
            }
          }
          if (!__pyx_1) {
            __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
            if (__pyx_1) {
              __pyx_1 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
              if (!__pyx_1) {
                __pyx_1 = ((__pyx_v_neighbors_side[__pyx_v_k]) == (-1));
                if (__pyx_1) {
                  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                  if (__pyx_1) {
                    __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                  }
                  if (!__pyx_1) {
                    __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                    if (__pyx_1) {
                      __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                  }
                }
                if (!__pyx_1) {
                  __pyx_1 = ((__pyx_v_neighbors_side[__pyx_v_k]) == 1);
                  if (__pyx_1) {
                    __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    if (__pyx_1) {
                      __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                    if (!__pyx_1) {
                      __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      if (__pyx_1) {
                        __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      }
                    }
                  }
                }
              }
            }
          }
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/model.pyx":1194 */
            __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_1) {

              /* "/home/jiba/src/soya/model/model.pyx":1195 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/model/model.pyx":1196 */
              __pyx_1 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_1) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L23;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L23:;
              goto __pyx_L22;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/model.pyx":1199 */
              __pyx_1 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_1) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L24;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L24:;

              /* "/home/jiba/src/soya/model/model.pyx":1201 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L22:;

            /* "/home/jiba/src/soya/model/model.pyx":1203 */
            __pyx_v_nb_segment = (__pyx_v_nb_segment + 1);

            /* "/home/jiba/src/soya/model/model.pyx":1204 */
            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/model.pyx":1205 */
            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/model.pyx":1206 */
            chunk_add_int(__pyx_v_chunk,(-1));
            goto __pyx_L21;
          }
          __pyx_L21:;
          __pyx_L19:;
        }
        __pyx_L20:;
        goto __pyx_L17;
      }
      __pyx_L17:;
      __pyx_L15:;
    }
    __pyx_L16:;

    /* "/home/jiba/src/soya/model/model.pyx":1209 */
    __pyx_7 = PyDict_New(); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1209; goto __pyx_L1;}
    Py_DECREF(__pyx_v_joined);
    __pyx_v_joined = __pyx_7;
    __pyx_7 = 0;

    /* "/home/jiba/src/soya/model/model.pyx":1210 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_segment; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/model.pyx":1211 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_segment; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/model.pyx":1212 */
        __pyx_1 = (__pyx_v_i == __pyx_v_j);
        if (__pyx_1) {
          goto __pyx_L27;
          goto __pyx_L29;
        }
        __pyx_L29:;

        /* "/home/jiba/src/soya/model/model.pyx":1213 */
        __pyx_7 = PyObject_GetAttr(__pyx_v_joined, __pyx_n_has_key); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1213; goto __pyx_L1;}
        __pyx_8 = PyInt_FromLong(__pyx_v_j); if (!__pyx_8) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1213; goto __pyx_L1;}
        __pyx_9 = PyTuple_New(1); if (!__pyx_9) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1213; 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 = 1213; goto __pyx_L1;}
        Py_DECREF(__pyx_7); __pyx_7 = 0;
        Py_DECREF(__pyx_9); __pyx_9 = 0;
        __pyx_2 = PyObject_IsTrue(__pyx_8); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1213; goto __pyx_L1;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        if (__pyx_2) {
          goto __pyx_L27;
          goto __pyx_L30;
        }
        __pyx_L30:;

        /* "/home/jiba/src/soya/model/model.pyx":1215 */
        __pyx_1 = (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_1) {

          /* "/home/jiba/src/soya/model/model.pyx":1216 */
          (((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/model.pyx":1218 */
          __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1218; goto __pyx_L1;}
          __pyx_9 = PyInt_FromLong(__pyx_v_j); if (!__pyx_9) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1218; goto __pyx_L1;}
          if (PyObject_SetItem(__pyx_v_joined, __pyx_9, __pyx_7) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1218; goto __pyx_L1;}
          Py_DECREF(__pyx_9); __pyx_9 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;

          /* "/home/jiba/src/soya/model/model.pyx":1220 */
          goto __pyx_L28;
          goto __pyx_L31;
        }
        __pyx_L31:;
        __pyx_L27:;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/model.pyx":1222 */
        if (__Pyx_PrintItem(__pyx_k298p) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1222; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1222; goto __pyx_L1;}
      }
      __pyx_L28:;
      __pyx_L25:;
    }
    __pyx_L26:;

    /* "/home/jiba/src/soya/model/model.pyx":1224 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/model/model.pyx":1225 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/model/model.pyx":1226 */
    for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nb_segment; ++__pyx_v_k) {

      /* "/home/jiba/src/soya/model/model.pyx":1227 */
      __pyx_2 = (__pyx_v_i == (-1));
      if (__pyx_2) {
        goto __pyx_L33;
        goto __pyx_L34;
      }
      __pyx_L34:;

      /* "/home/jiba/src/soya/model/model.pyx":1228 */
      __pyx_v_coord_ptr = ((float (*))(__pyx_v_chunk->content + (__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int ))))));

      /* "/home/jiba/src/soya/model/model.pyx":1230 */
      __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/model.pyx":1232 */
      memcpy(__pyx_v_fp1,__pyx_v_coord_ptr,(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/model/model.pyx":1233 */
      memcpy(__pyx_v_fp2,(__pyx_v_coord_ptr + 3),(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/model/model.pyx":1235 */
      __pyx_1 = (__pyx_v_light->_w == 0.0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1236 */
        memcpy(__pyx_v_v1,__pyx_v_light->_data,(3 * (sizeof(float ))));

        /* "/home/jiba/src/soya/model/model.pyx":1237 */
        memcpy(__pyx_v_v2,__pyx_v_light->_data,(3 * (sizeof(float ))));
        goto __pyx_L35;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/model.pyx":1239 */
        (__pyx_v_v1[0]) = ((__pyx_v_fp1[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/model/model.pyx":1240 */
        (__pyx_v_v1[1]) = ((__pyx_v_fp1[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/model/model.pyx":1241 */
        (__pyx_v_v1[2]) = ((__pyx_v_fp1[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/model/model.pyx":1242 */
        vector_normalize(__pyx_v_v1);

        /* "/home/jiba/src/soya/model/model.pyx":1244 */
        (__pyx_v_v2[0]) = ((__pyx_v_fp2[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/model/model.pyx":1245 */
        (__pyx_v_v2[1]) = ((__pyx_v_fp2[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/model/model.pyx":1246 */
        (__pyx_v_v2[2]) = ((__pyx_v_fp2[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/model/model.pyx":1247 */
        vector_normalize(__pyx_v_v2);
      }
      __pyx_L35:;

      /* "/home/jiba/src/soya/model/model.pyx":1250 */
      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/model.pyx":1251 */
      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/model.pyx":1253 */
      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/model.pyx":1254 */
      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/model.pyx":1256 */
      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/model.pyx":1257 */
      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/model.pyx":1259 */
      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/model.pyx":1260 */
      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/model.pyx":1262 */
      __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/model.pyx":1264 */
      glBegin(GL_POLYGON);

      /* "/home/jiba/src/soya/model/model.pyx":1265 */
      __pyx_2 = (__pyx_v_nb_points[0]);
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_2; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/model/model.pyx":1266 */
        glVertex3fv((__pyx_v_face_data + (__pyx_v_j * 3)));
        __pyx_L36:;
      }
      __pyx_L37:;

      /* "/home/jiba/src/soya/model/model.pyx":1267 */
      glEnd();

      /* "/home/jiba/src/soya/model/model.pyx":1269 */
      __pyx_1 = (__pyx_v_nb_points[1]);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1270 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[0])));

        /* "/home/jiba/src/soya/model/model.pyx":1271 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[1])));

        /* "/home/jiba/src/soya/model/model.pyx":1272 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[2])));

        /* "/home/jiba/src/soya/model/model.pyx":1273 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L38;
      }
      __pyx_L38:;

      /* "/home/jiba/src/soya/model/model.pyx":1275 */
      __pyx_2 = (__pyx_v_nb_points[2]);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/model.pyx":1276 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[0])));

        /* "/home/jiba/src/soya/model/model.pyx":1277 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[1])));

        /* "/home/jiba/src/soya/model/model.pyx":1278 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[2])));

        /* "/home/jiba/src/soya/model/model.pyx":1279 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L39;
      }
      __pyx_L39:;
      __pyx_L32:;
    }
    __pyx_L33:;

    /* "/home/jiba/src/soya/model/model.pyx":1283 */
    glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

    /* "/home/jiba/src/soya/model/model.pyx":1285 */
    glEndList();

    /* "/home/jiba/src/soya/model/model.pyx":1289 */
    glDisable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/model/model.pyx":1290 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/model/model.pyx":1291 */
    gluTessBeginPolygon(__pyx_v_5_soya_SHADOW_TESS,0);

    /* "/home/jiba/src/soya/model/model.pyx":1292 */
    gluTessBeginContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/model/model.pyx":1293 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_inter; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/model.pyx":1294 */
      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_L40:;
    }
    __pyx_L41:;

    /* "/home/jiba/src/soya/model/model.pyx":1295 */
    gluTessEndContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/model/model.pyx":1296 */
    gluTessEndPolygon(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/model/model.pyx":1297 */
    glLoadMatrixf(__pyx_v_coord_syst->_render_matrix);

    /* "/home/jiba/src/soya/model/model.pyx":1298 */
    glEnable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/model/model.pyx":1302 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/model/model.pyx":1303 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/model/model.pyx":1304 */
    glCallList(__pyx_v_displaylist);

    /* "/home/jiba/src/soya/model/model.pyx":1310 */
    __pyx_v_i = __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb;

    /* "/home/jiba/src/soya/model/model.pyx":1311 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/model/model.pyx":1312 */
    while (1) {
      __pyx_L42:;
      __pyx_1 = (__pyx_v_5_soya_SHADOW_TESS_CHUNK->nb < __pyx_v_i);
      if (!__pyx_1) break;
      free(chunk_get_ptr(__pyx_v_5_soya_SHADOW_TESS_CHUNK));
    }
    __pyx_L43:;

    /* "/home/jiba/src/soya/model/model.pyx":1314 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/model/model.pyx":1316 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/model/model.pyx":1317 */
    drop_chunk(__pyx_v_chunk2);
    goto __pyx_L14;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/model.pyx":1323 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/model/model.pyx":1324 */
    __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/model.pyx":1325 */
      __pyx_v_face = (__pyx_v_self->_faces + __pyx_v_i);

      /* "/home/jiba/src/soya/model/model.pyx":1327 */
      __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      }
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/model.pyx":1328 */
        __pyx_v_neighbors = (__pyx_v_self->_simple_neighbors + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/model.pyx":1329 */
        __pyx_v_neighbors_side = (__pyx_v_self->_simple_neighbors_side + (4 * __pyx_v_i));

        /* "/home/jiba/src/soya/model/model.pyx":1330 */
        __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
        if (__pyx_1) {
          __pyx_v_nbv = 4;
          goto __pyx_L47;
        }
        /*else*/ {
          __pyx_v_nbv = 3;
        }
        __pyx_L47:;

        /* "/home/jiba/src/soya/model/model.pyx":1333 */
        for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nbv; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/model/model.pyx":1334 */
          __pyx_v_neighbor_face = (__pyx_v_self->_faces + (__pyx_v_neighbors[__pyx_v_k]));

          /* "/home/jiba/src/soya/model/model.pyx":1336 */
          __pyx_1 = (!(__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED));
          if (__pyx_1) {
            __pyx_1 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
            if (!__pyx_1) {
              __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
            }
          }
          if (!__pyx_1) {
            __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
            if (__pyx_1) {
              __pyx_1 = ((__pyx_v_neighbors[__pyx_v_k]) == (-1));
              if (!__pyx_1) {
                __pyx_1 = ((__pyx_v_neighbors_side[__pyx_v_k]) == (-1));
                if (__pyx_1) {
                  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                  if (__pyx_1) {
                    __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                  }
                  if (!__pyx_1) {
                    __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                    if (__pyx_1) {
                      __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                  }
                }
                if (!__pyx_1) {
                  __pyx_1 = ((__pyx_v_neighbors_side[__pyx_v_k]) == 1);
                  if (__pyx_1) {
                    __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    if (__pyx_1) {
                      __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_FRONT);
                    }
                    if (!__pyx_1) {
                      __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      if (__pyx_1) {
                        __pyx_1 = (__pyx_v_neighbor_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
                      }
                    }
                  }
                }
              }
            }
          }
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/model.pyx":1345 */
            __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_1) {

              /* "/home/jiba/src/soya/model/model.pyx":1346 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/model/model.pyx":1347 */
              __pyx_1 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_1) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L52;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L52:;
              goto __pyx_L51;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/model.pyx":1350 */
              __pyx_1 = (__pyx_v_k < (__pyx_v_nbv - 1));
              if (__pyx_1) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L53;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L53:;

              /* "/home/jiba/src/soya/model/model.pyx":1352 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L51:;

            /* "/home/jiba/src/soya/model/model.pyx":1354 */
            __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/model.pyx":1355 */
            glVertex3fv(__pyx_v_coord_ptr);

            /* "/home/jiba/src/soya/model/model.pyx":1358 */
            __pyx_1 = (__pyx_v_light->_w == 0.0);
            if (__pyx_1) {

              /* "/home/jiba/src/soya/model/model.pyx":1359 */
              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_L54;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/model/model.pyx":1361 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/model/model.pyx":1362 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/model/model.pyx":1363 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/model/model.pyx":1364 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/model/model.pyx":1365 */
              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_L54:;

            /* "/home/jiba/src/soya/model/model.pyx":1367 */
            __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/model.pyx":1370 */
            __pyx_1 = (__pyx_v_light->_w == 0.0);
            if (__pyx_1) {

              /* "/home/jiba/src/soya/model/model.pyx":1371 */
              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/model.pyx":1373 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/model/model.pyx":1374 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/model/model.pyx":1375 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/model/model.pyx":1376 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/model/model.pyx":1377 */
              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/model.pyx":1379 */
            glVertex3fv(__pyx_v_coord_ptr);
            goto __pyx_L50;
          }
          __pyx_L50:;
          __pyx_L48:;
        }
        __pyx_L49:;
        goto __pyx_L46;
      }
      __pyx_L46:;
      __pyx_L44:;
    }
    __pyx_L45:;

    /* "/home/jiba/src/soya/model/model.pyx":1382 */
    glEnd();

    /* "/home/jiba/src/soya/model/model.pyx":1383 */
    glEndList();

    /* "/home/jiba/src/soya/model/model.pyx":1386 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/model/model.pyx":1387 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/model/model.pyx":1388 */
    glCallList(__pyx_v_displaylist);
  }
  __pyx_L14:;

  /* "/home/jiba/src/soya/model/model.pyx":1393 */
  __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._SimpleModel._build_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_model_option_activate(int __pyx_v_option) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/model.pyx":1404 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_MODEL_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.model_option_activate");
  __pyx_L0:;
}

static void __pyx_f_5_soya_model_option_inactivate(int __pyx_v_option) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/model.pyx":1407 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_MODEL_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.model_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/model.pyx":1410 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1411 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/model.pyx":1412 */
    glDisable(GL_CULL_FACE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":1413 */
  __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/model.pyx":1416 */
  __pyx_1 = (__pyx_v_option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
  if (__pyx_1) {

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

    /* "/home/jiba/src/soya/model/model.pyx":1418 */
    glEnable(GL_CULL_FACE);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model.pyx":1419 */
  __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_model_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/model.pyx":1424 */
  __pyx_1 = ((double (*))malloc((3 * (sizeof(double )))));
  __pyx_v_d = __pyx_1;
  (__pyx_v_out_data[0]) = __pyx_1;

  /* "/home/jiba/src/soya/model/model.pyx":1425 */
  memcpy(__pyx_v_d,__pyx_v_coords,(3 * (sizeof(double ))));

  /* "/home/jiba/src/soya/model/model.pyx":1427 */
  chunk_add_ptr(__pyx_v_5_soya_SHADOW_TESS_CHUNK,__pyx_v_d);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.model_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/model.pyx":1438 */
  __pyx_v_nb_face = 0;

  /* "/home/jiba/src/soya/model/model.pyx":1439 */
  __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/model.pyx":1441 */
  (__pyx_v_pv1[0]) = ((__pyx_v_p1[0]) + (__pyx_v_infinity * (__pyx_v_v1[0])));

  /* "/home/jiba/src/soya/model/model.pyx":1442 */
  (__pyx_v_pv1[1]) = ((__pyx_v_p1[1]) + (__pyx_v_infinity * (__pyx_v_v1[1])));

  /* "/home/jiba/src/soya/model/model.pyx":1443 */
  (__pyx_v_pv1[2]) = ((__pyx_v_p1[2]) + (__pyx_v_infinity * (__pyx_v_v1[2])));

  /* "/home/jiba/src/soya/model/model.pyx":1445 */
  (__pyx_v_pv2[0]) = ((__pyx_v_p2[0]) + (__pyx_v_infinity * (__pyx_v_v2[0])));

  /* "/home/jiba/src/soya/model/model.pyx":1446 */
  (__pyx_v_pv2[1]) = ((__pyx_v_p2[1]) + (__pyx_v_infinity * (__pyx_v_v2[1])));

  /* "/home/jiba/src/soya/model/model.pyx":1447 */
  (__pyx_v_pv2[2]) = ((__pyx_v_p2[2]) + (__pyx_v_infinity * (__pyx_v_v2[2])));

  /* "/home/jiba/src/soya/model/model.pyx":1450 */
  __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/model.pyx":1451 */
  __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/model.pyx":1452 */
  __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/model.pyx":1453 */
  __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/model.pyx":1455 */
  __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/model.pyx":1456 */
  __pyx_1 = (__pyx_v_fdiv != 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1457 */
    __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/model.pyx":1458 */
    __pyx_1 = (__pyx_v_f > 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":1459 */
      __pyx_v_has_i1 = 1;

      /* "/home/jiba/src/soya/model/model.pyx":1460 */
      (__pyx_v_i1[0]) = ((__pyx_v_p1[0]) + (__pyx_v_f * (__pyx_v_v1[0])));

      /* "/home/jiba/src/soya/model/model.pyx":1461 */
      (__pyx_v_i1[1]) = ((__pyx_v_p1[1]) + (__pyx_v_f * (__pyx_v_v1[1])));

      /* "/home/jiba/src/soya/model/model.pyx":1462 */
      (__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/model.pyx":1464 */
  __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/model.pyx":1465 */
  __pyx_1 = (__pyx_v_fdiv != 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1466 */
    __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/model.pyx":1467 */
    __pyx_1 = (__pyx_v_f > 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/model.pyx":1468 */
      __pyx_v_has_i2 = 1;

      /* "/home/jiba/src/soya/model/model.pyx":1469 */
      (__pyx_v_i2[0]) = ((__pyx_v_p2[0]) + (__pyx_v_f * (__pyx_v_v2[0])));

      /* "/home/jiba/src/soya/model/model.pyx":1470 */
      (__pyx_v_i2[1]) = ((__pyx_v_p2[1]) + (__pyx_v_f * (__pyx_v_v2[1])));

      /* "/home/jiba/src/soya/model/model.pyx":1471 */
      (__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/model.pyx":1473 */
  __pyx_1 = ((__pyx_v_p1d * __pyx_v_p2d) < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1474 */
    (__pyx_v_v[0]) = ((__pyx_v_p1[0]) - (__pyx_v_p2[0]));

    /* "/home/jiba/src/soya/model/model.pyx":1475 */
    (__pyx_v_v[1]) = ((__pyx_v_p1[1]) - (__pyx_v_p2[1]));

    /* "/home/jiba/src/soya/model/model.pyx":1476 */
    (__pyx_v_v[2]) = ((__pyx_v_p1[2]) - (__pyx_v_p2[2]));

    /* "/home/jiba/src/soya/model/model.pyx":1477 */
    __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/model.pyx":1478 */
    __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/model.pyx":1479 */
    __pyx_v_has_i3 = 1;

    /* "/home/jiba/src/soya/model/model.pyx":1480 */
    (__pyx_v_i3[0]) = ((__pyx_v_p1[0]) + (__pyx_v_f * (__pyx_v_v[0])));

    /* "/home/jiba/src/soya/model/model.pyx":1481 */
    (__pyx_v_i3[1]) = ((__pyx_v_p1[1]) + (__pyx_v_f * (__pyx_v_v[1])));

    /* "/home/jiba/src/soya/model/model.pyx":1482 */
    (__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/model.pyx":1484 */
  __pyx_1 = ((__pyx_v_pv1d * __pyx_v_pv2d) < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1485 */
    (__pyx_v_v[0]) = ((__pyx_v_pv1[0]) - (__pyx_v_pv2[0]));

    /* "/home/jiba/src/soya/model/model.pyx":1486 */
    (__pyx_v_v[1]) = ((__pyx_v_pv1[1]) - (__pyx_v_pv2[1]));

    /* "/home/jiba/src/soya/model/model.pyx":1487 */
    (__pyx_v_v[2]) = ((__pyx_v_pv1[2]) - (__pyx_v_pv2[2]));

    /* "/home/jiba/src/soya/model/model.pyx":1488 */
    __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/model.pyx":1489 */
    __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/model.pyx":1490 */
    __pyx_v_has_i4 = 1;

    /* "/home/jiba/src/soya/model/model.pyx":1491 */
    (__pyx_v_i4[0]) = ((__pyx_v_pv1[0]) + (__pyx_v_f * (__pyx_v_v[0])));

    /* "/home/jiba/src/soya/model/model.pyx":1492 */
    (__pyx_v_i4[1]) = ((__pyx_v_pv1[1]) + (__pyx_v_f * (__pyx_v_v[1])));

    /* "/home/jiba/src/soya/model/model.pyx":1493 */
    (__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/model.pyx":1495 */
  __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/model.pyx":1498 */
  __pyx_1 = (__pyx_v_p1d > 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1499 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_p1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1500 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/model.pyx":1502 */
  __pyx_1 = __pyx_v_has_i1;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1503 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1504 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/model.pyx":1506 */
  __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/model.pyx":1507 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_pv1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1508 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/model.pyx":1511 */
  __pyx_2 = __pyx_v_has_i4;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":1512 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i4,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1513 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/home/jiba/src/soya/model/model.pyx":1516 */
  __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/model.pyx":1517 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_pv2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1518 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L13;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/model/model.pyx":1520 */
  __pyx_2 = __pyx_v_has_i2;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":1521 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1522 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/jiba/src/soya/model/model.pyx":1524 */
  __pyx_1 = (__pyx_v_p2d > 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1525 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_p2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1526 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/model/model.pyx":1529 */
  __pyx_2 = __pyx_v_has_i3;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":1530 */
    memcpy((__pyx_v_face + __pyx_v_nb_face),__pyx_v_i3,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1531 */
    __pyx_v_nb_face = (__pyx_v_nb_face + 3);
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/jiba/src/soya/model/model.pyx":1534 */
  __pyx_1 = __pyx_v_has_i1;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1534 */
    memcpy(__pyx_v_inter1,__pyx_v_i1,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1534 */
    (__pyx_v_nb[1]) = 1;
    goto __pyx_L17;
  }
  __pyx_2 = __pyx_v_has_i3;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":1535 */
    memcpy(__pyx_v_inter1,__pyx_v_i3,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1535 */
    (__pyx_v_nb[1]) = 1;
    goto __pyx_L17;
  }
  __pyx_1 = __pyx_v_has_i4;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1536 */
    memcpy(__pyx_v_inter1,__pyx_v_i4,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1536 */
    (__pyx_v_nb[1]) = 1;
    goto __pyx_L17;
  }
  /*else*/ {
    (__pyx_v_nb[1]) = 0;
  }
  __pyx_L17:;

  /* "/home/jiba/src/soya/model/model.pyx":1539 */
  __pyx_2 = __pyx_v_has_i2;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":1539 */
    memcpy(__pyx_v_inter2,__pyx_v_i2,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1539 */
    (__pyx_v_nb[2]) = 1;
    goto __pyx_L18;
  }
  __pyx_1 = __pyx_v_has_i4;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/model.pyx":1540 */
    memcpy(__pyx_v_inter2,__pyx_v_i4,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1540 */
    (__pyx_v_nb[2]) = 1;
    goto __pyx_L18;
  }
  __pyx_2 = __pyx_v_has_i3;
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/model.pyx":1541 */
    memcpy(__pyx_v_inter2,__pyx_v_i3,(3 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/model.pyx":1541 */
    (__pyx_v_nb[2]) = 1;
    goto __pyx_L18;
  }
  /*else*/ {
    (__pyx_v_nb[2]) = 0;
  }
  __pyx_L18:;

  /* "/home/jiba/src/soya/model/model.pyx":1544 */
  (__pyx_v_nb[0]) = (__pyx_v_nb_face / 3);

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

static int __pyx_f_5_soya_10_ModelData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_10_ModelData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Body *__pyx_v_body = 0;
  struct __pyx_obj_5_soya__Model *__pyx_v_model = 0;
  int __pyx_r;
  static char *__pyx_argnames[] = {"body","model",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_body, &__pyx_v_model)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  Py_INCREF((PyObject *)__pyx_v_model);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_body), __pyx_ptype_5_soya__Body, 1, "body")) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1547; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__Model, 1, "model")) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1547; goto __pyx_L1;}

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

static void __pyx_f_5_soya_11_SolidModel__render(struct __pyx_obj_5_soya__SolidModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  float (__pyx_v_pos[3]);
  int (__pyx_v_v2[3]);
  __pyx_t_5_soya_ModelFace (*__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_body);

  /* "/home/jiba/src/soya/model/solid_model.pyx":28 */
  point_by_matrix_copy(__pyx_v_pos,__pyx_v_self->__pyx_base._sphere,__pyx_v_body->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/model/solid_model.pyx":31 */
  __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_model.pyx":35 */
    __pyx_vtabptr_5_soya__SimpleModel->__pyx_base._render(((struct __pyx_obj_5_soya__Model *)__pyx_v_self),__pyx_v_body);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/solid_model.pyx":41 */
    __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_INITED));
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._init_display_list(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self));
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":43 */
    __pyx_f_5_soya_model_option_activate(__pyx_v_self->__pyx_base._option);

    /* "/home/jiba/src/soya/model/solid_model.pyx":44 */
    __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
    if (__pyx_1) {
      glFrontFace(GL_CW);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":45 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/model/solid_model.pyx":47 */
    __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_model.pyx":48 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/solid_model.pyx":49 */
      __pyx_v_end = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/solid_model.pyx":51 */
      __pyx_v_start = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/solid_model.pyx":52 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->__pyx_base._display_lists->nb_alpha_list);
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":54 */
    __pyx_v_display_list = __pyx_v_self->__pyx_base._display_lists->display_lists;

    /* "/home/jiba/src/soya/model/solid_model.pyx":56 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/solid_model.pyx":57 */
      __pyx_v_display_list = (__pyx_v_self->__pyx_base._display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/solid_model.pyx":58 */
      __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_model.pyx":59 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/solid_model.pyx":61 */
      __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_model.pyx":62 */
        __pyx_v_face = (__pyx_v_self->__pyx_base._faces + __pyx_v_j);

        /* "/home/jiba/src/soya/model/solid_model.pyx":63 */
        __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_model.pyx":64 */
          __pyx_3 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_QUAD);
          if (__pyx_3) {

            /* "/home/jiba/src/soya/model/solid_model.pyx":65 */
            ((struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_solid(__pyx_v_self,__pyx_v_face,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_face->v);

            /* "/home/jiba/src/soya/model/solid_model.pyx":66 */
            (__pyx_v_v2[0]) = (__pyx_v_face->v[0]);

            /* "/home/jiba/src/soya/model/solid_model.pyx":67 */
            (__pyx_v_v2[1]) = (__pyx_v_face->v[2]);

            /* "/home/jiba/src/soya/model/solid_model.pyx":68 */
            (__pyx_v_v2[2]) = (__pyx_v_face->v[3]);

            /* "/home/jiba/src/soya/model/solid_model.pyx":69 */
            ((struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_solid(__pyx_v_self,__pyx_v_face,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_v2);
            goto __pyx_L11;
          }
          /*else*/ {

            /* "/home/jiba/src/soya/model/solid_model.pyx":71 */
            ((struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_render_triangle_solid(__pyx_v_self,__pyx_v_face,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_face->v);
          }
          __pyx_L11:;
          goto __pyx_L10;
        }
        __pyx_L10:;
        __pyx_L8:;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/model/solid_model.pyx":73 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L6:;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":74 */
    __pyx_f_5_soya_model_option_inactivate(__pyx_v_self->__pyx_base._option);

    /* "/home/jiba/src/soya/model/solid_model.pyx":75 */
    __pyx_3 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
    if (__pyx_3) {
      glFrontFace(GL_CCW);
      goto __pyx_L12;
    }
    __pyx_L12:;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._SolidModel._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_11_SolidModel__render_triangle_solid(struct __pyx_obj_5_soya__SolidModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__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_model.pyx":80 */
  __pyx_v_cur_inter3 = 0;

  /* "/home/jiba/src/soya/model/solid_model.pyx":81 */
  __pyx_v_nb_inter = 0;

  /* "/home/jiba/src/soya/model/solid_model.pyx":83 */
  __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_model.pyx":85 */
  glBegin(GL_TRIANGLES);

  /* "/home/jiba/src/soya/model/solid_model.pyx":86 */
  for (__pyx_v_i = 0; __pyx_v_i < 3; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/solid_model.pyx":87 */
    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_model.pyx":89 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":90 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":91 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":92 */
    __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_model.pyx":93 */
      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_model.pyx":94 */
      glNormal3fv(__pyx_v_n);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":95 */
    glVertex3fv((__pyx_v_p + (3 * __pyx_v_i)));
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/solid_model.pyx":96 */
  glEnd();

  /* "/home/jiba/src/soya/model/solid_model.pyx":98 */
  for (__pyx_v_i = 0; __pyx_v_i < 3; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/solid_model.pyx":99 */
    __pyx_v_i3 = (3 * __pyx_v_i);

    /* "/home/jiba/src/soya/model/solid_model.pyx":100 */
    __pyx_1 = (__pyx_v_i == 2);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/solid_model.pyx":100 */
      __pyx_v_j = 0;

      /* "/home/jiba/src/soya/model/solid_model.pyx":100 */
      __pyx_v_j3 = 0;
      goto __pyx_L11;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/solid_model.pyx":101 */
      __pyx_v_j = (__pyx_v_i + 1);

      /* "/home/jiba/src/soya/model/solid_model.pyx":101 */
      __pyx_v_j3 = (3 * __pyx_v_j);
    }
    __pyx_L11:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":103 */
    __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_model.pyx":104 */
      (__pyx_v_inter[__pyx_v_cur_inter3]) = (__pyx_v_p[__pyx_v_i3]);

      /* "/home/jiba/src/soya/model/solid_model.pyx":105 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 1)]) = (__pyx_v_p[(__pyx_v_i3 + 1)]);

      /* "/home/jiba/src/soya/model/solid_model.pyx":106 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 2)]) = ((-__pyx_v_5_soya_renderer->current_camera->_front) - 0.0001);

      /* "/home/jiba/src/soya/model/solid_model.pyx":108 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":109 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":110 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":112 */
      __pyx_v_cur_inter3 = (__pyx_v_cur_inter3 + 13);

      /* "/home/jiba/src/soya/model/solid_model.pyx":113 */
      __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":116 */
    __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_model.pyx":117 */
      (__pyx_v_n[0]) = ((__pyx_v_p[__pyx_v_i3]) - (__pyx_v_p[__pyx_v_j3]));

      /* "/home/jiba/src/soya/model/solid_model.pyx":118 */
      (__pyx_v_n[1]) = ((__pyx_v_p[(__pyx_v_i3 + 1)]) - (__pyx_v_p[(__pyx_v_j3 + 1)]));

      /* "/home/jiba/src/soya/model/solid_model.pyx":119 */
      (__pyx_v_n[2]) = ((__pyx_v_p[(__pyx_v_i3 + 2)]) - (__pyx_v_p[(__pyx_v_j3 + 2)]));

      /* "/home/jiba/src/soya/model/solid_model.pyx":121 */
      __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_model.pyx":122 */
      __pyx_v_f1 = (1.0 - __pyx_v_f);

      /* "/home/jiba/src/soya/model/solid_model.pyx":123 */
      (__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_model.pyx":124 */
      (__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_model.pyx":125 */
      (__pyx_v_inter[(__pyx_v_cur_inter3 + 2)]) = ((-__pyx_v_5_soya_renderer->current_camera->_front) - 0.0001);

      /* "/home/jiba/src/soya/model/solid_model.pyx":127 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_DIFFUSES);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/solid_model.pyx":128 */
        (__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_model.pyx":129 */
        (__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_model.pyx":130 */
        (__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_model.pyx":131 */
        (__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_model.pyx":133 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_EMISSIVES);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/solid_model.pyx":134 */
        (__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_model.pyx":135 */
        (__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_model.pyx":136 */
        (__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_model.pyx":137 */
        (__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_model.pyx":139 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_TEXCOORDS);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/solid_model.pyx":140 */
        (__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_model.pyx":141 */
        (__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_model.pyx":143 */
      __pyx_v_cur_inter3 = (__pyx_v_cur_inter3 + 13);

      /* "/home/jiba/src/soya/model/solid_model.pyx":144 */
      __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
      goto __pyx_L16;
    }
    __pyx_L16:;
    __pyx_L9:;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/solid_model.pyx":146 */
  __pyx_1 = (__pyx_v_cur_inter3 != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/solid_model.pyx":147 */
    __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_model.pyx":149 */
    glBegin(GL_POLYGON);

    /* "/home/jiba/src/soya/model/solid_model.pyx":150 */
    glNormal3f(0.0,0.0,1.0);

    /* "/home/jiba/src/soya/model/solid_model.pyx":151 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_inter; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/solid_model.pyx":152 */
      __pyx_v_cur_inter3 = (__pyx_v_i * 13);

      /* "/home/jiba/src/soya/model/solid_model.pyx":153 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_DIFFUSES);
      if (__pyx_1) {
        glColor4fv((__pyx_v_inter + (__pyx_v_cur_inter3 + 3)));
        goto __pyx_L24;
      }
      __pyx_L24:;

      /* "/home/jiba/src/soya/model/solid_model.pyx":154 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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_model.pyx":155 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_TEXCOORDS);
      if (__pyx_1) {
        glTexCoord2fv((__pyx_v_inter + (__pyx_v_cur_inter3 + 11)));
        goto __pyx_L26;
      }
      __pyx_L26:;

      /* "/home/jiba/src/soya/model/solid_model.pyx":156 */
      glVertex3fv((__pyx_v_inter + __pyx_v_cur_inter3));
      __pyx_L22:;
    }
    __pyx_L23:;

    /* "/home/jiba/src/soya/model/solid_model.pyx":157 */
    glEnd();

    /* "/home/jiba/src/soya/model/solid_model.pyx":159 */
    __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._SolidModel._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_CellShadingModel___getcstate__(struct __pyx_obj_5_soya__CellShadingModel *__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":28 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/cellshading.pyx":29 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_width);

  /* "/home/jiba/src/soya/model/cellshading.pyx":30 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/model/cellshading.pyx":31 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_color,4);

  /* "/home/jiba/src/soya/model/cellshading.pyx":32 */
  __pyx_1 = __pyx_vtabptr_5_soya__SimpleModel->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 32; 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 = 32; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 32; 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._CellShadingModel.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_17_CellShadingModel___setcstate__(struct __pyx_obj_5_soya__CellShadingModel *__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":35 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 35; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 35; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya__SimpleModel->__setcstate_data__(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/cellshading.pyx":38 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 38; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 38; 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":39 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_outline_width));

  /* "/home/jiba/src/soya/model/cellshading.pyx":40 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_outline_attenuation));

  /* "/home/jiba/src/soya/model/cellshading.pyx":41 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_outline_color,4);

  /* "/home/jiba/src/soya/model/cellshading.pyx":42 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/cellshading.pyx":43 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 43; 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 = 43; 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":46 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_display_list(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self));

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

static void __pyx_f_5_soya_17_CellShadingModel__build_cellshading(struct __pyx_obj_5_soya__CellShadingModel *__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":50 */
  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":51 */
  __pyx_v_self->_outline_width = __pyx_v_outline_width;

  /* "/home/jiba/src/soya/model/cellshading.pyx":52 */
  __pyx_v_self->_outline_attenuation = __pyx_v_outline_attenuation;

  /* "/home/jiba/src/soya/model/cellshading.pyx":53 */
  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 = 53; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_outline_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 53; 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 = 53; 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._CellShadingModel._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_CellShadingModel__batch(struct __pyx_obj_5_soya__CellShadingModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  float (__pyx_v_sphere[4]);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  /* "/home/jiba/src/soya/model/cellshading.pyx":56 */
  __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":58 */
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_LOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":59 */
    __pyx_vtabptr_5_soya__SimpleModel->__pyx_base._batch(((struct __pyx_obj_5_soya__Model *)__pyx_v_self),__pyx_v_body);

    /* "/home/jiba/src/soya/model/cellshading.pyx":60 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":66 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_HAS_SPHERE);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":67 */
    sphere_by_matrix_copy(__pyx_v_sphere,__pyx_v_self->__pyx_base._sphere,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

    /* "/home/jiba/src/soya/model/cellshading.pyx":68 */
    __pyx_1 = (sphere_in_frustum(__pyx_v_5_soya_renderer->root_frustum,__pyx_v_sphere) == 0);
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":70 */
  __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_body->_data),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":71 */
  __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_body->_data),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":74 */
  __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_body->_data),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),0);
    goto __pyx_L8;
  }
  __pyx_L8:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingModel._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_17_CellShadingModel__render(struct __pyx_obj_5_soya__CellShadingModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  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_body);
  __pyx_v_material = Py_None; Py_INCREF((PyObject *) __pyx_v_material);

  /* "/home/jiba/src/soya/model/cellshading.pyx":144 */
  __pyx_1 = (__pyx_v_5_soya_quality == __pyx_e_5_soya_QUALITY_LOW);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":145 */
    __pyx_vtabptr_5_soya__SimpleModel->__pyx_base._render(((struct __pyx_obj_5_soya__Model *)__pyx_v_self),__pyx_v_body);

    /* "/home/jiba/src/soya/model/cellshading.pyx":146 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":156 */
  __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":157 */
    __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_body));

    /* "/home/jiba/src/soya/model/cellshading.pyx":158 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":160 */
    __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
    if (__pyx_1) {
      glFrontFace(GL_CW);
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":161 */
    __pyx_f_5_soya_model_option_activate(__pyx_v_self->__pyx_base._option);

    /* "/home/jiba/src/soya/model/cellshading.pyx":163 */
    __pyx_v_chunk = get_chunk();

    /* "/home/jiba/src/soya/model/cellshading.pyx":164 */
    chunk_register(__pyx_v_chunk,(__pyx_v_self->__pyx_base._nb_vnormals * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/cellshading.pyx":165 */
    __pyx_v_shades = ((float (*))__pyx_v_chunk->content);

    /* "/home/jiba/src/soya/model/cellshading.pyx":166 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading(__pyx_v_self,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_shades);

    /* "/home/jiba/src/soya/model/cellshading.pyx":168 */
    __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":169 */
      __pyx_v_start = 0;

      /* "/home/jiba/src/soya/model/cellshading.pyx":170 */
      __pyx_v_end = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":172 */
      __pyx_v_start = __pyx_v_self->__pyx_base._display_lists->nb_opaque_list;

      /* "/home/jiba/src/soya/model/cellshading.pyx":173 */
      __pyx_v_end = (__pyx_v_start + __pyx_v_self->__pyx_base._display_lists->nb_alpha_list);
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":176 */
    glActiveTextureARB(GL_TEXTURE1);

    /* "/home/jiba/src/soya/model/cellshading.pyx":177 */
    __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_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":178 */
    glEnable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/model/cellshading.pyx":179 */
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);

    /* "/home/jiba/src/soya/model/cellshading.pyx":180 */
    glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_shader->_id);

    /* "/home/jiba/src/soya/model/cellshading.pyx":181 */
    glActiveTextureARB(GL_TEXTURE0);

    /* "/home/jiba/src/soya/model/cellshading.pyx":183 */
    for (__pyx_v_i = __pyx_v_start; __pyx_v_i < __pyx_v_end; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":184 */
      __pyx_v_display_list = (__pyx_v_self->__pyx_base._display_lists->display_lists + __pyx_v_i);

      /* "/home/jiba/src/soya/model/cellshading.pyx":186 */
      __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":187 */
      ((struct __pyx_vtabstruct_5_soya__Material *)__pyx_v_material->__pyx_base.__pyx_vtab)->_activate(__pyx_v_material);

      /* "/home/jiba/src/soya/model/cellshading.pyx":189 */
      __pyx_f_5_soya_face_option_activate(__pyx_v_display_list->option);

      /* "/home/jiba/src/soya/model/cellshading.pyx":191 */
      __pyx_v_face_id = __pyx_v_display_list->faces_id;

      /* "/home/jiba/src/soya/model/cellshading.pyx":192 */
      __pyx_1 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_TRIANGLE);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":193 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/model/cellshading.pyx":194 */
        while (1) {
          __pyx_L10:;
          __pyx_1 = ((__pyx_v_face_id[0]) != (-1));
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/cellshading.pyx":195 */
          ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":196 */
          __pyx_v_face_id = (__pyx_v_face_id + 1);
        }
        __pyx_L11:;
        goto __pyx_L9;
      }
      __pyx_1 = (__pyx_v_display_list->option & __pyx_e_5_soya_FACE_QUAD);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":199 */
        glBegin(GL_QUADS);

        /* "/home/jiba/src/soya/model/cellshading.pyx":200 */
        while (1) {
          __pyx_L12:;
          __pyx_1 = ((__pyx_v_face_id[0]) != (-1));
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/cellshading.pyx":201 */
          ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":202 */
          __pyx_v_face_id = (__pyx_v_face_id + 1);
        }
        __pyx_L13:;
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/model/cellshading.pyx":204 */
      glEnd();

      /* "/home/jiba/src/soya/model/cellshading.pyx":206 */
      __pyx_f_5_soya_face_option_inactivate(__pyx_v_display_list->option);
      __pyx_L7:;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":209 */
    glActiveTextureARB(GL_TEXTURE1);

    /* "/home/jiba/src/soya/model/cellshading.pyx":210 */
    glDisable(GL_TEXTURE_2D);

    /* "/home/jiba/src/soya/model/cellshading.pyx":211 */
    glActiveTextureARB(GL_TEXTURE0);

    /* "/home/jiba/src/soya/model/cellshading.pyx":214 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/model/cellshading.pyx":215 */
    __pyx_f_5_soya_model_option_inactivate(__pyx_v_self->__pyx_base._option);

    /* "/home/jiba/src/soya/model/cellshading.pyx":216 */
    __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
    if (__pyx_1) {
      glFrontFace(GL_CCW);
      goto __pyx_L14;
    }
    __pyx_L14:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._CellShadingModel._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_material);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_17_CellShadingModel__render_outline(struct __pyx_obj_5_soya__CellShadingModel *__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_ModelFace (*__pyx_v_face);
  __pyx_t_5_soya_ModelFace __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":226 */
  __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":227 */
  __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":229 */
    __pyx_v_d = (__pyx_v_self->_outline_width / __pyx_v_d);

    /* "/home/jiba/src/soya/model/cellshading.pyx":230 */
    __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":232 */
  ((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":233 */
  glLineWidth(__pyx_v_d);

  /* "/home/jiba/src/soya/model/cellshading.pyx":234 */
  glColor4fv(__pyx_v_self->_outline_color);

  /* "/home/jiba/src/soya/model/cellshading.pyx":235 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/cellshading.pyx":236 */
  glDepthFunc(GL_LEQUAL);

  /* "/home/jiba/src/soya/model/cellshading.pyx":239 */
  __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":240 */
    __pyx_v_face = (__pyx_v_self->__pyx_base._faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/cellshading.pyx":241 */
    __pyx_v_plane = (__pyx_v_self->__pyx_base._values + __pyx_v_face->normal);

    /* "/home/jiba/src/soya/model/cellshading.pyx":242 */
    __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":243 */
      __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":245 */
      __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":318 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/cellshading.pyx":319 */
  chunk_register(__pyx_v_chunk,(__pyx_v_self->__pyx_base._nb_coords * (sizeof(int ))));

  /* "/home/jiba/src/soya/model/cellshading.pyx":321 */
  __pyx_v_vertex_used = ((int (*))__pyx_v_chunk->content);

  /* "/home/jiba/src/soya/model/cellshading.pyx":322 */
  __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":326 */
  glBegin(GL_LINES);

  /* "/home/jiba/src/soya/model/cellshading.pyx":327 */
  __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":328 */
    __pyx_v_face = (__pyx_v_self->__pyx_base._faces + __pyx_v_i);

    /* "/home/jiba/src/soya/model/cellshading.pyx":329 */
    __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":331 */
    __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":334 */
    __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":335 */
      __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_DOUBLE_SIDED);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/cellshading.pyx":336 */
        for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/cellshading.pyx":337 */
          __pyx_v_k = (__pyx_v_self->__pyx_base._neighbors[((4 * __pyx_v_i) + __pyx_v_j)]);

          /* "/home/jiba/src/soya/model/cellshading.pyx":338 */
          __pyx_2 = (__pyx_v_k == (-1));
          if (__pyx_2) {

            /* "/home/jiba/src/soya/model/cellshading.pyx":339 */
            (__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":342 */
            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":343 */
            __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":347 */
            __pyx_v_ns = (__pyx_v_self->__pyx_base._neighbors_side[((4 * __pyx_v_i) + __pyx_v_j)]);

            /* "/home/jiba/src/soya/model/cellshading.pyx":348 */
            __pyx_v_neighbor_face = (__pyx_v_self->__pyx_base._faces[__pyx_v_k]);

            /* "/home/jiba/src/soya/model/cellshading.pyx":349 */
            __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":354 */
              (__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":357 */
              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":358 */
              __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":362 */
        __pyx_2 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_FRONT);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/cellshading.pyx":364 */
          for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb; ++__pyx_v_j) {

            /* "/home/jiba/src/soya/model/cellshading.pyx":365 */
            __pyx_v_k = (__pyx_v_self->__pyx_base._neighbors[((4 * __pyx_v_i) + __pyx_v_j)]);

            /* "/home/jiba/src/soya/model/cellshading.pyx":366 */
            __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":367 */
              (__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":370 */
              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":371 */
              __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":375 */
      __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":376 */
        for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/cellshading.pyx":378 */
          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":379 */
          __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":382 */
  glEnd();

  /* "/home/jiba/src/soya/model/cellshading.pyx":384 */
  glPointSize((__pyx_v_d / 2));

  /* "/home/jiba/src/soya/model/cellshading.pyx":386 */
  glBegin(GL_POINTS);

  /* "/home/jiba/src/soya/model/cellshading.pyx":387 */
  __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":388 */
    __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":389 */
  glEnd();

  /* "/home/jiba/src/soya/model/cellshading.pyx":392 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/cellshading.pyx":394 */
  glLineWidth(1.0);

  /* "/home/jiba/src/soya/model/cellshading.pyx":395 */
  glPointSize(1.0);

  /* "/home/jiba/src/soya/model/cellshading.pyx":396 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/cellshading.pyx":397 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/model/cellshading.pyx":398 */
  glColor4fv(__pyx_v_5_soya_white);

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

static float __pyx_f_5_soya_17_CellShadingModel__vertex_compute_cellshading(struct __pyx_obj_5_soya__CellShadingModel *__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":407 */
  __pyx_1 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 407; 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 = 407; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 407; 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":408 */
    __pyx_3 = (__pyx_v_light->_w == 0.0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":409 */
      __pyx_v_tmp = (-vector_dot_product(__pyx_v_normal,__pyx_v_light->_data));
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":411 */
      (__pyx_v_ptr[0]) = ((__pyx_v_light->_data[0]) - (__pyx_v_coord[0]));

      /* "/home/jiba/src/soya/model/cellshading.pyx":412 */
      (__pyx_v_ptr[1]) = ((__pyx_v_light->_data[1]) - (__pyx_v_coord[1]));

      /* "/home/jiba/src/soya/model/cellshading.pyx":413 */
      (__pyx_v_ptr[2]) = ((__pyx_v_light->_data[2]) - (__pyx_v_coord[2]));

      /* "/home/jiba/src/soya/model/cellshading.pyx":414 */
      vector_normalize(__pyx_v_ptr);

      /* "/home/jiba/src/soya/model/cellshading.pyx":415 */
      __pyx_v_tmp = vector_dot_product(__pyx_v_normal,__pyx_v_ptr);
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/cellshading.pyx":417 */
    __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":419 */
  __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._CellShadingModel._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_CellShadingModel__prepare_cellshading_shades(struct __pyx_obj_5_soya__CellShadingModel *__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":428 */
  __pyx_1 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 428; 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 = 428; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 428; 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":429 */
    __pyx_v_ptr1 = __pyx_v_self->__pyx_base._vnormals;

    /* "/home/jiba/src/soya/model/cellshading.pyx":430 */
    __pyx_3 = (__pyx_v_light->_w == 0.0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/model/cellshading.pyx":431 */
      __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":432 */
        __pyx_v_tmp = (-vector_dot_product(__pyx_v_ptr1,__pyx_v_light->_data));

        /* "/home/jiba/src/soya/model/cellshading.pyx":433 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/model/cellshading.pyx":434 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);
        __pyx_L5:;
      }
      __pyx_L6:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/cellshading.pyx":437 */
      __pyx_v_ptr2 = __pyx_v_self->__pyx_base._coords;

      /* "/home/jiba/src/soya/model/cellshading.pyx":438 */
      __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":439 */
        (__pyx_v_v[0]) = ((__pyx_v_light->_data[0]) - (__pyx_v_ptr2[0]));

        /* "/home/jiba/src/soya/model/cellshading.pyx":440 */
        (__pyx_v_v[1]) = ((__pyx_v_light->_data[1]) - (__pyx_v_ptr2[1]));

        /* "/home/jiba/src/soya/model/cellshading.pyx":441 */
        (__pyx_v_v[2]) = ((__pyx_v_light->_data[2]) - (__pyx_v_ptr2[2]));

        /* "/home/jiba/src/soya/model/cellshading.pyx":442 */
        vector_normalize(__pyx_v_v);

        /* "/home/jiba/src/soya/model/cellshading.pyx":443 */
        __pyx_v_tmp = vector_dot_product(__pyx_v_ptr1,__pyx_v_v);

        /* "/home/jiba/src/soya/model/cellshading.pyx":444 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/model/cellshading.pyx":445 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);

        /* "/home/jiba/src/soya/model/cellshading.pyx":446 */
        __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._CellShadingModel._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_CellShadingModel__prepare_cellshading(struct __pyx_obj_5_soya__CellShadingModel *__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":451 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_renderer->top_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 451; 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 = 451; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 451; 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":452 */
  __pyx_2 = PyObject_GetIter(__pyx_v_5_soya_renderer->current_context->lights); if (!__pyx_2) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 452; 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 = 452; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 452; 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":454 */
  __pyx_3 = (__pyx_v_self->__pyx_base._nb_vnormals > 0);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":455 */
    __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":456 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":457 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":460 */
    __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":463 */
      __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._CellShadingModel._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_CellShadingModel__render_triangle_cellshading(struct __pyx_obj_5_soya__CellShadingModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__pyx_v_face),float (*__pyx_v_shades)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":468 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":469 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":470 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":471 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":473 */
    glNormal3fv((__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":474 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":475 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":476 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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._CellShadingModel._render_triangle_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_17_CellShadingModel__render_quad_cellshading(struct __pyx_obj_5_soya__CellShadingModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__pyx_v_face),float (*__pyx_v_shades)) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/cellshading.pyx":479 */
  __pyx_1 = (__pyx_v_face->option & __pyx_e_5_soya_FACE_SMOOTH_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":480 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":481 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":482 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":483 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":485 */
    glNormal3fv((__pyx_v_self->__pyx_base._values + __pyx_v_face->normal));

    /* "/home/jiba/src/soya/model/cellshading.pyx":486 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":487 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":488 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":489 */
    ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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._CellShadingModel._render_quad_cellshading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_17_CellShadingModel__render_vertex_cellshading_smoothlit(struct __pyx_obj_5_soya__CellShadingModel *__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":497 */
  __pyx_v_n = (__pyx_v_self->__pyx_base._vertex_coords[__pyx_v_index]);

  /* "/home/jiba/src/soya/model/cellshading.pyx":498 */
  __pyx_v_coord = (__pyx_v_self->__pyx_base._coords + __pyx_v_n);

  /* "/home/jiba/src/soya/model/cellshading.pyx":500 */
  __pyx_1 = (__pyx_v_face_option & __pyx_e_5_soya_FACE_NON_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":501 */
    __pyx_v_shade = 0.5;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":503 */
    __pyx_v_shade = (__pyx_v_shades[(__pyx_v_n / 3)]);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/cellshading.pyx":505 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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":506 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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":507 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":508 */
    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":509 */
    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":512 */
  glNormal3fv((__pyx_v_self->__pyx_base._vnormals + __pyx_v_n));

  /* "/home/jiba/src/soya/model/cellshading.pyx":513 */
  glVertex3fv(__pyx_v_coord);

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

static void __pyx_f_5_soya_17_CellShadingModel__render_vertex_cellshading(struct __pyx_obj_5_soya__CellShadingModel *__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":519 */
  __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":521 */
  __pyx_1 = (__pyx_v_face_option & __pyx_e_5_soya_FACE_NON_LIT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":522 */
    __pyx_v_shade = 0.5;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/cellshading.pyx":524 */
    __pyx_v_shade = ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":525 */
    __pyx_v_shade = ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__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":526 */
    __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":529 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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":530 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_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":531 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_MODEL_TEXCOORDS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/cellshading.pyx":532 */
    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":533 */
    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":536 */
  glVertex3fv(__pyx_v_coord);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._CellShadingModel._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":29 */
  __pyx_v_node = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

  /* "/home/jiba/src/soya/model/tree.pyx":30 */
  __pyx_v_node->nb_faces = 1;

  /* "/home/jiba/src/soya/model/tree.pyx":31 */
  __pyx_v_node->faces = ((int (*))malloc((sizeof(int ))));

  /* "/home/jiba/src/soya/model/tree.pyx":32 */
  (__pyx_v_node->faces[0]) = __pyx_v_face_index;

  /* "/home/jiba/src/soya/model/tree.pyx":33 */
  __pyx_v_node->nb_children = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":34 */
  __pyx_v_node->children = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":35 */
  memcpy(__pyx_v_node->sphere,__pyx_v_sphere,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":36 */
  __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":41 */
  __pyx_v_d = point_distance_to(__pyx_v_node->sphere,__pyx_v_sphere);

  /* "/home/jiba/src/soya/model/tree.pyx":42 */
  __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":44 */
    __pyx_v_n = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

    /* "/home/jiba/src/soya/model/tree.pyx":45 */
    __pyx_v_n->nb_faces = 1;

    /* "/home/jiba/src/soya/model/tree.pyx":46 */
    __pyx_v_n->faces = ((int (*))malloc((sizeof(int ))));

    /* "/home/jiba/src/soya/model/tree.pyx":47 */
    (__pyx_v_n->faces[0]) = __pyx_v_face_index;

    /* "/home/jiba/src/soya/model/tree.pyx":48 */
    __pyx_v_n->nb_children = 1;

    /* "/home/jiba/src/soya/model/tree.pyx":49 */
    __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":50 */
    (__pyx_v_n->children[0]) = __pyx_v_node;

    /* "/home/jiba/src/soya/model/tree.pyx":51 */
    memcpy(__pyx_v_n->sphere,__pyx_v_sphere,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/tree.pyx":52 */
    __pyx_r = __pyx_v_n;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/tree.pyx":54 */
    __pyx_1 = (__pyx_v_parent == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":55 */
      __pyx_v_n = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

      /* "/home/jiba/src/soya/model/tree.pyx":56 */
      __pyx_v_n->nb_faces = 0;

      /* "/home/jiba/src/soya/model/tree.pyx":57 */
      __pyx_v_n->faces = 0;

      /* "/home/jiba/src/soya/model/tree.pyx":58 */
      __pyx_v_n->nb_children = 2;

      /* "/home/jiba/src/soya/model/tree.pyx":59 */
      __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":60 */
      (__pyx_v_n->children[0]) = __pyx_v_node;

      /* "/home/jiba/src/soya/model/tree.pyx":61 */
      (__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":62 */
      sphere_from_2_spheres(__pyx_v_n->sphere,__pyx_v_node->sphere,__pyx_v_sphere);

      /* "/home/jiba/src/soya/model/tree.pyx":63 */
      __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":65 */
  __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":70 */
  __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":71 */
    __pyx_v_d = point_distance_to((__pyx_v_node->children[__pyx_v_i])->sphere,__pyx_v_sphere);

    /* "/home/jiba/src/soya/model/tree.pyx":72 */
    __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":73 */
      __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":74 */
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":75 */
  __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":80 */
  __pyx_v_i = 0;
  __pyx_v_added = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":82 */
  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":83 */
    __pyx_1 = ((__pyx_v_node->children[__pyx_v_i]) == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":84 */
      __pyx_1 = (__pyx_v_added == 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/tree.pyx":85 */
        (__pyx_v_node->children[__pyx_v_i]) = __pyx_v_add;

        /* "/home/jiba/src/soya/model/tree.pyx":86 */
        __pyx_v_added = 1;
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/model/tree.pyx":87 */
      __pyx_v_i = (__pyx_v_i + 1);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/tree.pyx":89 */
      __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":90 */
      __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":92 */
        __pyx_f_5_soya_node_add_node(__pyx_v_add,(__pyx_v_node->children[__pyx_v_i]));

        /* "/home/jiba/src/soya/model/tree.pyx":93 */
        __pyx_1 = (__pyx_v_added == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/tree.pyx":94 */
          (__pyx_v_node->children[__pyx_v_i]) = __pyx_v_add;

          /* "/home/jiba/src/soya/model/tree.pyx":95 */
          __pyx_v_added = 1;

          /* "/home/jiba/src/soya/model/tree.pyx":96 */
          __pyx_v_i = (__pyx_v_i + 1);
          goto __pyx_L7;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/tree.pyx":98 */
          __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

          /* "/home/jiba/src/soya/model/tree.pyx":99 */
          (__pyx_v_node->children[__pyx_v_i]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);

          /* "/home/jiba/src/soya/model/tree.pyx":100 */
          (__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":102 */
  __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":107 */
  __pyx_v_new = __pyx_f_5_soya_node_new(__pyx_v_face_index,__pyx_v_sphere);

  /* "/home/jiba/src/soya/model/tree.pyx":108 */
  __pyx_f_5_soya_node_register_node(__pyx_v_node,__pyx_v_new);

  /* "/home/jiba/src/soya/model/tree.pyx":109 */
  __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":116 */
  __pyx_1 = (-1);
  __pyx_v_best1 = __pyx_1;
  __pyx_v_best2 = __pyx_1;

  /* "/home/jiba/src/soya/model/tree.pyx":119 */
  __pyx_2 = (__pyx_v_mode == 0);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/tree.pyx":120 */
    __pyx_v_min_radius = 100000.0;

    /* "/home/jiba/src/soya/model/tree.pyx":121 */
    __pyx_v_radius = (__pyx_v_param * (__pyx_v_node->sphere[3]));

    /* "/home/jiba/src/soya/model/tree.pyx":122 */
    __pyx_v_n = 0;

    /* "/home/jiba/src/soya/model/tree.pyx":123 */
    __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":124 */
      __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":125 */
        __pyx_v_best1 = __pyx_v_i;

        /* "/home/jiba/src/soya/model/tree.pyx":126 */
        __pyx_v_n = (__pyx_v_node->children[__pyx_v_i]);

        /* "/home/jiba/src/soya/model/tree.pyx":127 */
        __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":128 */
    __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":130 */
      __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":131 */
        __pyx_3 = (__pyx_v_i != __pyx_v_best1);
        if (__pyx_3) {

          /* "/home/jiba/src/soya/model/tree.pyx":132 */
          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":133 */
          __pyx_3 = ((__pyx_v_best_sphere[3]) <= __pyx_v_radius);
          if (__pyx_3) {

            /* "/home/jiba/src/soya/model/tree.pyx":134 */
            __pyx_v_best2 = __pyx_v_i;

            /* "/home/jiba/src/soya/model/tree.pyx":135 */
            goto __pyx_L8;
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;
        __pyx_L7:;
      }
      __pyx_L8:;

      /* "/home/jiba/src/soya/model/tree.pyx":136 */
      __pyx_r = 0;
      goto __pyx_L0;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/tree.pyx":140 */
    __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":141 */
      __pyx_v_n = (__pyx_v_node->children[__pyx_v_i]);

      /* "/home/jiba/src/soya/model/tree.pyx":142 */
      __pyx_2 = (__pyx_v_n != 0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/tree.pyx":143 */
        __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":144 */
          __pyx_4 = ((__pyx_v_node->children[__pyx_v_j]) != 0);
          if (__pyx_4) {

            /* "/home/jiba/src/soya/model/tree.pyx":145 */
            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":146 */
            __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":147 */
              memcpy(__pyx_v_best_sphere,__pyx_v_sphere,(4 * (sizeof(float ))));

              /* "/home/jiba/src/soya/model/tree.pyx":148 */
              __pyx_v_best1 = __pyx_v_i;

              /* "/home/jiba/src/soya/model/tree.pyx":149 */
              __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":150 */
  __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":152 */
  __pyx_v_n = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

  /* "/home/jiba/src/soya/model/tree.pyx":153 */
  __pyx_v_n->nb_faces = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":154 */
  __pyx_v_n->faces = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":155 */
  __pyx_v_n->nb_children = 2;

  /* "/home/jiba/src/soya/model/tree.pyx":156 */
  __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":157 */
  (__pyx_v_n->children[0]) = (__pyx_v_node->children[__pyx_v_best1]);

  /* "/home/jiba/src/soya/model/tree.pyx":158 */
  (__pyx_v_n->children[1]) = (__pyx_v_node->children[__pyx_v_best2]);

  /* "/home/jiba/src/soya/model/tree.pyx":159 */
  memcpy(__pyx_v_n->sphere,__pyx_v_best_sphere,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/tree.pyx":160 */
  __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

  /* "/home/jiba/src/soya/model/tree.pyx":161 */
  (__pyx_v_node->children[__pyx_v_best1]) = __pyx_v_n;

  /* "/home/jiba/src/soya/model/tree.pyx":162 */
  (__pyx_v_node->children[__pyx_v_best2]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);

  /* "/home/jiba/src/soya/model/tree.pyx":163 */
  __pyx_f_5_soya_node_added(__pyx_v_node,__pyx_v_n);

  /* "/home/jiba/src/soya/model/tree.pyx":164 */
  __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":170 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":171 */
  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":172 */
    __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":173 */
      __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":174 */
      __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":176 */
        __pyx_f_5_soya_node_add_node(__pyx_v_new,(__pyx_v_node->children[__pyx_v_i]));

        /* "/home/jiba/src/soya/model/tree.pyx":177 */
        __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

        /* "/home/jiba/src/soya/model/tree.pyx":178 */
        (__pyx_v_node->children[__pyx_v_i]) = (__pyx_v_node->children[__pyx_v_node->nb_children]);

        /* "/home/jiba/src/soya/model/tree.pyx":179 */
        (__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":184 */
  __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":185 */
  (__pyx_v_node->children[__pyx_v_node->nb_children]) = __pyx_v_add;

  /* "/home/jiba/src/soya/model/tree.pyx":186 */
  __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":190 */
  __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":191 */
    __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":192 */
      __pyx_f_5_soya_node_join(__pyx_v_node,(__pyx_v_node->children[__pyx_v_i]));

      /* "/home/jiba/src/soya/model/tree.pyx":193 */
      __pyx_v_node->nb_children = (__pyx_v_node->nb_children - 1);

      /* "/home/jiba/src/soya/model/tree.pyx":194 */
      (__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":198 */
  __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":199 */
  __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":200 */
  __pyx_v_n1->nb_faces = (__pyx_v_n1->nb_faces + __pyx_v_n2->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":202 */
  __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":203 */
  __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":204 */
  __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":208 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_node->nb_children > 2);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/tree.pyx":209 */
    __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":210 */
  __pyx_f_5_soya_node_collapse_with_child(__pyx_v_node,__pyx_v_collapse);

  /* "/home/jiba/src/soya/model/tree.pyx":211 */
  __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":212 */
  __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":216 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":217 */
  __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":218 */
    __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":219 */
    __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":220 */
  __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":224 */
  __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":225 */
  __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":226 */
  __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":231 */
  __pyx_1 = (sphere_distance_sphere(__pyx_v_sphere,__pyx_v_node->sphere) < 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":233 */
    chunk_add(__pyx_v_items,__pyx_v_node->faces,(__pyx_v_node->nb_faces * (sizeof(int ))));

    /* "/home/jiba/src/soya/model/tree.pyx":234 */
    __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 = 234; 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_TreeModel___getcstate__(struct __pyx_obj_5_soya__TreeModel *__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":241 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/tree.pyx":242 */
  __pyx_1 = ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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 = 242; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":243 */
  __pyx_1 = __pyx_vtabptr_5_soya__SimpleModel->__pyx_base.__pyx_base.__getcstate__(((struct __pyx_obj_5_soya__CObj *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 243; 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 = 243; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __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._TreeModel.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_10_TreeModel___setcstate__(struct __pyx_obj_5_soya__TreeModel *__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":246 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 246; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 246; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_vtabptr_5_soya__SimpleModel->__setcstate_data__(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_2);
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":249 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 249; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 249; 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":250 */
  __pyx_v_self->_tree = ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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":251 */
  drop_chunk(__pyx_v_chunk);

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

static PyObject *__pyx_f_5_soya_10_TreeModel__node2chunk(struct __pyx_obj_5_soya__TreeModel *__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":255 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_node->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":256 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_node->nb_children);

  /* "/home/jiba/src/soya/model/tree.pyx":257 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_node->sphere,4);

  /* "/home/jiba/src/soya/model/tree.pyx":258 */
  chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_node->faces,__pyx_v_node->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":259 */
  __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__TreeModel *)__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 = 259; 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._TreeModel._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_TreeModel__chunk2node(struct __pyx_obj_5_soya__TreeModel *__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":264 */
  __pyx_v_node = ((struct __pyx_t_5_soya__Node (*))malloc((sizeof(struct __pyx_t_5_soya__Node ))));

  /* "/home/jiba/src/soya/model/tree.pyx":265 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_node->nb_faces));

  /* "/home/jiba/src/soya/model/tree.pyx":266 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_node->nb_children));

  /* "/home/jiba/src/soya/model/tree.pyx":267 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_node->sphere,4);

  /* "/home/jiba/src/soya/model/tree.pyx":268 */
  __pyx_v_node->faces = ((int (*))malloc((__pyx_v_node->nb_faces * (sizeof(int )))));

  /* "/home/jiba/src/soya/model/tree.pyx":269 */
  __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":270 */
  chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_node->faces,__pyx_v_node->nb_faces);

  /* "/home/jiba/src/soya/model/tree.pyx":271 */
  __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__TreeModel *)__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":272 */
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeModel._chunk2node");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k299p;

static char (__pyx_k299[]) = "* Soya * Tree built,     %s levels, memory : %s bytes";

static void __pyx_f_5_soya_10_TreeModel__build_tree(struct __pyx_obj_5_soya__TreeModel *__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":278 */
  __pyx_v_tree = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":280 */
  __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":281 */
    ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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":282 */
    __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":285 */
  __pyx_v_self->_tree = __pyx_v_tree;

  /* "/home/jiba/src/soya/model/tree.pyx":287 */
  __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 = 287; 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 = 287; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 287; 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_k299p, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 287; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 287; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 287; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._TreeModel._build_tree");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k300p;

static char (__pyx_k300[]) = "* Soya * Tree optimized, %s levels, memory : %s bytes";

static void __pyx_f_5_soya_10_TreeModel__optimize_tree(struct __pyx_obj_5_soya__TreeModel *__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":290 */
  __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":292 */
  __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 = 292; 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 = 292; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 292; 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_k300p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 292; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 292; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 292; goto __pyx_L1;}

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

static void __pyx_f_5_soya_10_TreeModel_compute_sphere(struct __pyx_obj_5_soya__TreeModel *__pyx_v_self,__pyx_t_5_soya_ModelFace (*__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":296 */
  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":297 */
  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":298 */
  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":299 */
  __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":301 */
    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":302 */
    sphere_from_points(__pyx_v_sphere,__pyx_v_p,4);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static void __pyx_f_5_soya_10_TreeModel__batch(struct __pyx_obj_5_soya__TreeModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  __pyx_t_5_soya_Frustum (*__pyx_v_frustum);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  /* "/home/jiba/src/soya/model/tree.pyx":308 */
  __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_HIDDEN);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/tree.pyx":311 */
  __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_body));

  /* "/home/jiba/src/soya/model/tree.pyx":315 */
  ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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":316 */
  __pyx_f_5_soya_pack_batch_end(((PyObject *)__pyx_v_self),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeModel._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_10_TreeModel__batch_node(struct __pyx_obj_5_soya__TreeModel *__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":323 */
  __pyx_1 = (sphere_in_frustum(__pyx_v_frustum,__pyx_v_node->sphere) == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":324 */
    __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__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._batch_face(((struct __pyx_obj_5_soya__SimpleModel *)__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":325 */
    __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__TreeModel *)__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._TreeModel._batch_node");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_10_TreeModel__render(struct __pyx_obj_5_soya__TreeModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_instance) {
  struct __pyx_t_5_soya__Pack (*__pyx_v_pack);
  __pyx_t_5_soya_ModelFace (*__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":331 */
  __pyx_f_5_soya_model_option_activate(__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/tree.pyx":333 */
  __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":334 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_pack != 0);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/tree.pyx":335 */
    __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":336 */
    __pyx_f_5_soya_face_option_activate(__pyx_v_pack->option);

    /* "/home/jiba/src/soya/model/tree.pyx":338 */
    __pyx_v_face = ((__pyx_t_5_soya_ModelFace (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

    /* "/home/jiba/src/soya/model/tree.pyx":339 */
    __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_FACE_TRIANGLE);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/tree.pyx":340 */
      glBegin(GL_TRIANGLES);

      /* "/home/jiba/src/soya/model/tree.pyx":341 */
      while (1) {
        __pyx_L5:;
        __pyx_1 = (__pyx_v_face != 0);
        if (!__pyx_1) break;

        /* "/home/jiba/src/soya/model/tree.pyx":342 */
        ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._render_triangle(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_face);

        /* "/home/jiba/src/soya/model/tree.pyx":343 */
        __pyx_v_face = ((__pyx_t_5_soya_ModelFace (*))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":346 */
      glBegin(GL_QUADS);

      /* "/home/jiba/src/soya/model/tree.pyx":347 */
      while (1) {
        __pyx_L7:;
        __pyx_1 = (__pyx_v_face != 0);
        if (!__pyx_1) break;

        /* "/home/jiba/src/soya/model/tree.pyx":348 */
        ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._render_quad(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_self),__pyx_v_face);

        /* "/home/jiba/src/soya/model/tree.pyx":349 */
        __pyx_v_face = ((__pyx_t_5_soya_ModelFace (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
      }
      __pyx_L8:;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/tree.pyx":351 */
    glEnd();

    /* "/home/jiba/src/soya/model/tree.pyx":352 */
    __pyx_f_5_soya_face_option_inactivate(__pyx_v_pack->option);

    /* "/home/jiba/src/soya/model/tree.pyx":353 */
    __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":355 */
  __pyx_f_5_soya_model_option_inactivate(__pyx_v_self->__pyx_base._option);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._TreeModel._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_instance);
}

static void __pyx_f_5_soya_10_TreeModel__raypick(struct __pyx_obj_5_soya__TreeModel *__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":359 */
  __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":360 */
  ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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._TreeModel._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_TreeModel__raypick_b(struct __pyx_obj_5_soya__TreeModel *__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":364 */
  __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":365 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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._TreeModel._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_TreeModel__node_raypick(struct __pyx_obj_5_soya__TreeModel *__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":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) {
      ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick(((struct __pyx_obj_5_soya__SimpleModel *)__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":371 */
    __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__TreeModel *)__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._TreeModel._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_TreeModel__node_raypick_b(struct __pyx_obj_5_soya__TreeModel *__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":375 */
  __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_node->sphere) == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/tree.pyx":376 */
    __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":377 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick_b(((struct __pyx_obj_5_soya__SimpleModel *)__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":378 */
    __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":379 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya__TreeModel *)__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":380 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._TreeModel._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_TreeModel__collect_raypickables(struct __pyx_obj_5_soya__TreeModel *__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":383 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_self)));

  /* "/home/jiba/src/soya/model/tree.pyx":384 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_parent)));

  /* "/home/jiba/src/soya/model/tree.pyx":385 */
  __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 = 385; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/tree.pyx":386 */
  chunk_add_int(__pyx_v_items,(-1));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._TreeModel._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static void __pyx_f_5_soya_10_TreeModel__raypick_from_context(struct __pyx_obj_5_soya__TreeModel *__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":392 */
  __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":393 */
  __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":394 */
  __pyx_v_face_index = chunk_get_int(__pyx_v_items);

  /* "/home/jiba/src/soya/model/tree.pyx":395 */
  while (1) {
    __pyx_L2:;
    __pyx_2 = (__pyx_v_face_index != (-1));
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/model/tree.pyx":396 */
    ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick(((struct __pyx_obj_5_soya__SimpleModel *)__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":397 */
    __pyx_v_face_index = chunk_get_int(__pyx_v_items);
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._TreeModel._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_TreeModel__raypick_from_context_b(struct __pyx_obj_5_soya__TreeModel *__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":403 */
  __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":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/model/tree.pyx":405 */
  __pyx_v_face_index = chunk_get_int(__pyx_v_items);

  /* "/home/jiba/src/soya/model/tree.pyx":406 */
  while (1) {
    __pyx_L2:;
    __pyx_2 = (__pyx_v_face_index != (-1));
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/model/tree.pyx":407 */
    __pyx_2 = ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._face_raypick_b(((struct __pyx_obj_5_soya__SimpleModel *)__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":408 */
    __pyx_v_face_index = chunk_get_int(__pyx_v_items);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/tree.pyx":409 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._TreeModel._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":34 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_width); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 34; 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 = 35; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":36 */
  ((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":40 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Sprite *)__pyx_v_self)->_height); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 40; 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 = 41; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":42 */
  ((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":46 */
  __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 = 46; 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 = 46; 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 = 46; 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 = 46; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 46; 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":48 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 48; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 48; 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 = 48; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 48; 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 = 48; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 48; 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 = 48; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 48; 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 = 48; 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":52 */
  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 = 53; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":54 */
  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":58 */
  __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 = 58; 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 = 59; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":60 */
  __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_k96;
  __pyx_v_material = __pyx_k97;
  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 = 63; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 63; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":64 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 64; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 64; 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 = 64; 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":65 */
  __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 = 65; 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 = 65; 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":66 */
  (((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":67 */
  ((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":73 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/sprite.pyx":74 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/sprite.pyx":75 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":76 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_width);

  /* "/home/jiba/src/soya/model/sprite.pyx":77 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_height);

  /* "/home/jiba/src/soya/model/sprite.pyx":78 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":79 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 79; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 79; 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":82 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/sprite.pyx":87 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 87; 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 = 87; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 87; 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 = 87; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":88 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":89 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/sprite.pyx":90 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":91 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_width));

  /* "/home/jiba/src/soya/model/sprite.pyx":92 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_height));

  /* "/home/jiba/src/soya/model/sprite.pyx":93 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":94 */
  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 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":97 */
  __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":98 */
  __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":99 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_option); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 99; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_e_5_soya_SPRITE_ALPHA); if (!__pyx_3) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 99; goto __pyx_L1;}
    __pyx_4 = PyNumber_And(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 99; 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 = 99; 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 = 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->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 = 100; 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 = 101; 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":106 */
  __pyx_v_b = __pyx_v_self->__pyx_base.__pyx_base._parent->_render_matrix;

  /* "/home/jiba/src/soya/model/sprite.pyx":107 */
  __pyx_v_a = (&(__pyx_v_self->__pyx_base._matrix[12]));

  /* "/home/jiba/src/soya/model/sprite.pyx":108 */
  (__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":109 */
  (__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":110 */
  (__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":111 */
  ((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":112 */
  glLoadMatrixf(__pyx_v_5_soya__SPRITE_MATRIX);

  /* "/home/jiba/src/soya/model/sprite.pyx":113 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":114 */
  __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":116 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/sprite.pyx":117 */
    glNormal3f(0.0,0.0,(-1.0));
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":118 */
  glColor4fv(__pyx_v_self->_color);

  /* "/home/jiba/src/soya/model/sprite.pyx":120 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":121 */
  glTexCoord2f(0.0,0.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(1.0,0.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 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":123 */
  glVertex3f(__pyx_v_self->_width,__pyx_v_self->_height,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":124 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":124 */
  glVertex3f((-__pyx_v_self->_width),__pyx_v_self->_height,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":125 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":126 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":127 */
  __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":131 */
  __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":132 */
    __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":133 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/sprite.pyx":134 */
  __pyx_1 = ((__pyx_v_self->_color[3]) < 1.0);
  if (__pyx_1) {

    /* "/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);

    /* "/home/jiba/src/soya/model/sprite.pyx":136 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/sprite.pyx":137 */
  __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":145 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/sprite.pyx":146 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base.__pyx_base._option);

  /* "/home/jiba/src/soya/model/sprite.pyx":147 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base.__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":148 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._width);

  /* "/home/jiba/src/soya/model/sprite.pyx":149 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._height);

  /* "/home/jiba/src/soya/model/sprite.pyx":150 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":151 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 151; 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":154 */
  __pyx_v_self->__pyx_base.__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/sprite.pyx":159 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 159; 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 = 159; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 159; 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 = 159; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":160 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":161 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base.__pyx_base._option));

  /* "/home/jiba/src/soya/model/sprite.pyx":162 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base.__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":163 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._width));

  /* "/home/jiba/src/soya/model/sprite.pyx":164 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._height));

  /* "/home/jiba/src/soya/model/sprite.pyx":165 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":166 */
  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":172 */
  __pyx_v_m = __pyx_v_self->__pyx_base.__pyx_base.__pyx_base._parent->_render_matrix;

  /* "/home/jiba/src/soya/model/sprite.pyx":173 */
  __pyx_v_a = (&(__pyx_v_self->__pyx_base.__pyx_base._matrix[8]));

  /* "/home/jiba/src/soya/model/sprite.pyx":174 */
  (__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":175 */
  (__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":176 */
  (__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":177 */
  __pyx_v_a = (&(__pyx_v_self->__pyx_base.__pyx_base._matrix[12]));

  /* "/home/jiba/src/soya/model/sprite.pyx":178 */
  (__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":179 */
  (__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":180 */
  (__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":181 */
  __pyx_1 = ((__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[10]) == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":182 */
    __pyx_v_x = (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[8]);

    /* "/home/jiba/src/soya/model/sprite.pyx":183 */
    __pyx_v_y = (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[9]);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/sprite.pyx":185 */
    __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":186 */
    __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":187 */
    __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":189 */
  __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":190 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4]) = 0.0;

    /* "/home/jiba/src/soya/model/sprite.pyx":191 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) = 1.0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/sprite.pyx":193 */
    __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":194 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[5]) = ((-__pyx_v_x) * __pyx_v_f);

    /* "/home/jiba/src/soya/model/sprite.pyx":195 */
    (__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX[4]) = (__pyx_v_y * __pyx_v_f);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/sprite.pyx":196 */
  (__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":197 */
  (__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":198 */
  (__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":200 */
  ((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":201 */
  glLoadMatrixf(__pyx_v_5_soya__CYLINDER_SPRITE_MATRIX);

  /* "/home/jiba/src/soya/model/sprite.pyx":202 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":203 */
  __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":205 */
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

    /* "/home/jiba/src/soya/model/sprite.pyx":206 */
    glNormal3f(1.0,0.0,0.0);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/sprite.pyx":207 */
  glColor4fv(__pyx_v_self->__pyx_base._color);

  /* "/home/jiba/src/soya/model/sprite.pyx":208 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":209 */
  glTexCoord2f(0.0,0.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(1.0,0.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 */
  glTexCoord2f(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":211 */
  glVertex3f(0.0,__pyx_v_self->__pyx_base._height,__pyx_v_self->__pyx_base._width);

  /* "/home/jiba/src/soya/model/sprite.pyx":212 */
  glTexCoord2f(0.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":212 */
  glVertex3f(0.0,(-__pyx_v_self->__pyx_base._height),__pyx_v_self->__pyx_base._width);

  /* "/home/jiba/src/soya/model/sprite.pyx":213 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":214 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":215 */
  __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":228 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/sprite.pyx":229 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/sprite.pyx":230 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":231 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":232 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 232; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 232; 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":235 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/sprite.pyx":240 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 240; 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 = 240; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 240; 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 = 240; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 240; 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 = 240; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":241 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/sprite.pyx":242 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/sprite.pyx":243 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/sprite.pyx":244 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_color,4);

  /* "/home/jiba/src/soya/model/sprite.pyx":245 */
  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":249 */
  __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 = 249; 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 = 249; 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 = 249; 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 = 249; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 249; 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":251 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_x, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 251; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 251; 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 = 251; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 251; 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 = 251; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 251; 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 = 251; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 251; 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 = 251; 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":255 */
  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 = 256; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":257 */
  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":261 */
  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 = 262; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":263 */
  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":267 */
  __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 = 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._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 = 268; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":269 */
  __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_k98;
  __pyx_v_material = __pyx_k99;
  __pyx_v_halo = __pyx_k100;
  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 = 272; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_halo), __pyx_ptype_5_soya__Material, 1, "halo")) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/sprite.pyx":273 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 273; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 273; 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 = 273; 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":274 */
  __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 = 274; 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 = 274; 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":275 */
  __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 = 275; 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 = 275; 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":276 */
  (((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":279 */
  __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":280 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_BONUS_BATCHED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/sprite.pyx":282 */
    __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":283 */
    __pyx_v_self->_angle = (__pyx_v_self->_angle + 4.0);

    /* "/home/jiba/src/soya/model/sprite.pyx":284 */
    __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":285 */
  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":286 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/model/sprite.pyx":287 */
  ((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":291 */
  __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":292 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":293 */
  __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":301 */
  __pyx_v_m = __pyx_v_self->__pyx_base._render_matrix;

  /* "/home/jiba/src/soya/model/sprite.pyx":302 */
  (__pyx_v_5_soya__SPRITE_MATRIX[12]) = (__pyx_v_m[12]);

  /* "/home/jiba/src/soya/model/sprite.pyx":303 */
  (__pyx_v_5_soya__SPRITE_MATRIX[13]) = ((__pyx_v_m[13]) + 1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":304 */
  (__pyx_v_5_soya__SPRITE_MATRIX[14]) = (__pyx_v_m[14]);

  /* "/home/jiba/src/soya/model/sprite.pyx":305 */
  glLoadMatrixf(__pyx_v_5_soya__SPRITE_MATRIX);

  /* "/home/jiba/src/soya/model/sprite.pyx":307 */
  ((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":308 */
  glColor4fv(__pyx_v_self->_color);

  /* "/home/jiba/src/soya/model/sprite.pyx":309 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/sprite.pyx":310 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":311 */
  glTexCoord2f(0.0,1.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(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":312 */
  glVertex3f((-1.0),1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":313 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":313 */
  glVertex3f(1.0,1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":314 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":314 */
  glVertex3f(1.0,(-1.0),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":315 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":316 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/model/sprite.pyx":318 */
  glRotatef(__pyx_v_self->_angle,0.0,1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":319 */
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);

  /* "/home/jiba/src/soya/model/sprite.pyx":320 */
  ((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":321 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/sprite.pyx":322 */
  glTexCoord2f(0.0,1.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(1.0,1.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":323 */
  glVertex3f(0.5,(-0.5),0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":324 */
  glTexCoord2f(1.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":324 */
  glVertex3f(0.5,0.5,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":325 */
  glTexCoord2f(0.0,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":325 */
  glVertex3f((-0.5),0.5,0.0);

  /* "/home/jiba/src/soya/model/sprite.pyx":326 */
  glEnd();

  /* "/home/jiba/src/soya/model/sprite.pyx":327 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/sprite.pyx":328 */
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_FALSE);

  /* "/home/jiba/src/soya/model/sprite.pyx":329 */
  __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 = 21; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":23 */
  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":39 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/particle.pyx":40 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/model/particle.pyx":41 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/particle.pyx":42 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_particles);

  /* "/home/jiba/src/soya/model/particle.pyx":43 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_max_particles);

  /* "/home/jiba/src/soya/model/particle.pyx":44 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_particle_size);

  /* "/home/jiba/src/soya/model/particle.pyx":45 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_colors);

  /* "/home/jiba/src/soya/model/particle.pyx":46 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_sizes);

  /* "/home/jiba/src/soya/model/particle.pyx":47 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_max_particles_per_round);

  /* "/home/jiba/src/soya/model/particle.pyx":48 */
  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":49 */
  __pyx_1 = __pyx_v_self->_nb_colors;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":50 */
    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":51 */
  __pyx_1 = __pyx_v_self->_nb_sizes;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":52 */
    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":54 */
  __pyx_2 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 54; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 54; 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":58 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 58; 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 = 58; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 58; 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 = 58; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 58; 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 = 58; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":59 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate2);

  /* "/home/jiba/src/soya/model/particle.pyx":60 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/particle.pyx":61 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/particle.pyx":62 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_particles));

  /* "/home/jiba/src/soya/model/particle.pyx":63 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_max_particles));

  /* "/home/jiba/src/soya/model/particle.pyx":64 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":65 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/particle.pyx":66 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_sizes));

  /* "/home/jiba/src/soya/model/particle.pyx":67 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_max_particles_per_round));

  /* "/home/jiba/src/soya/model/particle.pyx":69 */
  __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":70 */
  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":71 */
  __pyx_4 = __pyx_v_self->_nb_colors;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/particle.pyx":72 */
    __pyx_v_self->_fading_colors = ((float (*))malloc(((4 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":73 */
    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":74 */
  __pyx_4 = __pyx_v_self->_nb_sizes;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/particle.pyx":75 */
    __pyx_v_self->_sizes = ((float (*))malloc(((2 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/particle.pyx":76 */
    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":78 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/particle.pyx":79 */
  __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":83 */
  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 = 84; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":85 */
  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":86 */
  ((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":90 */
  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 = 91; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":92 */
  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":96 */
  __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 = 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._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 = 97; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":98 */
  ((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":102 */
  __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 = 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._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 = 103; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":104 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":105 */
  ((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":109 */
  __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 = 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._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 = 110; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":111 */
  __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":116 */
  __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 = 116; 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 = 117; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":118 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":119 */
    ((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":120 */
    ((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":122 */
    ((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":123 */
    ((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":127 */
  __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 = 127; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_REMOVABLE); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 127; goto __pyx_L1;}
  __pyx_3 = PyNumber_And(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 127; 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 = 128; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":129 */
  __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":134 */
  __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 = 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._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 = 135; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":136 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":137 */
  __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_k101;
  __pyx_v_material = __pyx_k102;
  __pyx_v_nb_max_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_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 = 139; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 139; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":140 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 140; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 140; 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 = 140; 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":141 */
  __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 = 141; 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 = 141; 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":142 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particle_size = 11;

  /* "/home/jiba/src/soya/model/particle.pyx":143 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes = 1;

  /* "/home/jiba/src/soya/model/particle.pyx":144 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes = ((float (*))malloc((2 * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/particle.pyx":145 */
  (((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":146 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_max_particles_per_round = 1000000;

  /* "/home/jiba/src/soya/model/particle.pyx":147 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_creatable_particles = __pyx_v_nb_max_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":148 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_max_particles = __pyx_v_nb_max_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":149 */
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":150 */
  ((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":152 */
  __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":155 */
  __pyx_v_self->_particle_size = 11;

  /* "/home/jiba/src/soya/model/particle.pyx":156 */
  __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":157 */
  __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":158 */
  __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":159 */
  __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":162 */
  free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_particles);

  /* "/home/jiba/src/soya/model/particle.pyx":163 */
  free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_sizes);

  /* "/home/jiba/src/soya/model/particle.pyx":164 */
  __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_k105;
  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":168 */
  __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":169 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":170 */
  __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":171 */
  __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":172 */
  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 = 172; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 172; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 172; 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 = 172; 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":175 */
  __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":176 */
    ((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":179 */
  ((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_MAIN_LOOP;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_MAIN_LOOP = Py_None; Py_INCREF(__pyx_v_MAIN_LOOP);

  /* "/home/jiba/src/soya/model/particle.pyx":185 */
  __pyx_v_decay = ((-0.05) * __pyx_v_proportion);

  /* "/home/jiba/src/soya/model/particle.pyx":186 */
  __pyx_v_particle = __pyx_v_self->_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":187 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":188 */
  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":189 */
    (__pyx_v_particle[0]) = ((__pyx_v_particle[0]) + __pyx_v_decay);

    /* "/home/jiba/src/soya/model/particle.pyx":190 */
    __pyx_1 = ((__pyx_v_particle[0]) < 0.0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/particle.pyx":192 */
      __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 = 192; goto __pyx_L1;}
        __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 192; goto __pyx_L1;}
        __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 192; 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 = 192; 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 = 192; goto __pyx_L1;}
        if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 192; 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":193 */
        __pyx_v_self->_nb_creatable_particles = (__pyx_v_self->_nb_creatable_particles - 1);
        goto __pyx_L5;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/particle.pyx":195 */
        __pyx_v_self->_nb_particles = (__pyx_v_self->_nb_particles - 1);

        /* "/home/jiba/src/soya/model/particle.pyx":197 */
        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":200 */
        goto __pyx_L2;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/particle.pyx":203 */
      (__pyx_v_particle[5]) = ((__pyx_v_particle[5]) + ((__pyx_v_particle[8]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":204 */
      (__pyx_v_particle[6]) = ((__pyx_v_particle[6]) + ((__pyx_v_particle[9]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":205 */
      (__pyx_v_particle[7]) = ((__pyx_v_particle[7]) + ((__pyx_v_particle[10]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":206 */
      (__pyx_v_particle[2]) = ((__pyx_v_particle[2]) + ((__pyx_v_particle[5]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":207 */
      (__pyx_v_particle[3]) = ((__pyx_v_particle[3]) + ((__pyx_v_particle[6]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":208 */
      (__pyx_v_particle[4]) = ((__pyx_v_particle[4]) + ((__pyx_v_particle[7]) * __pyx_v_proportion));

      /* "/home/jiba/src/soya/model/particle.pyx":210 */
      __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":211 */
        ((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":214 */
      __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":215 */
        __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":219 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_PARTICLES_CYLINDER);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/particle.pyx":220 */
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/particle.pyx":222 */
    __pyx_v_particle = (__pyx_v_particle + __pyx_v_self->_particle_size);

    /* "/home/jiba/src/soya/model/particle.pyx":223 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/particle.pyx":225 */
  __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":226 */
    __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_regenerate); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 226; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_self->_nb_creatable_particles); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 226; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 226; 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 = 226; 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":227 */
    __pyx_v_self->_nb_creatable_particles = 0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/home/jiba/src/soya/model/particle.pyx":229 */
  __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":231 */
    __pyx_4 = PyList_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 231; goto __pyx_L1;}
    Py_INCREF(__pyx_n_MAIN_LOOP);
    PyList_SET_ITEM(__pyx_4, 0, __pyx_n_MAIN_LOOP);
    __pyx_2 = __Pyx_Import(__pyx_n_soya, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 231; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_MAIN_LOOP); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 231; goto __pyx_L1;}
    Py_DECREF(__pyx_v_MAIN_LOOP);
    __pyx_v_MAIN_LOOP = __pyx_3;
    __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/model/particle.pyx":232 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_MAIN_LOOP, __pyx_n_next_round_tasks); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 232; goto __pyx_L1;}
    __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 232; 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 = 232; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 232; 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 = 232; 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_MAIN_LOOP);
  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":235 */
  __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 = 235; 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 = 235; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 235; 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 = 235; 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":238 */
  __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":242 */
  ((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":243 */
  __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":244 */
    ((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":245 */
  __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":256 */
  ((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":258 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/model/particle.pyx":259 */
  __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":260 */
  __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":261 */
  __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":263 */
    __pyx_v_w = (__pyx_v_self->_sizes[0]);

    /* "/home/jiba/src/soya/model/particle.pyx":264 */
    __pyx_v_h = (__pyx_v_self->_sizes[1]);
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/particle.pyx":266 */
  glLoadIdentity();

  /* "/home/jiba/src/soya/model/particle.pyx":268 */
  __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 = 268; 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":270 */
  __pyx_v_particle = __pyx_v_self->_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":272 */
  glBegin(GL_QUADS);

  /* "/home/jiba/src/soya/model/particle.pyx":273 */
  __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":274 */
    __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":275 */
      glColor4fv((__pyx_v_particle + 11));

      /* "/home/jiba/src/soya/model/particle.pyx":277 */
      __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":278 */
        __pyx_v_w = (__pyx_v_particle[15]);

        /* "/home/jiba/src/soya/model/particle.pyx":279 */
        __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":281 */
      __pyx_v_w = (__pyx_v_particle[11]);

      /* "/home/jiba/src/soya/model/particle.pyx":282 */
      __pyx_v_h = (__pyx_v_particle[12]);
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/particle.pyx":284 */
    (__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":285 */
    (__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":286 */
    (__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":287 */
    glTexCoord2f(0.0,0.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(1.0,0.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 */
    glTexCoord2f(1.0,1.0);

    /* "/home/jiba/src/soya/model/particle.pyx":289 */
    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":290 */
    glTexCoord2f(0.0,1.0);

    /* "/home/jiba/src/soya/model/particle.pyx":290 */
    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":291 */
    __pyx_v_particle = (__pyx_v_particle + __pyx_v_self->_particle_size);
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/particle.pyx":293 */
  glEnd();

  /* "/home/jiba/src/soya/model/particle.pyx":294 */
  __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":295 */
  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":299 */
  __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":300 */
    __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":302 */
    __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":308 */
  __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":311 */
    __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":312 */
    __pyx_v_i = ((int )__pyx_v_life);

    /* "/home/jiba/src/soya/model/particle.pyx":313 */
    __pyx_v_c1 = (__pyx_v_self->_fading_colors + (4 * __pyx_v_i));

    /* "/home/jiba/src/soya/model/particle.pyx":314 */
    __pyx_v_c2 = (__pyx_v_self->_fading_colors + (4 * (__pyx_v_i + 1)));

    /* "/home/jiba/src/soya/model/particle.pyx":315 */
    __pyx_v_f2 = (__pyx_v_life - __pyx_v_i);

    /* "/home/jiba/src/soya/model/particle.pyx":316 */
    __pyx_v_f1 = (1.0 - __pyx_v_f2);

    /* "/home/jiba/src/soya/model/particle.pyx":317 */
    (__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":318 */
    (__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":319 */
    (__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":320 */
    (__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":326 */
  __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":329 */
    __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":330 */
    __pyx_v_i = ((int )__pyx_v_life);

    /* "/home/jiba/src/soya/model/particle.pyx":331 */
    __pyx_v_c1 = (__pyx_v_self->_sizes + (2 * __pyx_v_i));

    /* "/home/jiba/src/soya/model/particle.pyx":332 */
    __pyx_v_c2 = (__pyx_v_self->_sizes + (2 * (__pyx_v_i + 1)));

    /* "/home/jiba/src/soya/model/particle.pyx":333 */
    __pyx_v_f2 = (__pyx_v_life - __pyx_v_i);

    /* "/home/jiba/src/soya/model/particle.pyx":334 */
    __pyx_v_f1 = (1.0 - __pyx_v_f2);

    /* "/home/jiba/src/soya/model/particle.pyx":335 */
    (__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":336 */
    (__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":340 */
  __pyx_v_particle = (__pyx_v_self->_particles + (__pyx_v_index * __pyx_v_self->_particle_size));

  /* "/home/jiba/src/soya/model/particle.pyx":341 */
  (__pyx_v_particle[0]) = __pyx_v_life;
  (__pyx_v_particle[1]) = __pyx_v_life;

  /* "/home/jiba/src/soya/model/particle.pyx":342 */
  __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":344 */
  __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":346 */
  __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":347 */
    memcpy((__pyx_v_particle + 11),__pyx_v_self->_fading_colors,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/particle.pyx":348 */
    __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":351 */
  __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":352 */
  __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":355 */

  __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_k106;
  __pyx_v_dir_y = __pyx_k107;
  __pyx_v_dir_z = __pyx_k108;
  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":361 */
  __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":362 */
  (__pyx_v_particle[5]) = __pyx_v_speed_x;

  /* "/home/jiba/src/soya/model/particle.pyx":363 */
  (__pyx_v_particle[6]) = __pyx_v_speed_y;

  /* "/home/jiba/src/soya/model/particle.pyx":364 */
  (__pyx_v_particle[7]) = __pyx_v_speed_z;

  /* "/home/jiba/src/soya/model/particle.pyx":365 */
  (__pyx_v_particle[8]) = __pyx_v_accel_x;

  /* "/home/jiba/src/soya/model/particle.pyx":366 */
  (__pyx_v_particle[9]) = __pyx_v_accel_y;

  /* "/home/jiba/src/soya/model/particle.pyx":367 */
  (__pyx_v_particle[10]) = __pyx_v_accel_z;

  /* "/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_CYLINDER);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":369 */
    __pyx_v_i = 11;

    /* "/home/jiba/src/soya/model/particle.pyx":370 */
    __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":371 */
    __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":372 */
    (__pyx_v_particle[__pyx_v_i]) = __pyx_v_dir_x;

    /* "/home/jiba/src/soya/model/particle.pyx":373 */
    (__pyx_v_particle[(__pyx_v_i + 1)]) = __pyx_v_dir_y;

    /* "/home/jiba/src/soya/model/particle.pyx":374 */
    (__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_k109;
  __pyx_v_dir_y = __pyx_k110;
  __pyx_v_dir_z = __pyx_k111;
  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":380 */
  __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":381 */
  (__pyx_v_particle[0]) = __pyx_v_life;

  /* "/home/jiba/src/soya/model/particle.pyx":382 */
  (__pyx_v_particle[1]) = (__pyx_v_particle[0]);

  /* "/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_COLOR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":384 */
    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":385 */
    __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":386 */
  __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":387 */
  __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":389 */
  (__pyx_v_particle[2]) = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":390 */
  (__pyx_v_particle[3]) = __pyx_v_y;

  /* "/home/jiba/src/soya/model/particle.pyx":391 */
  (__pyx_v_particle[4]) = __pyx_v_z;

  /* "/home/jiba/src/soya/model/particle.pyx":392 */
  (__pyx_v_particle[5]) = __pyx_v_speed_x;

  /* "/home/jiba/src/soya/model/particle.pyx":393 */
  (__pyx_v_particle[6]) = __pyx_v_speed_y;

  /* "/home/jiba/src/soya/model/particle.pyx":394 */
  (__pyx_v_particle[7]) = __pyx_v_speed_z;

  /* "/home/jiba/src/soya/model/particle.pyx":395 */
  (__pyx_v_particle[8]) = __pyx_v_accel_x;

  /* "/home/jiba/src/soya/model/particle.pyx":396 */
  (__pyx_v_particle[9]) = __pyx_v_accel_y;

  /* "/home/jiba/src/soya/model/particle.pyx":397 */
  (__pyx_v_particle[10]) = __pyx_v_accel_z;

  /* "/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_CYLINDER);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":399 */
    __pyx_v_i = 11;

    /* "/home/jiba/src/soya/model/particle.pyx":400 */
    __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":401 */
    __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":402 */
    (__pyx_v_particle[__pyx_v_i]) = __pyx_v_dir_x;

    /* "/home/jiba/src/soya/model/particle.pyx":403 */
    (__pyx_v_particle[(__pyx_v_i + 1)]) = __pyx_v_dir_y;

    /* "/home/jiba/src/soya/model/particle.pyx":404 */
    (__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":408 */
  __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":409 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_particle[2])); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 409; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_particle[3])); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 409; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_particle[4])); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 409; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 409; 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":413 */
  __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":414 */
  (__pyx_v_particle[2]) = __pyx_v_x;

  /* "/home/jiba/src/soya/model/particle.pyx":415 */
  (__pyx_v_particle[3]) = __pyx_v_y;

  /* "/home/jiba/src/soya/model/particle.pyx":416 */
  (__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":421 */
  __pyx_1 = PyObject_Length(__pyx_v_colors); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 421; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors = __pyx_1;

  /* "/home/jiba/src/soya/model/particle.pyx":422 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_colors != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":423 */
    ((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":424 */
    __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":425 */
      __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 425; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_colors, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 425; 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":426 */
      __pyx_2 = PyInt_FromLong(0); 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)]) = __pyx_4;

      /* "/home/jiba/src/soya/model/particle.pyx":427 */
      __pyx_2 = PyInt_FromLong(1); 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) + 1)]) = __pyx_4;

      /* "/home/jiba/src/soya/model/particle.pyx":428 */
      __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 428; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 428; 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 = 428; 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":429 */
      __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 429; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 429; 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 = 429; 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":430 */
    ((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":431 */
    __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":434 */
    __pyx_1 = (((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors != 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/particle.pyx":435 */
      free(((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors);

      /* "/home/jiba/src/soya/model/particle.pyx":436 */
      ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_fading_colors = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/model/particle.pyx":437 */
    ((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":438 */
  ((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":439 */
  ((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":443 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_sizes); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 443; goto __pyx_L1;}
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/particle.pyx":444 */
    __pyx_1 = PyObject_Length(__pyx_v_sizes); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 444; goto __pyx_L1;}
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes = __pyx_1;

    /* "/home/jiba/src/soya/model/particle.pyx":445 */
    ((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":446 */
    __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":447 */
      __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 447; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_sizes, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 447; 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":448 */
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 448; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 448; 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 = 448; 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":449 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 449; goto __pyx_L1;}
      __pyx_3 = PyObject_GetItem(__pyx_v_size, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 449; 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 = 449; 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":450 */
    __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":453 */
    ((struct __pyx_obj_5_soya__Particles *)__pyx_v_self)->_nb_sizes = 1;

    /* "/home/jiba/src/soya/model/particle.pyx":454 */
    ((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":455 */
    (((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":456 */
    ((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":457 */
  ((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_k113;
  __pyx_v_material = __pyx_k114;
  __pyx_v_nb_particles = __pyx_k115;
  __pyx_v_removable = __pyx_k116;
  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 = 473; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 473; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":474 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 474; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 474; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 474; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 474; 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 = 474; 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":477 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; 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 = 477; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; 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 = 477; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; 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 = 477; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 477; 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 = 477; 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 = 477; 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":478 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 478; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.25); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 478; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.25); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 478; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 478; 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 = 478; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(1.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 478; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 478; 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 = 478; 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 = 478; 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":482 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 482; 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 = 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_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":483 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; 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 = 483; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; 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 = 483; goto __pyx_L1;}
  __pyx_1 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 483; 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 = 483; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":484 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; 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 = 484; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__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 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 484; 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 = 484; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":485 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; 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 = 485; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; 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 = 485; 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 = 485; 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 = 485; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; 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 = 485; goto __pyx_L1;}
  __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; 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 = 485; goto __pyx_L1;}
  __pyx_2 = PyNumber_Multiply(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 485; 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 = 485; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":486 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_index); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; 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 = 486; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; 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 = 486; 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 = 486; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(0.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble(0.0); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; goto __pyx_L1;}
  __pyx_11 = PyTuple_New(8); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 486; 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 = 486; 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_k117;
  __pyx_v_material = __pyx_k118;
  __pyx_v_nb_particles = __pyx_k119;
  __pyx_v_removable = __pyx_k120;
  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 = 489; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 489; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":490 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 490; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 490; 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 = 490; 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":493 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; 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 = 493; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; 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 = 493; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.3); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.3); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; 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 = 493; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 493; 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 = 493; 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 = 493; 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":494 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 494; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.25); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 494; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.25); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 494; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 494; 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 = 494; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(1.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 494; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 494; 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 = 494; 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 = 494; 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":498 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 498; 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 = 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_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":499 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; 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 = 499; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; 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 = 499; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 499; 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 = 499; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":500 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; 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 = 500; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__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 = PyFloat_FromDouble(0.5); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 500; 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 = 500; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":501 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; 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 = 501; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; 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 = 501; 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 = 501; 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 = 501; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; 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 = 501; goto __pyx_L1;}
  __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; 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 = 501; goto __pyx_L1;}
  __pyx_2 = PyNumber_Multiply(__pyx_5, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 501; 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 = 501; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":502 */
  __pyx_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_index); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; 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 = 502; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; 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 = 502; 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 = 502; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(0.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(0.0); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble(0.0); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; goto __pyx_L1;}
  __pyx_11 = PyTuple_New(8); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 502; 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 = 502; 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_k121;
  __pyx_v_material = __pyx_k122;
  __pyx_v_nb_particles = __pyx_k123;
  __pyx_v_removable = __pyx_k124;
  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 = 506; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":507 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 507; 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 = 507; 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":508 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(1.0); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; 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 = 508; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.7); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.8); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.8); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; 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 = 508; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.4); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.8); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.2); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 508; 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 = 508; 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 = 508; 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":509 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 509; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(0.25); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 509; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.25); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 509; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 509; 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 = 509; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 509; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 509; 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 = 509; 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 = 509; 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_k125;
  __pyx_v_y = __pyx_k126;
  __pyx_v_z = __pyx_k127;
  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":517 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 517; 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 = 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_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":518 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; 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 = 518; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; 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 = 518; goto __pyx_L1;}
  __pyx_1 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 518; 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 = 518; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":519 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; 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 = 519; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; 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 = 519; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 519; 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 = 519; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":520 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; 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 = 520; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; 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 = 520; 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 = 520; 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 = 520; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; 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 = 520; goto __pyx_L1;}
  __pyx_5 = PyNumber_Multiply(__pyx_6, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 520; 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 = 520; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":521 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.5); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; 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 = 521; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_5, __pyx_3); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; 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 = 521; 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 = 521; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(__pyx_v_y); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(__pyx_v_z); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble((__pyx_v_sx * __pyx_v_l)); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_11 = PyFloat_FromDouble(0.0); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_12 = PyFloat_FromDouble((-0.03)); if (!__pyx_12) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_13 = PyFloat_FromDouble(0.0); if (!__pyx_13) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; goto __pyx_L1;}
  __pyx_14 = PyTuple_New(11); if (!__pyx_14) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 521; 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 = 521; 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_k128;
  __pyx_v_material = __pyx_k129;
  __pyx_v_nb_particles = __pyx_k130;
  __pyx_v_removable = __pyx_k131;
  __pyx_v_subgenerator = __pyx_k132;
  __pyx_v_nb_sub_particles = __pyx_k133;
  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 = 533; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_material), __pyx_ptype_5_soya__Material, 1, "material")) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/particle.pyx":534 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 534; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_nb_particles); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 534; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_removable); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 534; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(5); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 534; 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 = 534; 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":535 */
  __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 = 535; 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 = 535; 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 = 535; 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 = 535; goto __pyx_L1;}
    if (PyDict_SetItem(__pyx_4, __pyx_n_nb_particles, __pyx_2) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 535; 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 = 535; 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 = 535; 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":536 */
  ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->_nb_sub_particles = __pyx_v_nb_sub_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":537 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_colors); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.9); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.7); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; 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 = 537; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; 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 = 537; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(1.0); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 537; 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 = 537; 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 = 537; 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":538 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_sizes); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 538; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(0.0); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 538; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(0.0); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 538; goto __pyx_L1;}
  __pyx_8 = PyTuple_New(2); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 538; 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 = 538; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.25); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 538; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 538; 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 = 538; 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 = 538; 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":539 */
  ((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":542 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya__Particles), __pyx_n_remove); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 542; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 542; 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 = 542; 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":543 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 543; 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 = 543; 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_k134;
  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":547 */
  __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":548 */
  __pyx_v_nb = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":549 */
  __pyx_v_i = ((struct __pyx_obj_5_soya_FlagFirework *)__pyx_v_self)->__pyx_base._nb_particles;

  /* "/home/jiba/src/soya/model/particle.pyx":550 */
  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":551 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_mygenerate); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 551; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 551; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 551; 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 = 551; 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":552 */
    __pyx_v_i = (__pyx_v_nb + 1);

    /* "/home/jiba/src/soya/model/particle.pyx":553 */
    __pyx_v_nb = (__pyx_v_i + 1);

    /* "/home/jiba/src/soya/model/particle.pyx":554 */
    __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":560 */
  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":561 */
  __pyx_1 = ((PyObject *)__pyx_v_subg) == Py_None;
  __pyx_2 = (!__pyx_1);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/particle.pyx":562 */
    __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":566 */
      __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 = 566; 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 = 566; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/particle.pyx":567 */
    __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_get_particle_position); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 567; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(__pyx_v_index); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 567; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 567; 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 = 567; 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":569 */
    __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":570 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_subg), __pyx_n_generate); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 570; goto __pyx_L1;}
      __pyx_5 = PyInt_FromLong(__pyx_v_i); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 570; goto __pyx_L1;}
      __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 570; goto __pyx_L1;}
      __pyx_6 = PyObject_GetItem(__pyx_v_p, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 570; 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 = 570; goto __pyx_L1;}
      __pyx_7 = PyObject_GetItem(__pyx_v_p, __pyx_4); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 570; 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 = 570; goto __pyx_L1;}
      __pyx_8 = PyObject_GetItem(__pyx_v_p, __pyx_4); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 570; 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 = 570; 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 = 570; 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":575 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 575; 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 = 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_sx = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":576 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; 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 = 576; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; 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 = 576; goto __pyx_L1;}
  __pyx_1 = PyNumber_Add(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 576; 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 = 576; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sy = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":577 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; 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 = 577; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; 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 = 577; goto __pyx_L1;}
  __pyx_1 = PyNumber_Subtract(__pyx_3, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 577; 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 = 577; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_v_sz = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":578 */
  __pyx_3 = PyFloat_FromDouble(0.2); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 578; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.8); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 578; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 578; goto __pyx_L1;}
  __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_random); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 578; 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 = 578; goto __pyx_L1;}
  __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_1); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 578; 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 = 578; 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 = 578; 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 = 578; goto __pyx_L1;}
  __pyx_6 = PyNumber_Divide(__pyx_1, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 578; 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 = 578; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  __pyx_v_l = __pyx_4;

  /* "/home/jiba/src/soya/model/particle.pyx":579 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_set_particle); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_index); if (!__pyx_5) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(0.5); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_random); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_6 = PyObject_GetAttr(__pyx_2, __pyx_n_random); if (!__pyx_6) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; 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 = 579; goto __pyx_L1;}
  __pyx_7 = PyObject_CallObject(__pyx_6, __pyx_2); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; 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 = 579; 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 = 579; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble((__pyx_v_sy * __pyx_v_l)); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble((__pyx_v_sz * __pyx_v_l)); if (!__pyx_7) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(0.0); if (!__pyx_8) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble((-0.03)); if (!__pyx_9) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_10 = PyFloat_FromDouble(0.0); if (!__pyx_10) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; goto __pyx_L1;}
  __pyx_11 = PyTuple_New(8); if (!__pyx_11) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 579; 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 = 579; 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":582 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_subgenerate); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 582; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_index); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 582; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 582; 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 = 582; 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":583 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_mygenerate); if (!__pyx_1) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 583; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_index); if (!__pyx_3) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 583; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 583; 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 = 583; 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_terrain_tri_dealloc(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":56 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":57 */
    __pyx_f_5_soya_terrain_tri_dealloc(__pyx_v_tri->left_child);

    /* "/home/jiba/src/soya/model/terrain.pyx":58 */
    __pyx_f_5_soya_terrain_tri_dealloc(__pyx_v_tri->right_child);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":59 */
  free(__pyx_v_tri);

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

static int __pyx_f_5_soya_terrain_tri_has_child(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  int __pyx_r;

  /* "/home/jiba/src/soya/model/terrain.pyx":62 */
  __pyx_r = (__pyx_v_tri->left_child != 0);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya.terrain_tri_has_child");
  __pyx_L0:;
  return __pyx_r;
}

static int __pyx_f_5_soya_terrain_tri_diamond(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  int __pyx_r;
  int __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":65 */
  __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.terrain_tri_diamond");
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya_terrain_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/terrain.pyx":71 */
  __pyx_v_f = (1.0 / 3.0);

  /* "/home/jiba/src/soya/model/terrain.pyx":72 */
  (__pyx_v_r[0]) = ((((__pyx_v_p1[0]) + (__pyx_v_p2[0])) + (__pyx_v_p3[0])) * __pyx_v_f);

  /* "/home/jiba/src/soya/model/terrain.pyx":73 */
  (__pyx_v_r[1]) = ((((__pyx_v_p1[1]) + (__pyx_v_p2[1])) + (__pyx_v_p3[1])) * __pyx_v_f);

  /* "/home/jiba/src/soya/model/terrain.pyx":74 */
  (__pyx_v_r[2]) = ((((__pyx_v_p1[2]) + (__pyx_v_p2[2])) + (__pyx_v_p3[2])) * __pyx_v_f);

  /* "/home/jiba/src/soya/model/terrain.pyx":75 */
  __pyx_v_x = ((__pyx_v_p1[0]) - (__pyx_v_r[0]));

  /* "/home/jiba/src/soya/model/terrain.pyx":76 */
  __pyx_v_y = ((__pyx_v_p1[1]) - (__pyx_v_r[1]));

  /* "/home/jiba/src/soya/model/terrain.pyx":77 */
  __pyx_v_z = ((__pyx_v_p1[2]) - (__pyx_v_r[2]));

  /* "/home/jiba/src/soya/model/terrain.pyx":78 */
  __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/terrain.pyx":79 */
  __pyx_v_x = ((__pyx_v_p2[0]) - (__pyx_v_r[0]));

  /* "/home/jiba/src/soya/model/terrain.pyx":80 */
  __pyx_v_y = ((__pyx_v_p2[1]) - (__pyx_v_r[1]));

  /* "/home/jiba/src/soya/model/terrain.pyx":81 */
  __pyx_v_z = ((__pyx_v_p2[2]) - (__pyx_v_r[2]));

  /* "/home/jiba/src/soya/model/terrain.pyx":82 */
  __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/terrain.pyx":83 */
  __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/terrain.pyx":84 */
  __pyx_v_x = ((__pyx_v_p3[0]) - (__pyx_v_r[0]));

  /* "/home/jiba/src/soya/model/terrain.pyx":85 */
  __pyx_v_y = ((__pyx_v_p3[1]) - (__pyx_v_r[1]));

  /* "/home/jiba/src/soya/model/terrain.pyx":86 */
  __pyx_v_z = ((__pyx_v_p3[2]) - (__pyx_v_r[2]));

  /* "/home/jiba/src/soya/model/terrain.pyx":87 */
  __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/terrain.pyx":88 */
  __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/terrain.pyx":89 */
  (__pyx_v_r[3]) = sqrt(__pyx_v_d);

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

static struct __pyx_t_5_soya__TerrainTri (*__pyx_f_5_soya_terrain_get_tri(void)) {
  struct __pyx_t_5_soya__TerrainTri (*__pyx_r);

  /* "/home/jiba/src/soya/model/terrain.pyx":94 */
  __pyx_r = ((struct __pyx_t_5_soya__TerrainTri (*))malloc((sizeof(struct __pyx_t_5_soya__TerrainTri ))));
  goto __pyx_L0;

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

static void __pyx_f_5_soya_terrain_tri_drop(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {

  /* "/home/jiba/src/soya/model/terrain.pyx":98 */
  free(__pyx_v_tri);

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

static struct __pyx_t_5_soya__TerrainTri (*__pyx_f_5_soya_terrain_create_tri(__pyx_t_5_soya_TerrainVertex (*__pyx_v_v1),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v2),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v3),struct __pyx_t_5_soya__TerrainPatch (*__pyx_v_patch))) {
  struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri);
  struct __pyx_t_5_soya__TerrainTri (*__pyx_r);

  /* "/home/jiba/src/soya/model/terrain.pyx":102 */
  __pyx_v_tri = __pyx_f_5_soya_terrain_get_tri();

  /* "/home/jiba/src/soya/model/terrain.pyx":103 */
  __pyx_v_tri->v1 = __pyx_v_v1;

  /* "/home/jiba/src/soya/model/terrain.pyx":104 */
  __pyx_v_tri->v2 = __pyx_v_v2;

  /* "/home/jiba/src/soya/model/terrain.pyx":105 */
  __pyx_v_tri->v3 = __pyx_v_v3;

  /* "/home/jiba/src/soya/model/terrain.pyx":106 */
  __pyx_v_tri->patch = __pyx_v_patch;

  /* "/home/jiba/src/soya/model/terrain.pyx":107 */
  __pyx_v_tri->level = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":108 */
  __pyx_v_tri->parent = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":109 */
  __pyx_v_tri->left_child = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":110 */
  __pyx_v_tri->right_child = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":111 */
  __pyx_v_tri->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":112 */
  __pyx_f_5_soya_terrain_tri_sphere(__pyx_v_tri->sphere,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/terrain.pyx":113 */
  face_normal(__pyx_v_tri->normal,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/terrain.pyx":114 */
  vector_normalize(__pyx_v_tri->normal);

  /* "/home/jiba/src/soya/model/terrain.pyx":115 */
  __pyx_r = __pyx_v_tri;
  goto __pyx_L0;

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

static struct __pyx_t_5_soya__TerrainTri (*__pyx_f_5_soya_terrain_create_child_tri(__pyx_t_5_soya_TerrainVertex (*__pyx_v_v1),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v2),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v3),struct __pyx_t_5_soya__TerrainTri (*__pyx_v_parent))) {
  struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri);
  struct __pyx_t_5_soya__TerrainTri (*__pyx_r);

  /* "/home/jiba/src/soya/model/terrain.pyx":119 */
  __pyx_v_tri = __pyx_f_5_soya_terrain_get_tri();

  /* "/home/jiba/src/soya/model/terrain.pyx":120 */
  __pyx_v_tri->v1 = __pyx_v_v1;

  /* "/home/jiba/src/soya/model/terrain.pyx":121 */
  __pyx_v_tri->v2 = __pyx_v_v2;

  /* "/home/jiba/src/soya/model/terrain.pyx":122 */
  __pyx_v_tri->v3 = __pyx_v_v3;

  /* "/home/jiba/src/soya/model/terrain.pyx":123 */
  __pyx_v_tri->parent = __pyx_v_parent;

  /* "/home/jiba/src/soya/model/terrain.pyx":124 */
  __pyx_v_tri->level = (__pyx_v_parent->level + 1);

  /* "/home/jiba/src/soya/model/terrain.pyx":125 */
  __pyx_v_tri->patch = __pyx_v_parent->patch;

  /* "/home/jiba/src/soya/model/terrain.pyx":126 */
  __pyx_v_tri->left_child = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":127 */
  __pyx_v_tri->right_child = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":128 */
  __pyx_f_5_soya_terrain_tri_sphere(__pyx_v_tri->sphere,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/terrain.pyx":129 */
  face_normal(__pyx_v_tri->normal,__pyx_v_v1->coord,__pyx_v_v2->coord,__pyx_v_v3->coord);

  /* "/home/jiba/src/soya/model/terrain.pyx":130 */
  vector_normalize(__pyx_v_tri->normal);

  /* "/home/jiba/src/soya/model/terrain.pyx":131 */
  __pyx_r = __pyx_v_tri;
  goto __pyx_L0;

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

static void __pyx_f_5_soya_terrain_tri_update_neighbor_after_split(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":134 */
  __pyx_v_tri->left_child->left_neighbor = __pyx_v_tri->right_child;

  /* "/home/jiba/src/soya/model/terrain.pyx":135 */
  __pyx_1 = (__pyx_v_tri->left_neighbor != 0);
  if (__pyx_1) {
    __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri->left_neighbor);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":136 */
    __pyx_v_tri->left_child->base_neighbor = __pyx_v_tri->left_neighbor->right_child;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/terrain.pyx":138 */
    __pyx_v_tri->left_child->base_neighbor = __pyx_v_tri->left_neighbor;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":140 */
  __pyx_v_tri->right_child->right_neighbor = __pyx_v_tri->left_child;

  /* "/home/jiba/src/soya/model/terrain.pyx":141 */
  __pyx_1 = (__pyx_v_tri->right_neighbor != 0);
  if (__pyx_1) {
    __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri->right_neighbor);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":142 */
    __pyx_v_tri->right_child->base_neighbor = __pyx_v_tri->right_neighbor->left_child;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/terrain.pyx":144 */
    __pyx_v_tri->right_child->base_neighbor = __pyx_v_tri->right_neighbor;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":146 */
  __pyx_1 = (__pyx_v_tri->base_neighbor == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":147 */
    __pyx_v_tri->left_child->right_neighbor = 0;

    /* "/home/jiba/src/soya/model/terrain.pyx":148 */
    __pyx_v_tri->right_child->left_neighbor = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/terrain.pyx":150 */
    __pyx_v_tri->left_child->right_neighbor = __pyx_v_tri->base_neighbor->right_child;

    /* "/home/jiba/src/soya/model/terrain.pyx":151 */
    __pyx_v_tri->right_child->left_neighbor = __pyx_v_tri->base_neighbor->left_child;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/terrain.pyx":153 */
  __pyx_1 = (__pyx_v_tri->left_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":154 */
    __pyx_1 = (__pyx_v_tri->v1 == __pyx_v_tri->left_neighbor->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":155 */
      __pyx_v_tri->left_neighbor->right_neighbor = __pyx_v_tri->left_child;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/terrain.pyx":157 */
      __pyx_v_tri->left_neighbor->base_neighbor = __pyx_v_tri->left_child;

      /* "/home/jiba/src/soya/model/terrain.pyx":158 */
      __pyx_1 = (__pyx_v_tri->left_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":159 */
        __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/terrain.pyx":161 */
  __pyx_1 = (__pyx_v_tri->right_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":162 */
    __pyx_1 = (__pyx_v_tri->v1 == __pyx_v_tri->right_neighbor->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":163 */
      __pyx_v_tri->right_neighbor->left_neighbor = __pyx_v_tri->right_child;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/terrain.pyx":165 */
      __pyx_v_tri->right_neighbor->base_neighbor = __pyx_v_tri->right_child;

      /* "/home/jiba/src/soya/model/terrain.pyx":166 */
      __pyx_1 = (__pyx_v_tri->right_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":167 */
        __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.terrain_tri_update_neighbor_after_split");
  __pyx_L0:;
}

static void __pyx_f_5_soya_terrain_tri_force_split(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri),__pyx_t_5_soya_TerrainVertex (*__pyx_v_apex)) {

  /* "/home/jiba/src/soya/model/terrain.pyx":170 */
  __pyx_v_tri->left_child = __pyx_f_5_soya_terrain_create_child_tri(__pyx_v_apex,__pyx_v_tri->v1,__pyx_v_tri->v2,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/terrain.pyx":171 */
  __pyx_v_tri->right_child = __pyx_f_5_soya_terrain_create_child_tri(__pyx_v_apex,__pyx_v_tri->v3,__pyx_v_tri->v1,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/terrain.pyx":172 */
  __pyx_f_5_soya_terrain_tri_update_neighbor_after_split(__pyx_v_tri);

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

static void __pyx_f_5_soya_terrain_tri_update_neighbor_after_merge(struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  int __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":175 */
  __pyx_1 = (__pyx_v_tri->left_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":176 */
    __pyx_1 = (__pyx_v_tri->left_neighbor->v1 == __pyx_v_tri->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":177 */
      __pyx_v_tri->left_neighbor->right_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/terrain.pyx":178 */
      __pyx_1 = __pyx_f_5_soya_terrain_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/terrain.pyx":180 */
      __pyx_v_tri->left_neighbor->base_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/terrain.pyx":181 */
      __pyx_1 = (__pyx_v_tri->left_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":182 */
        __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/terrain.pyx":183 */
  __pyx_1 = (__pyx_v_tri->right_neighbor != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":184 */
    __pyx_1 = (__pyx_v_tri->right_neighbor->v1 == __pyx_v_tri->v1);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":185 */
      __pyx_v_tri->right_neighbor->left_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/terrain.pyx":186 */
      __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri->right_neighbor);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":187 */
        __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/terrain.pyx":189 */
      __pyx_v_tri->right_neighbor->base_neighbor = __pyx_v_tri;

      /* "/home/jiba/src/soya/model/terrain.pyx":190 */
      __pyx_1 = (__pyx_v_tri->right_neighbor->parent != 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":191 */
        __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.terrain_tri_update_neighbor_after_merge");
  __pyx_L0:;
}

static void __pyx_f_5_soya_terrain_get_height_at_factors(__pyx_t_5_soya_TerrainVertex (*__pyx_v_v1),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v2),__pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":196 */
  __pyx_v_ptr = __pyx_v_v1->coord;

  /* "/home/jiba/src/soya/model/terrain.pyx":197 */
  (__pyx_v_u[0]) = ((__pyx_v_v2->coord[0]) - (__pyx_v_ptr[0]));

  /* "/home/jiba/src/soya/model/terrain.pyx":198 */
  (__pyx_v_u[1]) = ((__pyx_v_v2->coord[2]) - (__pyx_v_ptr[2]));

  /* "/home/jiba/src/soya/model/terrain.pyx":199 */
  (__pyx_v_w[0]) = ((__pyx_v_v3->coord[0]) - (__pyx_v_ptr[0]));

  /* "/home/jiba/src/soya/model/terrain.pyx":200 */
  (__pyx_v_w[1]) = ((__pyx_v_v3->coord[2]) - (__pyx_v_ptr[2]));

  /* "/home/jiba/src/soya/model/terrain.pyx":201 */
  __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/terrain.pyx":202 */
  (__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/terrain.pyx":203 */
  (__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.terrain_get_height_at_factors");
  __pyx_L0:;
}

static void __pyx_f_5_soya_terrain_drawColor_radeon(float (*__pyx_v_vect)) {

  /* "/home/jiba/src/soya/model/terrain.pyx":207 */
  glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,__pyx_v_vect);

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

static void __pyx_f_5_soya_noop(void) {

  /* "/home/jiba/src/soya/model/terrain.pyx":210 */

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

static void __pyx_f_5_soya_terrain_disableColor_radeon(void) {

  /* "/home/jiba/src/soya/model/terrain.pyx":214 */
  glDisable(GL_COLOR_MATERIAL);

  /* "/home/jiba/src/soya/model/terrain.pyx":215 */
  glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,__pyx_v_5_soya_white);

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

static void __pyx_f_5_soya_terrain_enableColor_radeon(void) {

  /* "/home/jiba/src/soya/model/terrain.pyx":218 */
  glEnable(GL_COLOR_MATERIAL);

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

static void __pyx_f_5_soya_SET_COLOR_OPAQUE(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,int __pyx_v_index) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":235 */
  __pyx_1 = (__pyx_v_self->_colors == 0);
  if (__pyx_1) {
    __pyx_v_5_soya_terrain_drawColor(__pyx_v_5_soya_renderer->current_material->_diffuse);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_5_soya_terrain_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__Terrain *__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/terrain.pyx":242 */
  __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/terrain.pyx":244 */
  (__pyx_v_ccc[0]) = (__pyx_v_color[0]);

  /* "/home/jiba/src/soya/model/terrain.pyx":245 */
  (__pyx_v_ccc[1]) = (__pyx_v_color[1]);

  /* "/home/jiba/src/soya/model/terrain.pyx":246 */
  (__pyx_v_ccc[2]) = (__pyx_v_color[2]);

  /* "/home/jiba/src/soya/model/terrain.pyx":247 */
  (__pyx_v_ccc[3]) = 0.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":248 */
  __pyx_v_5_soya_terrain_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_8_Terrain_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_5width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":273 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __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._Terrain.width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/model/terrain.pyx":276 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __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._Terrain.depth.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_10patch_size___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":280 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_patch_size); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 280; 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._Terrain.patch_size.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain_10patch_size___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_8_Terrain_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/terrain.pyx":282 */
  __pyx_1 = PyInt_AsLong(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 282; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_patch_size = __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":283 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option - __pyx_e_5_soya_TERRAIN_INITED);
    goto __pyx_L2;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain_18has_vertex_options___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":287 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __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._Terrain.has_vertex_options.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_12split_factor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":291 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_split_factor); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __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._Terrain.split_factor.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain_12split_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_8_Terrain_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/terrain.pyx":293 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 293; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_split_factor = __pyx_1;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain_12scale_factor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":297 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_scale_factor); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 297; 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._Terrain.scale_factor.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain_12scale_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_8_Terrain_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/terrain.pyx":299 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 299; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_scale_factor = __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":300 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_INITED));

  /* "/home/jiba/src/soya/model/terrain.pyx":301 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain_14texture_factor___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":305 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_texture_factor); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 305; 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._Terrain.texture_factor.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain_14texture_factor___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_8_Terrain_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/terrain.pyx":307 */
  __pyx_1 = PyFloat_AsDouble(__pyx_v_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 307; goto __pyx_L1;}
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_texture_factor = __pyx_1;

  /* "/home/jiba/src/soya/model/terrain.pyx":308 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain_16raypick_with_LOD___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":312 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 312; 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._Terrain.raypick_with_LOD.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain_16raypick_with_LOD___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_8_Terrain_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/terrain.pyx":314 */
  __pyx_1 = PyObject_IsTrue(__pyx_v_x); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 314; goto __pyx_L1;}
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK));
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_TerrainVertex (*__pyx_f_5_soya_8_Terrain__get_vertex(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,int __pyx_v_x,int __pyx_v_z)) {
  __pyx_t_5_soya_TerrainVertex (*__pyx_r);
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":319 */
  __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._Terrain._get_vertex");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k304p;
static PyObject *__pyx_k305p;

static char (__pyx_k304[]) = "WARNING Terrain size width must be (2^n) + 1";
static char (__pyx_k305[]) = "WARNING Terrain size depth must be (2^n) + 1";

static void __pyx_f_5_soya_8_Terrain__check_size(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":323 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":324 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/terrain.pyx":325 */
    __pyx_v_d = ((1 << __pyx_v_i) + 1);

    /* "/home/jiba/src/soya/model/terrain.pyx":326 */
    __pyx_2 = (__pyx_v_self->_nb_vertex_width <= __pyx_v_d);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/terrain.pyx":327 */
      __pyx_2 = (__pyx_v_self->_nb_vertex_width < __pyx_v_d);
      if (__pyx_2) {
        if (__Pyx_PrintItem(__pyx_k304p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 327; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 327; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/model/terrain.pyx":328 */
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/model/terrain.pyx":329 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":331 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":332 */
  while (1) {
    __pyx_L6:;
    __pyx_1 = 1;
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/terrain.pyx":333 */
    __pyx_v_d = ((1 << __pyx_v_i) + 1);

    /* "/home/jiba/src/soya/model/terrain.pyx":334 */
    __pyx_2 = (__pyx_v_self->_nb_vertex_depth <= __pyx_v_d);
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/terrain.pyx":335 */
      __pyx_2 = (__pyx_v_self->_nb_vertex_depth < __pyx_v_d);
      if (__pyx_2) {
        if (__Pyx_PrintItem(__pyx_k305p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 335; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 335; goto __pyx_L1;}
        goto __pyx_L9;
      }
      __pyx_L9:;

      /* "/home/jiba/src/soya/model/terrain.pyx":336 */
      goto __pyx_L7;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/model/terrain.pyx":337 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L7:;

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

static int __pyx_f_5_soya_8_Terrain___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_8_Terrain___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_TerrainVertex (*__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_k135;
  __pyx_v_width = __pyx_k136;
  __pyx_v_depth = __pyx_k137;
  __pyx_v_scale_factor = __pyx_k138;
  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 = 341; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":346 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 346; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 346; 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 = 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/model/terrain.pyx":347 */
  __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/terrain.pyx":349 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width = __pyx_v_width;

  /* "/home/jiba/src/soya/model/terrain.pyx":350 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth = __pyx_v_depth;

  /* "/home/jiba/src/soya/model/terrain.pyx":351 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_patch_size = 8;

  /* "/home/jiba/src/soya/model/terrain.pyx":352 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_texture_factor = 1.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":353 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_scale_factor = __pyx_v_scale_factor;

  /* "/home/jiba/src/soya/model/terrain.pyx":354 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_split_factor = 2.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":355 */
  __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 355; 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__Terrain *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":356 */
  __pyx_4 = (__pyx_v_width != 0);
  if (__pyx_4) {
    __pyx_4 = (__pyx_v_depth != 0);
  }
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/terrain.pyx":357 */
    __pyx_v_nb = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth);

    /* "/home/jiba/src/soya/model/terrain.pyx":358 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_size(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

    /* "/home/jiba/src/soya/model/terrain.pyx":359 */
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertices = ((__pyx_t_5_soya_TerrainVertex (*))malloc((__pyx_v_nb * (sizeof(__pyx_t_5_soya_TerrainVertex )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":360 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":361 */
      __pyx_v_v = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertices + __pyx_v_i);

      /* "/home/jiba/src/soya/model/terrain.pyx":362 */
      (__pyx_v_v->coord[1]) = 0;

      /* "/home/jiba/src/soya/model/terrain.pyx":363 */
      __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/terrain.pyx":364 */
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_normals = ((float (*))malloc(((((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width - 1) * (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth - 1)) * 6) * (sizeof(float )))));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":365 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Terrain *)__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._Terrain.__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_8_Terrain__free_patchs(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  struct __pyx_t_5_soya__TerrainPatch (*__pyx_v_patch);
  int __pyx_v_i;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":371 */
  __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/terrain.pyx":372 */
    __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

    /* "/home/jiba/src/soya/model/terrain.pyx":373 */
    __pyx_f_5_soya_terrain_tri_dealloc(__pyx_v_patch->tri_top);

    /* "/home/jiba/src/soya/model/terrain.pyx":374 */
    __pyx_f_5_soya_terrain_tri_dealloc(__pyx_v_patch->tri_left);

    /* "/home/jiba/src/soya/model/terrain.pyx":375 */
    __pyx_f_5_soya_terrain_tri_dealloc(__pyx_v_patch->tri_right);

    /* "/home/jiba/src/soya/model/terrain.pyx":376 */
    __pyx_f_5_soya_terrain_tri_dealloc(__pyx_v_patch->tri_bottom);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":377 */
  free(__pyx_v_self->_patchs);

  /* "/home/jiba/src/soya/model/terrain.pyx":378 */
  __pyx_v_self->_patchs = 0;

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

static void __pyx_f_5_soya_8_Terrain___del__(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":382 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_free_patchs(__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":383 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n___imul__); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 383; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 383; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 383; 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 = 383; 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/terrain.pyx":384 */
  free(__pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/terrain.pyx":385 */
  free(__pyx_v_self->_colors);

  /* "/home/jiba/src/soya/model/terrain.pyx":386 */
  free(__pyx_v_self->_normals);

  /* "/home/jiba/src/soya/model/terrain.pyx":387 */
  free(__pyx_v_self->_vertex_options);

  /* "/home/jiba/src/soya/model/terrain.pyx":388 */
  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._Terrain.__del__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_8_Terrain_from_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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 = 390; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":393 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width = __pyx_v_image->width;

  /* "/home/jiba/src/soya/model/terrain.pyx":394 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth = __pyx_v_image->height;

  /* "/home/jiba/src/soya/model/terrain.pyx":395 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_size(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/terrain.pyx":396 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertices != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertices);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":397 */
  __pyx_v_nb = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/terrain.pyx":398 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertices = ((__pyx_t_5_soya_TerrainVertex (*))malloc((__pyx_v_nb * (sizeof(__pyx_t_5_soya_TerrainVertex )))));

  /* "/home/jiba/src/soya/model/terrain.pyx":399 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {
    (((struct __pyx_obj_5_soya__Terrain *)__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/terrain.pyx":400 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_normals = ((float (*))malloc(((((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width - 1) * (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth - 1)) * 6) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/terrain.pyx":401 */
  __pyx_1 = (__pyx_v_image->nb_color == 3);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":402 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":403 */
      __pyx_v_ptr = (__pyx_v_image->_pixels + (__pyx_v_i * 3));

      /* "/home/jiba/src/soya/model/terrain.pyx":404 */
      ((((struct __pyx_obj_5_soya__Terrain *)__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/terrain.pyx":406 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":407 */
      __pyx_v_ptr = (__pyx_v_image->_pixels + (__pyx_v_i * 4));

      /* "/home/jiba/src/soya/model/terrain.pyx":408 */
      ((((struct __pyx_obj_5_soya__Terrain *)__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/terrain.pyx":410 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":411 */
      ((((struct __pyx_obj_5_soya__Terrain *)__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/terrain.pyx":413 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_INITED));

  /* "/home/jiba/src/soya/model/terrain.pyx":414 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_coords(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain__add_material(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":417 */
  __pyx_1 = PySequence_Contains(__pyx_v_self->_materials, ((PyObject *)__pyx_v_material)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 417; goto __pyx_L1;}
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":418 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_materials, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 418; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 418; 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 = 418; 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/terrain.pyx":419 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_INITED));

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._Terrain._add_material");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_material);
}

static PyObject *__pyx_k306p;
static PyObject *__pyx_k307p;
static PyObject *__pyx_k308p;

static char (__pyx_k306[]) = "WARNING Material map size must equal terrain size";
static char (__pyx_k307[]) = "WARNING Material map must be greyscale or indexed";
static char (__pyx_k308[]) = "WARNING Material map has more colors than provided materials";

static PyObject *__pyx_f_5_soya_8_Terrain_set_material_from_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_set_material_from_image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Image *__pyx_v_image = 0;
  PyObject *__pyx_v_materials = 0;
  int __pyx_v_i;
  int __pyx_v_m;
  int __pyx_v_w;
  int __pyx_v_h;
  int __pyx_v_hoffset;
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_vertex);
  struct __pyx_t_5_soya__Pack (*(__pyx_v_pack[256]));
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"image","materials",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_image, &__pyx_v_materials)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_image);
  Py_INCREF(__pyx_v_materials);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image), __pyx_ptype_5_soya__Image, 1, "image")) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 421; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":425 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width != __pyx_v_image->width);
  if (!__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth != __pyx_v_image->height);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":427 */
    if (__Pyx_PrintItem(__pyx_k306p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 427; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 427; goto __pyx_L1;}

    /* "/home/jiba/src/soya/model/terrain.pyx":428 */
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":429 */
  __pyx_1 = (__pyx_v_image->nb_color != 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":430 */
    if (__Pyx_PrintItem(__pyx_k307p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 430; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 430; goto __pyx_L1;}

    /* "/home/jiba/src/soya/model/terrain.pyx":431 */
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":432 */
  __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_image), __pyx_n_palette); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 432; goto __pyx_L1;}
  __pyx_1 = PyObject_IsTrue(__pyx_2); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 432; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_image), __pyx_n_palette); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 432; goto __pyx_L1;}
    __pyx_1 = PyObject_Length(__pyx_2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 432; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_v_m = (__pyx_1 / 3);
    goto __pyx_L4;
  }
  /*else*/ {
    __pyx_v_m = 256;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/terrain.pyx":434 */
  __pyx_1 = PyObject_Length(__pyx_v_materials); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 434; goto __pyx_L1;}
  __pyx_3 = (__pyx_1 < __pyx_v_m);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/terrain.pyx":435 */
    if (__Pyx_PrintItem(__pyx_k308p) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 435; goto __pyx_L1;}
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 435; goto __pyx_L1;}

    /* "/home/jiba/src/soya/model/terrain.pyx":436 */
    __pyx_r = Py_None; Py_INCREF(__pyx_r);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/terrain.pyx":437 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_m; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/terrain.pyx":438 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 438; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_materials, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 438; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),((struct __pyx_obj_5_soya__Material *)__pyx_4));
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/model/terrain.pyx":439 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 439; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_materials, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 439; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    (__pyx_v_pack[__pyx_v_i]) = ((struct __pyx_vtabstruct_5_soya__Material *)((struct __pyx_obj_5_soya__Material *)__pyx_4)->__pyx_base.__pyx_vtab)->_pack(((struct __pyx_obj_5_soya__Material *)__pyx_4),__pyx_e_5_soya_FACE_TRIANGLE);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/terrain.pyx":440 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_h = 0; __pyx_v_h < __pyx_1; ++__pyx_v_h) {

    /* "/home/jiba/src/soya/model/terrain.pyx":441 */
    __pyx_v_hoffset = (__pyx_v_h * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width);

    /* "/home/jiba/src/soya/model/terrain.pyx":442 */
    __pyx_3 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_w = 0; __pyx_v_w < __pyx_3; ++__pyx_v_w) {

      /* "/home/jiba/src/soya/model/terrain.pyx":443 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_w,__pyx_v_h);

      /* "/home/jiba/src/soya/model/terrain.pyx":444 */
      __pyx_v_i = (__pyx_v_image->_pixels[(__pyx_v_hoffset + __pyx_v_w)]);

      /* "/home/jiba/src/soya/model/terrain.pyx":445 */
      __pyx_v_vertex->pack = (__pyx_v_pack[__pyx_v_i]);
      __pyx_L10:;
    }
    __pyx_L11:;
    __pyx_L8:;
  }
  __pyx_L9:;

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._Terrain.set_material_from_image");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_image);
  Py_DECREF(__pyx_v_materials);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_set_material_layer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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_TerrainVertex (*__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 = 447; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":451 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_material);

  /* "/home/jiba/src/soya/model/terrain.pyx":452 */
  __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/terrain.pyx":453 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/terrain.pyx":454 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":455 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/terrain.pyx":456 */
      __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/terrain.pyx":457 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_INITED));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain_set_material_layer_angle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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_TerrainVertex (*__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 = 459; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":464 */
  (__pyx_v_v[0]) = 0.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":464 */
  (__pyx_v_v[1]) = 1.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":464 */
  (__pyx_v_v[2]) = 0.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":466 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":468 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_material);

  /* "/home/jiba/src/soya/model/terrain.pyx":469 */
  __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/terrain.pyx":470 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/terrain.pyx":471 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":472 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/terrain.pyx":473 */
      __pyx_v_f = fabs(to_degrees(vector_angle(__pyx_v_vertex->normal,__pyx_v_v)));

      /* "/home/jiba/src/soya/model/terrain.pyx":474 */
      __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/terrain.pyx":475 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_INITED));

  __pyx_r = Py_None; Py_INCREF(__pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._Terrain.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_8_Terrain_get_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_get_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_z;
  __pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":480 */
  __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_x,__pyx_v_z);

  /* "/home/jiba/src/soya/model/terrain.pyx":481 */
  __pyx_1 = PyFloat_FromDouble((__pyx_v_vertex->normal[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 481; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_vertex->normal[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 481; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_vertex->normal[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 481; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 481; 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._Terrain.get_normal");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_get_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":484 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_height(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_x,__pyx_v_z)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 484; 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._Terrain.get_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static float __pyx_f_5_soya_8_Terrain__get_height(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":487 */
  __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/terrain.pyx":488 */
  __pyx_r = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._get_height");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_get_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":491 */
  __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__Terrain *)__pyx_v_self)->_nb_vertex_width);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_z >= ((struct __pyx_obj_5_soya__Terrain *)__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/terrain.pyx":492 */
  __pyx_2 = (PyObject *)((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__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._Terrain.get_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_8_Terrain__set_height(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":495 */
  __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/terrain.pyx":496 */
  (((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._set_height");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_8_Terrain_set_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":499 */
  __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__Terrain *)__pyx_v_self)->_nb_vertex_width);
      if (!__pyx_1) {
        __pyx_1 = (__pyx_v_z >= ((struct __pyx_obj_5_soya__Terrain *)__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/terrain.pyx":500 */
  (((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__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._Terrain.set_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_multiply_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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_TerrainVertex (*__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/terrain.pyx":505 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/terrain.pyx":506 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":507 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/terrain.pyx":508 */
      (__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._Terrain.multiply_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_add_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_add_height(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_height;
  __pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":513 */
  __pyx_1 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_1; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/terrain.pyx":514 */
    __pyx_2 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":515 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/model/terrain.pyx":516 */
      (__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._Terrain.add_height");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_set_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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 = 518; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":520 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_add_material(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_material);

  /* "/home/jiba/src/soya/model/terrain.pyx":521 */
  __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/terrain.pyx":522 */
  __pyx_1 = 0 <= __pyx_v_x;
  if (__pyx_1) {
    __pyx_1 = __pyx_v_x < ((struct __pyx_obj_5_soya__Terrain *)__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__Terrain *)__pyx_v_self)->_nb_vertex_depth;
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":523 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__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._Terrain.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_8_Terrain_remove_colors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8_Terrain_remove_colors[] = "Terrain.remove_colors()\n\nRemoves all colors, from all vertices that have colors.";
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":529 */
  free(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors);

  /* "/home/jiba/src/soya/model/terrain.pyx":530 */
  free(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors);

  /* "/home/jiba/src/soya/model/terrain.pyx":531 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_colors = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":532 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":533 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":534 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_COLORED));

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

static PyObject *__pyx_f_5_soya_8_Terrain_get_vertex_option(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8_Terrain_get_vertex_option[] = "Terrain.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 Terrain.set_vertex_option for the available options.";
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":542 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_vertex_options(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/terrain.pyx":543 */
  __pyx_v_option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[(__pyx_v_x + (__pyx_v_z * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width))]);

  /* "/home/jiba/src/soya/model/terrain.pyx":544 */
  __pyx_1 = PyInt_FromLong((__pyx_v_option & __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN)); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 544; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong((__pyx_v_option & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID)); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 544; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong((__pyx_v_option & __pyx_e_5_soya_TERRAIN_VERTEX_FORCE_PRESENCE)); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 544; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 544; 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._Terrain.get_vertex_option");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_set_vertex_option(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8_Terrain_set_vertex_option[] = "Terrain.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 terrain, or non-rectangular terrain.\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_8_Terrain_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_k139;
  __pyx_v_non_solid = __pyx_k140;
  __pyx_v_force_presence = __pyx_k141;
  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/terrain.pyx":558 */
  __pyx_v_index = (__pyx_v_x + (__pyx_v_z * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/terrain.pyx":559 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_vertex_options(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));

  /* "/home/jiba/src/soya/model/terrain.pyx":560 */
  (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_index]) = (((((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_index]) & (~((__pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN | __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID) | __pyx_e_5_soya_TERRAIN_VERTEX_FORCE_PRESENCE))) | (__pyx_v_hidden * __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN)) | (__pyx_v_non_solid * __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID)) | (__pyx_v_force_presence * __pyx_e_5_soya_TERRAIN_VERTEX_FORCE_PRESENCE));

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

static PyObject *__pyx_f_5_soya_8_Terrain_set_vertex_color(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":565 */
  __pyx_v_n = (__pyx_v_x + (__pyx_v_z * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/terrain.pyx":566 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 566; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 566; 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 = 566; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[0]) = __pyx_3;

  /* "/home/jiba/src/soya/model/terrain.pyx":567 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 567; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 567; 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 = 567; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[1]) = __pyx_3;

  /* "/home/jiba/src/soya/model/terrain.pyx":568 */
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 568; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 568; 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 = 568; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[2]) = __pyx_3;

  /* "/home/jiba/src/soya/model/terrain.pyx":569 */
  __pyx_1 = PyInt_FromLong(3); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 569; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_color, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 569; 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 = 569; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  (__pyx_v_ccolor[3]) = __pyx_3;

  /* "/home/jiba/src/soya/model/terrain.pyx":570 */
  (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_n]) = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_check_color(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ccolor);

  /* "/home/jiba/src/soya/model/terrain.pyx":571 */
  __pyx_4 = ((1.0 - (__pyx_v_ccolor[3])) > EPSILON);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) | __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA);
    goto __pyx_L2;
  }
  __pyx_4 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) & (~__pyx_e_5_soya_TERRAIN_VERTEX_ALPHA));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":573 */
  __pyx_4 = ((__pyx_v_ccolor[3]) < EPSILON);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) | __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN);
    goto __pyx_L3;
  }
  __pyx_4 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
  if (__pyx_4) {
    (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_options[__pyx_v_n]) & (~__pyx_e_5_soya_TERRAIN_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._Terrain.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_8_Terrain_reinit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_8_Terrain_reinit[] = "Terrain.reinit()\n\nRe-inits the terrain.\nYou MUST call this method after the terrain have been modified manually\n(e.g. with Terrain.set_height).";
static PyObject *__pyx_f_5_soya_8_Terrain_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/terrain.pyx":582 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED);
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option - __pyx_e_5_soya_TERRAIN_INITED);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static void __pyx_f_5_soya_8_Terrain__init(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":586 */
  __pyx_1 = (__pyx_v_self->_patchs != 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":587 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_compute_normals(__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":588 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_create_patchs(__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":589 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":590 */
  __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_TERRAIN_INITED);

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

static void __pyx_f_5_soya_8_Terrain__compute_normal(struct __pyx_obj_5_soya__Terrain *__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_TerrainVertex (*__pyx_v_vertex);
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":595 */
  __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":596 */
  __pyx_v_y11 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":598 */
  __pyx_v_y00 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":599 */
  __pyx_v_y01 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":600 */
  __pyx_v_y10 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":601 */
  __pyx_v_y12 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":602 */
  __pyx_v_y21 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":603 */
  __pyx_v_y22 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":604 */
  __pyx_v_y02 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":605 */
  __pyx_v_y20 = (((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":607 */
  __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/terrain.pyx":608 */
  __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/terrain.pyx":609 */
  __pyx_v_c = 8.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":610 */
  (__pyx_v_vertex->normal[0]) = (-__pyx_v_a);

  /* "/home/jiba/src/soya/model/terrain.pyx":611 */
  (__pyx_v_vertex->normal[1]) = __pyx_v_c;

  /* "/home/jiba/src/soya/model/terrain.pyx":612 */
  (__pyx_v_vertex->normal[2]) = (-__pyx_v_b);

  /* "/home/jiba/src/soya/model/terrain.pyx":613 */
  vector_normalize(__pyx_v_vertex->normal);

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

static void __pyx_f_5_soya_8_Terrain__compute_normals(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  float (*__pyx_v_ptr);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v1);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v2);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v3);
  __pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":620 */
  __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/terrain.pyx":621 */
    __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/terrain.pyx":622 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":624 */
  __pyx_v_ptr = __pyx_v_self->_normals;

  /* "/home/jiba/src/soya/model/terrain.pyx":625 */
  __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/terrain.pyx":626 */
    __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/terrain.pyx":627 */
      __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":628 */
      __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":629 */
      __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":630 */
      __pyx_v_v4 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":631 */
      __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/terrain.pyx":632 */
        face_normal(__pyx_v_ptr,__pyx_v_v4->coord,__pyx_v_v3->coord,__pyx_v_v1->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":632 */
        vector_normalize(__pyx_v_ptr);

        /* "/home/jiba/src/soya/model/terrain.pyx":633 */
        face_normal((__pyx_v_ptr + 3),__pyx_v_v2->coord,__pyx_v_v1->coord,__pyx_v_v3->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":633 */
        vector_normalize((__pyx_v_ptr + 3));
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/terrain.pyx":635 */
        face_normal(__pyx_v_ptr,__pyx_v_v1->coord,__pyx_v_v4->coord,__pyx_v_v2->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":635 */
        vector_normalize(__pyx_v_ptr);

        /* "/home/jiba/src/soya/model/terrain.pyx":636 */
        face_normal((__pyx_v_ptr + 3),__pyx_v_v3->coord,__pyx_v_v2->coord,__pyx_v_v4->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":636 */
        vector_normalize((__pyx_v_ptr + 3));
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/model/terrain.pyx":637 */
      __pyx_v_ptr = (__pyx_v_ptr + 6);
      __pyx_L8:;
    }
    __pyx_L9:;
    __pyx_L6:;
  }
  __pyx_L7:;

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

static void __pyx_f_5_soya_8_Terrain__compute_coords(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_vertex);
  int __pyx_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":642 */
  __pyx_v_k = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":643 */
  __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/terrain.pyx":644 */
    __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/terrain.pyx":645 */
      __pyx_v_vertex = (__pyx_v_self->_vertices + __pyx_v_k);

      /* "/home/jiba/src/soya/model/terrain.pyx":646 */
      (__pyx_v_vertex->coord[0]) = (((float )__pyx_v_j) * __pyx_v_self->_scale_factor);

      /* "/home/jiba/src/soya/model/terrain.pyx":647 */
      (__pyx_v_vertex->coord[2]) = (((float )__pyx_v_i) * __pyx_v_self->_scale_factor);

      /* "/home/jiba/src/soya/model/terrain.pyx":648 */
      (__pyx_v_vertex->texcoord[0]) = (((float )__pyx_v_j) * __pyx_v_self->_texture_factor);

      /* "/home/jiba/src/soya/model/terrain.pyx":649 */
      (__pyx_v_vertex->texcoord[1]) = (((float )__pyx_v_i) * __pyx_v_self->_texture_factor);

      /* "/home/jiba/src/soya/model/terrain.pyx":650 */
      __pyx_v_k = (__pyx_v_k + 1);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

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

static void __pyx_f_5_soya_8_Terrain__create_patch(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainPatch (*__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_TerrainVertex (*__pyx_v_vertex);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_center);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v0);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v1);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v2);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v3);
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":656 */
  __pyx_v_patch->level = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":657 */
  __pyx_v_x1 = (__pyx_v_x * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":658 */
  __pyx_v_x2 = ((__pyx_v_x + 1) * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":659 */
  __pyx_v_z1 = (__pyx_v_z * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":660 */
  __pyx_v_z2 = ((__pyx_v_z + 1) * __pyx_v_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":663 */
  __pyx_v_nb = ((__pyx_v_patch_size + 1) * (__pyx_v_patch_size + 1));

  /* "/home/jiba/src/soya/model/terrain.pyx":664 */
  __pyx_v_coords = ((float (*))malloc(((__pyx_v_nb * 3) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/terrain.pyx":665 */
  __pyx_v_m = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":666 */
  for (__pyx_v_i = __pyx_v_x1; __pyx_v_i <= __pyx_v_x2; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/terrain.pyx":667 */
    for (__pyx_v_j = __pyx_v_z1; __pyx_v_j <= __pyx_v_z2; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/model/terrain.pyx":668 */
      __pyx_v_vertex = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":669 */
      memcpy((__pyx_v_coords + __pyx_v_m),__pyx_v_vertex->coord,(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/model/terrain.pyx":670 */
      __pyx_v_m = (__pyx_v_m + 3);
      __pyx_L4:;
    }
    __pyx_L5:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":671 */
  sphere_from_points(__pyx_v_patch->sphere,__pyx_v_coords,__pyx_v_nb);

  /* "/home/jiba/src/soya/model/terrain.pyx":672 */
  free(__pyx_v_coords);

  /* "/home/jiba/src/soya/model/terrain.pyx":675 */
  __pyx_v_v0 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":676 */
  __pyx_v_v1 = (__pyx_v_v0 + __pyx_v_self->_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":677 */
  __pyx_v_v2 = (__pyx_v_v0 + (__pyx_v_self->_patch_size * __pyx_v_self->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/terrain.pyx":678 */
  __pyx_v_v3 = (__pyx_v_v2 + __pyx_v_self->_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":679 */
  __pyx_v_center = (__pyx_v_v0 + ((__pyx_v_v3 - __pyx_v_v0) >> 1));

  /* "/home/jiba/src/soya/model/terrain.pyx":680 */
  __pyx_v_patch->tri_top = __pyx_f_5_soya_terrain_create_tri(__pyx_v_center,__pyx_v_v1,__pyx_v_v0,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/terrain.pyx":681 */
  __pyx_v_patch->tri_left = __pyx_f_5_soya_terrain_create_tri(__pyx_v_center,__pyx_v_v0,__pyx_v_v2,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/terrain.pyx":682 */
  __pyx_v_patch->tri_right = __pyx_f_5_soya_terrain_create_tri(__pyx_v_center,__pyx_v_v3,__pyx_v_v1,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/terrain.pyx":683 */
  __pyx_v_patch->tri_bottom = __pyx_f_5_soya_terrain_create_tri(__pyx_v_center,__pyx_v_v2,__pyx_v_v3,__pyx_v_patch);

  /* "/home/jiba/src/soya/model/terrain.pyx":684 */
  __pyx_v_patch->tri_top->left_neighbor = __pyx_v_patch->tri_right;

  /* "/home/jiba/src/soya/model/terrain.pyx":685 */
  __pyx_v_patch->tri_top->right_neighbor = __pyx_v_patch->tri_left;

  /* "/home/jiba/src/soya/model/terrain.pyx":686 */
  __pyx_v_patch->tri_top->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":687 */
  __pyx_v_patch->tri_left->left_neighbor = __pyx_v_patch->tri_top;

  /* "/home/jiba/src/soya/model/terrain.pyx":688 */
  __pyx_v_patch->tri_left->right_neighbor = __pyx_v_patch->tri_bottom;

  /* "/home/jiba/src/soya/model/terrain.pyx":689 */
  __pyx_v_patch->tri_left->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":690 */
  __pyx_v_patch->tri_right->left_neighbor = __pyx_v_patch->tri_bottom;

  /* "/home/jiba/src/soya/model/terrain.pyx":691 */
  __pyx_v_patch->tri_right->right_neighbor = __pyx_v_patch->tri_top;

  /* "/home/jiba/src/soya/model/terrain.pyx":692 */
  __pyx_v_patch->tri_right->base_neighbor = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":693 */
  __pyx_v_patch->tri_bottom->left_neighbor = __pyx_v_patch->tri_left;

  /* "/home/jiba/src/soya/model/terrain.pyx":694 */
  __pyx_v_patch->tri_bottom->right_neighbor = __pyx_v_patch->tri_right;

  /* "/home/jiba/src/soya/model/terrain.pyx":695 */
  __pyx_v_patch->tri_bottom->base_neighbor = 0;

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

static PyObject *__pyx_n_terrain_free_patchs;
static PyObject *__pyx_n_terrain;

static void __pyx_f_5_soya_8_Terrain__create_patchs(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  struct __pyx_t_5_soya__TerrainPatch (*__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/terrain.pyx":700 */
  __pyx_v_self->_max_level = ((exp_of_2(__pyx_v_self->_patch_size) * 2) - 1);

  /* "/home/jiba/src/soya/model/terrain.pyx":702 */
  __pyx_v_self->_nb_patch_width = ((int )((__pyx_v_self->_nb_vertex_width - 1) / __pyx_v_self->_patch_size));

  /* "/home/jiba/src/soya/model/terrain.pyx":703 */
  __pyx_v_self->_nb_patch_depth = ((int )((__pyx_v_self->_nb_vertex_depth - 1) / __pyx_v_self->_patch_size));

  /* "/home/jiba/src/soya/model/terrain.pyx":704 */
  __pyx_v_self->_nb_patchs = (__pyx_v_self->_nb_patch_width * __pyx_v_self->_nb_patch_depth);

  /* "/home/jiba/src/soya/model/terrain.pyx":705 */
  __pyx_1 = (__pyx_v_self->_patchs != 0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_terrain_free_patchs); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 705; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_terrain); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 705; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 705; 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 = 705; 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/terrain.pyx":706 */
  __pyx_v_self->_patchs = ((struct __pyx_t_5_soya__TerrainPatch (*))malloc((__pyx_v_self->_nb_patchs * (sizeof(struct __pyx_t_5_soya__TerrainPatch )))));

  /* "/home/jiba/src/soya/model/terrain.pyx":707 */
  __pyx_v_k = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":708 */
  __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/terrain.pyx":709 */
    __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/terrain.pyx":710 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":711 */
      __pyx_v_k = (__pyx_v_k + 1);
      __pyx_L5:;
    }
    __pyx_L6:;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/terrain.pyx":713 */
  __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/terrain.pyx":714 */
    __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/terrain.pyx":715 */
      __pyx_v_m = (__pyx_v_self->_patchs + (__pyx_v_i + (__pyx_v_j * __pyx_v_self->_nb_patch_width)));

      /* "/home/jiba/src/soya/model/terrain.pyx":716 */
      __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/terrain.pyx":717 */
      __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/terrain.pyx":718 */
      __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/terrain.pyx":719 */
      __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._Terrain._create_patchs");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_8_Terrain__register_color(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":724 */
  __pyx_v_c = __pyx_v_self->_colors;

  /* "/home/jiba/src/soya/model/terrain.pyx":725 */
  __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/terrain.pyx":726 */
    __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/terrain.pyx":730 */
    __pyx_v_c = (__pyx_v_c + 4);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":732 */
  __pyx_v_i = (__pyx_v_self->_nb_colors * 4);

  /* "/home/jiba/src/soya/model/terrain.pyx":733 */
  __pyx_v_self->_nb_colors = (__pyx_v_self->_nb_colors + 1);

  /* "/home/jiba/src/soya/model/terrain.pyx":734 */
  __pyx_v_self->_colors = ((float (*))realloc(__pyx_v_self->_colors,((__pyx_v_self->_nb_colors * 4) * (sizeof(float )))));

  /* "/home/jiba/src/soya/model/terrain.pyx":735 */
  memcpy((__pyx_v_self->_colors + __pyx_v_i),__pyx_v_color,(4 * (sizeof(float ))));

  /* "/home/jiba/src/soya/model/terrain.pyx":736 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._register_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_8_Terrain_compute_shadow_color(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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 = 738; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/terrain.pyx":744 */
  __pyx_v_nb = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width * ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/terrain.pyx":745 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":747 */
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 747; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 747; 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 = 747; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[0]) = __pyx_4;

  /* "/home/jiba/src/soya/model/terrain.pyx":748 */
  __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 748; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 748; 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 = 748; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[1]) = __pyx_4;

  /* "/home/jiba/src/soya/model/terrain.pyx":749 */
  __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 749; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 749; 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 = 749; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[2]) = __pyx_4;

  /* "/home/jiba/src/soya/model/terrain.pyx":750 */
  __pyx_2 = PyInt_FromLong(3); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 750; goto __pyx_L1;}
  __pyx_3 = PyObject_GetItem(__pyx_v_shadow_color, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 750; 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 = 750; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_cshadow_color[3]) = __pyx_4;

  /* "/home/jiba/src/soya/model/terrain.pyx":753 */
  __pyx_v_old_colors = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors;

  /* "/home/jiba/src/soya/model/terrain.pyx":754 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":755 */
  ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_colors = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":756 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_COLORED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":757 */
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_TERRAIN_COLORED);

    /* "/home/jiba/src/soya/model/terrain.pyx":758 */
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors = ((int (*))malloc((__pyx_v_nb * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":759 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {
      (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = (-1);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/terrain.pyx":760 */
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_colors = 2;

    /* "/home/jiba/src/soya/model/terrain.pyx":761 */
    ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors = ((float (*))malloc((8 * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":762 */
    __pyx_v_wcolor = 0;

    /* "/home/jiba/src/soya/model/terrain.pyx":763 */
    __pyx_v_scolor = 4;

    /* "/home/jiba/src/soya/model/terrain.pyx":764 */
    memcpy((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors + __pyx_v_wcolor),__pyx_v_5_soya_white,(4 * (sizeof(float ))));

    /* "/home/jiba/src/soya/model/terrain.pyx":765 */
    memcpy((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors + __pyx_v_scolor),__pyx_v_cshadow_color,(4 * (sizeof(float ))));
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":768 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/terrain.pyx":769 */
    __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__Terrain *)__pyx_v_self)->_vertices + __pyx_v_i)->coord);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":770 */
      __pyx_1 = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) == (-1));
      if (__pyx_1) {
        (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = __pyx_v_scolor;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/terrain.pyx":772 */
        __pyx_v_ocolor = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors + (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]));

        /* "/home/jiba/src/soya/model/terrain.pyx":773 */
        (__pyx_v_color[0]) = ((__pyx_v_ocolor[0]) * (__pyx_v_cshadow_color[0]));

        /* "/home/jiba/src/soya/model/terrain.pyx":774 */
        (__pyx_v_color[1]) = ((__pyx_v_ocolor[1]) * (__pyx_v_cshadow_color[1]));

        /* "/home/jiba/src/soya/model/terrain.pyx":775 */
        (__pyx_v_color[2]) = ((__pyx_v_ocolor[2]) * (__pyx_v_cshadow_color[2]));

        /* "/home/jiba/src/soya/model/terrain.pyx":776 */
        (__pyx_v_color[3]) = ((__pyx_v_ocolor[3]) * (__pyx_v_cshadow_color[3]));

        /* "/home/jiba/src/soya/model/terrain.pyx":777 */
        (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_register_color(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_color);
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/model/terrain.pyx":779 */
      __pyx_1 = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) == (-1));
      if (__pyx_1) {
        (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = __pyx_v_wcolor;
        goto __pyx_L10;
      }
      /*else*/ {
        (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i]) = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_register_color(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_colors + (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_vertex_colors[__pyx_v_i])));
      }
      __pyx_L10:;
    }
    __pyx_L8:;
    __pyx_L6:;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/model/terrain.pyx":781 */
  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._Terrain.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_8_Terrain__tri_split(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":786 */
  __pyx_1 = (!__pyx_f_5_soya_terrain_tri_diamond(__pyx_v_tri));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":789 */
  __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/terrain.pyx":791 */
  __pyx_v_tri->left_child = __pyx_f_5_soya_terrain_create_child_tri(__pyx_v_v,__pyx_v_tri->v1,__pyx_v_tri->v2,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/terrain.pyx":792 */
  __pyx_v_tri->right_child = __pyx_f_5_soya_terrain_create_child_tri(__pyx_v_v,__pyx_v_tri->v3,__pyx_v_tri->v1,__pyx_v_tri);

  /* "/home/jiba/src/soya/model/terrain.pyx":793 */
  __pyx_1 = (__pyx_v_tri->base_neighbor != 0);
  if (__pyx_1) {
    __pyx_f_5_soya_terrain_tri_force_split(__pyx_v_tri->base_neighbor,__pyx_v_v);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/model/terrain.pyx":794 */
  __pyx_f_5_soya_terrain_tri_update_neighbor_after_split(__pyx_v_tri);

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

static int __pyx_f_5_soya_8_Terrain__tri_merge_child(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  struct __pyx_t_5_soya__TerrainTri (*__pyx_v_base);
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":799 */
  __pyx_v_base = __pyx_v_tri->base_neighbor;

  /* "/home/jiba/src/soya/model/terrain.pyx":800 */
  __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/terrain.pyx":803 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri->left_child);
  if (__pyx_1) {
    __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":804 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri->right_child);
  if (__pyx_1) {
    __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":805 */
  __pyx_1 = (__pyx_v_base != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":806 */
    __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_base->left_child);
    if (__pyx_1) {
      __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":807 */
    __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_base->right_child);
    if (__pyx_1) {
      __pyx_1 = (!((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":809 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_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_TERRAIN_VERTEX_FORCE_PRESENCE);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":810 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/home/jiba/src/soya/model/terrain.pyx":812 */
  __pyx_f_5_soya_terrain_tri_update_neighbor_after_merge(__pyx_v_tri);

  /* "/home/jiba/src/soya/model/terrain.pyx":813 */
  __pyx_1 = (__pyx_v_base != 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":814 */
    __pyx_f_5_soya_terrain_tri_update_neighbor_after_merge(__pyx_v_base);

    /* "/home/jiba/src/soya/model/terrain.pyx":815 */
    __pyx_f_5_soya_terrain_tri_drop(__pyx_v_base->left_child);

    /* "/home/jiba/src/soya/model/terrain.pyx":816 */
    __pyx_f_5_soya_terrain_tri_drop(__pyx_v_base->right_child);

    /* "/home/jiba/src/soya/model/terrain.pyx":817 */
    __pyx_v_base->left_child = 0;
    __pyx_v_base->right_child = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/model/terrain.pyx":819 */
  __pyx_f_5_soya_terrain_tri_drop(__pyx_v_tri->left_child);

  /* "/home/jiba/src/soya/model/terrain.pyx":820 */
  __pyx_f_5_soya_terrain_tri_drop(__pyx_v_tri->right_child);

  /* "/home/jiba/src/soya/model/terrain.pyx":821 */
  __pyx_v_tri->left_child = 0;
  __pyx_v_tri->right_child = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":822 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._tri_merge_child");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_8_Terrain__tri_set_level(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri),char __pyx_v_level) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":825 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":826 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":827 */
    __pyx_1 = (__pyx_v_tri->left_child == 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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__Terrain *)__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/terrain.pyx":830 */
    __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__Terrain *)__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/terrain.pyx":832 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_split(__pyx_v_self,__pyx_v_tri);

      /* "/home/jiba/src/soya/model/terrain.pyx":833 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":834 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._tri_set_level");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__patch_set_level(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainPatch (*__pyx_v_patch),char __pyx_v_level) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":837 */
  __pyx_1 = (__pyx_v_patch->level != __pyx_v_level);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":838 */
    __pyx_v_patch->level = __pyx_v_level;

    /* "/home/jiba/src/soya/model/terrain.pyx":839 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":840 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":841 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":842 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._patch_set_level");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_8_Terrain__patch_update(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainPatch (*__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/terrain.pyx":849 */
  __pyx_v_v1 = __pyx_v_patch->tri_top->v3->coord;

  /* "/home/jiba/src/soya/model/terrain.pyx":850 */
  __pyx_v_v2 = __pyx_v_patch->tri_bottom->v3->coord;

  /* "/home/jiba/src/soya/model/terrain.pyx":851 */
  __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/terrain.pyx":852 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":853 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/terrain.pyx":855 */
    __pyx_v_d = point_distance_to(__pyx_v_patch->sphere,__pyx_v_frustum->position);

    /* "/home/jiba/src/soya/model/terrain.pyx":856 */
    __pyx_v_r = ((__pyx_v_patch->sphere[3]) * __pyx_v_self->_split_factor);

    /* "/home/jiba/src/soya/model/terrain.pyx":857 */
    __pyx_1 = (__pyx_v_d <= __pyx_v_r);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":859 */
      __pyx_v_level = ((char )((__pyx_v_self->_max_level + 1) - ((int )(__pyx_v_d / __pyx_v_r))));

      /* "/home/jiba/src/soya/model/terrain.pyx":860 */
      __pyx_1 = (__pyx_v_level < 0);
      if (__pyx_1) {
        __pyx_v_level = 0;
        goto __pyx_L4;
      }
      __pyx_L4:;

      /* "/home/jiba/src/soya/model/terrain.pyx":861 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":862 */
    __pyx_r = 1;
    goto __pyx_L0;
  }
  __pyx_L2:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._patch_update");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_8_Terrain__tri_force_presence(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri),__pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":867 */
  __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/terrain.pyx":868 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":869 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":870 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":872 */
    (__pyx_v_u[0]) = ((__pyx_v_tri->v2->coord[0]) - (__pyx_v_tri->v1->coord[0]));

    /* "/home/jiba/src/soya/model/terrain.pyx":873 */
    (__pyx_v_u[1]) = ((__pyx_v_tri->v2->coord[2]) - (__pyx_v_tri->v1->coord[2]));

    /* "/home/jiba/src/soya/model/terrain.pyx":874 */
    (__pyx_v_w[0]) = ((__pyx_v_tri->v3->coord[0]) - (__pyx_v_tri->v1->coord[0]));

    /* "/home/jiba/src/soya/model/terrain.pyx":875 */
    (__pyx_v_w[1]) = ((__pyx_v_tri->v3->coord[2]) - (__pyx_v_tri->v1->coord[2]));

    /* "/home/jiba/src/soya/model/terrain.pyx":876 */
    __pyx_v_x = ((__pyx_v_v->coord[0]) - (__pyx_v_tri->v1->coord[0]));

    /* "/home/jiba/src/soya/model/terrain.pyx":877 */
    __pyx_v_z = ((__pyx_v_v->coord[2]) - (__pyx_v_tri->v1->coord[2]));

    /* "/home/jiba/src/soya/model/terrain.pyx":878 */
    __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/terrain.pyx":879 */
    __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/terrain.pyx":880 */
    __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/terrain.pyx":881 */
    __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/terrain.pyx":882 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_tri_split(__pyx_v_self,__pyx_v_tri);

      /* "/home/jiba/src/soya/model/terrain.pyx":883 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":884 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._tri_force_presence");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__force_presence(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v);
  struct __pyx_t_5_soya__TerrainPatch (*__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/terrain.pyx":890 */
  __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/terrain.pyx":891 */
    __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/terrain.pyx":892 */
      __pyx_3 = ((__pyx_v_self->_vertex_options[(__pyx_v_i + (__pyx_v_j * __pyx_v_self->_nb_vertex_width))]) & __pyx_e_5_soya_TERRAIN_VERTEX_FORCE_PRESENCE);
      if (__pyx_3) {

        /* "/home/jiba/src/soya/model/terrain.pyx":893 */
        __pyx_v_a = ((int )(((float )__pyx_v_i) / __pyx_v_self->_patch_size));

        /* "/home/jiba/src/soya/model/terrain.pyx":894 */
        __pyx_v_b = ((int )(((float )__pyx_v_j) / __pyx_v_self->_patch_size));

        /* "/home/jiba/src/soya/model/terrain.pyx":895 */
        __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/terrain.pyx":896 */
        __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/terrain.pyx":897 */
        __pyx_v_patch = ((__pyx_v_self->_patchs + __pyx_v_a) + (__pyx_v_b * __pyx_v_self->_nb_patch_width));

        /* "/home/jiba/src/soya/model/terrain.pyx":898 */
        __pyx_v_v = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":899 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":900 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":901 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":902 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._force_presence");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__tri_batch(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__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/terrain.pyx":909 */
  __pyx_1 = sphere_in_frustum(__pyx_v_frustum,__pyx_v_tri->sphere);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":910 */
    __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":911 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":912 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":914 */
      __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":915 */
        __pyx_v_o1 = (__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]);

        /* "/home/jiba/src/soya/model/terrain.pyx":916 */
        __pyx_v_o2 = (__pyx_v_self->_vertex_options[(__pyx_v_tri->v2 - __pyx_v_self->_vertices)]);

        /* "/home/jiba/src/soya/model/terrain.pyx":917 */
        __pyx_v_o3 = (__pyx_v_self->_vertex_options[(__pyx_v_tri->v3 - __pyx_v_self->_vertices)]);

        /* "/home/jiba/src/soya/model/terrain.pyx":918 */
        __pyx_1 = (__pyx_v_o1 & __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN);
        if (__pyx_1) {
          __pyx_1 = (__pyx_v_o2 & __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN);
          if (__pyx_1) {
            __pyx_1 = (__pyx_v_o3 & __pyx_e_5_soya_TERRAIN_VERTEX_HIDDEN);
          }
        }
        if (__pyx_1) {
          goto __pyx_L0;
          goto __pyx_L5;
        }
        __pyx_L5:;

        /* "/home/jiba/src/soya/model/terrain.pyx":921 */
        __pyx_1 = (__pyx_v_o1 & __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA);
        if (!__pyx_1) {
          __pyx_1 = (__pyx_v_o2 & __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA);
          if (!__pyx_1) {
            __pyx_1 = (__pyx_v_o3 & __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA);
          }
        }
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/terrain.pyx":923 */
          __pyx_v_p1 = __pyx_f_5_soya_pack_get_secondpass(__pyx_v_tri->v1->pack);

          /* "/home/jiba/src/soya/model/terrain.pyx":924 */
          __pyx_v_p2 = __pyx_f_5_soya_pack_get_secondpass(__pyx_v_tri->v2->pack);

          /* "/home/jiba/src/soya/model/terrain.pyx":925 */
          __pyx_v_p3 = __pyx_f_5_soya_pack_get_secondpass(__pyx_v_tri->v3->pack);

          /* "/home/jiba/src/soya/model/terrain.pyx":926 */
          __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/terrain.pyx":928 */
          __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/terrain.pyx":929 */
          __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/terrain.pyx":930 */
          __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/terrain.pyx":931 */
          __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/terrain.pyx":932 */
          __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/terrain.pyx":933 */
          goto __pyx_L0;
          goto __pyx_L6;
        }
        __pyx_L6:;
        goto __pyx_L4;
      }
      __pyx_L4:;

      /* "/home/jiba/src/soya/model/terrain.pyx":935 */
      __pyx_v_p1 = __pyx_v_tri->v1->pack;

      /* "/home/jiba/src/soya/model/terrain.pyx":936 */
      __pyx_v_p2 = __pyx_v_tri->v2->pack;

      /* "/home/jiba/src/soya/model/terrain.pyx":937 */
      __pyx_v_p3 = __pyx_v_tri->v3->pack;

      /* "/home/jiba/src/soya/model/terrain.pyx":940 */
      __pyx_1 = (__pyx_v_p1 == __pyx_v_p2);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":941 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/terrain.pyx":942 */
        __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/terrain.pyx":944 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/terrain.pyx":945 */
        __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/terrain.pyx":947 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p2,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/terrain.pyx":948 */
        __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/terrain.pyx":951 */
        __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/terrain.pyx":952 */
          __pyx_v_p4 = __pyx_v_tri->base_neighbor->v1->pack;

          /* "/home/jiba/src/soya/model/terrain.pyx":953 */
          __pyx_1 = (__pyx_v_p2 == __pyx_v_p4);
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/terrain.pyx":954 */
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p2,__pyx_v_tri);

            /* "/home/jiba/src/soya/model/terrain.pyx":955 */
            __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/terrain.pyx":956 */
            __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/terrain.pyx":957 */
            goto __pyx_L0;
            goto __pyx_L17;
          }
          __pyx_1 = (__pyx_v_p3 == __pyx_v_p4);
          if (__pyx_1) {

            /* "/home/jiba/src/soya/model/terrain.pyx":959 */
            __pyx_f_5_soya_pack_batch_face(__pyx_v_p3,__pyx_v_tri);

            /* "/home/jiba/src/soya/model/terrain.pyx":960 */
            __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/terrain.pyx":961 */
            __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/terrain.pyx":962 */
            goto __pyx_L0;
            goto __pyx_L17;
          }
          __pyx_L17:;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "/home/jiba/src/soya/model/terrain.pyx":963 */
        __pyx_f_5_soya_pack_batch_face(__pyx_v_p1,__pyx_v_tri);

        /* "/home/jiba/src/soya/model/terrain.pyx":964 */
        __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/terrain.pyx":965 */
        __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._Terrain._tri_batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__patch_batch(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainPatch (*__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/terrain.pyx":968 */
  __pyx_1 = sphere_in_frustum(__pyx_v_frustum,__pyx_v_patch->sphere);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":969 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":970 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":971 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":972 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._patch_batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__batch(struct __pyx_obj_5_soya__Terrain *__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__TerrainPatch (*__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/terrain.pyx":975 */
  __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/terrain.pyx":977 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":979 */
  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/terrain.pyx":980 */
  __pyx_v_self->__pyx_base._frustum_id = (-1);

  /* "/home/jiba/src/soya/model/terrain.pyx":990 */
  __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/terrain.pyx":991 */
  __pyx_v_ptr = __pyx_v_frustum->points;

  /* "/home/jiba/src/soya/model/terrain.pyx":992 */
  (__pyx_v_frustum_box[0]) = (__pyx_v_ptr[0]);

  /* "/home/jiba/src/soya/model/terrain.pyx":993 */
  (__pyx_v_frustum_box[1]) = (__pyx_v_ptr[2]);

  /* "/home/jiba/src/soya/model/terrain.pyx":994 */
  (__pyx_v_frustum_box[2]) = (__pyx_v_ptr[0]);

  /* "/home/jiba/src/soya/model/terrain.pyx":995 */
  (__pyx_v_frustum_box[3]) = (__pyx_v_ptr[2]);

  /* "/home/jiba/src/soya/model/terrain.pyx":996 */
  __pyx_v_i = 3;

  /* "/home/jiba/src/soya/model/terrain.pyx":997 */
  while (1) {
    __pyx_L4:;
    __pyx_1 = (__pyx_v_i < 24);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/model/terrain.pyx":998 */
    __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/terrain.pyx":999 */
    __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/terrain.pyx":1000 */
    __pyx_v_i = (__pyx_v_i + 2);

    /* "/home/jiba/src/soya/model/terrain.pyx":1001 */
    __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/terrain.pyx":1002 */
    __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/terrain.pyx":1003 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1005 */
  __pyx_v_patch = __pyx_v_self->_patchs;

  /* "/home/jiba/src/soya/model/terrain.pyx":1006 */
  __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/terrain.pyx":1007 */
    __pyx_v_patch->visible = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1008 */
    __pyx_v_patch = (__pyx_v_patch + 1);
    __pyx_L10:;
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1010 */
  __pyx_v_patch = __pyx_v_self->_patchs;

  /* "/home/jiba/src/soya/model/terrain.pyx":1011 */
  __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/terrain.pyx":1012 */
    __pyx_2 = __pyx_v_patch->visible;
    if (__pyx_2) {
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1013 */
    __pyx_v_patch = (__pyx_v_patch + 1);
    __pyx_L12:;
  }
  __pyx_L13:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1015 */
  __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._Terrain._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_8_Terrain__vertex_render_special(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,__pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":1025 */
  __pyx_v_index = (__pyx_v_vertex - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/terrain.pyx":1026 */
  __pyx_v_color = (__pyx_v_self->_colors + __pyx_v_index);

  /* "/home/jiba/src/soya/model/terrain.pyx":1028 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
  if (__pyx_1) {
    __pyx_1 = ((__pyx_v_self->_vertex_options[__pyx_v_index]) & __pyx_e_5_soya_TERRAIN_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/terrain.pyx":1029 */
    (__pyx_v_ccc[0]) = (__pyx_v_color[0]);

    /* "/home/jiba/src/soya/model/terrain.pyx":1030 */
    (__pyx_v_ccc[1]) = (__pyx_v_color[1]);

    /* "/home/jiba/src/soya/model/terrain.pyx":1031 */
    (__pyx_v_ccc[2]) = (__pyx_v_color[2]);

    /* "/home/jiba/src/soya/model/terrain.pyx":1032 */
    (__pyx_v_ccc[3]) = 0.0;

    /* "/home/jiba/src/soya/model/terrain.pyx":1033 */
    __pyx_v_5_soya_terrain_drawColor(__pyx_v_ccc);
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_v_5_soya_terrain_drawColor(__pyx_v_color);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1036 */
  glTexCoord2fv(__pyx_v_vertex->texcoord);

  /* "/home/jiba/src/soya/model/terrain.pyx":1037 */
  glNormal3fv(__pyx_v_vertex->normal);

  /* "/home/jiba/src/soya/model/terrain.pyx":1038 */
  glVertex3fv(__pyx_v_vertex->coord);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Terrain._vertex_render_special");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__tri_render_middle(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri)) {
  float (__pyx_v_ccc[4]);
  __pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":1046 */
  __pyx_1 = (__pyx_v_self->_colors == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1047 */
    __pyx_v_color = __pyx_v_5_soya_renderer->current_material->_diffuse;

    /* "/home/jiba/src/soya/model/terrain.pyx":1048 */
    (__pyx_v_ccc[0]) = (__pyx_v_color[0]);

    /* "/home/jiba/src/soya/model/terrain.pyx":1049 */
    (__pyx_v_ccc[1]) = (__pyx_v_color[1]);

    /* "/home/jiba/src/soya/model/terrain.pyx":1050 */
    (__pyx_v_ccc[2]) = (__pyx_v_color[2]);
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/terrain.pyx":1052 */
    __pyx_v_color = (__pyx_v_self->_colors + (__pyx_v_tri->v2 - __pyx_v_self->_vertices));

    /* "/home/jiba/src/soya/model/terrain.pyx":1053 */
    __pyx_v_color2 = (__pyx_v_self->_colors + (__pyx_v_tri->v3 - __pyx_v_self->_vertices));

    /* "/home/jiba/src/soya/model/terrain.pyx":1054 */
    (__pyx_v_ccc[0]) = (((__pyx_v_color[0]) + (__pyx_v_color2[0])) * 0.5);

    /* "/home/jiba/src/soya/model/terrain.pyx":1055 */
    (__pyx_v_ccc[1]) = (((__pyx_v_color[1]) + (__pyx_v_color2[1])) * 0.5);

    /* "/home/jiba/src/soya/model/terrain.pyx":1056 */
    (__pyx_v_ccc[2]) = (((__pyx_v_color[2]) + (__pyx_v_color2[2])) * 0.5);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1057 */
  (__pyx_v_ccc[3]) = 0.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":1058 */
  __pyx_v_5_soya_terrain_drawColor(__pyx_v_ccc);

  /* "/home/jiba/src/soya/model/terrain.pyx":1060 */
  __pyx_1 = (__pyx_v_tri->level == __pyx_v_self->_max_level);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1061 */
    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/terrain.pyx":1063 */
    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/terrain.pyx":1066 */
    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/terrain.pyx":1070 */
    __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/terrain.pyx":1073 */
    glTexCoord2fv(__pyx_v_v->texcoord);

    /* "/home/jiba/src/soya/model/terrain.pyx":1074 */
    glNormal3fv(__pyx_v_v->normal);

    /* "/home/jiba/src/soya/model/terrain.pyx":1075 */
    glVertex3fv(__pyx_v_v->coord);
  }
  __pyx_L3:;

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

static void __pyx_f_5_soya_8_Terrain__tri_render_secondpass(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__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/terrain.pyx":1082 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS));
  if (!__pyx_1) {
    __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA);
    if (!__pyx_2) {
      __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_ALPHA);
      if (!__pyx_2) {
        __pyx_2 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_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/terrain.pyx":1088 */
    __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/terrain.pyx":1092 */
      __pyx_v_index = (__pyx_v_tri->v1 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/terrain.pyx":1092 */
      __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/terrain.pyx":1092 */
      glTexCoord2fv(__pyx_v_tri->v1->texcoord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1092 */
      glNormal3fv(__pyx_v_tri->v1->normal);

      /* "/home/jiba/src/soya/model/terrain.pyx":1092 */
      glVertex3fv(__pyx_v_tri->v1->coord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1093 */
      __pyx_v_index = (__pyx_v_tri->v2 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/terrain.pyx":1093 */
      __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/terrain.pyx":1093 */
      glTexCoord2fv(__pyx_v_tri->v2->texcoord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1093 */
      glNormal3fv(__pyx_v_tri->v2->normal);

      /* "/home/jiba/src/soya/model/terrain.pyx":1093 */
      glVertex3fv(__pyx_v_tri->v2->coord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1094 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1095 */
      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/terrain.pyx":1101 */
      __pyx_v_index = (__pyx_v_tri->v1 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/terrain.pyx":1101 */
      __pyx_f_5_soya_SET_COLOR_ALPHA(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/terrain.pyx":1101 */
      glTexCoord2fv(__pyx_v_tri->v1->texcoord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1101 */
      glNormal3fv(__pyx_v_tri->v1->normal);

      /* "/home/jiba/src/soya/model/terrain.pyx":1101 */
      glVertex3fv(__pyx_v_tri->v1->coord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1102 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1103 */
      __pyx_v_index = (__pyx_v_tri->v3 - __pyx_v_self->_vertices);

      /* "/home/jiba/src/soya/model/terrain.pyx":1103 */
      __pyx_f_5_soya_SET_COLOR_OPAQUE(__pyx_v_self,__pyx_v_index);

      /* "/home/jiba/src/soya/model/terrain.pyx":1103 */
      glTexCoord2fv(__pyx_v_tri->v3->texcoord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1103 */
      glNormal3fv(__pyx_v_tri->v3->normal);

      /* "/home/jiba/src/soya/model/terrain.pyx":1103 */
      glVertex3fv(__pyx_v_tri->v3->coord);

      /* "/home/jiba/src/soya/model/terrain.pyx":1104 */
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1106 */
  __pyx_v_index = (__pyx_v_tri->v1 - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/terrain.pyx":1107 */
  __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/terrain.pyx":1109 */
  glTexCoord2fv(__pyx_v_tri->v1->texcoord);

  /* "/home/jiba/src/soya/model/terrain.pyx":1110 */
  glNormal3fv(__pyx_v_tri->v1->normal);

  /* "/home/jiba/src/soya/model/terrain.pyx":1111 */
  glVertex3fv(__pyx_v_tri->v1->coord);

  /* "/home/jiba/src/soya/model/terrain.pyx":1114 */
  __pyx_v_index = (__pyx_v_tri->v2 - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/terrain.pyx":1115 */
  __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/terrain.pyx":1117 */
  glTexCoord2fv(__pyx_v_tri->v2->texcoord);

  /* "/home/jiba/src/soya/model/terrain.pyx":1118 */
  glNormal3fv(__pyx_v_tri->v2->normal);

  /* "/home/jiba/src/soya/model/terrain.pyx":1119 */
  glVertex3fv(__pyx_v_tri->v2->coord);

  /* "/home/jiba/src/soya/model/terrain.pyx":1122 */
  __pyx_v_index = (__pyx_v_tri->v3 - __pyx_v_self->_vertices);

  /* "/home/jiba/src/soya/model/terrain.pyx":1123 */
  __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/terrain.pyx":1125 */
  glTexCoord2fv(__pyx_v_tri->v3->texcoord);

  /* "/home/jiba/src/soya/model/terrain.pyx":1126 */
  glNormal3fv(__pyx_v_tri->v3->normal);

  /* "/home/jiba/src/soya/model/terrain.pyx":1127 */
  glVertex3fv(__pyx_v_tri->v3->coord);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Terrain._tri_render_secondpass");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_8_Terrain__render(struct __pyx_obj_5_soya__Terrain *__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__TerrainTri (*__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/terrain.pyx":1136 */
  __pyx_v_5_soya_terrain_disableColor();

  /* "/home/jiba/src/soya/model/terrain.pyx":1143 */
  __pyx_v_cur = __pyx_v_5_soya_renderer->data->nb;

  /* "/home/jiba/src/soya/model/terrain.pyx":1144 */
  __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

  /* "/home/jiba/src/soya/model/terrain.pyx":1146 */
  __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_OPAQUE);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1147 */
    while (1) {
      __pyx_L3:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/terrain.pyx":1148 */
      __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/terrain.pyx":1150 */
      glBegin(GL_TRIANGLES);

      /* "/home/jiba/src/soya/model/terrain.pyx":1151 */
      __pyx_v_tri = ((struct __pyx_t_5_soya__TerrainTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

      /* "/home/jiba/src/soya/model/terrain.pyx":1152 */
      while (1) {
        __pyx_L5:;
        __pyx_1 = (__pyx_v_tri != 0);
        if (!__pyx_1) break;

        /* "/home/jiba/src/soya/model/terrain.pyx":1154 */
        __pyx_1 = (__pyx_v_self->_colors != 0);
        if (__pyx_1) {
          __pyx_v_5_soya_terrain_drawColor((__pyx_v_self->_colors + __pyx_v_index));
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1156 */
        glTexCoord2fv(__pyx_v_tri->v1->texcoord);

        /* "/home/jiba/src/soya/model/terrain.pyx":1157 */
        glNormal3fv(__pyx_v_tri->v1->normal);

        /* "/home/jiba/src/soya/model/terrain.pyx":1158 */
        glVertex3fv(__pyx_v_tri->v1->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":1161 */
        __pyx_1 = (__pyx_v_self->_colors != 0);
        if (__pyx_1) {
          __pyx_v_5_soya_terrain_drawColor((__pyx_v_self->_colors + __pyx_v_index));
          goto __pyx_L8;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1163 */
        glTexCoord2fv(__pyx_v_tri->v2->texcoord);

        /* "/home/jiba/src/soya/model/terrain.pyx":1164 */
        glNormal3fv(__pyx_v_tri->v2->normal);

        /* "/home/jiba/src/soya/model/terrain.pyx":1165 */
        glVertex3fv(__pyx_v_tri->v2->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":1168 */
        __pyx_1 = (__pyx_v_self->_colors != 0);
        if (__pyx_1) {
          __pyx_v_5_soya_terrain_drawColor((__pyx_v_self->_colors + __pyx_v_index));
          goto __pyx_L9;
        }
        __pyx_L9:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1170 */
        glTexCoord2fv(__pyx_v_tri->v3->texcoord);

        /* "/home/jiba/src/soya/model/terrain.pyx":1171 */
        glNormal3fv(__pyx_v_tri->v3->normal);

        /* "/home/jiba/src/soya/model/terrain.pyx":1172 */
        glVertex3fv(__pyx_v_tri->v3->coord);

        /* "/home/jiba/src/soya/model/terrain.pyx":1174 */
        __pyx_v_tri = ((struct __pyx_t_5_soya__TerrainTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/terrain.pyx":1176 */
      glEnd();

      /* "/home/jiba/src/soya/model/terrain.pyx":1177 */
      __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/terrain.pyx":1181 */
    glEnable(GL_BLEND);

    /* "/home/jiba/src/soya/model/terrain.pyx":1186 */
    while (1) {
      __pyx_L10:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/terrain.pyx":1187 */
      __pyx_1 = (__pyx_v_pack->option & __pyx_e_5_soya_PACK_SPECIAL);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1188 */
        __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/terrain.pyx":1189 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/model/terrain.pyx":1190 */
        __pyx_v_tri = ((struct __pyx_t_5_soya__TerrainTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

        /* "/home/jiba/src/soya/model/terrain.pyx":1191 */
        while (1) {
          __pyx_L13:;
          __pyx_1 = (__pyx_v_tri != 0);
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/terrain.pyx":1192 */
          ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1193 */
          ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1194 */
          ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1195 */
          __pyx_v_tri = ((struct __pyx_t_5_soya__TerrainTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
        }
        __pyx_L14:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1196 */
        glEnd();
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/terrain.pyx":1198 */
        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/terrain.pyx":1200 */
      __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/terrain.pyx":1203 */
    glDepthFunc(GL_LEQUAL);

    /* "/home/jiba/src/soya/model/terrain.pyx":1204 */
    glPolygonOffset((-1.0),0.0);

    /* "/home/jiba/src/soya/model/terrain.pyx":1205 */
    __pyx_v_5_soya_renderer->data->nb = __pyx_v_cur;

    /* "/home/jiba/src/soya/model/terrain.pyx":1206 */
    __pyx_v_pack = ((struct __pyx_t_5_soya__Pack (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

    /* "/home/jiba/src/soya/model/terrain.pyx":1207 */
    while (1) {
      __pyx_L17:;
      __pyx_1 = (__pyx_v_pack != 0);
      if (!__pyx_1) break;

      /* "/home/jiba/src/soya/model/terrain.pyx":1208 */
      __pyx_1 = (!(__pyx_v_pack->option & __pyx_e_5_soya_PACK_SPECIAL));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1209 */
        __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/terrain.pyx":1210 */
        glEnable(GL_POLYGON_OFFSET_FILL);

        /* "/home/jiba/src/soya/model/terrain.pyx":1211 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/model/terrain.pyx":1212 */
        __pyx_v_tri = ((struct __pyx_t_5_soya__TerrainTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));

        /* "/home/jiba/src/soya/model/terrain.pyx":1213 */
        while (1) {
          __pyx_L20:;
          __pyx_1 = (__pyx_v_tri != 0);
          if (!__pyx_1) break;

          /* "/home/jiba/src/soya/model/terrain.pyx":1214 */
          ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1215 */
          __pyx_v_tri = ((struct __pyx_t_5_soya__TerrainTri (*))chunk_get_ptr(__pyx_v_5_soya_renderer->data));
        }
        __pyx_L21:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1216 */
        glEnd();

        /* "/home/jiba/src/soya/model/terrain.pyx":1217 */
        glDisable(GL_POLYGON_OFFSET_FILL);
        goto __pyx_L19;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/terrain.pyx":1219 */
        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/terrain.pyx":1221 */
      __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/terrain.pyx":1223 */
    glDisable(GL_BLEND);

    /* "/home/jiba/src/soya/model/terrain.pyx":1224 */
    glDepthFunc(GL_LESS);

    /* "/home/jiba/src/soya/model/terrain.pyx":1225 */
    glDisable(GL_POLYGON_OFFSET_FILL);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1227 */
  __pyx_v_5_soya_terrain_drawColor(__pyx_v_5_soya_white);

  /* "/home/jiba/src/soya/model/terrain.pyx":1228 */
  __pyx_v_5_soya_terrain_enableColor();

  /* "/home/jiba/src/soya/model/terrain.pyx":1229 */
  glDisableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/model/terrain.pyx":1230 */
  glDisableClientState(GL_NORMAL_ARRAY);

  /* "/home/jiba/src/soya/model/terrain.pyx":1231 */
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Terrain._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static void __pyx_f_5_soya_8_Terrain__tri_raypick(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__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/terrain.pyx":1235 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1236 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1237 */
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1239 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
    if (__pyx_1) {
      __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_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_TERRAIN_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_TERRAIN_VERTEX_NON_SOLID);
        }
      }
    }
    if (__pyx_1) {
      goto __pyx_L0;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/model/terrain.pyx":1244 */
    __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/terrain.pyx":1245 */
      __pyx_v_root_r = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1246 */
      __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/terrain.pyx":1247 */
        __pyx_v_data->result = __pyx_v_r;

        /* "/home/jiba/src/soya/model/terrain.pyx":1248 */
        __pyx_v_data->root_result = __pyx_v_root_r;

        /* "/home/jiba/src/soya/model/terrain.pyx":1249 */
        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/terrain.pyx":1250 */
        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._Terrain._tri_raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static void __pyx_f_5_soya_8_Terrain__full_raypick(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,__pyx_t_5_soya_TerrainVertex (*__pyx_v_v1),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v2),__pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":1255 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS));
  if (!__pyx_1) {
    __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID));
    if (!__pyx_1) {
      __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID));
      if (!__pyx_1) {
        __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID));
      }
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1259 */
    __pyx_v_coord1 = __pyx_v_v1->coord;

    /* "/home/jiba/src/soya/model/terrain.pyx":1260 */
    __pyx_v_coord2 = __pyx_v_v2->coord;

    /* "/home/jiba/src/soya/model/terrain.pyx":1261 */
    __pyx_v_coord3 = __pyx_v_v3->coord;

    /* "/home/jiba/src/soya/model/terrain.pyx":1263 */
    __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/terrain.pyx":1264 */
    __pyx_1 = (__pyx_v_a < (2 * __pyx_v_self->_scale_factor));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1265 */
      __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/terrain.pyx":1266 */
      __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/terrain.pyx":1268 */
      __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/terrain.pyx":1269 */
        __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/terrain.pyx":1270 */
          __pyx_v_root_a = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1271 */
          __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/terrain.pyx":1272 */
            __pyx_v_data->result = __pyx_v_a;

            /* "/home/jiba/src/soya/model/terrain.pyx":1273 */
            __pyx_v_data->root_result = __pyx_v_root_a;

            /* "/home/jiba/src/soya/model/terrain.pyx":1274 */
            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/terrain.pyx":1275 */
            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._Terrain._full_raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static void __pyx_f_5_soya_8_Terrain__full_raypick_rect(struct __pyx_obj_5_soya__Terrain *__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_TerrainVertex (*__pyx_v_p);
  __pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":1281 */
  __pyx_v_p0 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1283 */
  for (__pyx_v_j = __pyx_v_z1; __pyx_v_j < __pyx_v_z2; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1284 */
    __pyx_v_p = __pyx_v_p0;

    /* "/home/jiba/src/soya/model/terrain.pyx":1285 */
    __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/terrain.pyx":1286 */
    for (__pyx_v_i = __pyx_v_x1; __pyx_v_i < __pyx_v_x2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1287 */
      __pyx_1 = (!((__pyx_v_i + __pyx_v_j) & 1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1288 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1289 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/terrain.pyx":1290 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1291 */
        __pyx_v_normal = (__pyx_v_normal + 3);
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/terrain.pyx":1293 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1294 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/terrain.pyx":1295 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1296 */
        __pyx_v_normal = (__pyx_v_normal + 3);
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/terrain.pyx":1297 */
      __pyx_v_p = (__pyx_v_p + 1);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/terrain.pyx":1298 */
    __pyx_v_p0 = (__pyx_v_p0 + __pyx_v_self->_nb_vertex_width);
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._full_raypick_rect");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
}

static void __pyx_f_5_soya_8_Terrain__raypick(struct __pyx_obj_5_soya__Terrain *__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__TerrainPatch (*__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/terrain.pyx":1301 */
  __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/terrain.pyx":1307 */
  __pyx_v_data = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1308 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1310 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1311 */
    __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/terrain.pyx":1312 */
      __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

      /* "/home/jiba/src/soya/model/terrain.pyx":1313 */
      __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/terrain.pyx":1315 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1316 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1317 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1318 */
      ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1321 */
    __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/terrain.pyx":1322 */
      __pyx_v_x = ((int )((__pyx_v_data[0]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/terrain.pyx":1323 */
      __pyx_v_z = ((int )((__pyx_v_data[2]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/terrain.pyx":1324 */
      __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/terrain.pyx":1325 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1327 */
      __pyx_2 = ((__pyx_v_data[6]) < 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1328 */
        __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/terrain.pyx":1329 */
          __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

          /* "/home/jiba/src/soya/model/terrain.pyx":1330 */
          __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/terrain.pyx":1332 */
          ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1339 */
        __pyx_2 = (__pyx_v_raypick_data->option & __pyx_e_5_soya_RAYPICK_HALF_LINE);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1340 */
          __pyx_v_x1 = (__pyx_v_data[0]);

          /* "/home/jiba/src/soya/model/terrain.pyx":1341 */
          __pyx_v_z1 = (__pyx_v_data[2]);
          goto __pyx_L14;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/terrain.pyx":1343 */
          __pyx_v_x1 = ((__pyx_v_data[0]) - ((__pyx_v_data[6]) * (__pyx_v_data[3])));

          /* "/home/jiba/src/soya/model/terrain.pyx":1344 */
          __pyx_v_z1 = ((__pyx_v_data[2]) - ((__pyx_v_data[6]) * (__pyx_v_data[5])));
        }
        __pyx_L14:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1345 */
        __pyx_v_x2 = ((__pyx_v_data[0]) + ((__pyx_v_data[6]) * (__pyx_v_data[3])));

        /* "/home/jiba/src/soya/model/terrain.pyx":1346 */
        __pyx_v_z2 = ((__pyx_v_data[2]) + ((__pyx_v_data[6]) * (__pyx_v_data[5])));

        /* "/home/jiba/src/soya/model/terrain.pyx":1347 */
        __pyx_1 = (__pyx_v_x1 > __pyx_v_x2);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1348 */
          __pyx_v_f = __pyx_v_x1;

          /* "/home/jiba/src/soya/model/terrain.pyx":1349 */
          __pyx_v_x1 = __pyx_v_x2;

          /* "/home/jiba/src/soya/model/terrain.pyx":1350 */
          __pyx_v_x2 = __pyx_v_f;
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1351 */
        __pyx_2 = (__pyx_v_z1 > __pyx_v_z2);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1352 */
          __pyx_v_f = __pyx_v_z1;

          /* "/home/jiba/src/soya/model/terrain.pyx":1353 */
          __pyx_v_z1 = __pyx_v_z2;

          /* "/home/jiba/src/soya/model/terrain.pyx":1354 */
          __pyx_v_z2 = __pyx_v_f;
          goto __pyx_L16;
        }
        __pyx_L16:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1356 */
        __pyx_v_x1 = (__pyx_v_x1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1357 */
        __pyx_v_z1 = (__pyx_v_z1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1358 */
        __pyx_v_x2 = (__pyx_v_x2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1359 */
        __pyx_v_z2 = (__pyx_v_z2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1360 */
        __pyx_1 = (__pyx_v_x2 < 0.0);
        if (__pyx_1) {
          goto __pyx_L0;
          goto __pyx_L17;
        }
        __pyx_L17:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1361 */
        __pyx_2 = (__pyx_v_z2 < 0.0);
        if (__pyx_2) {
          goto __pyx_L0;
          goto __pyx_L18;
        }
        __pyx_L18:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1362 */
        __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/terrain.pyx":1363 */
        __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/terrain.pyx":1364 */
        __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/terrain.pyx":1365 */
        __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/terrain.pyx":1366 */
        __pyx_v_x2 = (__pyx_v_x2 + 1.0);

        /* "/home/jiba/src/soya/model/terrain.pyx":1367 */
        __pyx_v_z2 = (__pyx_v_z2 + 1.0);

        /* "/home/jiba/src/soya/model/terrain.pyx":1368 */
        __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/terrain.pyx":1369 */
        __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/terrain.pyx":1370 */
        ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._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_8_Terrain__tri_raypick_b(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,struct __pyx_t_5_soya__TerrainTri (*__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/terrain.pyx":1374 */
  __pyx_1 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1375 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1376 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1378 */
    __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1379 */
      __pyx_1 = ((__pyx_v_self->_vertex_options[(__pyx_v_tri->v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_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_TERRAIN_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_TERRAIN_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/terrain.pyx":1382 */
    __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/terrain.pyx":1383 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1384 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._tri_raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain__full_raypick_b(struct __pyx_obj_5_soya__Terrain *__pyx_v_self,__pyx_t_5_soya_TerrainVertex (*__pyx_v_v1),__pyx_t_5_soya_TerrainVertex (*__pyx_v_v2),__pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":1389 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS));
  if (!__pyx_1) {
    __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v1 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID));
    if (!__pyx_1) {
      __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v2 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID));
      if (!__pyx_1) {
        __pyx_1 = (!((__pyx_v_self->_vertex_options[(__pyx_v_v3 - __pyx_v_self->_vertices)]) & __pyx_e_5_soya_TERRAIN_VERTEX_NON_SOLID));
      }
    }
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1393 */
    __pyx_v_coord1 = __pyx_v_v1->coord;

    /* "/home/jiba/src/soya/model/terrain.pyx":1394 */
    __pyx_v_coord2 = __pyx_v_v2->coord;

    /* "/home/jiba/src/soya/model/terrain.pyx":1395 */
    __pyx_v_coord3 = __pyx_v_v3->coord;

    /* "/home/jiba/src/soya/model/terrain.pyx":1397 */
    __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/terrain.pyx":1398 */
    __pyx_1 = (__pyx_v_a < (2 * __pyx_v_self->_scale_factor));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1399 */
      __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/terrain.pyx":1400 */
      __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/terrain.pyx":1401 */
      __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/terrain.pyx":1402 */
        __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/terrain.pyx":1403 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._full_raypick_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain__full_raypick_rect_b(struct __pyx_obj_5_soya__Terrain *__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_TerrainVertex (*__pyx_v_p);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_p0);
  float (*__pyx_v_normal);
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":1409 */
  __pyx_v_p0 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1411 */
  for (__pyx_v_j = __pyx_v_z1; __pyx_v_j < __pyx_v_z2; ++__pyx_v_j) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1412 */
    __pyx_v_p = __pyx_v_p0;

    /* "/home/jiba/src/soya/model/terrain.pyx":1413 */
    __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/terrain.pyx":1414 */
    for (__pyx_v_i = __pyx_v_x1; __pyx_v_i < __pyx_v_x2; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1415 */
      __pyx_1 = (!((__pyx_v_i + __pyx_v_j) & 1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1416 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1417 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/terrain.pyx":1418 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1419 */
        __pyx_v_normal = (__pyx_v_normal + 3);
        goto __pyx_L6;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/model/terrain.pyx":1421 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1422 */
        __pyx_v_normal = (__pyx_v_normal + 3);

        /* "/home/jiba/src/soya/model/terrain.pyx":1423 */
        __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1424 */
        __pyx_v_normal = (__pyx_v_normal + 3);
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/model/terrain.pyx":1425 */
      __pyx_v_p = (__pyx_v_p + 1);
      __pyx_L4:;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/model/terrain.pyx":1426 */
    __pyx_v_p0 = (__pyx_v_p0 + __pyx_v_self->_nb_vertex_width);
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1427 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._full_raypick_rect_b");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_8_Terrain__raypick_b(struct __pyx_obj_5_soya__Terrain *__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__TerrainPatch (*__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/terrain.pyx":1430 */
  __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/terrain.pyx":1436 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1437 */
  __pyx_v_data = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1439 */
  __pyx_1 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1440 */
    __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/terrain.pyx":1441 */
      __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

      /* "/home/jiba/src/soya/model/terrain.pyx":1442 */
      __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/terrain.pyx":1444 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1445 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1446 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1447 */
      __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1450 */
    __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/terrain.pyx":1451 */
      __pyx_v_x = ((int )((__pyx_v_data[0]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/terrain.pyx":1452 */
      __pyx_v_z = ((int )((__pyx_v_data[2]) / __pyx_v_self->_scale_factor));

      /* "/home/jiba/src/soya/model/terrain.pyx":1454 */
      __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/terrain.pyx":1455 */
        __pyx_r = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1457 */
      __pyx_2 = ((__pyx_v_data[6]) < 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1458 */
        __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/terrain.pyx":1459 */
          __pyx_v_patch = (__pyx_v_self->_patchs + __pyx_v_i);

          /* "/home/jiba/src/soya/model/terrain.pyx":1460 */
          __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/terrain.pyx":1462 */
          __pyx_2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1468 */
        __pyx_2 = (__pyx_v_raypick_data->option & __pyx_e_5_soya_RAYPICK_HALF_LINE);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1469 */
          __pyx_v_x1 = (__pyx_v_data[0]);

          /* "/home/jiba/src/soya/model/terrain.pyx":1470 */
          __pyx_v_z1 = (__pyx_v_data[2]);
          goto __pyx_L19;
        }
        /*else*/ {

          /* "/home/jiba/src/soya/model/terrain.pyx":1472 */
          __pyx_v_x1 = ((__pyx_v_data[0]) - ((__pyx_v_data[6]) * (__pyx_v_data[3])));

          /* "/home/jiba/src/soya/model/terrain.pyx":1473 */
          __pyx_v_z1 = ((__pyx_v_data[2]) - ((__pyx_v_data[6]) * (__pyx_v_data[5])));
        }
        __pyx_L19:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1474 */
        __pyx_v_x2 = ((__pyx_v_data[0]) + ((__pyx_v_data[6]) * (__pyx_v_data[3])));

        /* "/home/jiba/src/soya/model/terrain.pyx":1475 */
        __pyx_v_z2 = ((__pyx_v_data[2]) + ((__pyx_v_data[6]) * (__pyx_v_data[5])));

        /* "/home/jiba/src/soya/model/terrain.pyx":1476 */
        __pyx_1 = (__pyx_v_x1 > __pyx_v_x2);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1477 */
          __pyx_v_f = __pyx_v_x1;

          /* "/home/jiba/src/soya/model/terrain.pyx":1478 */
          __pyx_v_x1 = __pyx_v_x2;

          /* "/home/jiba/src/soya/model/terrain.pyx":1479 */
          __pyx_v_x2 = __pyx_v_f;
          goto __pyx_L20;
        }
        __pyx_L20:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1480 */
        __pyx_2 = (__pyx_v_z1 > __pyx_v_z2);
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1481 */
          __pyx_v_f = __pyx_v_z1;

          /* "/home/jiba/src/soya/model/terrain.pyx":1482 */
          __pyx_v_z1 = __pyx_v_z2;

          /* "/home/jiba/src/soya/model/terrain.pyx":1483 */
          __pyx_v_z2 = __pyx_v_f;
          goto __pyx_L21;
        }
        __pyx_L21:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1484 */
        __pyx_v_x1 = (__pyx_v_x1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1485 */
        __pyx_v_z1 = (__pyx_v_z1 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1486 */
        __pyx_v_x2 = (__pyx_v_x2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1487 */
        __pyx_v_z2 = (__pyx_v_z2 / __pyx_v_self->_scale_factor);

        /* "/home/jiba/src/soya/model/terrain.pyx":1488 */
        __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/terrain.pyx":1489 */
        __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/terrain.pyx":1490 */
        __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/terrain.pyx":1491 */
        __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/terrain.pyx":1492 */
        __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/terrain.pyx":1493 */
        __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/terrain.pyx":1494 */
        __pyx_v_x2 = (__pyx_v_x2 + 1.0);

        /* "/home/jiba/src/soya/model/terrain.pyx":1495 */
        __pyx_v_z2 = (__pyx_v_z2 + 1.0);

        /* "/home/jiba/src/soya/model/terrain.pyx":1496 */
        __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/terrain.pyx":1497 */
        __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/terrain.pyx":1498 */
        __pyx_r = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1499 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Terrain._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_8_Terrain__collect_raypickables(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":1502 */
  __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/terrain.pyx":1505 */
  chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_self)));

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

static PyObject *__pyx_f_5_soya_8_Terrain_get_true_height_and_normal(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_8_Terrain_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_TerrainVertex (*__pyx_v_v1);
  __pyx_t_5_soya_TerrainVertex (*__pyx_v_v2);
  struct __pyx_t_5_soya__TerrainPatch (*__pyx_v_patch);
  struct __pyx_t_5_soya__TerrainTri (*__pyx_v_tri);
  int __pyx_v_ix;
  int __pyx_v_iz;
  float __pyx_v_nx;
  float __pyx_v_nz;
  __pyx_t_5_soya_TerrainVertex (*__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/terrain.pyx":1519 */
  __pyx_1 = (!(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_init(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self));
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/terrain.pyx":1520 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_TERRAIN_REAL_LOD_RAYPICK);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1522 */
    __pyx_1 = ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_patchs;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1523 */
      __pyx_v_patch = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_patchs + __pyx_v_i);

      /* "/home/jiba/src/soya/model/terrain.pyx":1524 */
      __pyx_v_v1 = __pyx_v_patch->tri_top->v3;

      /* "/home/jiba/src/soya/model/terrain.pyx":1525 */
      __pyx_v_v2 = __pyx_v_patch->tri_bottom->v3;

      /* "/home/jiba/src/soya/model/terrain.pyx":1526 */
      __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/terrain.pyx":1530 */
        __pyx_v_tri = __pyx_v_patch->tri_top;

        /* "/home/jiba/src/soya/model/terrain.pyx":1531 */
        for (__pyx_v_j = 0; __pyx_v_j < 4; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1532 */
          __pyx_f_5_soya_terrain_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/terrain.pyx":1533 */
          __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/terrain.pyx":1534 */
            while (1) {
              __pyx_L10:;
              __pyx_3 = 1;
              if (!__pyx_3) break;

              /* "/home/jiba/src/soya/model/terrain.pyx":1535 */
              __pyx_f_5_soya_terrain_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/terrain.pyx":1536 */
              __pyx_2 = __pyx_f_5_soya_terrain_tri_has_child(__pyx_v_tri);
              if (__pyx_2) {

                /* "/home/jiba/src/soya/model/terrain.pyx":1537 */
                __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/terrain.pyx":1540 */
                __pyx_v_norm = __pyx_v_tri->normal;

                /* "/home/jiba/src/soya/model/terrain.pyx":1541 */
                __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 = 1541; goto __pyx_L1;}
                __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1541; goto __pyx_L1;}
                __pyx_6 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1541; goto __pyx_L1;}
                __pyx_7 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1541; goto __pyx_L1;}
                __pyx_8 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1541; goto __pyx_L1;}
                __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1541; 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 = 1541; 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 = 1541; 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/terrain.pyx":1543 */
          __pyx_v_tri = (__pyx_v_tri + 1);
          __pyx_L7:;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/model/terrain.pyx":1545 */
        goto __pyx_L5;
        goto __pyx_L6;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/terrain.pyx":1548 */
    __pyx_v_nx = (__pyx_v_x / ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_scale_factor);

    /* "/home/jiba/src/soya/model/terrain.pyx":1549 */
    __pyx_v_nz = (__pyx_v_z / ((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_scale_factor);

    /* "/home/jiba/src/soya/model/terrain.pyx":1550 */
    __pyx_v_ix = ((int )__pyx_v_nx);

    /* "/home/jiba/src/soya/model/terrain.pyx":1551 */
    __pyx_v_iz = ((int )__pyx_v_nz);

    /* "/home/jiba/src/soya/model/terrain.pyx":1552 */
    __pyx_2 = 0 <= __pyx_v_ix;
    if (__pyx_2) {
      __pyx_2 = __pyx_v_ix < ((struct __pyx_obj_5_soya__Terrain *)__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__Terrain *)__pyx_v_self)->_nb_vertex_depth;
      }
    }
    if (__pyx_2) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1553 */
      __pyx_1 = (!((__pyx_v_ix + __pyx_v_iz) & 1));
      if (__pyx_1) {

        /* "/home/jiba/src/soya/model/terrain.pyx":1554 */
        __pyx_2 = ((__pyx_v_nz - __pyx_v_iz) > (__pyx_v_nx - __pyx_v_ix));
        if (__pyx_2) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1555 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ix,(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/terrain.pyx":1556 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ix,__pyx_v_iz);

          /* "/home/jiba/src/soya/model/terrain.pyx":1557 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(__pyx_v_ix + 1),(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/terrain.pyx":1558 */
          __pyx_f_5_soya_terrain_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/terrain.pyx":1559 */
          __pyx_v_norm = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width - 1)))));

          /* "/home/jiba/src/soya/model/terrain.pyx":1560 */
          __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 = 1560; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1560; goto __pyx_L1;}
          __pyx_9 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1560; goto __pyx_L1;}
          __pyx_4 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1560; goto __pyx_L1;}
          __pyx_6 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1560; goto __pyx_L1;}
          __pyx_7 = PyTuple_New(4); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1560; 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 = 1560; 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 = 1560; 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/terrain.pyx":1562 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(__pyx_v_ix + 1),__pyx_v_iz);

          /* "/home/jiba/src/soya/model/terrain.pyx":1563 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(__pyx_v_ix + 1),(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/terrain.pyx":1564 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ix,__pyx_v_iz);

          /* "/home/jiba/src/soya/model/terrain.pyx":1565 */
          __pyx_f_5_soya_terrain_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/terrain.pyx":1566 */
          __pyx_v_norm = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width - 1))))) + 3);

          /* "/home/jiba/src/soya/model/terrain.pyx":1567 */
          __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 = 1567; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1567; goto __pyx_L1;}
          __pyx_7 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1567; goto __pyx_L1;}
          __pyx_8 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1567; goto __pyx_L1;}
          __pyx_9 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1567; goto __pyx_L1;}
          __pyx_4 = PyTuple_New(4); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1567; 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 = 1567; 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 = 1567; 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/terrain.pyx":1570 */
        __pyx_1 = ((((__pyx_v_nz - __pyx_v_iz) + __pyx_v_nx) - __pyx_v_ix) < 1);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/model/terrain.pyx":1571 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ix,__pyx_v_iz);

          /* "/home/jiba/src/soya/model/terrain.pyx":1572 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(__pyx_v_ix + 1),__pyx_v_iz);

          /* "/home/jiba/src/soya/model/terrain.pyx":1573 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ix,(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/terrain.pyx":1574 */
          __pyx_f_5_soya_terrain_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/terrain.pyx":1575 */
          __pyx_v_norm = (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width - 1)))));

          /* "/home/jiba/src/soya/model/terrain.pyx":1576 */
          __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 = 1576; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1576; goto __pyx_L1;}
          __pyx_4 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1576; goto __pyx_L1;}
          __pyx_6 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1576; goto __pyx_L1;}
          __pyx_7 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_7) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1576; goto __pyx_L1;}
          __pyx_8 = PyTuple_New(4); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1576; 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 = 1576; 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 = 1576; 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/terrain.pyx":1578 */
          __pyx_v_v1 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(__pyx_v_ix + 1),(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/terrain.pyx":1579 */
          __pyx_v_v2 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),__pyx_v_ix,(__pyx_v_iz + 1));

          /* "/home/jiba/src/soya/model/terrain.pyx":1580 */
          __pyx_v_v3 = ((struct __pyx_vtabstruct_5_soya__Terrain *)((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_get_vertex(((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self),(__pyx_v_ix + 1),__pyx_v_iz);

          /* "/home/jiba/src/soya/model/terrain.pyx":1581 */
          __pyx_f_5_soya_terrain_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/terrain.pyx":1582 */
          __pyx_v_norm = ((((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_normals + (6 * (__pyx_v_ix + (__pyx_v_iz * (((struct __pyx_obj_5_soya__Terrain *)__pyx_v_self)->_nb_vertex_width - 1))))) + 3);

          /* "/home/jiba/src/soya/model/terrain.pyx":1583 */
          __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 = 1583; goto __pyx_L1;}
          __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_Vector); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1583; goto __pyx_L1;}
          __pyx_8 = PyFloat_FromDouble((__pyx_v_norm[0])); if (!__pyx_8) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1583; goto __pyx_L1;}
          __pyx_9 = PyFloat_FromDouble((__pyx_v_norm[1])); if (!__pyx_9) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1583; goto __pyx_L1;}
          __pyx_4 = PyFloat_FromDouble((__pyx_v_norm[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1583; goto __pyx_L1;}
          __pyx_6 = PyTuple_New(4); if (!__pyx_6) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1583; 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 = 1583; 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 = 1583; 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/terrain.pyx":1585 */
  __pyx_4 = PyFloat_FromDouble((-1.0)); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1585; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1585; 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._Terrain.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_8_Terrain___getcstate__(struct __pyx_obj_5_soya__Terrain *__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_TerrainVertex (*__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/terrain.pyx":1593 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1593; goto __pyx_L1;}
  Py_DECREF(__pyx_v_material_id2index);
  __pyx_v_material_id2index = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/terrain.pyx":1594 */
  __pyx_2 = PyObject_Length(__pyx_v_self->_materials); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1594; 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 = 1594; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1594; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1594; 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 = 1594; 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/terrain.pyx":1595 */
  __pyx_v_nb = (__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/terrain.pyx":1597 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/terrain.pyx":1598 */
  chunk_add_int_endian_safe(__pyx_v_chunk,(__pyx_v_self->__pyx_base._option & (~__pyx_e_5_soya_TERRAIN_INITED)));

  /* "/home/jiba/src/soya/model/terrain.pyx":1599 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/terrain.pyx":1600 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vertex_width);

  /* "/home/jiba/src/soya/model/terrain.pyx":1601 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/terrain.pyx":1602 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_patch_size);

  /* "/home/jiba/src/soya/model/terrain.pyx":1603 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_texture_factor);

  /* "/home/jiba/src/soya/model/terrain.pyx":1604 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_scale_factor);

  /* "/home/jiba/src/soya/model/terrain.pyx":1605 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_split_factor);

  /* "/home/jiba/src/soya/model/terrain.pyx":1606 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_nb_colors);

  /* "/home/jiba/src/soya/model/terrain.pyx":1608 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_COLORED);
  if (__pyx_2) {
    __pyx_2 = (__pyx_v_self->_nb_colors > 0);
  }
  if (__pyx_2) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1609 */
    chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

    /* "/home/jiba/src/soya/model/terrain.pyx":1610 */
    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/terrain.pyx":1612 */
  __pyx_2 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_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/terrain.pyx":1614 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1615 */
    __pyx_v_v = (__pyx_v_self->_vertices + __pyx_v_i);

    /* "/home/jiba/src/soya/model/terrain.pyx":1616 */
    chunk_add_float_endian_safe(__pyx_v_chunk,(__pyx_v_v->coord[1]));

    /* "/home/jiba/src/soya/model/terrain.pyx":1617 */
    __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 = 1617; 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 = 1617; 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/terrain.pyx":1619 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1619; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1619; 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._Terrain.__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_8_Terrain___setcstate__(struct __pyx_obj_5_soya__Terrain *__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_TerrainVertex (*__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/terrain.pyx":1626 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1626; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1626; 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/terrain.pyx":1627 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1627; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1627; 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/terrain.pyx":1629 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/model/terrain.pyx":1630 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/model/terrain.pyx":1631 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vertex_width));

  /* "/home/jiba/src/soya/model/terrain.pyx":1632 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_vertex_depth));

  /* "/home/jiba/src/soya/model/terrain.pyx":1633 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_patch_size));

  /* "/home/jiba/src/soya/model/terrain.pyx":1634 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_texture_factor));

  /* "/home/jiba/src/soya/model/terrain.pyx":1635 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_scale_factor));

  /* "/home/jiba/src/soya/model/terrain.pyx":1636 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_split_factor));

  /* "/home/jiba/src/soya/model/terrain.pyx":1637 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_nb_colors));

  /* "/home/jiba/src/soya/model/terrain.pyx":1638 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/model/terrain.pyx":1640 */
  __pyx_v_nb = (__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth);

  /* "/home/jiba/src/soya/model/terrain.pyx":1641 */
  __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_COLORED);
  if (__pyx_3) {
    __pyx_3 = (__pyx_v_self->_nb_colors > 0);
  }
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1642 */
    __pyx_v_self->_colors = ((float (*))malloc(((4 * __pyx_v_self->_nb_colors) * (sizeof(float )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":1643 */
    __pyx_v_self->_vertex_colors = ((int (*))malloc((__pyx_v_nb * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":1644 */
    chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_colors,(4 * __pyx_v_self->_nb_colors));

    /* "/home/jiba/src/soya/model/terrain.pyx":1645 */
    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/terrain.pyx":1648 */
  __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1649 */
    __pyx_v_self->_vertex_options = ((char (*))malloc((__pyx_v_nb * (sizeof(char )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":1650 */
    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/terrain.pyx":1653 */
  __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/terrain.pyx":1654 */
    __pyx_v_self->_vertices = ((__pyx_t_5_soya_TerrainVertex (*))malloc((__pyx_v_nb * (sizeof(__pyx_t_5_soya_TerrainVertex )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":1655 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/model/terrain.pyx":1656 */
      __pyx_v_v = (__pyx_v_self->_vertices + __pyx_v_i);

      /* "/home/jiba/src/soya/model/terrain.pyx":1657 */
      chunk_get_float_endian_safe(__pyx_v_chunk,(__pyx_v_v->coord + 1));

      /* "/home/jiba/src/soya/model/terrain.pyx":1658 */
      chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_temp));

      /* "/home/jiba/src/soya/model/terrain.pyx":1659 */
      __pyx_1 = PyInt_FromLong(__pyx_v_temp); if (!__pyx_1) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1659; goto __pyx_L1;}
      __pyx_2 = PyObject_GetItem(__pyx_v_self->_materials, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 1659; 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/terrain.pyx":1660 */
    __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/terrain.pyx":1663 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/model/terrain.pyx":1664 */
  ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_8_Terrain__check_vertex_options(struct __pyx_obj_5_soya__Terrain *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/terrain.pyx":1668 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1669 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_TERRAIN_VERTEX_OPTIONS);

    /* "/home/jiba/src/soya/model/terrain.pyx":1671 */
    __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._Terrain._check_vertex_options");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_8_Terrain__check_color(struct __pyx_obj_5_soya__Terrain *__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/terrain.pyx":1675 */
  __pyx_1 = (!(__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_TERRAIN_COLORED));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/terrain.pyx":1676 */
    __pyx_v_nb = (__pyx_v_self->_nb_vertex_width * __pyx_v_self->_nb_vertex_depth);

    /* "/home/jiba/src/soya/model/terrain.pyx":1677 */
    __pyx_v_self->__pyx_base._option = (__pyx_v_self->__pyx_base._option | __pyx_e_5_soya_TERRAIN_COLORED);

    /* "/home/jiba/src/soya/model/terrain.pyx":1678 */
    __pyx_v_self->_vertex_colors = ((int (*))malloc((__pyx_v_nb * (sizeof(int )))));

    /* "/home/jiba/src/soya/model/terrain.pyx":1679 */
    __pyx_v_my_white = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1680 */
    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/terrain.pyx":1681 */
  __pyx_1 = ((1.0 - (__pyx_v_color[3])) > EPSILON);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__Terrain *)__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/terrain.pyx":1682 */
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__Terrain *)__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._Terrain._check_color");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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/model_builder.pyx":21 */
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 21; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 21; 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 = 21; 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 = 21; 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 = 21; 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__Model *__pyx_f_5_soya_12ModelBuilder__to_model(struct __pyx_obj_5_soya_ModelBuilder *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__Model *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_world);

  /* "/home/jiba/src/soya/model/model_builder.pyx":26 */

  __pyx_r = Py_None; Py_INCREF((PyObject *) __pyx_r);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.ModelBuilder._to_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

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

  /* "/home/jiba/src/soya/model/model_builder.pyx":47 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_SimpleModelBuilder *)__pyx_v_self)->_shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 47; 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.SimpleModelBuilder.shadow.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_18SimpleModelBuilder_6shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_18SimpleModelBuilder_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 = 48; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":49 */
  ((struct __pyx_obj_5_soya_SimpleModelBuilder *)__pyx_v_self)->_shadow = __pyx_v_x;

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

static PyObject *__pyx_f_5_soya_18SimpleModelBuilder_14max_face_angle___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_18SimpleModelBuilder_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/model_builder.pyx":53 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_SimpleModelBuilder *)__pyx_v_self)->_max_face_angle); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 53; 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.SimpleModelBuilder.max_face_angle.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_18SimpleModelBuilder_14max_face_angle___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_18SimpleModelBuilder_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 = 54; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":55 */
  ((struct __pyx_obj_5_soya_SimpleModelBuilder *)__pyx_v_self)->_max_face_angle = __pyx_v_x;

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

static int __pyx_f_5_soya_18SimpleModelBuilder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_18SimpleModelBuilder___init__[] = "SimpleModelBuilder(**attributes) -> SimpleModelBuilder\n\nSee SimpleModelBuilder.__doc__ for more info.";
static int __pyx_f_5_soya_18SimpleModelBuilder___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_k142;
  __pyx_v_max_face_angle = __pyx_k143;
  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/model_builder.pyx":61 */
  ((struct __pyx_obj_5_soya_SimpleModelBuilder *)__pyx_v_self)->_shadow = __pyx_v_shadow;

  /* "/home/jiba/src/soya/model/model_builder.pyx":62 */
  ((struct __pyx_obj_5_soya_SimpleModelBuilder *)__pyx_v_self)->_max_face_angle = __pyx_v_max_face_angle;

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

static PyObject *__pyx_f_5_soya_18SimpleModelBuilder___getcstate__(struct __pyx_obj_5_soya_SimpleModelBuilder *__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/model_builder.pyx":65 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->_shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 65; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->_max_face_angle); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 65; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 65; 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.SimpleModelBuilder.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_18SimpleModelBuilder___setcstate__(struct __pyx_obj_5_soya_SimpleModelBuilder *__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/model_builder.pyx":68 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 68; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 68; 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 = 68; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 68; 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 = 68; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya.SimpleModelBuilder.__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__Model *__pyx_f_5_soya_18SimpleModelBuilder__to_model(struct __pyx_obj_5_soya_SimpleModelBuilder *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__SimpleModel *__pyx_v_model;
  int __pyx_v_option;
  PyObject *__pyx_v_ligths;
  struct __pyx_obj_5_soya__Model *__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_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);
  __pyx_v_ligths = Py_None; Py_INCREF(__pyx_v_ligths);

  /* "/home/jiba/src/soya/model/model_builder.pyx":74 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":75 */
  __pyx_1 = __pyx_v_self->_shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_MODEL_PLANE_EQUATION) | __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_MODEL_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model_builder.pyx":76 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_SimpleModel); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->_max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_option); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; 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 = 76; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; 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 = 76; 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 = 76; 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 = 76; 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__SimpleModel)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 76; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_v_model = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":77 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_vtab)->_build_sphere(__pyx_v_model);

  /* "/home/jiba/src/soya/model/model_builder.pyx":78 */
  ((struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_vtab)->_build_display_list(__pyx_v_model);

  /* "/home/jiba/src/soya/model/model_builder.pyx":79 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_r = (struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_model);
  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.SimpleModelBuilder._to_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF(__pyx_v_ligths);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

static struct __pyx_obj_5_soya__Model *__pyx_f_5_soya_17SolidModelBuilder__to_model(struct __pyx_obj_5_soya_SolidModelBuilder *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__SolidModel *__pyx_v_model;
  int __pyx_v_option;
  PyObject *__pyx_v_ligths;
  struct __pyx_obj_5_soya__Model *__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_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);
  __pyx_v_ligths = Py_None; Py_INCREF(__pyx_v_ligths);

  /* "/home/jiba/src/soya/model/model_builder.pyx":89 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":90 */
  __pyx_1 = __pyx_v_self->__pyx_base._shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_MODEL_PLANE_EQUATION) | __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_MODEL_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model_builder.pyx":91 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_SolidModel); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 91; 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 = 91; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_option); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 91; 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 = 91; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 91; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 91; 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 = 91; 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 = 91; 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 = 91; 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__SolidModel)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 91; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_v_model = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":92 */
  ((struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_sphere(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_model));

  /* "/home/jiba/src/soya/model/model_builder.pyx":93 */
  ((struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_display_list(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_model));

  /* "/home/jiba/src/soya/model/model_builder.pyx":94 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_r = (struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_model);
  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.SolidModelBuilder._to_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF(__pyx_v_ligths);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya_16TreeModelBuilder_19collapsing_distance___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_16TreeModelBuilder_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/model_builder.pyx":125 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_collapsing_distance); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 125; 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.TreeModelBuilder.collapsing_distance.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_16TreeModelBuilder_19collapsing_distance___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_16TreeModelBuilder_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 = 126; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":127 */
  ((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_collapsing_distance = __pyx_v_x;

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

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

  /* "/home/jiba/src/soya/model/model_builder.pyx":131 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_quality); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __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.TreeModelBuilder.quality.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_16TreeModelBuilder_7quality___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_16TreeModelBuilder_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 = 132; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":133 */
  ((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_quality = __pyx_v_x;

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

static PyObject *__pyx_f_5_soya_16TreeModelBuilder_16max_child_radius___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_16TreeModelBuilder_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/model_builder.pyx":137 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_max_child_radius); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 137; 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.TreeModelBuilder.max_child_radius.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_16TreeModelBuilder_16max_child_radius___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_16TreeModelBuilder_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 = 138; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":139 */
  ((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_max_child_radius = __pyx_v_x;

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

static int __pyx_f_5_soya_16TreeModelBuilder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_16TreeModelBuilder___init__[] = "TreeModelBuilder(**attributes) -> TreeModelBuilder\n\nSee TreeModelBuilder.__doc__ for more info.";
static int __pyx_f_5_soya_16TreeModelBuilder___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_k144;
  __pyx_v_max_face_angle = __pyx_k145;
  __pyx_v_collapsing_distance = __pyx_k146;
  __pyx_v_quality = __pyx_k147;
  __pyx_v_max_child_radius = __pyx_k148;
  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/model_builder.pyx":145 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_SimpleModelBuilder), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_shadow); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 145; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 145; 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 = 145; 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/model_builder.pyx":146 */
  ((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_collapsing_distance = __pyx_v_collapsing_distance;

  /* "/home/jiba/src/soya/model/model_builder.pyx":147 */
  ((struct __pyx_obj_5_soya_TreeModelBuilder *)__pyx_v_self)->_quality = __pyx_v_quality;

  /* "/home/jiba/src/soya/model/model_builder.pyx":148 */
  ((struct __pyx_obj_5_soya_TreeModelBuilder *)__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.TreeModelBuilder.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_16TreeModelBuilder___getcstate__(struct __pyx_obj_5_soya_TreeModelBuilder *__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/model_builder.pyx":151 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->__pyx_base._shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 151; 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 = 151; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->_collapsing_distance); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_self->_quality); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(__pyx_v_self->_max_child_radius); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(5); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 151; 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.TreeModelBuilder.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_16TreeModelBuilder___setcstate__(struct __pyx_obj_5_soya_TreeModelBuilder *__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/model_builder.pyx":154 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 154; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 154; 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 = 154; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 154; 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 = 154; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 154; 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 = 154; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 154; 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 = 154; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 154; 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 = 154; goto __pyx_L1;}

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

static struct __pyx_obj_5_soya__Model *__pyx_f_5_soya_16TreeModelBuilder__to_model(struct __pyx_obj_5_soya_TreeModelBuilder *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__TreeModel *__pyx_v_model;
  int __pyx_v_option;
  struct __pyx_obj_5_soya__Model *__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_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);

  /* "/home/jiba/src/soya/model/model_builder.pyx":159 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":160 */
  __pyx_1 = __pyx_v_self->__pyx_base._shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_MODEL_PLANE_EQUATION) | __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_MODEL_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model_builder.pyx":161 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_TreeModel); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 161; 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 = 161; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_v_option); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 161; 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 = 161; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 161; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 161; 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 = 161; 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 = 161; 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 = 161; 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__TreeModel)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 161; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_v_model = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":162 */
  ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_tree(__pyx_v_model);

  /* "/home/jiba/src/soya/model/model_builder.pyx":163 */
  ((struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_optimize_tree(__pyx_v_model,__pyx_v_self->_collapsing_distance,__pyx_v_self->_quality,__pyx_v_self->_max_child_radius);

  /* "/home/jiba/src/soya/model/model_builder.pyx":164 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_r = (struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_model);
  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.TreeModelBuilder._to_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

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

  /* "/home/jiba/src/soya/model/model_builder.pyx":193 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_shader));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_shader);
  goto __pyx_L0;

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

static int __pyx_f_5_soya_23CellShadingModelBuilder_6shader___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_23CellShadingModelBuilder_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 = 194; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":195 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_shader));
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_shader = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingModelBuilder.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_23CellShadingModelBuilder_13outline_color___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_23CellShadingModelBuilder_13outline_color___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/model_builder.pyx":199 */
  Py_INCREF(((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_color);
  __pyx_r = ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_color;
  goto __pyx_L0;

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

static int __pyx_f_5_soya_23CellShadingModelBuilder_13outline_color___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_5_soya_23CellShadingModelBuilder_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/model_builder.pyx":201 */
  Py_INCREF(__pyx_v_x);
  Py_DECREF(((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_color);
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_color = __pyx_v_x;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya.CellShadingModelBuilder.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_23CellShadingModelBuilder_13outline_width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_23CellShadingModelBuilder_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/model_builder.pyx":205 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_width); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 205; 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.CellShadingModelBuilder.outline_width.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_23CellShadingModelBuilder_13outline_width___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_23CellShadingModelBuilder_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 = 206; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":207 */
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_width = __pyx_v_x;

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

static PyObject *__pyx_f_5_soya_23CellShadingModelBuilder_19outline_attenuation___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_23CellShadingModelBuilder_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/model_builder.pyx":211 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_attenuation); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 211; 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.CellShadingModelBuilder.outline_attenuation.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_23CellShadingModelBuilder_19outline_attenuation___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_23CellShadingModelBuilder_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 = 212; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":213 */
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_attenuation = __pyx_v_x;

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

static int __pyx_f_5_soya_23CellShadingModelBuilder___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_23CellShadingModelBuilder___init__[] = "CellShadingModelBuilder(**attributes) -> CellShadingModelBuilder\n\nSee CellShadingModelBuilder.__doc__ for more info.";
static int __pyx_f_5_soya_23CellShadingModelBuilder___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_k149;
  __pyx_v_max_face_angle = __pyx_k150;
  __pyx_v_shader = __pyx_k151;
  __pyx_v_outline_color = __pyx_k152;
  __pyx_v_outline_width = __pyx_k153;
  __pyx_v_outline_attenuation = __pyx_k154;
  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 = 215; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":219 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_SimpleModelBuilder), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 219; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_shadow); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 219; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_max_face_angle); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 219; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 219; 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 = 219; 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/model_builder.pyx":220 */
  __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 = 220; 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 = 220; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_shader));
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_shader = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":221 */
  Py_INCREF(__pyx_v_outline_color);
  Py_DECREF(((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_color);
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_color = __pyx_v_outline_color;

  /* "/home/jiba/src/soya/model/model_builder.pyx":222 */
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__pyx_v_self)->_outline_width = __pyx_v_outline_width;

  /* "/home/jiba/src/soya/model/model_builder.pyx":223 */
  ((struct __pyx_obj_5_soya_CellShadingModelBuilder *)__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.CellShadingModelBuilder.__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_23CellShadingModelBuilder___getcstate__(struct __pyx_obj_5_soya_CellShadingModelBuilder *__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/model_builder.pyx":226 */
  __pyx_1 = PyInt_FromLong(__pyx_v_self->__pyx_base._shadow); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 226; 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 = 226; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->_outline_width); if (!__pyx_3) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_self->_outline_attenuation); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 226; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(6); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 226; 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.CellShadingModelBuilder.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_23CellShadingModelBuilder___setcstate__(struct __pyx_obj_5_soya_CellShadingModelBuilder *__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/model_builder.pyx":229 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 229; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 229; 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 = 229; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 229; 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 = 229; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 229; 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 = 229; 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 = 229; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 229; 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 = 229; goto __pyx_L1;}
  __pyx_7 = PyFloat_AsDouble(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 229; 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 = 229; goto __pyx_L1;}

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya.CellShadingModelBuilder.__setcstate__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static struct __pyx_obj_5_soya__Model *__pyx_f_5_soya_23CellShadingModelBuilder__to_model(struct __pyx_obj_5_soya_CellShadingModelBuilder *__pyx_v_self,struct __pyx_obj_5_soya__World *__pyx_v_world) {
  struct __pyx_obj_5_soya__CellShadingModel *__pyx_v_model;
  int __pyx_v_option;
  struct __pyx_obj_5_soya__Model *__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_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);

  /* "/home/jiba/src/soya/model/model_builder.pyx":234 */
  __pyx_v_option = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":235 */
  __pyx_1 = __pyx_v_self->__pyx_base._shadow;
  if (__pyx_1) {
    __pyx_v_option = (((__pyx_v_option | __pyx_e_5_soya_MODEL_PLANE_EQUATION) | __pyx_e_5_soya_MODEL_SIMPLE_NEIGHBORS) | __pyx_e_5_soya_MODEL_SHADOW);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/model_builder.pyx":236 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_CellShadingModel); if (!__pyx_2) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 236; 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 = 236; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong((((__pyx_v_option | __pyx_e_5_soya_MODEL_PLANE_EQUATION) | __pyx_e_5_soya_MODEL_NEIGHBORS) | __pyx_e_5_soya_MODEL_CELLSHADING)); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 236; 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 = 236; goto __pyx_L1;}
  __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n__is_static_light); if (!__pyx_6) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 236; goto __pyx_L1;}
  __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 236; 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 = 236; 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 = 236; 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 = 236; 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__CellShadingModel)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 236; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_v_model = __pyx_7;
  __pyx_7 = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":237 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_sphere(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_model));

  /* "/home/jiba/src/soya/model/model_builder.pyx":238 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_cellshading(__pyx_v_model,__pyx_v_self->_shader,__pyx_v_self->_outline_color,__pyx_v_self->_outline_width,__pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/model/model_builder.pyx":239 */
  ((struct __pyx_vtabstruct_5_soya__CellShadingModel *)__pyx_v_model->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._build_display_list(((struct __pyx_obj_5_soya__SimpleModel *)__pyx_v_model));

  /* "/home/jiba/src/soya/model/model_builder.pyx":240 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_r = (struct __pyx_obj_5_soya__Model *)((PyObject *)__pyx_v_model);
  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.CellShadingModelBuilder._to_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_world);
  return ((struct __pyx_obj_5_soya__Model *)__pyx_r) ;
}

static PyObject *__pyx_f_5_soya__set_default_model_builder(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya__set_default_model_builder(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya_ModelBuilder *__pyx_v_model_builder = 0;
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {"model_builder",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_model_builder)) return 0;
  Py_INCREF((PyObject *)__pyx_v_model_builder);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model_builder), __pyx_ptype_5_soya_ModelBuilder, 1, "model_builder")) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 245; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/model_builder.pyx":247 */
  Py_INCREF(((PyObject *)__pyx_v_model_builder));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__DEFAULT_MODEL_BUILDER));
  __pyx_v_5_soya__DEFAULT_MODEL_BUILDER = ((PyObject *)__pyx_v_model_builder);

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

static void __pyx_f_5_soya_quit_cal3d(void) {

  /* "/home/jiba/src/soya/cal3d/model.pyx":30 */
  free(__pyx_v_5_soya_cal3d_texcoords_array);

  /* "/home/jiba/src/soya/cal3d/model.pyx":31 */
  free(__pyx_v_5_soya_cal3d_shades_array);

  /* "/home/jiba/src/soya/cal3d/model.pyx":32 */
  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_k314p;

static char (__pyx_k314[]) = " ";

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/model.pyx":38 */
  __pyx_1 = __Pyx_Import(__pyx_n_struct, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_DECREF(__pyx_v_struct);
  __pyx_v_struct = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":38 */
  __pyx_1 = __Pyx_Import(__pyx_n_array, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_DECREF(__pyx_v_array);
  __pyx_v_array = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":40 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 40; 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 = 40; 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/model.pyx":41 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_struct, __pyx_n_unpack); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_read); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(12); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; 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 = 41; 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 = 41; 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 = 41; 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 = 41; goto __pyx_L1;}
  __pyx_5 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; 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 = 41; goto __pyx_L1;}
  __pyx_6 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; 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 = 41; goto __pyx_L1;}
  __pyx_7 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 41; 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 = 41; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":42 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_array, __pyx_n_array); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_read); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 42; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 42; 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 = 42; 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 = 42; 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/model.pyx":45 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_array, __pyx_n_array); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 45; goto __pyx_L1;}
  __pyx_5 = PyObject_Length(__pyx_v_data); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 45; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 45; goto __pyx_L1;}
  __pyx_1 = PyNumber_Multiply(__pyx_k314p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 45; 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 = 45; 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 = 45; 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/model.pyx":46 */
  __pyx_v_line_length = (__pyx_v_width * __pyx_v_nb_colors);

  /* "/home/jiba/src/soya/cal3d/model.pyx":47 */
  for (__pyx_v_y = 0; __pyx_v_y < __pyx_v_height; ++__pyx_v_y) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":48 */
    __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 = 48; 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 = 48; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":50 */
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_Image); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_v_data2, __pyx_n_tostring); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; 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 = 50; goto __pyx_L1;}
  __pyx_3 = PyInt_FromLong(__pyx_v_height); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_8 = PyInt_FromLong(__pyx_v_nb_colors); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(4); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 50; 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 = 50; 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_k316p;
static PyObject *__pyx_k317p;
static PyObject *__pyx_k330p;
static PyObject *__pyx_k331p;

static char (__pyx_k316[]) = "#";
static char (__pyx_k317[]) = "=";
static char (__pyx_k330[]) = ",";
static char (__pyx_k331[]) = "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 model 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__AnimatedModel *__pyx_v_model;
  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_model = Py_None; Py_INCREF((PyObject *) __pyx_v_model);
  __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/model.pyx":54 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 54; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":57 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_AnimatedModel); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; 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__AnimatedModel)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_v_model = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":58 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 58; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 58; 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 = 58; 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 = 58; 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 = 58; 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/model.pyx":59 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 59; goto __pyx_L1;}
  __pyx_1 = PyObject_GetAttr(__pyx_3, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 59; 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 = 59; 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 = 59; 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 = 59; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_model->__pyx_base._filename);
  __pyx_v_model->__pyx_base._filename = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":60 */
  Py_INCREF(__pyx_v_filename);
  Py_DECREF(__pyx_v_model->_full_filename);
  __pyx_v_model->_full_filename = __pyx_v_filename;

  /* "/home/jiba/src/soya/cal3d/model.pyx":64 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 64; goto __pyx_L1;}
  Py_DECREF(__pyx_v_already_done);
  __pyx_v_already_done = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":66 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 66; 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 = 66; 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 = 66; 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 = 66; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 66; 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 = 66; 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 = 66; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_line);
    __pyx_v_line = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":67 */
    __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 = 67; 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 = 67; goto __pyx_L1;}
      __pyx_5 = PyObject_GetItem(__pyx_v_line, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 67; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      if (PyObject_Cmp(__pyx_5, __pyx_k316p, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 67; 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 = 67; goto __pyx_L1;}
    }
    __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 67; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":68 */
      __pyx_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_split); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 68; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 68; goto __pyx_L1;}
      Py_INCREF(__pyx_k317p);
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k317p);
      __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 68; 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/model.pyx":69 */
      __pyx_4 = PyObject_Length(__pyx_v_parts); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 69; goto __pyx_L1;}
      __pyx_6 = (__pyx_4 == 2);
      if (__pyx_6) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":70 */
        __pyx_1 = __Pyx_UnpackItem(__pyx_v_parts, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 70; 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 = 70; 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 = 70; goto __pyx_L1;}

        /* "/home/jiba/src/soya/cal3d/model.pyx":71 */
        __pyx_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_rstrip); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 71; goto __pyx_L1;}
        __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 71; goto __pyx_L1;}
        __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 71; 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/model.pyx":72 */
        /*try:*/ {
          __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_int); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 72; goto __pyx_L6;}
          __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 72; 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 = 72; 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/model.pyx":73 */
        /*except:*/ {
          __Pyx_AddTraceback("_soya.parse_cal3d_cfg_file");
          __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 73; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;

          /* "/home/jiba/src/soya/cal3d/model.pyx":74 */
          /*try:*/ {
            __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 74; goto __pyx_L8;}
            __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 74; 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 = 74; 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/model.pyx":75 */
          /*except:*/ {
            __Pyx_AddTraceback("_soya.parse_cal3d_cfg_file");
            __pyx_1 = __Pyx_GetExcValue(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 75; 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/model.pyx":77 */
        __pyx_5 = PyObject_GetAttr(__pyx_v_already_done, __pyx_n_get); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 77; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 77; 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 = 77; 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 = 77; 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 = 77; 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/model.pyx":78 */
        __pyx_5 = PyInt_FromLong(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; goto __pyx_L1;}
        __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 78; 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 = 78; goto __pyx_L1;}
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        Py_DECREF(__pyx_5); __pyx_5 = 0;

        /* "/home/jiba/src/soya/cal3d/model.pyx":80 */
        if (PyObject_Cmp(__pyx_v_key, __pyx_n_skeleton, &__pyx_6) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_model), __pyx_n_load_skeleton); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 80; 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 = 80; 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 = 80; 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 = 80; 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 = 80; 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 = 80; 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 = 81; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_7 = PyObject_GetAttr(((PyObject *)__pyx_v_model), __pyx_n_load_mesh); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; goto __pyx_L1;}
          __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 81; 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 = 81; 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 = 81; 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 = 81; 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 = 81; 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 = 81; 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 = 82; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {
          __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_model), __pyx_n_load_material); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
          __pyx_7 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(__pyx_7, __pyx_n_path); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 82; 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 = 82; 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 = 82; 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 = 82; 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 = 82; 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 = 82; 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 = 83; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {
          __pyx_5 = PyObject_GetAttr(((PyObject *)__pyx_v_model), __pyx_n_load_animation); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
          __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 83; 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 = 83; 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 = 83; 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 = 83; 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 = 83; 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 = 83; 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 = 84; 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 = 84; goto __pyx_L1;}
          __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; 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 = 84; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_model), __pyx_n_shadow, __pyx_7) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 84; 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 = 85; 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 = 85; goto __pyx_L1;}
          __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 85; 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 = 85; goto __pyx_L1;}
          Py_DECREF(__pyx_1); __pyx_1 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_model), __pyx_n_double_sided, __pyx_5) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 85; 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 = 86; 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 = 86; goto __pyx_L1;}
          __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_float); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_split); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
          __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; goto __pyx_L1;}
          __pyx_8 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; 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 = 86; 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 = 86; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (PyObject_SetAttr(((PyObject *)__pyx_v_model), __pyx_n_sphere, __pyx_5) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 86; 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 = 87; goto __pyx_L1;}
        __pyx_4 = __pyx_4 == 0;
        if (__pyx_4) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":88 */
          __pyx_6 = PyObject_IsTrue(__pyx_v_value); if (__pyx_6 < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
          if (__pyx_6) {
            __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_model), __pyx_n_set_cellshading); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
            __pyx_8 = PyTuple_New(0); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; goto __pyx_L1;}
            __pyx_7 = PyObject_CallObject(__pyx_1, __pyx_8); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 88; 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 = 89; 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 = 89; goto __pyx_L1;}
          __pyx_5 = PyObject_GetAttr(__pyx_2, __pyx_n_get); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 89; 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 = 89; 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 = 89; 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 = 89; goto __pyx_L1;}
          Py_DECREF((PyObject *)((PyObject *)__pyx_v_model->_shader));
          __pyx_v_model->_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 = 90; 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 = 90; goto __pyx_L1;}
          __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 90; 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 = 90; 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 = 90; goto __pyx_L1;}
          Py_DECREF(__pyx_5); __pyx_5 = 0;
          __pyx_v_model->_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 = 91; 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 = 91; goto __pyx_L1;}
          __pyx_8 = PyTuple_New(1); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 91; 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 = 91; 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 = 91; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          __pyx_v_model->_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 = 92; goto __pyx_L1;}
        __pyx_6 = __pyx_6 == 0;
        if (__pyx_6) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":93 */
          __pyx_2 = PyObject_GetAttr(__pyx_v_value, __pyx_n_split); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; goto __pyx_L1;}
          __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; goto __pyx_L1;}
          Py_INCREF(__pyx_k330p);
          PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k330p);
          __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 93; 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/model.pyx":94 */
          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 = 94; goto __pyx_L1;}
            __pyx_7 = PyInt_FromLong(__pyx_v_i); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 94; goto __pyx_L1;}
            __pyx_2 = PyObject_GetItem(__pyx_v_value, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 94; 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 = 94; 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 = 94; 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 = 94; goto __pyx_L1;}
            Py_DECREF(__pyx_1); __pyx_1 = 0;
            (__pyx_v_model->_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 = 95; 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_k331p, __pyx_7); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 95; goto __pyx_L1;}
          Py_DECREF(__pyx_7); __pyx_7 = 0;
          if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 95; goto __pyx_L1;}
          Py_DECREF(__pyx_2); __pyx_2 = 0;
          if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 95; 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/model.pyx":96 */
  __pyx_8 = PyObject_GetAttr(((PyObject *)__pyx_v_model), __pyx_n_build_materials); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 96; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_8, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 96; 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/model.pyx":97 */
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_model));
  __pyx_r = ((PyObject *)__pyx_v_model);
  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_model);
  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/model.pyx":109 */
  __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/model.pyx":110 */
  __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__AnimatedModel *__pyx_v_model,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_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":119 */
  __pyx_v_self->_mesh = __pyx_v_mesh;

  /* "/home/jiba/src/soya/cal3d/model.pyx":120 */
  __pyx_v_self->_submesh = __pyx_v_submesh;

  /* "/home/jiba/src/soya/cal3d/model.pyx":121 */
  __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 = 121; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_model->_materials, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 121; 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 = 121; 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/model.pyx":123 */
  __pyx_v_cal_core_submesh = CalCoreMesh_GetCoreSubmesh(__pyx_v_cal_core_mesh,__pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/model.pyx":126 */
  __pyx_v_self->_nb_faces = CalCoreSubmesh_GetFaceCount(__pyx_v_cal_core_submesh);

  /* "/home/jiba/src/soya/cal3d/model.pyx":127 */
  __pyx_v_self->_faces = ((int (*))malloc(((__pyx_v_self->_nb_faces * 3) * (sizeof(int )))));

  /* "/home/jiba/src/soya/cal3d/model.pyx":128 */
  CalRenderer_GetFaces(__pyx_v_cal_renderer,__pyx_v_self->_faces);

  /* "/home/jiba/src/soya/cal3d/model.pyx":130 */
  __pyx_3 = (__pyx_v_5_soya_cal3d_nb_faces < __pyx_v_self->_nb_faces);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":131 */
    __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/model.pyx":132 */
    __pyx_v_5_soya_cal3d_nb_faces = __pyx_v_self->_nb_faces;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":136 */
  __pyx_v_self->_nb_vertices = CalCoreSubmesh_GetVertexCount(__pyx_v_cal_core_submesh);

  /* "/home/jiba/src/soya/cal3d/model.pyx":138 */
  __pyx_3 = (__pyx_v_5_soya_cal3d_nb_vertices < __pyx_v_self->_nb_vertices);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":139 */
    __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/model.pyx":140 */
    __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/model.pyx":141 */
    __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_model);
  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_k333p;
static PyObject *__pyx_k335p;

static char (__pyx_k333[]) = "* Soya * Computing neighbor for Cal3D model, and caching the result in file %s...";
static char (__pyx_k335[]) = "* 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/model.pyx":152 */
  __pyx_v_self->_option = (__pyx_v_self->_option | __pyx_e_5_soya_CAL3D_NEIGHBORS);

  /* "/home/jiba/src/soya/cal3d/model.pyx":154 */
  __pyx_v_self->_face_neighbors = ((int (*))malloc(((__pyx_v_self->_nb_faces * 3) * (sizeof(int )))));

  /* "/home/jiba/src/soya/cal3d/model.pyx":157 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 157; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 157; 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 = 157; 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 = 157; 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 = 157; 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 = 157; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":158 */
    __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 158; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 158; 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 = 158; 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/model.pyx":159 */
    __pyx_1 = PyObject_GetAttr(__pyx_v_file, __pyx_n_read); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 159; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 159; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 159; 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/model.pyx":160 */
    chunk_get_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_face_neighbors,(3 * __pyx_v_self->_nb_faces));

    /* "/home/jiba/src/soya/cal3d/model.pyx":161 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/cal3d/model.pyx":163 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":165 */
  __pyx_1 = PyNumber_Remainder(__pyx_k333p, __pyx_v_cache_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 165; goto __pyx_L1;}
  if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 165; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 165; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":167 */
  __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/model.pyx":168 */
    for (__pyx_v_k = 0; __pyx_v_k < 3; ++__pyx_v_k) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":169 */
      __pyx_v_p1 = (__pyx_v_self->_faces[((3 * __pyx_v_i) + __pyx_v_k)]);

      /* "/home/jiba/src/soya/cal3d/model.pyx":170 */
      __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/model.pyx":173 */
      __pyx_v_coord1 = (__pyx_v_coords + (3 * __pyx_v_p1));

      /* "/home/jiba/src/soya/cal3d/model.pyx":174 */
      __pyx_v_coord2 = (__pyx_v_coords + (3 * __pyx_v_p2));

      /* "/home/jiba/src/soya/cal3d/model.pyx":176 */
      __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/model.pyx":177 */
        __pyx_6 = (__pyx_v_i == __pyx_v_j);
        if (__pyx_6) {
          goto __pyx_L8;
          goto __pyx_L10;
        }
        __pyx_L10:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":179 */
        __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/model.pyx":180 */
          (__pyx_v_self->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]) = __pyx_v_j;

          /* "/home/jiba/src/soya/cal3d/model.pyx":181 */
          goto __pyx_L9;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":183 */
        __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/model.pyx":184 */
          (__pyx_v_self->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]) = __pyx_v_j;

          /* "/home/jiba/src/soya/cal3d/model.pyx":185 */
          goto __pyx_L9;
          goto __pyx_L12;
        }
        __pyx_L12:;
        __pyx_L8:;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/model.pyx":187 */
        (__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/model.pyx":190 */
  /*try:*/ {

    /* "/home/jiba/src/soya/cal3d/model.pyx":191 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_open); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 191; goto __pyx_L13;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 191; 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 = 191; 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/model.pyx":192 */
  /*except:*/ {
    __Pyx_AddTraceback("_soya._build_neighbors");
    __pyx_2 = __Pyx_GetExcValue(); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 192; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":193 */
    __pyx_3 = PyNumber_Remainder(__pyx_k335p, __pyx_v_cache_filename); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 193; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 193; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 193; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/model.pyx":194 */
    goto __pyx_L0;
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":196 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/cal3d/model.pyx":197 */
  chunk_add_ints_endian_safe(__pyx_v_chunk,__pyx_v_self->_face_neighbors,(3 * __pyx_v_self->_nb_faces));

  /* "/home/jiba/src/soya/cal3d/model.pyx":198 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_file, __pyx_n_write); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 198; 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 = 198; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 198; 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 = 198; 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 void __pyx_f_5_soya_14_AnimatedModel__instanced(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body,PyObject *__pyx_v_opt) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  Py_INCREF(__pyx_v_opt);

  /* "/home/jiba/src/soya/cal3d/model.pyx":216 */
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 216; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_body));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_body));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_self));
  Py_INCREF(__pyx_v_opt);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_opt);
  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya__AnimatedModelData), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 216; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 216; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_body->_data));
  __pyx_v_body->_data = __pyx_2;
  __pyx_2 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._AnimatedModel._instanced");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF(__pyx_v_opt);
}

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":220 */
  Py_INCREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->__pyx_base._filename);
  __pyx_r = ((struct __pyx_obj_5_soya__AnimatedModel *)__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._AnimatedModel.filename.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":224 */
  Py_INCREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_full_filename);
  __pyx_r = ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_full_filename;
  goto __pyx_L0;

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

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":228 */
  Py_INCREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_materials);
  __pyx_r = ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_materials;
  goto __pyx_L0;

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

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":232 */
  Py_INCREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_meshes);
  __pyx_r = ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_meshes;
  goto __pyx_L0;

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

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":236 */
  Py_INCREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_animations);
  __pyx_r = ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_animations;
  goto __pyx_L0;

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

static PyObject *__pyx_f_5_soya_14_AnimatedModel_6sphere___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":240 */
  __pyx_1 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_sphere[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_sphere[1])); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_sphere[2])); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_sphere[3])); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 240; 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._AnimatedModel.sphere.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14_AnimatedModel_6sphere___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_sphere); /*proto*/
static int __pyx_f_5_soya_14_AnimatedModel_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/model.pyx":242 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_sphere, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 242; goto __pyx_L1;}
  __pyx_2 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 242; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__AnimatedModel *)__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 = 242; goto __pyx_L1;}
  __pyx_3 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 242; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__AnimatedModel *)__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 = 242; goto __pyx_L1;}
  __pyx_4 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 242; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__AnimatedModel *)__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 = 242; goto __pyx_L1;}
  __pyx_5 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 242; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_sphere[3]) = __pyx_5;
  if (__Pyx_EndUnpack(__pyx_v_sphere, 4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 242; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._AnimatedModel.sphere.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_sphere);
  return __pyx_r;
}

static PyObject *__pyx_k337p;

static char (__pyx_k336[]) = "";
static char (__pyx_k337[]) = "CalCoreModel_Create failed: %s";

static int __pyx_f_5_soya_14_AnimatedModel___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_14_AnimatedModel___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/model.pyx":246 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 246; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_meshes);
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_meshes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":247 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 247; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_animations);
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_animations = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":248 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 248; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_materials);
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_materials = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":249 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 249; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_submeshes);
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_submeshes = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":250 */
  (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_sphere[3]) = (-1.0);

  /* "/home/jiba/src/soya/cal3d/model.pyx":251 */
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model = CalCoreModel_New(__pyx_k336);

  /* "/home/jiba/src/soya/cal3d/model.pyx":252 */
  __pyx_2 = (((struct __pyx_obj_5_soya__AnimatedModel *)__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 = 252; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 252; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k337p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 252; 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 = 252; 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 = 252; 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 = 252; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":254 */
  ((struct __pyx_obj_5_soya__AnimatedModel *)__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._AnimatedModel.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_AnimatedModel_12double_sided___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":258 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 258; 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._AnimatedModel.double_sided.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14_AnimatedModel_12double_sided___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_14_AnimatedModel_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 = 259; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":260 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option | __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option & (~__pyx_e_5_soya_CAL3D_DOUBLE_SIDED));
  }
  __pyx_L2:;

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

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":265 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option & __pyx_e_5_soya_CAL3D_SHADOW)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __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._AnimatedModel.shadow.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_14_AnimatedModel_6shadow___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_14_AnimatedModel_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 = 266; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":267 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option | __pyx_e_5_soya_CAL3D_SHADOW);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option & (~__pyx_e_5_soya_CAL3D_SHADOW));
  }
  __pyx_L2:;

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

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":272 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option & __pyx_e_5_soya_CAL3D_CELL_SHADING)); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 272; 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._AnimatedModel.cellshading.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_14_AnimatedModel_set_cellshading(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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_k156;
  __pyx_v_outline_color = __pyx_k157;
  __pyx_v_outline_width = __pyx_k158;
  __pyx_v_outline_attenuation = __pyx_k159;
  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 = 274; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":276 */
  __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 = 276; 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 = 276; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_shader));
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_shader = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":277 */
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_outline_width = __pyx_v_outline_width;

  /* "/home/jiba/src/soya/cal3d/model.pyx":278 */
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_outline_attenuation = __pyx_v_outline_attenuation;

  /* "/home/jiba/src/soya/cal3d/model.pyx":279 */
  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 = 279; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_outline_color, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 279; 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 = 279; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    (((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_outline_color[__pyx_v_i]) = __pyx_4;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":281 */
  ((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_option = (((struct __pyx_obj_5_soya__AnimatedModel *)__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._AnimatedModel.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_k338p;

static char (__pyx_k338[]) = "CalRenderer_BeginRendering failed: %s";

static void __pyx_f_5_soya_14_AnimatedModel__build_submeshes(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":290 */
  __pyx_v_cal_model = CalModel_New(__pyx_v_self->_core_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":291 */
  __pyx_v_nb_mesh = CalCoreModel_GetCoreMeshCount(__pyx_v_self->_core_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":292 */
  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/model.pyx":293 */
  CalModel_SetMaterialSet(__pyx_v_cal_model,0);

  /* "/home/jiba/src/soya/cal3d/model.pyx":295 */
  __pyx_v_cal_renderer = CalModel_GetRenderer(__pyx_v_cal_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":296 */
  __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 = 296; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 296; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k338p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 296; 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 = 296; 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 = 296; 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 = 296; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":298 */
  __pyx_v_self->_nb_faces = 0;
  __pyx_v_self->_nb_vertices = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":300 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_mesh; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":301 */
    __pyx_v_cal_core_mesh = CalCoreModel_GetCoreMesh(__pyx_v_self->_core_model,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/model.pyx":302 */
    __pyx_v_nb_submesh = CalCoreMesh_GetCoreSubmeshCount(__pyx_v_cal_core_mesh);

    /* "/home/jiba/src/soya/cal3d/model.pyx":303 */
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_submesh; ++__pyx_v_j) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":304 */
      CalRenderer_SelectMeshSubmesh(__pyx_v_cal_renderer,__pyx_v_i,__pyx_v_j);

      /* "/home/jiba/src/soya/cal3d/model.pyx":306 */
      __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 306; 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 = 306; 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 = 306; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_my_submesh));
      __pyx_v_my_submesh = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/model.pyx":307 */
      __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 = 307; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;

      /* "/home/jiba/src/soya/cal3d/model.pyx":308 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_self->_submeshes, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 308; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 308; 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 = 308; 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/model.pyx":309 */
      __pyx_v_self->_nb_faces = (__pyx_v_self->_nb_faces + __pyx_v_my_submesh->_nb_faces);

      /* "/home/jiba/src/soya/cal3d/model.pyx":310 */
      __pyx_v_self->_nb_vertices = (__pyx_v_self->_nb_vertices + __pyx_v_my_submesh->_nb_vertices);

      /* "/home/jiba/src/soya/cal3d/model.pyx":311 */
      __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/model.pyx":313 */
  CalRenderer_EndRendering(__pyx_v_cal_renderer);

  /* "/home/jiba/src/soya/cal3d/model.pyx":314 */
  CalModel_Delete(__pyx_v_cal_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":315 */
  __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._AnimatedModel._build_submeshes");
  __pyx_L0:;
  Py_DECREF(__pyx_v_my_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_14_AnimatedModel__set_face_neighborhood(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":332 */

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

static void __pyx_f_5_soya_14_AnimatedModel__set_cell_shading(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":336 */

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModel._set_cell_shading");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_shader);
}

static void __pyx_f_5_soya_14_AnimatedModel__batch(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_data;
  float (__pyx_v_sphere[4]);
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":342 */
  Py_INCREF(((PyObject *)((PyObject *)__pyx_v_body->_data)));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_data));
  __pyx_v_data = ((PyObject *)((PyObject *)__pyx_v_body->_data));

  /* "/home/jiba/src/soya/cal3d/model.pyx":344 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_data->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(__pyx_v_data,0);

  /* "/home/jiba/src/soya/cal3d/model.pyx":346 */
  __pyx_1 = (!(__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_HIDDEN));
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":347 */
    __pyx_1 = ((__pyx_v_self->_sphere[3]) != (-1.0));
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":348 */
      sphere_by_matrix_copy(__pyx_v_sphere,__pyx_v_self->_sphere,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

      /* "/home/jiba/src/soya/cal3d/model.pyx":349 */
      __pyx_1 = (sphere_in_frustum(__pyx_v_5_soya_renderer->root_frustum,__pyx_v_sphere) == 0);
      if (__pyx_1) {
        goto __pyx_L0;
        goto __pyx_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":354 */
    __pyx_v_data->_vertex_ok = 1;

    /* "/home/jiba/src/soya/cal3d/model.pyx":355 */
    __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_ALPHA);
    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),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
      goto __pyx_L5;
    }
    /*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),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":359 */
    __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_CELL_SHADING);
    if (__pyx_1) {
      __pyx_1 = (__pyx_v_self->_outline_width > 0.0);
    }
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":360 */
      ((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),((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),(-1));
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModel._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static PyObject *__pyx_k339p;
static PyObject *__pyx_k340p;
static PyObject *__pyx_k341p;
static PyObject *__pyx_k342p;

static char (__pyx_k339[]) = "erreur 1";
static char (__pyx_k340[]) = "CalRenderer_BeginRendering failed: %s";
static char (__pyx_k341[]) = "neighbors_%s-%s";
static char (__pyx_k342[]) = "neighbors_%s-%s";

static void __pyx_f_5_soya_14_AnimatedModel__render(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_data;
  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_body);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/model.pyx":375 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_body->_data), __pyx_ptype_5_soya__AnimatedModelData)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 375; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_body->_data));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_data));
  __pyx_v_data = ((PyObject *)__pyx_v_body->_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":376 */
  __pyx_v_ptrf = __pyx_v_data->_coords;

  /* "/home/jiba/src/soya/cal3d/model.pyx":377 */
  __pyx_v_ptrn = __pyx_v_data->_vnormals;

  /* "/home/jiba/src/soya/cal3d/model.pyx":379 */
  __pyx_1 = (__pyx_v_5_soya_renderer->state == __pyx_e_5_soya_RENDERER_STATE_SECONDPASS);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":380 */
    __pyx_1 = (__pyx_v_data->_face_plane_ok <= 0);
    if (__pyx_1) {
      ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_data->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_data);
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":382 */
    __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_body));

    /* "/home/jiba/src/soya/cal3d/model.pyx":383 */
    __pyx_v_plane = __pyx_v_data->_face_planes;

    /* "/home/jiba/src/soya/cal3d/model.pyx":384 */
    __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 384; 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 = 384; goto __pyx_L1;}
        break;
      }
      if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 384; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_submesh));
      __pyx_v_submesh = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/model.pyx":385 */
      __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 385; goto __pyx_L1;}
      __pyx_4 = PyObject_GetItem(__pyx_v_data->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 385; 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 = 385; goto __pyx_L1;}
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":386 */
        ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__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/model.pyx":387 */
      __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

      /* "/home/jiba/src/soya/cal3d/model.pyx":388 */
      __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));

      /* "/home/jiba/src/soya/cal3d/model.pyx":389 */
      __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/model.pyx":390 */
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":392 */
  __pyx_v_cal_renderer = CalModel_GetRenderer(__pyx_v_data->_cal_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":394 */
  __pyx_1 = (CalRenderer_BeginRendering(__pyx_v_cal_renderer) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":395 */
    if (__Pyx_PrintItem(__pyx_k339p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 395; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 395; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 395; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 395; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/model.pyx":396 */
    __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 396; goto __pyx_L1;}
    __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 396; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k340p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 396; 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 = 396; 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 = 396; 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 = 396; goto __pyx_L1;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":398 */
  __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/model.pyx":399 */
  glEnableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/cal3d/model.pyx":400 */
  glEnableClientState(GL_NORMAL_ARRAY);

  /* "/home/jiba/src/soya/cal3d/model.pyx":401 */
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);

  /* "/home/jiba/src/soya/cal3d/model.pyx":402 */
  __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
  if (__pyx_1) {
    glFrontFace(GL_CW);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":404 */
  __pyx_4 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 404; goto __pyx_L1;}
  for (;;) {
    __pyx_L10:;
    __pyx_2 = PyIter_Next(__pyx_4);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 404; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 404; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":405 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 405; goto __pyx_L1;}
    __pyx_2 = PyObject_GetItem(__pyx_v_data->_attached_meshes, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 405; 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 = 405; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":410 */
      CalRenderer_SelectMeshSubmesh(__pyx_v_cal_renderer,__pyx_v_submesh->_mesh,__pyx_v_submesh->_submesh);

      /* "/home/jiba/src/soya/cal3d/model.pyx":413 */
      CalRenderer_GetVertices(__pyx_v_cal_renderer,__pyx_v_ptrf);

      /* "/home/jiba/src/soya/cal3d/model.pyx":414 */
      CalRenderer_GetNormals(__pyx_v_cal_renderer,__pyx_v_ptrn);

      /* "/home/jiba/src/soya/cal3d/model.pyx":415 */
      CalRenderer_GetTextureCoordinates(__pyx_v_cal_renderer,0,__pyx_v_5_soya_cal3d_texcoords_array);

      /* "/home/jiba/src/soya/cal3d/model.pyx":416 */
      glVertexPointer(3,GL_FLOAT,0,__pyx_v_ptrf);

      /* "/home/jiba/src/soya/cal3d/model.pyx":417 */
      glNormalPointer(GL_FLOAT,0,__pyx_v_ptrn);

      /* "/home/jiba/src/soya/cal3d/model.pyx":418 */
      glTexCoordPointer(2,GL_FLOAT,0,__pyx_v_5_soya_cal3d_texcoords_array);

      /* "/home/jiba/src/soya/cal3d/model.pyx":420 */
      __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_submesh->_material), __pyx_n_activate); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 420; goto __pyx_L1;}
      __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 420; goto __pyx_L1;}
      __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 420; 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/model.pyx":422 */
      __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_CELL_SHADING);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":423 */
        __pyx_1 = (!(__pyx_v_submesh->_option & __pyx_e_5_soya_CAL3D_NEIGHBORS));
        if (__pyx_1) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":424 */
          __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 424; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 424; 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 = 424; 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 = 424; goto __pyx_L1;}
          __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 424; 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 = 424; 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 = 424; 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 = 424; 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 = 424; goto __pyx_L1;}
          __pyx_2 = PyInt_FromLong(__pyx_v_submesh->_submesh); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 424; goto __pyx_L1;}
          __pyx_7 = PyTuple_New(2); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 424; 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_k341p, __pyx_7); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 424; 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 = 424; 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 = 424; 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_L14;
        }
        __pyx_L14:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":426 */
        __pyx_v_shades = __pyx_v_5_soya_cal3d_shades_array;

        /* "/home/jiba/src/soya/cal3d/model.pyx":427 */
        ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_prepare_cellshading(__pyx_v_self,((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_shades,__pyx_v_submesh->_nb_vertices,__pyx_v_ptrf,__pyx_v_ptrn);

        /* "/home/jiba/src/soya/cal3d/model.pyx":430 */
        glActiveTextureARB(GL_TEXTURE1);

        /* "/home/jiba/src/soya/cal3d/model.pyx":431 */
        __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_L15;
        }
        __pyx_L15:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":432 */
        glEnable(GL_TEXTURE_2D);

        /* "/home/jiba/src/soya/cal3d/model.pyx":433 */
        glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);

        /* "/home/jiba/src/soya/cal3d/model.pyx":434 */
        glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_shader->_id);

        /* "/home/jiba/src/soya/cal3d/model.pyx":435 */
        glActiveTextureARB(GL_TEXTURE0);

        /* "/home/jiba/src/soya/cal3d/model.pyx":437 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/cal3d/model.pyx":438 */
        __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/model.pyx":439 */
          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/model.pyx":443 */
          glArrayElement((__pyx_v_submesh->_faces[__pyx_v_j]));
          __pyx_L16:;
        }
        __pyx_L17:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":444 */
        glEnd();

        /* "/home/jiba/src/soya/cal3d/model.pyx":447 */
        glActiveTextureARB(GL_TEXTURE1);

        /* "/home/jiba/src/soya/cal3d/model.pyx":448 */
        glDisable(GL_TEXTURE_2D);

        /* "/home/jiba/src/soya/cal3d/model.pyx":449 */
        glActiveTextureARB(GL_TEXTURE0);
        goto __pyx_L13;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/model.pyx":452 */
        __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/model.pyx":453 */
          __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 453; goto __pyx_L1;}
          __pyx_3 = PyObject_GetAttr(__pyx_6, __pyx_n_path); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 453; 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 = 453; 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 = 453; goto __pyx_L1;}
          __pyx_7 = PyObject_GetAttr(__pyx_2, __pyx_n_path); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 453; 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 = 453; 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 = 453; 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 = 453; 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 = 453; goto __pyx_L1;}
          __pyx_6 = PyInt_FromLong(__pyx_v_submesh->_submesh); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 453; goto __pyx_L1;}
          __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 453; 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_k342p, __pyx_3); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 453; 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 = 453; 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 = 453; 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_L18;
        }
        __pyx_L18:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":455 */
        glBegin(GL_TRIANGLES);

        /* "/home/jiba/src/soya/cal3d/model.pyx":456 */
        __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/model.pyx":460 */
          glArrayElement((__pyx_v_submesh->_faces[__pyx_v_j]));
          __pyx_L19:;
        }
        __pyx_L20:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":461 */
        glEnd();
      }
      __pyx_L13:;
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":463 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/model.pyx":464 */
    __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));
  }
  __pyx_L11:;
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":466 */
  CalRenderer_EndRendering(__pyx_v_cal_renderer);

  /* "/home/jiba/src/soya/cal3d/model.pyx":467 */
  glDisableClientState(GL_NORMAL_ARRAY);

  /* "/home/jiba/src/soya/cal3d/model.pyx":468 */
  glDisableClientState(GL_TEXTURE_COORD_ARRAY);

  /* "/home/jiba/src/soya/cal3d/model.pyx":469 */
  glDisableClientState(GL_VERTEX_ARRAY);

  /* "/home/jiba/src/soya/cal3d/model.pyx":470 */
  __pyx_1 = (__pyx_v_body->__pyx_base._option & __pyx_e_5_soya_LEFTHANDED);
  if (__pyx_1) {
    glFrontFace(GL_CCW);
    goto __pyx_L21;
  }
  __pyx_L21:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":471 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
  if (__pyx_1) {
    glEnable(GL_CULL_FACE);
    goto __pyx_L22;
  }
  __pyx_L22:;

  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._AnimatedModel._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_data);
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static PyObject *__pyx_k343p;
static PyObject *__pyx_k344p;

static char (__pyx_k343[]) = "erreur 1";
static char (__pyx_k344[]) = "CalRenderer_BeginRendering failed: %s";

static void __pyx_f_5_soya_14_AnimatedModel__build_vertices(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_data) {
  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_data);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/model.pyx":479 */
  __pyx_v_ptrf = __pyx_v_data->_coords;

  /* "/home/jiba/src/soya/cal3d/model.pyx":480 */
  __pyx_v_ptrn = __pyx_v_data->_vnormals;

  /* "/home/jiba/src/soya/cal3d/model.pyx":482 */
  __pyx_v_cal_renderer = CalModel_GetRenderer(__pyx_v_data->_cal_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":484 */
  __pyx_1 = (CalRenderer_BeginRendering(__pyx_v_cal_renderer) == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":485 */
    if (__Pyx_PrintItem(__pyx_k343p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 485; goto __pyx_L1;}
    __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 485; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 485; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 485; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/model.pyx":486 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 486; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 486; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k344p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 486; 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 = 486; 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 = 486; 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 = 486; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":488 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 488; 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 = 488; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 488; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":489 */
    __pyx_4 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 489; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_data->_attached_meshes, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 489; 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 = 489; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":490 */
      CalRenderer_SelectMeshSubmesh(__pyx_v_cal_renderer,__pyx_v_submesh->_mesh,__pyx_v_submesh->_submesh);

      /* "/home/jiba/src/soya/cal3d/model.pyx":493 */
      CalRenderer_GetVertices(__pyx_v_cal_renderer,__pyx_v_ptrf);

      /* "/home/jiba/src/soya/cal3d/model.pyx":494 */
      CalRenderer_GetNormals(__pyx_v_cal_renderer,__pyx_v_ptrn);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":496 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/model.pyx":497 */
    __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/model.pyx":499 */
  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._AnimatedModel._build_vertices");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_data);
}

static void __pyx_f_5_soya_14_AnimatedModel__prepare_cellshading(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":505 */
  __pyx_1 = PyObject_GetIter(__pyx_v_5_soya_renderer->top_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 505; 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 = 505; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 505; 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/model.pyx":506 */
  __pyx_2 = PyObject_GetIter(__pyx_v_5_soya_renderer->current_context->lights); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 506; 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 = 506; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 506; 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/model.pyx":508 */
  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/model.pyx":509 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__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/model.pyx":510 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__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/model.pyx":513 */
  for (__pyx_v_n = 0; __pyx_v_n < __pyx_v_nb_vertices; ++__pyx_v_n) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":516 */
    __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._AnimatedModel._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_14_AnimatedModel__prepare_cellshading_shades(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":526 */
  __pyx_1 = PyObject_GetIter(__pyx_v_lights); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 526; 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 = 526; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Light)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 526; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_light));
    __pyx_v_light = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":527 */
    __pyx_v_ptr1 = __pyx_v_vnormals;

    /* "/home/jiba/src/soya/cal3d/model.pyx":528 */
    __pyx_3 = (__pyx_v_light->_w == 0.0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":529 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_vertices; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":530 */
        __pyx_v_tmp = (-vector_dot_product(__pyx_v_ptr1,__pyx_v_light->_data));

        /* "/home/jiba/src/soya/cal3d/model.pyx":531 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/cal3d/model.pyx":532 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);
        __pyx_L5:;
      }
      __pyx_L6:;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/cal3d/model.pyx":535 */
      __pyx_v_ptr2 = __pyx_v_coords;

      /* "/home/jiba/src/soya/cal3d/model.pyx":536 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_vertices; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":537 */
        (__pyx_v_v[0]) = ((__pyx_v_light->_data[0]) - (__pyx_v_ptr2[0]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":538 */
        (__pyx_v_v[1]) = ((__pyx_v_light->_data[1]) - (__pyx_v_ptr2[1]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":539 */
        (__pyx_v_v[2]) = ((__pyx_v_light->_data[2]) - (__pyx_v_ptr2[2]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":540 */
        vector_normalize(__pyx_v_v);

        /* "/home/jiba/src/soya/cal3d/model.pyx":541 */
        __pyx_v_tmp = vector_dot_product(__pyx_v_ptr1,__pyx_v_v);

        /* "/home/jiba/src/soya/cal3d/model.pyx":542 */
        (__pyx_v_shades[__pyx_v_j]) = ((__pyx_v_shades[__pyx_v_j]) + __pyx_v_tmp);

        /* "/home/jiba/src/soya/cal3d/model.pyx":543 */
        __pyx_v_ptr1 = (__pyx_v_ptr1 + 3);

        /* "/home/jiba/src/soya/cal3d/model.pyx":544 */
        __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._AnimatedModel._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_14_AnimatedModel__render_outline(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":556 */
  __pyx_v_facesides = __pyx_v_5_soya_cal3d_facesides_array;

  /* "/home/jiba/src/soya/cal3d/model.pyx":559 */
  __pyx_v_d = (sphere_distance_point(__pyx_v_self->_sphere,__pyx_v_frustum->position) * __pyx_v_self->_outline_attenuation);

  /* "/home/jiba/src/soya/cal3d/model.pyx":560 */
  __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/model.pyx":562 */
    __pyx_v_d = (__pyx_v_self->_outline_width / __pyx_v_d);

    /* "/home/jiba/src/soya/cal3d/model.pyx":563 */
    __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/model.pyx":565 */
  ((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/model.pyx":566 */
  glLineWidth(__pyx_v_d);

  /* "/home/jiba/src/soya/cal3d/model.pyx":567 */
  glColor4fv(__pyx_v_self->_outline_color);

  /* "/home/jiba/src/soya/cal3d/model.pyx":568 */
  glDisable(GL_LIGHTING);

  /* "/home/jiba/src/soya/cal3d/model.pyx":569 */
  glDepthFunc(GL_LEQUAL);

  /* "/home/jiba/src/soya/cal3d/model.pyx":572 */
  __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/model.pyx":573 */
    __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/model.pyx":574 */
      (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_FRONT;
      goto __pyx_L6;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/cal3d/model.pyx":576 */
      (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_BACK;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":578 */
    __pyx_v_plane = (__pyx_v_plane + 4);
    __pyx_L4:;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":581 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/cal3d/model.pyx":582 */
  chunk_register(__pyx_v_chunk,(__pyx_v_submesh->_nb_vertices * (sizeof(int ))));

  /* "/home/jiba/src/soya/cal3d/model.pyx":584 */
  __pyx_v_vertex_used = ((int (*))__pyx_v_chunk->content);

  /* "/home/jiba/src/soya/cal3d/model.pyx":585 */
  __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/model.pyx":589 */
  glBegin(GL_LINES);

  /* "/home/jiba/src/soya/cal3d/model.pyx":590 */
  __pyx_1 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":591 */
    __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/model.pyx":592 */
      for (__pyx_v_j = 0; __pyx_v_j < 3; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":593 */
        __pyx_v_k = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_j)]);

        /* "/home/jiba/src/soya/cal3d/model.pyx":594 */
        __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/model.pyx":595 */
          (__pyx_v_vertex_used[(__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)])]) = 1;

          /* "/home/jiba/src/soya/cal3d/model.pyx":598 */
          glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)]))));

          /* "/home/jiba/src/soya/cal3d/model.pyx":599 */
          __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/model.pyx":603 */
    __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/model.pyx":604 */
      __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_FRONT);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":606 */
        for (__pyx_v_j = 0; __pyx_v_j < 3; ++__pyx_v_j) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":607 */
          __pyx_v_k = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_j)]);

          /* "/home/jiba/src/soya/cal3d/model.pyx":608 */
          __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/model.pyx":609 */
            (__pyx_v_vertex_used[(__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)])]) = 1;

            /* "/home/jiba/src/soya/cal3d/model.pyx":612 */
            glVertex3fv((__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_j)]))));

            /* "/home/jiba/src/soya/cal3d/model.pyx":613 */
            __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/model.pyx":616 */
  glEnd();

  /* "/home/jiba/src/soya/cal3d/model.pyx":618 */
  glPointSize((__pyx_v_d / 2));

  /* "/home/jiba/src/soya/cal3d/model.pyx":620 */
  glBegin(GL_POINTS);

  /* "/home/jiba/src/soya/cal3d/model.pyx":621 */
  __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/model.pyx":622 */
    __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/model.pyx":623 */
  glEnd();

  /* "/home/jiba/src/soya/cal3d/model.pyx":625 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/cal3d/model.pyx":627 */
  glLineWidth(1.0);

  /* "/home/jiba/src/soya/cal3d/model.pyx":628 */
  glPointSize(1.0);

  /* "/home/jiba/src/soya/cal3d/model.pyx":629 */
  glEnable(GL_LIGHTING);

  /* "/home/jiba/src/soya/cal3d/model.pyx":630 */
  glDepthFunc(GL_LESS);

  /* "/home/jiba/src/soya/cal3d/model.pyx":631 */
  glColor4fv(__pyx_v_5_soya_white);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModel._render_outline");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_submesh);
}

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

  /* "/home/jiba/src/soya/cal3d/model.pyx":636 */
  CalCoreModel_Delete(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._AnimatedModel.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_k345p;

static char (__pyx_k345[]) = "CalCoreModel_LoadCoreSkeleton failed: %s";

static PyObject *__pyx_f_5_soya_14_AnimatedModel_load_skeleton(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":639 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 639; goto __pyx_L1;}
  __pyx_2 = (CalCoreModel_LoadCoreSkeleton(((struct __pyx_obj_5_soya__AnimatedModel *)__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 = 639; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 639; goto __pyx_L1;}
    __pyx_5 = PyNumber_Remainder(__pyx_k345p, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 639; 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 = 639; 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 = 639; 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 = 639; 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._AnimatedModel.load_skeleton");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_k346p;

static char (__pyx_k346[]) = "CalCoreModel_LoadCoreMesh failed on file %s: %s";

static PyObject *__pyx_f_5_soya_14_AnimatedModel_load_mesh(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":643 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 643; goto __pyx_L1;}
  __pyx_v_i = CalCoreModel_LoadCoreMesh(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model,__pyx_1);

  /* "/home/jiba/src/soya/cal3d/model.pyx":644 */
  __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 = 644; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 644; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 644; 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_k346p, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 644; 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 = 644; 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 = 644; 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 = 644; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":645 */
  __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 645; goto __pyx_L1;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 645; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_path); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 645; 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 = 645; 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 = 645; 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 = 645; 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 = 645; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (PyObject_SetItem(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_meshes, __pyx_5, __pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 645; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":646 */
  __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 646; 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._AnimatedModel.load_mesh");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_k347p;

static char (__pyx_k347[]) = "CalCoreModel_LoadCoreMaterial failed on file %s: %s";

static PyObject *__pyx_f_5_soya_14_AnimatedModel_load_material(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":650 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 650; goto __pyx_L1;}
  __pyx_v_i = CalCoreModel_LoadCoreMaterial(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model,__pyx_1);

  /* "/home/jiba/src/soya/cal3d/model.pyx":651 */
  __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 = 651; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; 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_k347p, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 651; 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 = 651; 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 = 651; 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 = 651; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":652 */
  __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 652; 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._AnimatedModel.load_material");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_filename);
  return __pyx_r;
}

static PyObject *__pyx_k348p;

static char (__pyx_k348[]) = "CalCoreModel_LoadCoreAnimation failed on file %s: %s";

static PyObject *__pyx_f_5_soya_14_AnimatedModel_load_animation(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":656 */
  __pyx_1 = PyString_AsString(__pyx_v_filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 656; goto __pyx_L1;}
  __pyx_v_i = CalCoreModel_LoadCoreAnimation(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model,__pyx_1);

  /* "/home/jiba/src/soya/cal3d/model.pyx":657 */
  __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 = 657; goto __pyx_L1;}
    __pyx_4 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 657; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 657; 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_k348p, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 657; 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 = 657; 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 = 657; 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 = 657; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":658 */
  __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 658; goto __pyx_L1;}
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 658; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_5, __pyx_n_path); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 658; 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 = 658; 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 = 658; 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 = 658; 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 = 658; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;
  if (PyObject_SetItem(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_animations, __pyx_5, __pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 658; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":659 */
  __pyx_4 = PyInt_FromLong(__pyx_v_i); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 659; 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._AnimatedModel.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_14_AnimatedModel_build_materials(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_14_AnimatedModel_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/model.pyx":665 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_materials, __pyx_n___imul__); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 665; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 665; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 665; 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 = 665; 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/model.pyx":666 */
  __pyx_4 = (((struct __pyx_obj_5_soya__AnimatedModel *)__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/model.pyx":668 */
  __pyx_v_nb = CalCoreModel_GetCoreMaterialCount(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":669 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":670 */
    __pyx_v_material = CalCoreModel_GetCoreMaterial(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/model.pyx":673 */
    __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_materials, __pyx_n_append); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 673; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalCoreMaterial_GetMapFilename(__pyx_v_material,0)); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 673; goto __pyx_L1;}
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__AnimatedModel *)((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_vtab)->_get_material_4_cal3d(((struct __pyx_obj_5_soya__AnimatedModel *)__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 = 673; 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 = 673; 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 = 673; 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/model.pyx":675 */
    CalCoreModel_CreateCoreMaterialThread(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/model.pyx":676 */
    CalCoreModel_SetCoreMaterialId(((struct __pyx_obj_5_soya__AnimatedModel *)__pyx_v_self)->_core_model,__pyx_v_i,0,__pyx_v_i);

    /* "/home/jiba/src/soya/cal3d/model.pyx":677 */
    CalCoreMaterial_SetUserData(__pyx_v_material,((CalUserData )__pyx_v_i));
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":679 */
  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._AnimatedModel.build_materials");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_find;

static PyObject *__pyx_k349p;

static char (__pyx_k349[]) = ".";

static struct __pyx_obj_5_soya__Material *__pyx_f_5_soya_14_AnimatedModel__get_material_4_cal3d(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":710 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 710; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 710; 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 = 710; 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 = 710; 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 = 710; 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/model.pyx":711 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_material_name, __pyx_n_find); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 711; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 711; goto __pyx_L1;}
  Py_INCREF(__pyx_k349p);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k349p);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 711; 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 = 711; 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 = 711; goto __pyx_L1;}
  Py_DECREF(__pyx_v_material_name);
  __pyx_v_material_name = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":712 */
  /*try:*/ {

    /* "/home/jiba/src/soya/cal3d/model.pyx":713 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Material); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; goto __pyx_L2;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 713; 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 = 713; 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 = 713; 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 = 713; 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/model.pyx":714 */
  __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 714; 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 = 714; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":715 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__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 = 715; 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._AnimatedModel._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_k350p;
static PyObject *__pyx_k351p;
static PyObject *__pyx_k353p;

static char (__pyx_k350[]) = "__cal3dmaterial_texture_%s_diffuse_%s_%s_%s_%s_specular_%s_%s_%s_%s_shininess_%s__";
static char (__pyx_k351[]) = "";
static char (__pyx_k353[]) = ".raw";

static struct __pyx_obj_5_soya__Material *__pyx_f_5_soya_14_AnimatedModel__create_material_4_cal3d(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":718 */
  __pyx_1 = PyFloat_FromDouble(__pyx_v_diffuse_r); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_diffuse_g); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_diffuse_b); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_diffuse_a); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(__pyx_v_specular_r); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_6 = PyFloat_FromDouble(__pyx_v_specular_g); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(__pyx_v_specular_b); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(__pyx_v_specular_a); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(__pyx_v_shininess); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; goto __pyx_L1;}
  __pyx_10 = PyTuple_New(10); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; 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_k350p, __pyx_10); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 718; 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/model.pyx":720 */
  /*try:*/ {

    /* "/home/jiba/src/soya/cal3d/model.pyx":721 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Material); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 721; goto __pyx_L2;}
    __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_get); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 721; 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 = 721; 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 = 721; 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 = 721; 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/model.pyx":722 */
  __pyx_6 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 722; 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 = 722; goto __pyx_L1;}
    Py_DECREF(__pyx_7); __pyx_7 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":723 */
    goto __pyx_L3;
  }
  goto __pyx_L1;
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":726 */
  __pyx_8 = __Pyx_GetName(__pyx_m, __pyx_n_Material); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; goto __pyx_L1;}
  __pyx_9 = PyTuple_New(0); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; goto __pyx_L1;}
  __pyx_10 = PyObject_CallObject(__pyx_8, __pyx_9); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 726; 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 = 726; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_material));
  __pyx_v_material = __pyx_10;
  __pyx_10 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":727 */
  if (PyObject_SetAttr(((PyObject *)__pyx_v_material), __pyx_n_filename, __pyx_v_material_name) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 727; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":728 */
  __pyx_1 = PyFloat_FromDouble(__pyx_v_diffuse_r); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 728; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_diffuse_g); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 728; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_diffuse_b); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 728; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(__pyx_v_diffuse_a); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 728; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 728; 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 = 728; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":729 */
  __pyx_6 = PyFloat_FromDouble(__pyx_v_specular_r); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 729; goto __pyx_L1;}
  __pyx_7 = PyFloat_FromDouble(__pyx_v_specular_g); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 729; goto __pyx_L1;}
  __pyx_8 = PyFloat_FromDouble(__pyx_v_specular_b); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 729; goto __pyx_L1;}
  __pyx_9 = PyFloat_FromDouble(__pyx_v_specular_a); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 729; goto __pyx_L1;}
  __pyx_10 = PyTuple_New(4); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 729; 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 = 729; goto __pyx_L1;}
  Py_DECREF(__pyx_10); __pyx_10 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":730 */
  __pyx_v_material->shininess = __pyx_v_shininess;

  /* "/home/jiba/src/soya/cal3d/model.pyx":732 */
  if (PyObject_Cmp(__pyx_v_image_filename, __pyx_k351p, &__pyx_11) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 732; goto __pyx_L1;}
  __pyx_11 = __pyx_11 != 0;
  if (__pyx_11) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":733 */
    __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 733; goto __pyx_L1;}
    Py_DECREF(__pyx_v_soya);
    __pyx_v_soya = __pyx_1;
    __pyx_1 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":734 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 734; goto __pyx_L1;}
    __pyx_3 = PyObject_GetIter(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 734; 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 = 734; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_path);
      __pyx_v_path = __pyx_4;
      __pyx_4 = 0;

      /* "/home/jiba/src/soya/cal3d/model.pyx":735 */
      __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 735; goto __pyx_L1;}
      __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_path); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 735; 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 = 735; 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 = 735; goto __pyx_L1;}
      __pyx_9 = PyObject_GetAttr(__pyx_8, __pyx_n_DIRNAME); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 735; 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 = 735; goto __pyx_L1;}
      __pyx_1 = PyObject_GetAttr(__pyx_10, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 735; 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 = 735; 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 = 735; 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 = 735; 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 = 735; 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 = 735; 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/model.pyx":736 */
      __pyx_10 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 736; goto __pyx_L1;}
      __pyx_1 = PyObject_GetAttr(__pyx_10, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 736; 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 = 736; 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 = 736; 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 = 736; 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 = 736; goto __pyx_L1;}
      Py_DECREF(__pyx_9); __pyx_9 = 0;
      if (__pyx_11) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":737 */
        __pyx_5 = PyObject_GetAttr(__pyx_v_image_filename, __pyx_n_endswith); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 737; goto __pyx_L1;}
        __pyx_7 = PyTuple_New(1); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 737; goto __pyx_L1;}
        Py_INCREF(__pyx_k353p);
        PyTuple_SET_ITEM(__pyx_7, 0, __pyx_k353p);
        __pyx_6 = PyObject_CallObject(__pyx_5, __pyx_7); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 737; 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 = 737; 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 = 737; goto __pyx_L1;}
          __pyx_10 = PyTuple_New(1); if (!__pyx_10) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 737; 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 = 737; 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 = 737; 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 = 738; goto __pyx_L1;}
          __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 738; 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 = 738; 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 = 738; goto __pyx_L1;}
          Py_DECREF(__pyx_9); __pyx_9 = 0;
        }
        __pyx_L8:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":739 */
        goto __pyx_L6;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    /*else*/ {
      ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__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/model.pyx":742 */
  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._AnimatedModel._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_k354p;

static char (__pyx_k354[]) = ".raw";

static void __pyx_f_5_soya_14_AnimatedModel__set_texture_from_model(struct __pyx_obj_5_soya__AnimatedModel *__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/model.pyx":746 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 746; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_path); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 746; 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 = 746; 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 = 746; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_path); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 746; 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 = 746; 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 = 746; 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 = 746; 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 = 746; 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 = 746; 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/model.pyx":747 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_image_filename, __pyx_n_endswith); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; goto __pyx_L1;}
  Py_INCREF(__pyx_k354p);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k354p);
  __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; 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 = 747; 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 = 747; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 747; 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 = 747; 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 = 747; 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 = 748; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 748; 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 = 748; 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 = 748; 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._AnimatedModel._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_14_AnimatedModel__shadow(struct __pyx_obj_5_soya__AnimatedModel *__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__Body *__pyx_v_body;
  struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_data;
  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_body = Py_None; Py_INCREF((PyObject *) __pyx_v_body);
  __pyx_v_data = Py_None; Py_INCREF((PyObject *) __pyx_v_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":752 */
  __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/model.pyx":760 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_coordsyst), __pyx_ptype_5_soya__Body)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 760; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_coordsyst));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_body));
  __pyx_v_body = ((PyObject *)__pyx_v_coordsyst);

  /* "/home/jiba/src/soya/cal3d/model.pyx":761 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_body->_data), __pyx_ptype_5_soya__AnimatedModelData)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 761; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_body->_data));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_data));
  __pyx_v_data = ((PyObject *)__pyx_v_body->_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":762 */
  __pyx_1 = (__pyx_v_data->_face_plane_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_data->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_data);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":764 */
  __pyx_v_ptrf = __pyx_v_data->_coords;

  /* "/home/jiba/src/soya/cal3d/model.pyx":765 */
  __pyx_v_ptrn = __pyx_v_data->_vnormals;

  /* "/home/jiba/src/soya/cal3d/model.pyx":766 */
  __pyx_v_plane = __pyx_v_data->_face_planes;

  /* "/home/jiba/src/soya/cal3d/model.pyx":767 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":768 */
  __pyx_v_r = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":770 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 770; 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 = 770; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 770; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":771 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 771; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_data->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 771; 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 = 771; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":772 */
      __pyx_1 = ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_shadow2(__pyx_v_self,__pyx_v_submesh,__pyx_v_body,__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/model.pyx":773 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/model.pyx":774 */
    __pyx_v_ptrn = (__pyx_v_ptrn + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/model.pyx":775 */
    __pyx_v_plane = (__pyx_v_plane + (__pyx_v_submesh->_nb_faces * 4));

    /* "/home/jiba/src/soya/cal3d/model.pyx":776 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L5:;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":778 */
  __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._AnimatedModel._shadow");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF((PyObject *)__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static PyObject *__pyx_k355p;

static char (__pyx_k355[]) = "* Soya * warning : drawing shadow for non-closed model (can't join segments)!";

static int __pyx_f_5_soya_14_AnimatedModel__shadow2(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya__Cal3dSubMesh *__pyx_v_submesh,struct __pyx_obj_5_soya__Body *__pyx_v_body,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_body);
  Py_INCREF((PyObject *)__pyx_v_light);
  __pyx_v_joined = Py_None; Py_INCREF(__pyx_v_joined);

  /* "/home/jiba/src/soya/cal3d/model.pyx":781 */
  __pyx_1 = (!(__pyx_v_submesh->_option & __pyx_e_5_soya_CAL3D_NEIGHBORS));
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":795 */
  __pyx_v_facesides = __pyx_v_5_soya_cal3d_facesides_array;

  /* "/home/jiba/src/soya/cal3d/model.pyx":803 */
  __pyx_v_b = __pyx_v_5_soya_renderer->current_camera->_back;

  /* "/home/jiba/src/soya/cal3d/model.pyx":807 */
  ((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_body));

  /* "/home/jiba/src/soya/cal3d/model.pyx":808 */
  __pyx_1 = (__pyx_v_light->_w == 0.0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":809 */
    cone_from_sphere_and_vector(__pyx_v_cone,__pyx_v_self->_sphere,__pyx_v_light->_data,__pyx_v_b);

    /* "/home/jiba/src/soya/cal3d/model.pyx":810 */
    __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/model.pyx":812 */
      __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_L6;
      }
      /*else*/ {
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_FRONT;
      }
      __pyx_L6:;
      __pyx_L4:;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/model.pyx":816 */
    __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_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":817 */
    __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/model.pyx":819 */
      __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/model.pyx":820 */
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_FRONT;
        goto __pyx_L10;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/model.pyx":822 */
        (__pyx_v_facesides[__pyx_v_i]) = __pyx_e_5_soya_FACE_LIGHT_BACK;
      }
      __pyx_L10:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":823 */
      __pyx_v_plane = (__pyx_v_plane + 4);
      __pyx_L8:;
    }
    __pyx_L9:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":826 */
  glStencilFunc(GL_ALWAYS,1,4294967295);

  /* "/home/jiba/src/soya/cal3d/model.pyx":827 */
  glFrontFace(GL_CW);

  /* "/home/jiba/src/soya/cal3d/model.pyx":830 */
  glStencilOp(GL_KEEP,GL_KEEP,GL_INCR);

  /* "/home/jiba/src/soya/cal3d/model.pyx":831 */
  glLoadMatrixf(__pyx_v_body->__pyx_base._render_matrix);

  /* "/home/jiba/src/soya/cal3d/model.pyx":832 */
  glNewList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST,GL_COMPILE_AND_EXECUTE);

  /* "/home/jiba/src/soya/cal3d/model.pyx":835 */
  __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_body));

  /* "/home/jiba/src/soya/cal3d/model.pyx":836 */
  (__pyx_v_coord[0]) = (0.5 * ((__pyx_v_frustum->points[0]) + (__pyx_v_frustum->points[6])));

  /* "/home/jiba/src/soya/cal3d/model.pyx":837 */
  (__pyx_v_coord[1]) = (0.5 * ((__pyx_v_frustum->points[1]) + (__pyx_v_frustum->points[7])));

  /* "/home/jiba/src/soya/cal3d/model.pyx":838 */
  (__pyx_v_coord[2]) = (0.5 * ((__pyx_v_frustum->points[2]) + (__pyx_v_frustum->points[8])));

  /* "/home/jiba/src/soya/cal3d/model.pyx":839 */
  (__pyx_v_coord[3]) = point_distance_to(__pyx_v_coord,__pyx_v_frustum->points);

  /* "/home/jiba/src/soya/cal3d/model.pyx":840 */
  __pyx_2 = sphere_is_in_cone(__pyx_v_coord,__pyx_v_cone);
  if (__pyx_2) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":845 */
    __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/model.pyx":847 */
    __pyx_v_chunk = get_chunk();

    /* "/home/jiba/src/soya/cal3d/model.pyx":848 */
    __pyx_v_chunk2 = get_chunk();

    /* "/home/jiba/src/soya/cal3d/model.pyx":849 */
    __pyx_v_nb_inter = 0;
    __pyx_v_nb_segment = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":852 */
    __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/model.pyx":853 */
      __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":855 */
        for (__pyx_v_k = 0; __pyx_v_k < 3; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":856 */
          __pyx_v_neighbor_face = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]);

          /* "/home/jiba/src/soya/cal3d/model.pyx":859 */
          __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/model.pyx":861 */
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/model.pyx":862 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/cal3d/model.pyx":863 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L19;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L19:;
              goto __pyx_L18;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/model.pyx":866 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L20;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L20:;

              /* "/home/jiba/src/soya/cal3d/model.pyx":868 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L18:;

            /* "/home/jiba/src/soya/cal3d/model.pyx":870 */
            __pyx_v_nb_segment = (__pyx_v_nb_segment + 1);

            /* "/home/jiba/src/soya/cal3d/model.pyx":871 */
            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/model.pyx":872 */
            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/model.pyx":873 */
            chunk_add_int(__pyx_v_chunk,(-1));
            goto __pyx_L17;
          }
          __pyx_L17:;
          __pyx_L15:;
        }
        __pyx_L16:;
        goto __pyx_L14;
      }
      __pyx_L14:;
      __pyx_L12:;
    }
    __pyx_L13:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":876 */
    __pyx_7 = PyDict_New(); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 876; goto __pyx_L1;}
    Py_DECREF(__pyx_v_joined);
    __pyx_v_joined = __pyx_7;
    __pyx_7 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":877 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_segment; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":878 */
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_v_nb_segment; ++__pyx_v_j) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":879 */
        __pyx_2 = (__pyx_v_i == __pyx_v_j);
        if (__pyx_2) {
          goto __pyx_L23;
          goto __pyx_L25;
        }
        __pyx_L25:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":880 */
        __pyx_7 = PyObject_GetAttr(__pyx_v_joined, __pyx_n_has_key); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 880; goto __pyx_L1;}
        __pyx_8 = PyInt_FromLong(__pyx_v_j); if (!__pyx_8) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 880; goto __pyx_L1;}
        __pyx_9 = PyTuple_New(1); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 880; 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 = 880; 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 = 880; goto __pyx_L1;}
        Py_DECREF(__pyx_8); __pyx_8 = 0;
        if (__pyx_1) {
          goto __pyx_L23;
          goto __pyx_L26;
        }
        __pyx_L26:;

        /* "/home/jiba/src/soya/cal3d/model.pyx":882 */
        __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/model.pyx":883 */
          (((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/model.pyx":884 */
          __pyx_7 = PyInt_FromLong(1); if (!__pyx_7) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 884; goto __pyx_L1;}
          __pyx_9 = PyInt_FromLong(__pyx_v_j); if (!__pyx_9) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 884; goto __pyx_L1;}
          if (PyObject_SetItem(__pyx_v_joined, __pyx_9, __pyx_7) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 884; goto __pyx_L1;}
          Py_DECREF(__pyx_9); __pyx_9 = 0;
          Py_DECREF(__pyx_7); __pyx_7 = 0;

          /* "/home/jiba/src/soya/cal3d/model.pyx":885 */
          goto __pyx_L24;
          goto __pyx_L27;
        }
        __pyx_L27:;
        __pyx_L23:;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/model.pyx":887 */
        if (__Pyx_PrintItem(__pyx_k355p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 887; goto __pyx_L1;}
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 887; goto __pyx_L1;}
      }
      __pyx_L24:;
      __pyx_L21:;
    }
    __pyx_L22:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":889 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/cal3d/model.pyx":890 */
    __pyx_v_i = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":891 */
    for (__pyx_v_k = 0; __pyx_v_k < __pyx_v_nb_segment; ++__pyx_v_k) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":892 */
      __pyx_1 = (__pyx_v_i == (-1));
      if (__pyx_1) {
        goto __pyx_L29;
        goto __pyx_L30;
      }
      __pyx_L30:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":893 */
      __pyx_v_coord_ptr = ((float (*))(__pyx_v_chunk->content + (__pyx_v_i * ((6 * (sizeof(float ))) + (sizeof(int ))))));

      /* "/home/jiba/src/soya/cal3d/model.pyx":895 */
      __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/model.pyx":897 */
      memcpy(__pyx_v_fp1,__pyx_v_coord_ptr,(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/cal3d/model.pyx":898 */
      memcpy(__pyx_v_fp2,(__pyx_v_coord_ptr + 3),(3 * (sizeof(float ))));

      /* "/home/jiba/src/soya/cal3d/model.pyx":900 */
      __pyx_2 = (__pyx_v_light->_w == 0.0);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":901 */
        memcpy(__pyx_v_v1,__pyx_v_light->_data,(3 * (sizeof(float ))));

        /* "/home/jiba/src/soya/cal3d/model.pyx":902 */
        memcpy(__pyx_v_v2,__pyx_v_light->_data,(3 * (sizeof(float ))));
        goto __pyx_L31;
      }
      /*else*/ {

        /* "/home/jiba/src/soya/cal3d/model.pyx":904 */
        (__pyx_v_v1[0]) = ((__pyx_v_fp1[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":905 */
        (__pyx_v_v1[1]) = ((__pyx_v_fp1[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":906 */
        (__pyx_v_v1[2]) = ((__pyx_v_fp1[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":907 */
        vector_normalize(__pyx_v_v1);

        /* "/home/jiba/src/soya/cal3d/model.pyx":909 */
        (__pyx_v_v2[0]) = ((__pyx_v_fp2[0]) - (__pyx_v_light->_data[0]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":910 */
        (__pyx_v_v2[1]) = ((__pyx_v_fp2[1]) - (__pyx_v_light->_data[1]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":911 */
        (__pyx_v_v2[2]) = ((__pyx_v_fp2[2]) - (__pyx_v_light->_data[2]));

        /* "/home/jiba/src/soya/cal3d/model.pyx":912 */
        vector_normalize(__pyx_v_v2);
      }
      __pyx_L31:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":915 */
      point_by_matrix(__pyx_v_fp1,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

      /* "/home/jiba/src/soya/cal3d/model.pyx":916 */
      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/model.pyx":918 */
      point_by_matrix(__pyx_v_fp2,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

      /* "/home/jiba/src/soya/cal3d/model.pyx":919 */
      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/model.pyx":921 */
      vector_by_matrix(__pyx_v_v1,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

      /* "/home/jiba/src/soya/cal3d/model.pyx":922 */
      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/model.pyx":924 */
      vector_by_matrix(__pyx_v_v2,((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._root_matrix(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body)));

      /* "/home/jiba/src/soya/cal3d/model.pyx":925 */
      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/model.pyx":928 */
      __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/model.pyx":930 */
      glBegin(GL_POLYGON);

      /* "/home/jiba/src/soya/cal3d/model.pyx":931 */
      __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/model.pyx":932 */
        glVertex3fv((__pyx_v_face_data + (__pyx_v_j * 3)));
        __pyx_L32:;
      }
      __pyx_L33:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":933 */
      glEnd();

      /* "/home/jiba/src/soya/cal3d/model.pyx":935 */
      __pyx_2 = (__pyx_v_nb_points[1]);
      if (__pyx_2) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":936 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[0])));

        /* "/home/jiba/src/soya/cal3d/model.pyx":937 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[1])));

        /* "/home/jiba/src/soya/cal3d/model.pyx":938 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter1[2])));

        /* "/home/jiba/src/soya/cal3d/model.pyx":939 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L34;
      }
      __pyx_L34:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":941 */
      __pyx_1 = (__pyx_v_nb_points[2]);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":942 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[0])));

        /* "/home/jiba/src/soya/cal3d/model.pyx":943 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[1])));

        /* "/home/jiba/src/soya/cal3d/model.pyx":944 */
        chunk_add_double(__pyx_v_chunk2,((double )(__pyx_v_inter2[2])));

        /* "/home/jiba/src/soya/cal3d/model.pyx":945 */
        __pyx_v_nb_inter = (__pyx_v_nb_inter + 1);
        goto __pyx_L35;
      }
      __pyx_L35:;
      __pyx_L28:;
    }
    __pyx_L29:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":947 */
    glLoadMatrixf(__pyx_v_body->__pyx_base._render_matrix);

    /* "/home/jiba/src/soya/cal3d/model.pyx":949 */
    glEndList();

    /* "/home/jiba/src/soya/cal3d/model.pyx":952 */
    glDisable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/cal3d/model.pyx":953 */
    glLoadIdentity();

    /* "/home/jiba/src/soya/cal3d/model.pyx":954 */
    gluTessBeginPolygon(__pyx_v_5_soya_SHADOW_TESS,0);

    /* "/home/jiba/src/soya/cal3d/model.pyx":955 */
    gluTessBeginContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/cal3d/model.pyx":956 */
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb_inter; ++__pyx_v_i) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":957 */
      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_L36:;
    }
    __pyx_L37:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":958 */
    gluTessEndContour(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/cal3d/model.pyx":959 */
    gluTessEndPolygon(__pyx_v_5_soya_SHADOW_TESS);

    /* "/home/jiba/src/soya/cal3d/model.pyx":960 */
    glLoadMatrixf(__pyx_v_body->__pyx_base._render_matrix);

    /* "/home/jiba/src/soya/cal3d/model.pyx":961 */
    glEnable(GL_CULL_FACE);

    /* "/home/jiba/src/soya/cal3d/model.pyx":965 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/cal3d/model.pyx":966 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/cal3d/model.pyx":967 */
    glCallList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST);

    /* "/home/jiba/src/soya/cal3d/model.pyx":971 */
    __pyx_v_i = __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb;

    /* "/home/jiba/src/soya/cal3d/model.pyx":972 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":973 */
    while (1) {
      __pyx_L38:;
      __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_L39:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":975 */
    __pyx_v_5_soya_SHADOW_TESS_CHUNK->nb = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":977 */
    drop_chunk(__pyx_v_chunk);

    /* "/home/jiba/src/soya/cal3d/model.pyx":978 */
    drop_chunk(__pyx_v_chunk2);
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/cal3d/model.pyx":983 */
    glBegin(GL_QUADS);

    /* "/home/jiba/src/soya/cal3d/model.pyx":984 */
    __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/model.pyx":985 */
      __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/model.pyx":986 */
        for (__pyx_v_k = 0; __pyx_v_k < 3; ++__pyx_v_k) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":987 */
          __pyx_v_neighbor_face = (__pyx_v_submesh->_face_neighbors[((3 * __pyx_v_i) + __pyx_v_k)]);

          /* "/home/jiba/src/soya/cal3d/model.pyx":991 */
          __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/model.pyx":993 */
            __pyx_2 = ((__pyx_v_facesides[__pyx_v_i]) == __pyx_e_5_soya_FACE_LIGHT_BACK);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/model.pyx":994 */
              __pyx_v_p1 = __pyx_v_k;

              /* "/home/jiba/src/soya/cal3d/model.pyx":995 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p2 = (__pyx_v_k + 1);
                goto __pyx_L47;
              }
              /*else*/ {
                __pyx_v_p2 = 0;
              }
              __pyx_L47:;
              goto __pyx_L46;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/model.pyx":998 */
              __pyx_2 = (__pyx_v_k < 2);
              if (__pyx_2) {
                __pyx_v_p1 = (__pyx_v_k + 1);
                goto __pyx_L48;
              }
              /*else*/ {
                __pyx_v_p1 = 0;
              }
              __pyx_L48:;

              /* "/home/jiba/src/soya/cal3d/model.pyx":1000 */
              __pyx_v_p2 = __pyx_v_k;
            }
            __pyx_L46:;

            /* "/home/jiba/src/soya/cal3d/model.pyx":1002 */
            __pyx_v_coord_ptr = (__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_p1)])));

            /* "/home/jiba/src/soya/cal3d/model.pyx":1003 */
            glVertex3fv(__pyx_v_coord_ptr);

            /* "/home/jiba/src/soya/cal3d/model.pyx":1006 */
            __pyx_2 = (__pyx_v_light->_w == 0.0);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/model.pyx":1007 */
              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/model.pyx":1009 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/cal3d/model.pyx":1010 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/cal3d/model.pyx":1011 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/cal3d/model.pyx":1012 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/cal3d/model.pyx":1013 */
              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/model.pyx":1015 */
            __pyx_v_coord_ptr = (__pyx_v_coords + (3 * (__pyx_v_submesh->_faces[((3 * __pyx_v_i) + __pyx_v_p2)])));

            /* "/home/jiba/src/soya/cal3d/model.pyx":1018 */
            __pyx_2 = (__pyx_v_light->_w == 0.0);
            if (__pyx_2) {

              /* "/home/jiba/src/soya/cal3d/model.pyx":1019 */
              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_L50;
            }
            /*else*/ {

              /* "/home/jiba/src/soya/cal3d/model.pyx":1021 */
              (__pyx_v_coord[0]) = ((__pyx_v_coord_ptr[0]) - (__pyx_v_light->_data[0]));

              /* "/home/jiba/src/soya/cal3d/model.pyx":1022 */
              (__pyx_v_coord[1]) = ((__pyx_v_coord_ptr[1]) - (__pyx_v_light->_data[1]));

              /* "/home/jiba/src/soya/cal3d/model.pyx":1023 */
              (__pyx_v_coord[2]) = ((__pyx_v_coord_ptr[2]) - (__pyx_v_light->_data[2]));

              /* "/home/jiba/src/soya/cal3d/model.pyx":1024 */
              vector_normalize(__pyx_v_coord);

              /* "/home/jiba/src/soya/cal3d/model.pyx":1025 */
              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_L50:;

            /* "/home/jiba/src/soya/cal3d/model.pyx":1027 */
            glVertex3fv(__pyx_v_coord_ptr);
            goto __pyx_L45;
          }
          __pyx_L45:;
          __pyx_L43:;
        }
        __pyx_L44:;
        goto __pyx_L42;
      }
      __pyx_L42:;
      __pyx_L40:;
    }
    __pyx_L41:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1030 */
    glEnd();

    /* "/home/jiba/src/soya/cal3d/model.pyx":1031 */
    glEndList();

    /* "/home/jiba/src/soya/cal3d/model.pyx":1034 */
    glFrontFace(GL_CCW);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1035 */
    glStencilOp(GL_KEEP,GL_KEEP,GL_DECR);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1036 */
    glCallList(__pyx_v_5_soya_SHADOW_DISPLAY_LIST);
  }
  __pyx_L11:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1039 */
  __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._AnimatedModel._shadow2");
  __pyx_L0:;
  Py_DECREF(__pyx_v_joined);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF((PyObject *)__pyx_v_light);
  return __pyx_r;
}

static void __pyx_f_5_soya_14_AnimatedModel__raypick(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  struct __pyx_obj_5_soya__Body *__pyx_v_body;
  struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_da;
  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_raypickable);
  __pyx_v_body = Py_None; Py_INCREF((PyObject *) __pyx_v_body);
  __pyx_v_da = Py_None; Py_INCREF((PyObject *) __pyx_v_da);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1047 */
  Py_INCREF(((PyObject *)((PyObject *)__pyx_v_raypickable)));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_body));
  __pyx_v_body = ((PyObject *)((PyObject *)__pyx_v_raypickable));

  /* "/home/jiba/src/soya/cal3d/model.pyx":1048 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_body->_data), __pyx_ptype_5_soya__AnimatedModelData)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1048; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_body->_data));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_da));
  __pyx_v_da = ((PyObject *)__pyx_v_body->_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1050 */
  __pyx_1 = (__pyx_v_da->_vertex_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_da->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(__pyx_v_da,1);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1051 */
  __pyx_1 = (__pyx_v_da->_face_plane_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_da->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_da);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1059 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1060 */
  __pyx_1 = ((__pyx_v_self->_sphere[3]) > 0.0);
  if (__pyx_1) {
    __pyx_1 = (sphere_raypick(__pyx_v_raydata,__pyx_v_self->_sphere) == 0);
  }
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1062 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1063 */
  __pyx_v_plane = __pyx_v_da->_face_planes;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1064 */
  __pyx_v_ptrf = __pyx_v_da->_coords;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1065 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1065; goto __pyx_L1;}
  for (;;) {
    __pyx_L5:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1065; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1065; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1066 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1066; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_da->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1066; 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 = 1066; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":1067 */
      __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/model.pyx":1068 */
        __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/model.pyx":1070 */
        __pyx_5 = (__pyx_v_r != 0);
        if (__pyx_5) {

          /* "/home/jiba/src/soya/cal3d/model.pyx":1071 */
          __pyx_v_root_z = ((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._distance_out(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_z);

          /* "/home/jiba/src/soya/cal3d/model.pyx":1072 */
          __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/model.pyx":1073 */
            __pyx_v_data->result = __pyx_v_z;

            /* "/home/jiba/src/soya/cal3d/model.pyx":1074 */
            __pyx_v_data->root_result = __pyx_v_root_z;

            /* "/home/jiba/src/soya/cal3d/model.pyx":1075 */
            Py_INCREF(((PyObject *)__pyx_v_body));
            Py_DECREF((PyObject *)((PyObject *)__pyx_v_data->result_coordsyst));
            __pyx_v_data->result_coordsyst = ((PyObject *)__pyx_v_body);

            /* "/home/jiba/src/soya/cal3d/model.pyx":1076 */
            __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_L12;
            }
            __pyx_5 = (__pyx_v_r == __pyx_e_5_soya_RAYPICK_INDIRECT);
            if (__pyx_5) {

              /* "/home/jiba/src/soya/cal3d/model.pyx":1078 */
              __pyx_5 = (__pyx_v_self->_option & __pyx_e_5_soya_CAL3D_DOUBLE_SIDED);
              if (__pyx_5) {

                /* "/home/jiba/src/soya/cal3d/model.pyx":1079 */
                (__pyx_v_data->normal[0]) = (-((__pyx_v_plane + (4 * __pyx_v_j))[0]));

                /* "/home/jiba/src/soya/cal3d/model.pyx":1080 */
                (__pyx_v_data->normal[1]) = (-((__pyx_v_plane + (4 * __pyx_v_j))[1]));

                /* "/home/jiba/src/soya/cal3d/model.pyx":1081 */
                (__pyx_v_data->normal[2]) = (-((__pyx_v_plane + (4 * __pyx_v_j))[2]));
                goto __pyx_L13;
              }
              /*else*/ {
                memcpy(__pyx_v_data->normal,(__pyx_v_plane + (4 * __pyx_v_j)),(3 * (sizeof(float ))));
              }
              __pyx_L13:;
              goto __pyx_L12;
            }
            __pyx_L12:;

            /* "/home/jiba/src/soya/cal3d/model.pyx":1083 */
            vector_normalize(__pyx_v_data->normal);
            goto __pyx_L11;
          }
          __pyx_L11:;
          goto __pyx_L10;
        }
        __pyx_L10:;
        __pyx_L8:;
      }
      __pyx_L9:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1085 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1086 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1087 */
    __pyx_v_plane = (__pyx_v_plane + (__pyx_v_submesh->_nb_faces * 4));
  }
  __pyx_L6:;
  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._AnimatedModel._raypick");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF((PyObject *)__pyx_v_da);
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
}

static int __pyx_f_5_soya_14_AnimatedModel__raypick_b(struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_self,struct __pyx_obj_5_soya_RaypickData *__pyx_v_data,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_raypickable) {
  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;
  struct __pyx_obj_5_soya__Body *__pyx_v_body;
  struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_da;
  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_raypickable);
  __pyx_v_submesh = Py_None; Py_INCREF((PyObject *) __pyx_v_submesh);
  __pyx_v_body = Py_None; Py_INCREF((PyObject *) __pyx_v_body);
  __pyx_v_da = Py_None; Py_INCREF((PyObject *) __pyx_v_da);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1096 */
  Py_INCREF(((PyObject *)((PyObject *)__pyx_v_raypickable)));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_body));
  __pyx_v_body = ((PyObject *)((PyObject *)__pyx_v_raypickable));

  /* "/home/jiba/src/soya/cal3d/model.pyx":1097 */
  if (!__Pyx_TypeTest(((PyObject *)__pyx_v_body->_data), __pyx_ptype_5_soya__AnimatedModelData)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1097; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_body->_data));
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_da));
  __pyx_v_da = ((PyObject *)__pyx_v_body->_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1099 */
  __pyx_1 = (__pyx_v_da->_vertex_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_da->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(__pyx_v_da,1);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1100 */
  __pyx_1 = (__pyx_v_da->_face_plane_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_da->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_face_planes(__pyx_v_da);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1103 */
  __pyx_v_raydata = ((struct __pyx_vtabstruct_5_soya__Body *)__pyx_v_body->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_data(((struct __pyx_obj_5_soya_CoordSyst *)__pyx_v_body),__pyx_v_data);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1104 */
  __pyx_1 = ((__pyx_v_self->_sphere[3]) > 0.0);
  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_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1106 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1107 */
  __pyx_v_plane = __pyx_v_da->_face_planes;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1108 */
  __pyx_v_ptrf = __pyx_v_da->_coords;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1109 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1109; goto __pyx_L1;}
  for (;;) {
    __pyx_L5:;
    __pyx_3 = PyIter_Next(__pyx_2);
    if (!__pyx_3) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1109; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1109; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1110 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1110; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_da->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1110; 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 = 1110; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":1111 */
      __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/model.pyx":1112 */
        __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/model.pyx":1114 */
  __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._AnimatedModel._raypick_b");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF((PyObject *)__pyx_v_da);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_raypickable);
  return __pyx_r;
}

static void __pyx_f_5_soya_14_AnimatedModel__collect_raypickables(struct __pyx_obj_5_soya__AnimatedModel *__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/cal3d/model.pyx":1117 */
  __pyx_1 = ((__pyx_v_self->_sphere[3]) < 0.0);
  if (!__pyx_1) {
    __pyx_1 = (sphere_distance_sphere(__pyx_v_sphere,__pyx_v_self->_sphere) < 0.0);
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":1118 */
    chunk_add_ptr(__pyx_v_items,((void (*))((PyObject *)__pyx_v_parent)));
    goto __pyx_L2;
  }
  __pyx_L2:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModel._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static PyObject *__pyx_k356p;
static PyObject *__pyx_k357p;

static char (__pyx_k356[]) = "error CalModel_Create";
static char (__pyx_k357[]) = "CalModel_Create failed: %s";

static int __pyx_f_5_soya_18_AnimatedModelData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_18_AnimatedModelData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_5_soya__Body *__pyx_v_body = 0;
  struct __pyx_obj_5_soya__AnimatedModel *__pyx_v_model = 0;
  PyObject *__pyx_v_attached_meshes = 0;
  PyObject *__pyx_v_nb;
  PyObject *__pyx_v_i;
  int __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  long __pyx_5;
  long __pyx_6;
  int __pyx_7;
  static char *__pyx_argnames[] = {"body","model","attached_meshes",0};
  __pyx_v_attached_meshes = __pyx_k160;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_body, &__pyx_v_model, &__pyx_v_attached_meshes)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  Py_INCREF((PyObject *)__pyx_v_model);
  Py_INCREF(__pyx_v_attached_meshes);
  __pyx_v_nb = Py_None; Py_INCREF(__pyx_v_nb);
  __pyx_v_i = Py_None; Py_INCREF(__pyx_v_i);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_body), __pyx_ptype_5_soya__Body, 1, "body")) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1134; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_model), __pyx_ptype_5_soya__AnimatedModel, 1, "model")) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1134; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":1135 */
  Py_INCREF(((PyObject *)__pyx_v_body));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_body));
  ((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_body = ((PyObject *)__pyx_v_body);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1136 */
  Py_INCREF(((PyObject *)__pyx_v_model));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_model));
  ((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_model = ((PyObject *)__pyx_v_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1138 */
  ((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_cal_model = CalModel_New(__pyx_v_model->_core_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1139 */
  __pyx_1 = (((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_cal_model == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":1140 */
    if (__Pyx_PrintItem(__pyx_k356p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1140; goto __pyx_L1;}
    __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1140; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1140; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1140; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/model.pyx":1141 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1141; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1141; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k357p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1141; 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 = 1141; 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 = 1141; 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 = 1141; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1143 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1143; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_attached_meshes);
  ((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_attached_meshes = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1144 */
  __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1144; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_attached_coordsysts);
  ((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_attached_coordsysts = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1145 */
  __pyx_4 = PyInt_FromLong(CalCoreModel_GetCoreMeshCount(__pyx_v_model->_core_model)); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1145; goto __pyx_L1;}
  Py_DECREF(__pyx_v_nb);
  __pyx_v_nb = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1146 */
  __pyx_6 = PyInt_AsLong(__pyx_v_nb); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1146; goto __pyx_L1;}
  for (__pyx_5 = 0; __pyx_5 < __pyx_6; ++__pyx_5) {
    __pyx_2 = PyInt_FromLong(__pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1146; goto __pyx_L1;}
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_2;
    __pyx_2 = 0;
    __pyx_3 = PyObject_GetAttr(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_attached_meshes, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1146; goto __pyx_L1;}
    __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1146; goto __pyx_L1;}
    __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1146; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1146; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1147 */
  __pyx_1 = __pyx_v_attached_meshes == Py_None;
  __pyx_7 = (!__pyx_1);
  if (__pyx_7) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._attach(((struct __pyx_obj_5_soya__Model *)((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)),__pyx_v_attached_meshes);
    goto __pyx_L5;
  }
  /*else*/ {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_attach_all(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self));
  }
  __pyx_L5:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya._AnimatedModelData.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_nb);
  Py_DECREF(__pyx_v_i);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
  Py_DECREF((PyObject *)__pyx_v_model);
  Py_DECREF(__pyx_v_attached_meshes);
  return __pyx_r;
}

static void __pyx_f_5_soya_18_AnimatedModelData___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_18_AnimatedModelData___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1151 */
  CalModel_Delete(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_cal_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1152 */
  __pyx_1 = (((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_coords != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_coords);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1153 */
  __pyx_1 = (((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_vnormals != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_vnormals);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1154 */
  __pyx_1 = (((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_face_planes != 0);
  if (__pyx_1) {
    free(((struct __pyx_obj_5_soya__AnimatedModelData *)__pyx_v_self)->_face_planes);
    goto __pyx_L4;
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._AnimatedModelData.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_18_AnimatedModelData___getcstate__(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1157 */
  __pyx_1 = PyTuple_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1157; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_body));
  PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_self->_body));
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_model));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_self->_model));
  Py_INCREF(__pyx_v_self->_attached_meshes);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_self->_attached_meshes);
  Py_INCREF(__pyx_v_self->_attached_coordsysts);
  PyTuple_SET_ITEM(__pyx_1, 3, __pyx_v_self->_attached_coordsysts);
  __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._AnimatedModelData.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k358p;
static PyObject *__pyx_k359p;
static PyObject *__pyx_k360p;
static PyObject *__pyx_k361p;

static char (__pyx_k358[]) = "erreur CalModel_Create";
static char (__pyx_k359[]) = "CalModel_Create failed: %s";
static char (__pyx_k360[]) = "erreur CalModel_AttachMesh";
static char (__pyx_k361[]) = "CalModel_AttachMesh failed: %s";

static void __pyx_f_5_soya_18_AnimatedModelData___setcstate__(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_cstate) {
  PyObject *__pyx_v_i;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  long __pyx_6;
  int __pyx_7;
  int __pyx_8;
  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/model.pyx":1160 */
  __pyx_1 = __Pyx_UnpackItem(__pyx_v_cstate, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Body)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_body));
  __pyx_v_self->_body = __pyx_1;
  __pyx_1 = 0;
  __pyx_2 = __Pyx_UnpackItem(__pyx_v_cstate, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__AnimatedModel)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_model));
  __pyx_v_self->_model = __pyx_2;
  __pyx_2 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_v_cstate, 2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_attached_meshes);
  __pyx_v_self->_attached_meshes = __pyx_3;
  __pyx_3 = 0;
  __pyx_4 = __Pyx_UnpackItem(__pyx_v_cstate, 3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}
  Py_DECREF(__pyx_v_self->_attached_coordsysts);
  __pyx_v_self->_attached_coordsysts = __pyx_4;
  __pyx_4 = 0;
  if (__Pyx_EndUnpack(__pyx_v_cstate, 4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1160; goto __pyx_L1;}

  /* "/home/jiba/src/soya/cal3d/model.pyx":1162 */
  __pyx_v_self->_cal_model = CalModel_New(__pyx_v_self->_model->_core_model);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1163 */
  __pyx_5 = (__pyx_v_self->_cal_model == 0);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":1164 */
    if (__Pyx_PrintItem(__pyx_k358p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1164; goto __pyx_L1;}
    __pyx_1 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1164; goto __pyx_L1;}
    if (__Pyx_PrintItem(__pyx_1) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1164; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1164; goto __pyx_L1;}

    /* "/home/jiba/src/soya/cal3d/model.pyx":1165 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1165; goto __pyx_L1;}
    __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1165; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k359p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1165; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1165; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_4);
    __pyx_4 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1165; 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[24]; __pyx_lineno = 1165; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1167 */
  __pyx_5 = PyObject_Length(__pyx_v_self->_attached_meshes); if (__pyx_5 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1167; goto __pyx_L1;}
  for (__pyx_6 = 0; __pyx_6 < __pyx_5; ++__pyx_6) {
    __pyx_4 = PyInt_FromLong(__pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1167; goto __pyx_L1;}
    Py_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1168 */
    __pyx_2 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1168; goto __pyx_L1;}
    __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1168; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_7) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1168; goto __pyx_L1;}
    __pyx_7 = __pyx_7 == 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    if (__pyx_7) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":1169 */
      __pyx_7 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1169; goto __pyx_L1;}
      __pyx_8 = (CalModel_AttachMesh(__pyx_v_self->_cal_model,__pyx_7) == 0);
      if (__pyx_8) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":1170 */
        if (__Pyx_PrintItem(__pyx_k360p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1170; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1170; goto __pyx_L1;}
        if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1170; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1170; goto __pyx_L1;}

        /* "/home/jiba/src/soya/cal3d/model.pyx":1171 */
        __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1171; goto __pyx_L1;}
        __pyx_2 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1171; goto __pyx_L1;}
        __pyx_1 = PyNumber_Remainder(__pyx_k361p, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1171; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1171; goto __pyx_L1;}
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1);
        __pyx_1 = 0;
        __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1171; goto __pyx_L1;}
        Py_DECREF(__pyx_4); __pyx_4 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __Pyx_Raise(__pyx_2, 0, 0);
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1171; goto __pyx_L1;}
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
    __pyx_L3:;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1172 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData.__setcstate__");
  __pyx_L0:;
  Py_DECREF(__pyx_v_i);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_cstate);
}

static void __pyx_f_5_soya_18_AnimatedModelData__build_submeshes(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1175 */
  __pyx_1 = (!(__pyx_v_self->_model->_option & __pyx_e_5_soya_CAL3D_INITED));
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self->_model);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1177 */
  __pyx_1 = (__pyx_v_self->_coords != 0);
  if (__pyx_1) {
    free(__pyx_v_self->_coords);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1178 */
  __pyx_1 = (__pyx_v_self->_vnormals != 0);
  if (__pyx_1) {
    free(__pyx_v_self->_vnormals);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1179 */
  __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/model.pyx":1181 */
  __pyx_v_self->_coords = ((GLfloat (*))malloc(((__pyx_v_self->_model->_nb_vertices * 3) * (sizeof(GLfloat )))));

  /* "/home/jiba/src/soya/cal3d/model.pyx":1182 */
  __pyx_v_self->_vnormals = ((GLfloat (*))malloc(((__pyx_v_self->_model->_nb_vertices * 3) * (sizeof(GLfloat )))));

  /* "/home/jiba/src/soya/cal3d/model.pyx":1183 */
  __pyx_v_self->_face_planes = ((GLfloat (*))malloc(((__pyx_v_self->_model->_nb_faces * 4) * (sizeof(GLfloat )))));

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

static void __pyx_f_5_soya_18_AnimatedModelData__build_face_planes(struct __pyx_obj_5_soya__AnimatedModelData *__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/model.pyx":1190 */
  __pyx_1 = (__pyx_v_self->_vertex_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(__pyx_v_self,1);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1192 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1193 */
  __pyx_v_plane = __pyx_v_self->_face_planes;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1194 */
  __pyx_v_ptrf = __pyx_v_self->_coords;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1195 */
  __pyx_2 = PyObject_GetIter(__pyx_v_self->_model->_submeshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1195; 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 = 1195; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya__Cal3dSubMesh)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1195; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_submesh));
    __pyx_v_submesh = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1196 */
    __pyx_3 = PyInt_FromLong(__pyx_v_submesh->_mesh); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1196; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1196; 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 = 1196; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/cal3d/model.pyx":1197 */
      __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/model.pyx":1198 */
        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/model.pyx":1201 */
    __pyx_v_i = (__pyx_v_i + 1);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1202 */
    __pyx_v_ptrf = (__pyx_v_ptrf + (__pyx_v_submesh->_nb_vertices * 3));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1203 */
    __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/model.pyx":1205 */
  __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._AnimatedModelData._build_face_planes");
  __pyx_L0:;
  Py_DECREF(__pyx_v_submesh);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_meshes;

static PyObject *__pyx_k362p;
static PyObject *__pyx_k363p;

static char (__pyx_k362[]) = "erreur CalModel_AttachMesh";
static char (__pyx_k363[]) = "CalModel_AttachMesh failed: %s";

static void __pyx_f_5_soya_18_AnimatedModelData__attach(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_mesh_names) {
  int __pyx_v_i;
  PyObject *__pyx_v_mesh_name;
  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_mesh_names);
  __pyx_v_mesh_name = Py_None; Py_INCREF(__pyx_v_mesh_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1209 */
  __pyx_1 = PyObject_GetIter(__pyx_v_mesh_names); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1209; 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 = 1209; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_mesh_name);
    __pyx_v_mesh_name = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1210 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_model), __pyx_n_meshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1210; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_v_mesh_name); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1210; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1210; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_i = __pyx_4;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1211 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1211; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1211; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1211; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1211; 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/model.pyx":1212 */
      __pyx_4 = (CalModel_AttachMesh(__pyx_v_self->_cal_model,__pyx_v_i) == 0);
      if (__pyx_4) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":1213 */
        if (__Pyx_PrintItem(__pyx_k362p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1213; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1213; goto __pyx_L1;}
        if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1213; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1213; goto __pyx_L1;}

        /* "/home/jiba/src/soya/cal3d/model.pyx":1214 */
        __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1214; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1214; goto __pyx_L1;}
        __pyx_5 = PyNumber_Remainder(__pyx_k363p, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1214; 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 = 1214; 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[24]; __pyx_lineno = 1214; 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[24]; __pyx_lineno = 1214; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":1216 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1216; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1216; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_self->_attached_meshes, __pyx_3, __pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1216; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1217 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._attach");
  __pyx_L0:;
  Py_DECREF(__pyx_v_mesh_name);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_names);
}

static PyObject *__pyx_k364p;
static PyObject *__pyx_k365p;

static char (__pyx_k364[]) = "erreur CalModel_DetachMesh";
static char (__pyx_k365[]) = "CalModel_DetachMesh failed: %s";

static void __pyx_f_5_soya_18_AnimatedModelData__detach(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_mesh_names) {
  int __pyx_v_i;
  PyObject *__pyx_v_mesh_name;
  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_mesh_names);
  __pyx_v_mesh_name = Py_None; Py_INCREF(__pyx_v_mesh_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1221 */
  __pyx_1 = PyObject_GetIter(__pyx_v_mesh_names); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1221; 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 = 1221; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_mesh_name);
    __pyx_v_mesh_name = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1222 */
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_model), __pyx_n_meshes); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1222; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_2, __pyx_v_mesh_name); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1222; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1222; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_i = __pyx_4;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1223 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1223; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1223; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1223; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1223; 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/model.pyx":1224 */
      __pyx_4 = (CalModel_DetachMesh(__pyx_v_self->_cal_model,__pyx_v_i) == 0);
      if (__pyx_4) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":1225 */
        if (__Pyx_PrintItem(__pyx_k364p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1225; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1225; goto __pyx_L1;}
        if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1225; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1225; goto __pyx_L1;}

        /* "/home/jiba/src/soya/cal3d/model.pyx":1226 */
        __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1226; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1226; goto __pyx_L1;}
        __pyx_5 = PyNumber_Remainder(__pyx_k365p, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1226; 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 = 1226; 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[24]; __pyx_lineno = 1226; 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[24]; __pyx_lineno = 1226; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":1227 */
      __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1227; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1227; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_self->_attached_meshes, __pyx_3, __pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1227; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1228 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._detach");
  __pyx_L0:;
  Py_DECREF(__pyx_v_mesh_name);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_names);
}

static PyObject *__pyx_k366p;
static PyObject *__pyx_k367p;

static char (__pyx_k366[]) = "erreur CalModel_AttachMesh";
static char (__pyx_k367[]) = "CalModel_AttachMesh failed: %s";

static void __pyx_f_5_soya_18_AnimatedModelData__attach_all(struct __pyx_obj_5_soya__AnimatedModelData *__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/model.pyx":1232 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_attached_meshes); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1232; goto __pyx_L1;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":1233 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1233; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1233; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1233; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_3, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1233; 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/model.pyx":1234 */
      __pyx_4 = (CalModel_AttachMesh(__pyx_v_self->_cal_model,__pyx_v_i) == 0);
      if (__pyx_4) {

        /* "/home/jiba/src/soya/cal3d/model.pyx":1235 */
        if (__Pyx_PrintItem(__pyx_k366p) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1235; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1235; goto __pyx_L1;}
        if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1235; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1235; goto __pyx_L1;}

        /* "/home/jiba/src/soya/cal3d/model.pyx":1236 */
        __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1236; goto __pyx_L1;}
        __pyx_3 = PyString_FromString(CalError_GetLastErrorDescription()); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1236; goto __pyx_L1;}
        __pyx_5 = PyNumber_Remainder(__pyx_k367p, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1236; 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 = 1236; 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[24]; __pyx_lineno = 1236; 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[24]; __pyx_lineno = 1236; goto __pyx_L1;}
        goto __pyx_L5;
      }
      __pyx_L5:;

      /* "/home/jiba/src/soya/cal3d/model.pyx":1237 */
      __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1237; goto __pyx_L1;}
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1237; goto __pyx_L1;}
      if (PyObject_SetItem(__pyx_v_self->_attached_meshes, __pyx_3, __pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1237; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1238 */
  ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_submeshes(__pyx_v_self);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._attach_all");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static int __pyx_f_5_soya_18_AnimatedModelData__is_attached(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_mesh_name) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_mesh_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1241 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->_model), __pyx_n_meshes); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1241; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_1, __pyx_v_mesh_name); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1241; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyObject_GetItem(__pyx_v_self->_attached_meshes, __pyx_2); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1241; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_3 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1241; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._is_attached");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_mesh_name);
  return __pyx_r;
}

static PyObject *__pyx_k368p;

static char (__pyx_k368[]) = "No bone named %s !";

static void __pyx_f_5_soya_18_AnimatedModelData__attach_to_bone(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst,PyObject *__pyx_v_bone_name) {
  int __pyx_v_i;
  char (*__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_coordsyst);
  Py_INCREF(__pyx_v_bone_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1245 */
  __pyx_1 = PyString_AsString(__pyx_v_bone_name); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1245; goto __pyx_L1;}
  __pyx_v_i = CalCoreSkeleton_GetCoreBoneId(CalCoreModel_GetCoreSkeleton(__pyx_v_self->_model->_core_model),__pyx_1);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1246 */
  __pyx_2 = (__pyx_v_i == (-1));
  if (__pyx_2) {
    __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1246; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k368p, __pyx_v_bone_name); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1246; goto __pyx_L1;}
    __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1246; 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 = 1246; 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 = 1246; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1247 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_self->_attached_coordsysts, __pyx_n_append); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1247; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(__pyx_v_i); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1247; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(1); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1247; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(3); if (!__pyx_6) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1247; 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_5);
  PyTuple_SET_ITEM(__pyx_6, 2, __pyx_4);
  __pyx_5 = 0;
  __pyx_4 = 0;
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1247; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_6);
  __pyx_6 = 0;
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1247; 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_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  Py_XDECREF(__pyx_6);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._attach_to_bone");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
  Py_DECREF(__pyx_v_bone_name);
}

static void __pyx_f_5_soya_18_AnimatedModelData__detach_from_bone(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,struct __pyx_obj_5_soya_CoordSyst *__pyx_v_coordsyst) {
  int __pyx_v_i;
  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_coordsyst);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1251 */
  __pyx_1 = PyObject_Length(__pyx_v_self->_attached_coordsysts); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1251; goto __pyx_L1;}
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":1252 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1252; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_self->_attached_coordsysts, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1252; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1252; goto __pyx_L1;}
    __pyx_4 = PyObject_GetItem(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1252; 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/model.pyx":1253 */
      __pyx_3 = PyInt_FromLong(__pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1253; goto __pyx_L1;}
      if (PyObject_DelItem(__pyx_v_self->_attached_coordsysts, __pyx_3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1253; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;

      /* "/home/jiba/src/soya/cal3d/model.pyx":1254 */
      goto __pyx_L3;
      goto __pyx_L4;
    }
    __pyx_L4:;
    __pyx_L2:;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._detach_from_bone");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_coordsyst);
}

static PyObject *__pyx_f_5_soya_18_AnimatedModelData__get_attached_meshes(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_self->_attached_meshes);
  __pyx_r = __pyx_v_self->_attached_meshes;
  goto __pyx_L0;

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

static PyObject *__pyx_f_5_soya_18_AnimatedModelData__get_attached_coordsysts(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_self->_attached_coordsysts);
  __pyx_r = __pyx_v_self->_attached_coordsysts;
  goto __pyx_L0;

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

static void __pyx_f_5_soya_18_AnimatedModelData__animate_blend_cycle(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_animation_name,float __pyx_v_weight,float __pyx_v_fade_in) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1262 */
  __pyx_1 = PyObject_GetItem(__pyx_v_self->_model->_animations, __pyx_v_animation_name); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1262; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1262; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  CalMixer_BlendCycle(CalModel_GetMixer(__pyx_v_self->_cal_model),__pyx_2,__pyx_v_weight,__pyx_v_fade_in);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._animate_blend_cycle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
}

static void __pyx_f_5_soya_18_AnimatedModelData__animate_clear_cycle(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_animation_name,float __pyx_v_fade_out) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1265 */
  __pyx_1 = PyObject_GetItem(__pyx_v_self->_model->_animations, __pyx_v_animation_name); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1265; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1265; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  CalMixer_ClearCycle(CalModel_GetMixer(__pyx_v_self->_cal_model),__pyx_2,__pyx_v_fade_out);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._animate_clear_cycle");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
}

static void __pyx_f_5_soya_18_AnimatedModelData__animate_execute_action(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,PyObject *__pyx_v_animation_name,float __pyx_v_fade_in,float __pyx_v_fade_out) {
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_animation_name);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1268 */
  __pyx_1 = PyObject_GetItem(__pyx_v_self->_model->_animations, __pyx_v_animation_name); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1268; goto __pyx_L1;}
  __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1268; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  CalMixer_ExecuteAction(CalModel_GetMixer(__pyx_v_self->_cal_model),__pyx_2,__pyx_v_fade_in,__pyx_v_fade_out);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._animate_execute_action");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_animation_name);
}

static void __pyx_f_5_soya_18_AnimatedModelData__animate_reset(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1273 */
  CalMixer_UpdateAnimation(CalModel_GetMixer(__pyx_v_self->_cal_model),0.0);

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

static void __pyx_f_5_soya_18_AnimatedModelData__set_lod_level(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,float __pyx_v_lod_level) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1280 */
  CalModel_SetLodLevel(__pyx_v_self->_cal_model,__pyx_v_lod_level);

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

static void __pyx_f_5_soya_18_AnimatedModelData__begin_round(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self) {
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1283 */
  __pyx_v_self->_vertex_ok = (__pyx_v_self->_vertex_ok - 1);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1284 */
  __pyx_v_self->_face_plane_ok = (__pyx_v_self->_face_plane_ok - 1);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1286 */
  __pyx_1 = (__pyx_v_self->_vertex_ok <= 0);
  if (__pyx_1) {
    ((struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(__pyx_v_self,0);
    goto __pyx_L2;
  }
  __pyx_L2:;

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

static PyObject *__pyx_n_round_duration;


static void __pyx_f_5_soya_18_AnimatedModelData__advance_time(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,float __pyx_v_proportion) {
  PyObject *__pyx_v_soya;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_soya = Py_None; Py_INCREF(__pyx_v_soya);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1289 */
  __pyx_1 = __Pyx_Import(__pyx_n_soya, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1289; goto __pyx_L1;}
  Py_DECREF(__pyx_v_soya);
  __pyx_v_soya = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1290 */
  __pyx_1 = PyFloat_FromDouble(__pyx_v_self->_delta_time); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1290; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1290; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_v_soya, __pyx_n_MAIN_LOOP); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1290; goto __pyx_L1;}
  __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_round_duration); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1290; 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[24]; __pyx_lineno = 1290; 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[24]; __pyx_lineno = 1290; 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[24]; __pyx_lineno = 1290; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_self->_delta_time = __pyx_5;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._advance_time");
  __pyx_L0:;
  Py_DECREF(__pyx_v_soya);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_18_AnimatedModelData__build_vertices(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,int __pyx_v_vertices) {
  int __pyx_v_bone_id;
  int __pyx_v_option;
  struct CalBone (*__pyx_v_bone);
  struct __pyx_obj_5_soya_CoordSyst *__pyx_v_csyst;
  float (*__pyx_v_trans);
  float (*__pyx_v_quat);
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  int __pyx_5;
  int __pyx_6;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_csyst = Py_None; Py_INCREF((PyObject *) __pyx_v_csyst);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1299 */
  CalModel_Update(__pyx_v_self->_cal_model,__pyx_v_self->_delta_time);

  /* "/home/jiba/src/soya/cal3d/model.pyx":1300 */
  __pyx_v_self->_delta_time = 0.0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1302 */
  __pyx_1 = PyObject_GetIter(__pyx_v_self->_attached_coordsysts); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; 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 = 1302; goto __pyx_L1;}
      break;
    }
    __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; 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[24]; __pyx_lineno = 1302; goto __pyx_L1;}
    __pyx_5 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_bone_id = __pyx_5;
    __pyx_4 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_4) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; goto __pyx_L1;}
    __pyx_6 = PyInt_AsLong(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_v_option = __pyx_6;
    if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1302; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/cal3d/model.pyx":1303 */
    __pyx_v_bone = CalSkeleton_GetBone(CalModel_GetSkeleton(__pyx_v_self->_cal_model),__pyx_v_bone_id);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1304 */
    __pyx_v_quat = CalQuaternion_Get(CalBone_GetRotationAbsolute(__pyx_v_bone));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1305 */
    (__pyx_v_quat[3]) = (-(__pyx_v_quat[3]));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1306 */
    matrix_from_quaternion(__pyx_v_csyst->_matrix,__pyx_v_quat);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1307 */
    __pyx_v_trans = CalVector_Get(CalBone_GetTranslationAbsolute(__pyx_v_bone));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1308 */
    (__pyx_v_csyst->_matrix[12]) = ((GLfloat )(__pyx_v_trans[0]));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1309 */
    (__pyx_v_csyst->_matrix[13]) = ((GLfloat )(__pyx_v_trans[1]));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1310 */
    (__pyx_v_csyst->_matrix[14]) = ((GLfloat )(__pyx_v_trans[2]));

    /* "/home/jiba/src/soya/cal3d/model.pyx":1311 */
    ((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/model.pyx":1313 */
  __pyx_5 = (__pyx_v_vertices == 1);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/cal3d/model.pyx":1314 */
    ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->_build_vertices(__pyx_v_self->_model,__pyx_v_self);

    /* "/home/jiba/src/soya/cal3d/model.pyx":1315 */
    __pyx_v_self->_vertex_ok = 1;
    goto __pyx_L4;
  }
  __pyx_L4:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._build_vertices");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_csyst);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static void __pyx_f_5_soya_18_AnimatedModelData__batch(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._batch(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),__pyx_v_body);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static PyObject *__pyx_n_coord_syst;

static void __pyx_f_5_soya_18_AnimatedModelData__render(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_coord_syst); if (!__pyx_1) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1318; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya__Body)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1318; goto __pyx_L1;}
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._render(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),((struct __pyx_obj_5_soya__Body *)__pyx_1));
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static int __pyx_f_5_soya_18_AnimatedModelData__shadow(struct __pyx_obj_5_soya__AnimatedModelData *__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);
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._shadow(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),__pyx_v_coord_syst,__pyx_v_light);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._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_18_AnimatedModelData__get_box(struct __pyx_obj_5_soya__AnimatedModelData *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  Py_INCREF((PyObject *)__pyx_v_self);
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._get_box(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),__pyx_v_box,__pyx_v_matrix);

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

static void __pyx_f_5_soya_18_AnimatedModelData__raypick(struct __pyx_obj_5_soya__AnimatedModelData *__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);
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),__pyx_v_raypick_data,__pyx_v_raypickable);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._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_18_AnimatedModelData__raypick_b(struct __pyx_obj_5_soya__AnimatedModelData *__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);
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._raypick_b(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),__pyx_v_raypick_data,__pyx_v_raypickable);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._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_18_AnimatedModelData__collect_raypickables(struct __pyx_obj_5_soya__AnimatedModelData *__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);
  ((struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_v_self->_model->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._collect_raypickables(((struct __pyx_obj_5_soya__Model *)__pyx_v_self->_model),__pyx_v_items,__pyx_v_rsphere,__pyx_v_sphere,__pyx_v_parent);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._AnimatedModelData._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

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":33 */
  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_k370p;

static char (__pyx_k370[]) = "<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":36 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->width); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((struct __pyx_obj_5_soya_Glyph *)__pyx_v_self)->height); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 36; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(3); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 36; 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_k370p, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 36; 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_5_Font_6height___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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":53 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 53; 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_5_Font_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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":57 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_width); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 57; 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_k371p;
static PyObject *__pyx_k372p;

static char (__pyx_k371[]) = "os.path";
static char (__pyx_k372[]) = "Cannot open font file %s";

static int __pyx_f_5_soya_5_Font___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_5_Font___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_k161;
  __pyx_v_height = __pyx_k162;
  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":60 */
  __pyx_1 = __Pyx_Import(__pyx_k371p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 60; goto __pyx_L1;}
  Py_DECREF(__pyx_v_os);
  __pyx_v_os = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":61 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_os, __pyx_n_path); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 61; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_exists); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 61; 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 = 61; 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[25]; __pyx_lineno = 61; 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[25]; __pyx_lineno = 61; 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[25]; __pyx_lineno = 61; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 61; goto __pyx_L1;}
    Py_INCREF(__pyx_k372p);
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k372p);
    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[25]; __pyx_lineno = 61; 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[25]; __pyx_lineno = 61; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":63 */
  ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_width = __pyx_v_width;

  /* "/home/jiba/src/soya/text/text.pyx":64 */
  ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height = (__pyx_v_height + 4);

  /* "/home/jiba/src/soya/text/text.pyx":65 */
  ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_pixels_height = (-1);

  /* "/home/jiba/src/soya/text/text.pyx":66 */
  __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 66; 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":67 */
  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_k374p;
static PyObject *__pyx_k375p;
static PyObject *__pyx_k376p;

static char (__pyx_k373[]) = "Real initialization, which is not done in __init__, since we need Soya to be fully\ninitialized to make OpenGL calls.";
static char (__pyx_k374[]) = "Cannot init FreeType";
static char (__pyx_k375[]) = "Cannot open font file %s";
static char (__pyx_k376[]) = "Cannot set char size";

static void __pyx_f_5_soya_5_Font__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":70 */
  __pyx_k373;

  /* "/home/jiba/src/soya/text/text.pyx":72 */
  glGenTextures(1,(&__pyx_v_self->_tex_id));

  /* "/home/jiba/src/soya/text/text.pyx":73 */
  glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":74 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":75 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":76 */
  glBindTexture(GL_TEXTURE_2D,0);

  /* "/home/jiba/src/soya/text/text.pyx":80 */
  __pyx_1 = (__pyx_v_5_soya_library_inited == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":81 */
    __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[25]; __pyx_lineno = 81; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 81; goto __pyx_L1;}
      Py_INCREF(__pyx_k374p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k374p);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 81; 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[25]; __pyx_lineno = 81; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/text/text.pyx":82 */
    __pyx_v_5_soya_library_inited = 1;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":85 */
  __pyx_5 = PyString_AsString(__pyx_v_self->filename); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 85; 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[25]; __pyx_lineno = 85; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 85; goto __pyx_L1;}
    Py_INCREF(__pyx_k375p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k375p);
    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[25]; __pyx_lineno = 85; 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[25]; __pyx_lineno = 85; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/text/text.pyx":86 */
  __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[25]; __pyx_lineno = 86; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 86; goto __pyx_L1;}
    Py_INCREF(__pyx_k376p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k376p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 86; 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[25]; __pyx_lineno = 86; goto __pyx_L1;}
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/text/text.pyx":87 */
  __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_5_Font___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_5_Font___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF(__pyx_v_self);

  /* "/home/jiba/src/soya/text/text.pyx":100 */
  FT_Done_Face(((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_face);

  /* "/home/jiba/src/soya/text/text.pyx":101 */
  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_5_Font__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":106 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_ord); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 106; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 106; 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[25]; __pyx_lineno = 106; 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[25]; __pyx_lineno = 106; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_v_code = __pyx_4;

  /* "/home/jiba/src/soya/text/text.pyx":107 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->_glyphs, __pyx_n_get); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 107; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_code); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 107; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 107; 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[25]; __pyx_lineno = 107; 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[25]; __pyx_lineno = 107; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_glyph));
  __pyx_v_glyph = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":108 */
  __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[25]; __pyx_lineno = 108; goto __pyx_L1;}
    if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 108; 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[25]; __pyx_lineno = 108; goto __pyx_L1;}
    if (PyObject_SetItem(__pyx_v_self->_glyphs, __pyx_3, __pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 108; 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":109 */
  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_k377p;
static PyObject *__pyx_k378p;

static char (__pyx_k377[]) = "Glyph %s does not exist !";
static char (__pyx_k378[]) = " ";

static PyObject *__pyx_f_5_soya_5_Font__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":118 */
  __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":120 */
  __pyx_1 = __pyx_v_self->_rendering;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":120 */
    glEnd();

    /* "/home/jiba/src/soya/text/text.pyx":120 */
    __pyx_v_self->_rendering = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":122 */
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 122; 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[25]; __pyx_lineno = 122; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 122; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_glyph));
  __pyx_v_glyph = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":123 */
  __pyx_v_glyph_index = FT_Get_Char_Index(__pyx_v_self->_face,__pyx_v_code);

  /* "/home/jiba/src/soya/text/text.pyx":125 */
  __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[25]; __pyx_lineno = 125; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_glyph_index); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 125; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k377p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 125; 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 = 125; 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[25]; __pyx_lineno = 125; 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[25]; __pyx_lineno = 125; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/text/text.pyx":126 */
  __pyx_1 = (__pyx_v_self->_face->glyph->format != FT_GLYPH_FORMAT_BITMAP);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":127 */
    FT_Render_Glyph(__pyx_v_self->_face->glyph,FT_RENDER_MODE_NORMAL);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/text/text.pyx":129 */
  __pyx_v_bitmap = __pyx_v_self->_face->glyph->bitmap;

  /* "/home/jiba/src/soya/text/text.pyx":130 */
  __pyx_v_g_height = __pyx_v_bitmap.rows;

  /* "/home/jiba/src/soya/text/text.pyx":132 */
  __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":133 */
    __pyx_v_self->_current_x = 0;

    /* "/home/jiba/src/soya/text/text.pyx":134 */
    __pyx_v_self->_current_y = ((__pyx_v_self->_current_y + __pyx_v_self->_current_height) + 1);

    /* "/home/jiba/src/soya/text/text.pyx":135 */
    __pyx_v_self->_current_height = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/text/text.pyx":137 */
  __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":139 */
  __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":140 */
    ((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":142 */
  if (PyObject_Cmp(__pyx_v_char_, __pyx_k378p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 142; 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":144 */
  __pyx_v_glyph->height = __pyx_v_g_height;

  /* "/home/jiba/src/soya/text/text.pyx":145 */
  __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":146 */
  __pyx_v_glyph->_pixels_y1 = (((float )__pyx_v_self->_current_y) / ((float )__pyx_v_self->_pixels_height));

  /* "/home/jiba/src/soya/text/text.pyx":147 */
  __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":148 */
  __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":149 */
  __pyx_v_glyph->y = (__pyx_v_self->_height - __pyx_v_self->_face->glyph->bitmap_top);

  /* "/home/jiba/src/soya/text/text.pyx":150 */
  __pyx_v_glyph->x = __pyx_v_self->_face->glyph->bitmap_left;

  /* "/home/jiba/src/soya/text/text.pyx":152 */
  __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":153 */
    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":155 */
  __pyx_v_self->_current_x = ((__pyx_v_self->_current_x + __pyx_v_glyph->width) + 5);

  /* "/home/jiba/src/soya/text/text.pyx":157 */
  glBindTexture(GL_TEXTURE_2D,__pyx_v_self->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":158 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":159 */
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

  /* "/home/jiba/src/soya/text/text.pyx":160 */
  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":166 */
  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_max;

static PyObject *__pyx_k379p;

static char (__pyx_k379[]) = "Too many characters in font %s -- no space left on texture.";

static void __pyx_f_5_soya_5_Font__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":169 */
  __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[25]; __pyx_lineno = 176; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k379p, ((PyObject *)__pyx_v_self)); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; goto __pyx_L1;}
    __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_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 176; 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[25]; __pyx_lineno = 176; goto __pyx_L1;}
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/text/text.pyx":179 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_self->_glyphs, __pyx_n_values); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 179; 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[25]; __pyx_lineno = 179; 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[25]; __pyx_lineno = 179; goto __pyx_L1;}
      break;
    }
    if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_5_soya_Glyph)) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 179; goto __pyx_L1;}
    Py_DECREF(((PyObject *)__pyx_v_glyph));
    __pyx_v_glyph = __pyx_4;
    __pyx_4 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":180 */
    __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":181 */
    __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":183 */
  __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":187 */
  __pyx_3 = PyInt_FromLong(__pyx_v_5_soya_MAX_TEXTURE_SIZE); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_self->_pixels_height); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_5 = PyInt_FromLong(0); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(2); if (!__pyx_6) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 187; 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[25]; __pyx_lineno = 187; 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[25]; __pyx_lineno = 187; 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[25]; __pyx_lineno = 187; 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":188 */
    (__pyx_v_self->_pixels[__pyx_v_i]) = 0;
    __pyx_L5:;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/text/text.pyx":190 */
  __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_k380p;

static char (__pyx_k380[]) = "<Font '%s', width = %s, height = %s, %s characters loaded>";

static PyObject *__pyx_f_5_soya_5_Font___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font___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":193 */
  __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_width); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 193; 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[25]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(__pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 193; 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_k380p, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 193; 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_5_Font_get_glyph(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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":196 */
  __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[25]; __pyx_lineno = 196; 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_5_Font_create_glyphs(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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":199 */
  __pyx_1 = PyObject_GetIter(__pyx_v_text); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 199; 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 = 199; 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[25]; __pyx_lineno = 199; 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_k381p;

static char (__pyx_k381[]) = "\n";

static PyObject *__pyx_f_5_soya_5_Font_get_print_size(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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":204 */
  __pyx_v_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":205 */
  __pyx_v_height = ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height;

  /* "/home/jiba/src/soya/text/text.pyx":206 */
  __pyx_v_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":208 */
  __pyx_1 = PyObject_GetIter(__pyx_v_text); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 208; 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 = 208; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_2;
    __pyx_2 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":209 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k381p, &__pyx_3) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 209; goto __pyx_L1;}
    __pyx_3 = __pyx_3 == 0;
    if (__pyx_3) {

      /* "/home/jiba/src/soya/text/text.pyx":210 */
      __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":211 */
      __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":212 */
      __pyx_v_line_width = 0.0;
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":214 */
      __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[25]; __pyx_lineno = 214; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":215 */
      __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":216 */
  __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":218 */
  __pyx_2 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 218; goto __pyx_L1;}
  __pyx_1 = PyFloat_FromDouble(__pyx_v_height); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 218; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 218; 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_k382p;
static PyObject *__pyx_k383p;
static PyObject *__pyx_k384p;
static PyObject *__pyx_k385p;

static char (__pyx_k382[]) = "";
static char (__pyx_k383[]) = "\n";
static char (__pyx_k384[]) = " ";
static char (__pyx_k385[]) = "\n";

static PyObject *__pyx_f_5_soya_5_Font_wordwrap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Font_wordwrap[] = " return a tuple like:\n			( max_line_width, total_height, wrapped text ) \n		";
static PyObject *__pyx_f_5_soya_5_Font_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":228 */
  __pyx_v_height = ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height;

  /* "/home/jiba/src/soya/text/text.pyx":229 */
  __pyx_v_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":230 */
  __pyx_v_max_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":231 */
  __pyx_v_word_start = (-1);

  /* "/home/jiba/src/soya/text/text.pyx":232 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/text/text.pyx":233 */
  __pyx_1 = PyObject_Length(__pyx_v_text); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 233; goto __pyx_L1;}
  __pyx_v_nb = __pyx_1;

  /* "/home/jiba/src/soya/text/text.pyx":234 */
  Py_INCREF(__pyx_k382p);
  Py_DECREF(__pyx_v_text2);
  __pyx_v_text2 = __pyx_k382p;

  /* "/home/jiba/src/soya/text/text.pyx":235 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_nb);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/text/text.pyx":236 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 236; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_text, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 236; 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":237 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k383p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 237; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/text/text.pyx":238 */
      __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":239 */
      __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":240 */
      __pyx_v_line_width = 0.0;

      /* "/home/jiba/src/soya/text/text.pyx":241 */
      __pyx_v_word_start = (-1);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":243 */
      if (PyObject_Cmp(__pyx_v_char_, __pyx_k384p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 243; 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":244 */
      __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[25]; __pyx_lineno = 244; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":245 */
      __pyx_v_line_width = ((__pyx_v_line_width + __pyx_v_glyph->width) + __pyx_v_glyph->x);

      /* "/home/jiba/src/soya/text/text.pyx":246 */
      __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":247 */
        __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

        /* "/home/jiba/src/soya/text/text.pyx":248 */
        __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":249 */
        __pyx_v_line_width = 0.0;

        /* "/home/jiba/src/soya/text/text.pyx":250 */
        __pyx_1 = PyObject_Length(__pyx_v_text2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 250; goto __pyx_L1;}
        __pyx_3 = PySequence_GetSlice(__pyx_v_text, __pyx_1, __pyx_v_word_start); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 250; goto __pyx_L1;}
        __pyx_2 = PyNumber_Add(__pyx_v_text2, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 250; goto __pyx_L1;}
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __pyx_3 = PyNumber_Add(__pyx_2, __pyx_k385p); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 250; 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":251 */
        __pyx_v_i = __pyx_v_word_start;

        /* "/home/jiba/src/soya/text/text.pyx":252 */
        __pyx_v_word_start = (-1);
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/text/text.pyx":253 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":254 */
  __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":255 */
  __pyx_1 = PyObject_Length(__pyx_v_text2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_2 = PySequence_GetSlice(__pyx_v_text, __pyx_1, 0x7fffffff); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_3 = PyNumber_Add(__pyx_v_text2, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 255; 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":256 */
  __pyx_2 = PyFloat_FromDouble(__pyx_v_max_line_width); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 256; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_height); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 256; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 256; 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_k386p;
static PyObject *__pyx_k387p;

static char (__pyx_k386[]) = "\n";
static char (__pyx_k387[]) = " ";

static PyObject *__pyx_f_5_soya_5_Font_wordwrap_line(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Font_wordwrap_line[] = " return a tuple like :\n			( max_line_width, total_height, [ (\'line1\', line1width), (\'line2\', linewidth2) ... ] ) \n		";
static PyObject *__pyx_f_5_soya_5_Font_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":265 */
  __pyx_v_height = ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height;

  /* "/home/jiba/src/soya/text/text.pyx":266 */
  __pyx_v_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":267 */
  __pyx_v_max_line_width = 0.0;

  /* "/home/jiba/src/soya/text/text.pyx":268 */
  __pyx_v_word_start = (-1);

  /* "/home/jiba/src/soya/text/text.pyx":269 */
  __pyx_v_i = 0;

  /* "/home/jiba/src/soya/text/text.pyx":270 */
  __pyx_1 = PyObject_Length(__pyx_v_text); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 270; goto __pyx_L1;}
  __pyx_v_nb = __pyx_1;

  /* "/home/jiba/src/soya/text/text.pyx":271 */
  __pyx_2 = PyList_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 271; goto __pyx_L1;}
  Py_DECREF(__pyx_v_lines);
  __pyx_v_lines = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":272 */
  __pyx_v_line_start = 0;

  /* "/home/jiba/src/soya/text/text.pyx":273 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = (__pyx_v_i < __pyx_v_nb);
    if (!__pyx_1) break;

    /* "/home/jiba/src/soya/text/text.pyx":274 */
    __pyx_2 = PyInt_FromLong(__pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 274; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(__pyx_v_text, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 274; 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":275 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k386p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 275; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/text/text.pyx":276 */
      __pyx_2 = PyObject_GetAttr(__pyx_v_lines, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 276; goto __pyx_L1;}
      __pyx_3 = PySequence_GetSlice(__pyx_v_text, __pyx_v_line_start, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 276; goto __pyx_L1;}
      __pyx_4 = PyFloat_FromDouble(__pyx_v_line_width); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 276; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 276; 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[25]; __pyx_lineno = 276; 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[25]; __pyx_lineno = 276; 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":277 */
      __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":278 */
      __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":279 */
      __pyx_v_line_width = 0.0;

      /* "/home/jiba/src/soya/text/text.pyx":280 */
      __pyx_v_word_start = (-1);

      /* "/home/jiba/src/soya/text/text.pyx":281 */
      __pyx_v_line_start = (__pyx_v_i + 1);
      goto __pyx_L4;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/text/text.pyx":283 */
      if (PyObject_Cmp(__pyx_v_char_, __pyx_k387p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 283; 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":284 */
      __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[25]; __pyx_lineno = 284; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_5;
      __pyx_5 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":285 */
      __pyx_v_char_width = (__pyx_v_glyph->width + __pyx_v_glyph->x);

      /* "/home/jiba/src/soya/text/text.pyx":286 */
      __pyx_v_line_width = (__pyx_v_line_width + __pyx_v_char_width);

      /* "/home/jiba/src/soya/text/text.pyx":287 */
      __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":288 */
        __pyx_2 = PyObject_GetAttr(__pyx_v_lines, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 288; 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[25]; __pyx_lineno = 288; goto __pyx_L1;}
        __pyx_4 = PyFloat_FromDouble((__pyx_v_line_width - __pyx_v_char_width)); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 288; goto __pyx_L1;}
        __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 288; 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[25]; __pyx_lineno = 288; 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[25]; __pyx_lineno = 288; 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":289 */
        __pyx_v_height = (__pyx_v_height + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

        /* "/home/jiba/src/soya/text/text.pyx":290 */
        __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":291 */
        __pyx_v_line_width = 0.0;

        /* "/home/jiba/src/soya/text/text.pyx":292 */
        __pyx_v_line_start = (__pyx_v_word_start + 1);

        /* "/home/jiba/src/soya/text/text.pyx":293 */
        __pyx_v_i = __pyx_v_word_start;

        /* "/home/jiba/src/soya/text/text.pyx":294 */
        __pyx_v_word_start = (-1);
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/text/text.pyx":295 */
    __pyx_v_i = (__pyx_v_i + 1);
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/text/text.pyx":296 */
  __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":297 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_lines, __pyx_n_append); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 297; goto __pyx_L1;}
  __pyx_2 = PySequence_GetSlice(__pyx_v_text, __pyx_v_line_start, 0x7fffffff); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 297; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_line_width); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 297; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 297; 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[25]; __pyx_lineno = 297; 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[25]; __pyx_lineno = 297; 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":298 */
  __pyx_4 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 298; goto __pyx_L1;}
  __pyx_5 = PyFloat_FromDouble(__pyx_v_height); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 298; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 298; 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_k388p;

static char (__pyx_k388[]) = "\n";

static PyObject *__pyx_f_5_soya_5_Font_draw(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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_k163;
  __pyx_v_cull_face = __pyx_k164;
  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":304 */
  __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":305 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/text/text.pyx":306 */
  glEnable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":307 */
  glBindTexture(GL_TEXTURE_2D,((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":309 */
  __pyx_v_x_orig = __pyx_v_x;

  /* "/home/jiba/src/soya/text/text.pyx":310 */
  ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 0;

  /* "/home/jiba/src/soya/text/text.pyx":311 */
  __pyx_2 = PyObject_GetIter(__pyx_v_text); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 311; 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 = 311; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_char_);
    __pyx_v_char_ = __pyx_3;
    __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":312 */
    if (PyObject_Cmp(__pyx_v_char_, __pyx_k388p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 312; goto __pyx_L1;}
    __pyx_1 = __pyx_1 == 0;
    if (__pyx_1) {

      /* "/home/jiba/src/soya/text/text.pyx":313 */
      __pyx_v_x = __pyx_v_x_orig;

      /* "/home/jiba/src/soya/text/text.pyx":314 */
      __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":316 */
      __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[25]; __pyx_lineno = 316; goto __pyx_L1;}
      Py_DECREF(((PyObject *)__pyx_v_glyph));
      __pyx_v_glyph = __pyx_3;
      __pyx_3 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":317 */
      __pyx_1 = (((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering == 0);
      if (__pyx_1) {

        /* "/home/jiba/src/soya/text/text.pyx":317 */
        glBegin(GL_QUADS);

        /* "/home/jiba/src/soya/text/text.pyx":317 */
        ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 1;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "/home/jiba/src/soya/text/text.pyx":319 */
      __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->x);

      /* "/home/jiba/src/soya/text/text.pyx":320 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y1);

      /* "/home/jiba/src/soya/text/text.pyx":320 */
      glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);

      /* "/home/jiba/src/soya/text/text.pyx":321 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x1,__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 */
      __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->width);

      /* "/home/jiba/src/soya/text/text.pyx":323 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y2);

      /* "/home/jiba/src/soya/text/text.pyx":323 */
      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":324 */
      glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y1);

      /* "/home/jiba/src/soya/text/text.pyx":324 */
      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":326 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":326 */
    glEnd();

    /* "/home/jiba/src/soya/text/text.pyx":326 */
    ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/home/jiba/src/soya/text/text.pyx":328 */
  __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":329 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":330 */
  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_k389p;

static char (__pyx_k389[]) = "\n";

static PyObject *__pyx_f_5_soya_5_Font_draw_area(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_5_Font_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":336 */
  glDisable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/text/text.pyx":337 */
  glEnable(GL_TEXTURE_2D);

  /* "/home/jiba/src/soya/text/text.pyx":338 */
  glEnable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":339 */
  glBindTexture(GL_TEXTURE_2D,((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_tex_id);

  /* "/home/jiba/src/soya/text/text.pyx":341 */
  __pyx_v_x_orig = __pyx_v_x;

  /* "/home/jiba/src/soya/text/text.pyx":342 */
  ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 0;

  /* "/home/jiba/src/soya/text/text.pyx":343 */
  __pyx_1 = (__pyx_v_align == __pyx_e_5_soya_TEXT_ALIGN_LEFT);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":344 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_wordwrap); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 344; 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[25]; __pyx_lineno = 344; 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[25]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 344; 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[25]; __pyx_lineno = 344; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 344; 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[25]; __pyx_lineno = 344; 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[25]; __pyx_lineno = 344; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":346 */
    __pyx_4 = PyObject_GetIter(__pyx_v_text); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 346; goto __pyx_L1;}
    for (;;) {
      __pyx_L3:;
      __pyx_2 = PyIter_Next(__pyx_4);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 346; goto __pyx_L1;}
        break;
      }
      Py_DECREF(__pyx_v_char_);
      __pyx_v_char_ = __pyx_2;
      __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":347 */
      if (PyObject_Cmp(__pyx_v_char_, __pyx_k389p, &__pyx_1) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 347; goto __pyx_L1;}
      __pyx_1 = __pyx_1 == 0;
      if (__pyx_1) {

        /* "/home/jiba/src/soya/text/text.pyx":348 */
        __pyx_v_x = __pyx_v_x_orig;

        /* "/home/jiba/src/soya/text/text.pyx":349 */
        __pyx_v_y = (__pyx_v_y + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

        /* "/home/jiba/src/soya/text/text.pyx":350 */
        __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":352 */
        __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[25]; __pyx_lineno = 352; goto __pyx_L1;}
        Py_DECREF(((PyObject *)__pyx_v_glyph));
        __pyx_v_glyph = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":353 */
        __pyx_1 = (((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/text/text.pyx":353 */
          glBegin(GL_QUADS);

          /* "/home/jiba/src/soya/text/text.pyx":353 */
          ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 1;
          goto __pyx_L7;
        }
        __pyx_L7:;

        /* "/home/jiba/src/soya/text/text.pyx":355 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->x);

        /* "/home/jiba/src/soya/text/text.pyx":356 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":356 */
        glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":357 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__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 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->width);

        /* "/home/jiba/src/soya/text/text.pyx":359 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y2);

        /* "/home/jiba/src/soya/text/text.pyx":359 */
        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":360 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":360 */
        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":364 */
    __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_wordwrap_line); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_3 = PyFloat_FromDouble(__pyx_v_width); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 364; 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[25]; __pyx_lineno = 364; 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[25]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_5 = PyFloat_AsDouble(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 364; 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[25]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_6 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 364; 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[25]; __pyx_lineno = 364; 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[25]; __pyx_lineno = 364; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/text/text.pyx":365 */
    __pyx_4 = PyObject_GetIter(__pyx_v_lines); if (!__pyx_4) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 365; goto __pyx_L1;}
    for (;;) {
      __pyx_L8:;
      __pyx_2 = PyIter_Next(__pyx_4);
      if (!__pyx_2) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 365; goto __pyx_L1;}
        break;
      }
      __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 365; 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[25]; __pyx_lineno = 365; goto __pyx_L1;}
      __pyx_5 = PyFloat_AsDouble(__pyx_7); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 365; 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[25]; __pyx_lineno = 365; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;

      /* "/home/jiba/src/soya/text/text.pyx":366 */
      __pyx_7 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_7) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 366; goto __pyx_L1;}
      __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_2) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 366; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 366; 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[25]; __pyx_lineno = 366; 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[25]; __pyx_lineno = 366; 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[25]; __pyx_lineno = 366; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 366; 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[25]; __pyx_lineno = 366; 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":368 */
      __pyx_v_x = (__pyx_v_x_orig + ((__pyx_v_width - __pyx_v_w) / 2.0));

      /* "/home/jiba/src/soya/text/text.pyx":369 */
      __pyx_7 = PyObject_GetIter(__pyx_v_line); if (!__pyx_7) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 369; goto __pyx_L1;}
      for (;;) {
        __pyx_L11:;
        __pyx_3 = PyIter_Next(__pyx_7);
        if (!__pyx_3) {
          if (PyErr_Occurred()) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 369; goto __pyx_L1;}
          break;
        }
        Py_DECREF(__pyx_v_char_);
        __pyx_v_char_ = __pyx_3;
        __pyx_3 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":370 */
        __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[25]; __pyx_lineno = 370; goto __pyx_L1;}
        Py_DECREF(((PyObject *)__pyx_v_glyph));
        __pyx_v_glyph = __pyx_2;
        __pyx_2 = 0;

        /* "/home/jiba/src/soya/text/text.pyx":371 */
        __pyx_1 = (((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering == 0);
        if (__pyx_1) {

          /* "/home/jiba/src/soya/text/text.pyx":371 */
          glBegin(GL_QUADS);

          /* "/home/jiba/src/soya/text/text.pyx":371 */
          ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 1;
          goto __pyx_L13;
        }
        __pyx_L13:;

        /* "/home/jiba/src/soya/text/text.pyx":373 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->x);

        /* "/home/jiba/src/soya/text/text.pyx":374 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":374 */
        glVertex3f(__pyx_v_x,(__pyx_v_y + __pyx_v_glyph->y),__pyx_v_z);

        /* "/home/jiba/src/soya/text/text.pyx":375 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x1,__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 */
        __pyx_v_x = (__pyx_v_x + __pyx_v_glyph->width);

        /* "/home/jiba/src/soya/text/text.pyx":377 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y2);

        /* "/home/jiba/src/soya/text/text.pyx":377 */
        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":378 */
        glTexCoord2f(__pyx_v_glyph->_pixels_x2,__pyx_v_glyph->_pixels_y1);

        /* "/home/jiba/src/soya/text/text.pyx":378 */
        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":380 */
      __pyx_v_y = (__pyx_v_y + ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_height);

      /* "/home/jiba/src/soya/text/text.pyx":381 */
      __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":384 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering == 1);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/text/text.pyx":384 */
    glEnd();

    /* "/home/jiba/src/soya/text/text.pyx":384 */
    ((struct __pyx_obj_5_soya__Font *)__pyx_v_self)->_rendering = 0;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/jiba/src/soya/text/text.pyx":386 */
  glEnable(GL_CULL_FACE);

  /* "/home/jiba/src/soya/text/text.pyx":387 */
  glDisable(GL_BLEND);

  /* "/home/jiba/src/soya/text/text.pyx":388 */
  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_k391p;

static char (__pyx_k391[]) = "PIL.Image";

static PyObject *__pyx_f_5_soya_5_Font__image(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_5_Font__image[] = "Debugging stuff -- return the font loaded glyphs as a PIL image.";
static PyObject *__pyx_f_5_soya_5_Font__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":392 */
  __pyx_1 = __Pyx_Import(__pyx_k391p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 392; goto __pyx_L1;}
  Py_DECREF(__pyx_v_PIL);
  __pyx_v_PIL = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/text/text.pyx":395 */
  __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":396 */
  __pyx_v_pixels = ((GLubyte (*))malloc(__pyx_v_size));

  /* "/home/jiba/src/soya/text/text.pyx":397 */
  __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":398 */
    (__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":399 */
    (__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":400 */
    (__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":402 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_PIL, __pyx_n_Image); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 402; goto __pyx_L1;}
  __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_new); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 402; 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[25]; __pyx_lineno = 402; 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[25]; __pyx_lineno = 402; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 402; 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[25]; __pyx_lineno = 402; 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[25]; __pyx_lineno = 402; 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":403 */
  __pyx_5 = PyObject_GetAttr(__pyx_v_image, __pyx_n_fromstring); if (!__pyx_5) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_3 = PyString_FromStringAndSize(((char (*))__pyx_v_pixels),__pyx_v_size); if (!__pyx_3) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 403; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 403; 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[25]; __pyx_lineno = 403; 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":404 */
  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 PyObject *__pyx_n_AL_INVALID_NAME;
static PyObject *__pyx_n_AL_INVALID_ENUM;
static PyObject *__pyx_n_AL_INVALID_VALUE;
static PyObject *__pyx_n_AL_INVALID_OPERATION;
static PyObject *__pyx_n_AL_OUT_OF_MEMORY;
static PyObject *__pyx_n_ALC_INVALID_DEVICE;
static PyObject *__pyx_n_ALC_INVALID_CONTEXT;
static PyObject *__pyx_n_ALC_INVALID_ENUM;
static PyObject *__pyx_n_ALC_INVALID_VALUE;
static PyObject *__pyx_n_ALC_OUT_OF_MEMORY;


static PyObject *__pyx_f_5_soya_check_al_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_check_al_error[] = "check_al_error()\n\nChecks for OpenAL errors, and raise an ALError if so.";
static PyObject *__pyx_f_5_soya_check_al_error(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  ALenum __pyx_v_error;
  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[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);

  /* "/home/jiba/src/soya/sound/sound.pyx":30 */
  __pyx_v_error = alGetError();

  /* "/home/jiba/src/soya/sound/sound.pyx":31 */
  __pyx_1 = (__pyx_v_error != AL_NO_ERROR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/sound/sound.pyx":32 */
    __pyx_1 = (__pyx_v_error == AL_INVALID_NAME);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_AL_INVALID_NAME);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_AL_INVALID_NAME;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == AL_INVALID_ENUM);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_AL_INVALID_ENUM);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_AL_INVALID_ENUM;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == AL_INVALID_VALUE);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_AL_INVALID_VALUE);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_AL_INVALID_VALUE;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == AL_INVALID_OPERATION);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_AL_INVALID_OPERATION);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_AL_INVALID_OPERATION;
      goto __pyx_L3;
    }
    __pyx_1 = (__pyx_v_error == AL_OUT_OF_MEMORY);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_AL_OUT_OF_MEMORY);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_AL_OUT_OF_MEMORY;
      goto __pyx_L3;
    }
    __pyx_L3:;

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

    /* "/home/jiba/src/soya/sound/sound.pyx":38 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_ALError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 38; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 38; 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[26]; __pyx_lineno = 38; 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 = 38; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":40 */
  __pyx_v_error = alcGetError(__pyx_v_5_soya__device);

  /* "/home/jiba/src/soya/sound/sound.pyx":41 */
  __pyx_1 = (__pyx_v_error != ALC_NO_ERROR);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/sound/sound.pyx":42 */
    __pyx_1 = (__pyx_v_error == ALC_INVALID_DEVICE);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_ALC_INVALID_DEVICE);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_ALC_INVALID_DEVICE;
      goto __pyx_L5;
    }
    __pyx_1 = (__pyx_v_error == ALC_INVALID_CONTEXT);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_ALC_INVALID_CONTEXT);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_ALC_INVALID_CONTEXT;
      goto __pyx_L5;
    }
    __pyx_1 = (__pyx_v_error == ALC_INVALID_ENUM);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_ALC_INVALID_ENUM);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_ALC_INVALID_ENUM;
      goto __pyx_L5;
    }
    __pyx_1 = (__pyx_v_error == ALC_INVALID_VALUE);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_ALC_INVALID_VALUE);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_ALC_INVALID_VALUE;
      goto __pyx_L5;
    }
    __pyx_1 = (__pyx_v_error == ALC_OUT_OF_MEMORY);
    if (__pyx_1) {
      Py_INCREF(__pyx_n_ALC_OUT_OF_MEMORY);
      Py_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_n_ALC_OUT_OF_MEMORY;
      goto __pyx_L5;
    }
    __pyx_L5:;

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

    /* "/home/jiba/src/soya/sound/sound.pyx":48 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_ALError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 48; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 48; 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[26]; __pyx_lineno = 48; 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 = 48; goto __pyx_L1;}
    goto __pyx_L4;
  }
  __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.check_al_error");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_s);
  return __pyx_r;
}

static PyObject *__pyx_k403p;
static PyObject *__pyx_k404p;
static PyObject *__pyx_k405p;
static PyObject *__pyx_k406p;
static PyObject *__pyx_k407p;

static char (__pyx_k403[]) = "Cannot create an OpenAL device!";
static char (__pyx_k404[]) = "Cannot create an OpenAL context!";
static char (__pyx_k405[]) = "* Using OpenAL %s";
static char (__pyx_k406[]) = "*   - renderer  : %s";
static char (__pyx_k407[]) = "*   - vendor    : %s";

static void __pyx_f_5_soya__init_sound(PyObject *__pyx_v_device_names,int __pyx_v_frequency,float __pyx_v_reference_distance,float __pyx_v_doppler_factor) {
  char (*__pyx_v_s);
  char __pyx_v_s2;
  int (__pyx_v_attrs[6]);
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_device_names);

  /* "/home/jiba/src/soya/sound/sound.pyx":71 */
  __pyx_1 = (__pyx_v_5_soya__SOUND_INITED == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/sound/sound.pyx":73 */
    __pyx_v_5_soya__device = alcOpenDevice(PyString_AS_STRING(__pyx_v_device_names));

    /* "/home/jiba/src/soya/sound/sound.pyx":75 */
    __pyx_1 = (__pyx_v_5_soya__device == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/sound/sound.pyx":76 */
      __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 76; goto __pyx_L1;}
      __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 76; goto __pyx_L1;}
      Py_INCREF(__pyx_k403p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k403p);
      __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 76; 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 = 76; goto __pyx_L1;}
      goto __pyx_L3;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/sound/sound.pyx":78 */
    (__pyx_v_attrs[0]) = ALC_FREQUENCY;

    /* "/home/jiba/src/soya/sound/sound.pyx":79 */
    (__pyx_v_attrs[1]) = __pyx_v_frequency;

    /* "/home/jiba/src/soya/sound/sound.pyx":80 */
    (__pyx_v_attrs[2]) = ALC_INVALID;

    /* "/home/jiba/src/soya/sound/sound.pyx":81 */
    __pyx_v_5_soya__context = alcCreateContext(__pyx_v_5_soya__device,__pyx_v_attrs);

    /* "/home/jiba/src/soya/sound/sound.pyx":83 */
    __pyx_1 = (__pyx_v_5_soya__context == 0);
    if (__pyx_1) {

      /* "/home/jiba/src/soya/sound/sound.pyx":84 */
      __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); 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_k404p);
      PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k404p);
      __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_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/sound/sound.pyx":86 */
    alcMakeContextCurrent(__pyx_v_5_soya__context);

    /* "/home/jiba/src/soya/sound/sound.pyx":88 */
    alDopplerFactor(__pyx_v_doppler_factor);

    /* "/home/jiba/src/soya/sound/sound.pyx":89 */
    __pyx_v_5_soya__reference_distance = __pyx_v_reference_distance;

    /* "/home/jiba/src/soya/sound/sound.pyx":91 */
    __pyx_v_5_soya__SOUND_INITED = 1;

    /* "/home/jiba/src/soya/sound/sound.pyx":93 */
    __pyx_v_s = alGetString(AL_VERSION);

    /* "/home/jiba/src/soya/sound/sound.pyx":93 */
    __pyx_2 = PyString_FromString(__pyx_v_s); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 93; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k405p, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 93; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__Pyx_PrintItem(__pyx_3) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 93; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 93; goto __pyx_L1;}

    /* "/home/jiba/src/soya/sound/sound.pyx":94 */
    __pyx_v_s = alGetString(AL_RENDERER);

    /* "/home/jiba/src/soya/sound/sound.pyx":94 */
    __pyx_4 = PyString_FromString(__pyx_v_s); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 94; goto __pyx_L1;}
    __pyx_2 = PyNumber_Remainder(__pyx_k406p, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 94; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__Pyx_PrintItem(__pyx_2) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 94; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 94; goto __pyx_L1;}

    /* "/home/jiba/src/soya/sound/sound.pyx":95 */
    __pyx_v_s = alGetString(AL_VENDOR);

    /* "/home/jiba/src/soya/sound/sound.pyx":95 */
    __pyx_3 = PyString_FromString(__pyx_v_s); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 95; goto __pyx_L1;}
    __pyx_4 = PyNumber_Remainder(__pyx_k407p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 95; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__Pyx_PrintItem(__pyx_4) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 95; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    if (__Pyx_PrintNewline() < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 95; goto __pyx_L1;}
    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._init_sound");
  __pyx_L0:;
  Py_DECREF(__pyx_v_device_names);
}

static PyObject *__pyx_k408p;

static char (__pyx_k408[]) = "Sound has not been initialized yet, call soya.init(sound = 1) before!";

static PyObject *__pyx_f_5_soya_set_sound_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_set_sound_volume[] = "set_sound_volume(volume)\n\nSets the global sound volume. VOLUME is a value between 0.0 (no sound) and 1.0 (default).";
static PyObject *__pyx_f_5_soya_set_sound_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_volume;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  static char *__pyx_argnames[] = {"volume",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "f", __pyx_argnames, &__pyx_v_volume)) return 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":103 */
  __pyx_1 = (__pyx_v_5_soya__SOUND_INITED == 0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 103; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 103; goto __pyx_L1;}
    Py_INCREF(__pyx_k408p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k408p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 103; 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 = 103; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":104 */
  alListenerf(AL_GAIN,__pyx_v_volume);

  __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_sound_volume");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static PyObject *__pyx_k409p;

static char (__pyx_k409[]) = "Sound has not been initialized yet, call soya.init(sound = 1) before!";

static PyObject *__pyx_f_5_soya_get_sound_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5_soya_get_sound_volume[] = "get_sound_volume() -> float\n\nReturns the global sound volume, a value between 0.0 (no sound) and 1.0 (default).";
static PyObject *__pyx_f_5_soya_get_sound_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_x;
  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;

  /* "/home/jiba/src/soya/sound/sound.pyx":111 */
  __pyx_1 = (__pyx_v_5_soya__SOUND_INITED == 0);
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 111; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 111; goto __pyx_L1;}
    Py_INCREF(__pyx_k409p);
    PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k409p);
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 111; 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 = 111; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":112 */
  alGetListenerf(AL_GAIN,(&__pyx_v_x));

  /* "/home/jiba/src/soya/sound/sound.pyx":113 */
  __pyx_2 = PyFloat_FromDouble(__pyx_v_x); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 113; 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);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_soya.get_sound_volume");
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

static void __pyx_f_5_soya__update_sound_listener_position(struct __pyx_obj_5_soya_CoordSyst *__pyx_v_ear,float __pyx_v_proportion) {
  float (__pyx_v_pos[6]);
  float (__pyx_v_v[3]);
  float __pyx_v_dt;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  float __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_ear);

  /* "/home/jiba/src/soya/sound/sound.pyx":118 */
  __pyx_1 = (__pyx_v_ear->_option & __pyx_e_5_soya_COORDSYS_STATIC);
  if (__pyx_1) {
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":124 */
  ((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_ear->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._out(((struct __pyx_obj_5_soya_Position *)__pyx_v_ear),__pyx_v_pos);

  /* "/home/jiba/src/soya/sound/sound.pyx":126 */
  alListenerfv(AL_POSITION,__pyx_v_pos);

  /* "/home/jiba/src/soya/sound/sound.pyx":127 */
  alGetListenerfv(AL_POSITION,__pyx_v_pos);

  /* "/home/jiba/src/soya/sound/sound.pyx":129 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 129; goto __pyx_L1;}
  __pyx_1 = __pyx_2 == Py_None;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {
    __pyx_v_dt = (__pyx_v_proportion * 0.030);
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 130; goto __pyx_L1;}
    __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 130; goto __pyx_L1;}
    __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_round_duration); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 130; 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[26]; __pyx_lineno = 130; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_5 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 130; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_v_dt = __pyx_5;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/sound/sound.pyx":131 */
  alListener3f(AL_VELOCITY,(((__pyx_v_pos[0]) - (__pyx_v_5_soya__ear_old_pos[0])) / __pyx_v_dt),(((__pyx_v_pos[1]) - (__pyx_v_5_soya__ear_old_pos[1])) / __pyx_v_dt),(((__pyx_v_pos[2]) - (__pyx_v_5_soya__ear_old_pos[2])) / __pyx_v_dt));

  /* "/home/jiba/src/soya/sound/sound.pyx":137 */
  memcpy(__pyx_v_5_soya__ear_old_pos,__pyx_v_pos,(3 * (sizeof(float ))));

  /* "/home/jiba/src/soya/sound/sound.pyx":139 */
  (__pyx_v_pos[0]) = 0.0;

  /* "/home/jiba/src/soya/sound/sound.pyx":140 */
  (__pyx_v_pos[1]) = 0.0;

  /* "/home/jiba/src/soya/sound/sound.pyx":141 */
  (__pyx_v_pos[2]) = (-1.0);

  /* "/home/jiba/src/soya/sound/sound.pyx":142 */
  vector_by_matrix(__pyx_v_pos,((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_ear->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_ear));

  /* "/home/jiba/src/soya/sound/sound.pyx":143 */
  (__pyx_v_pos[3]) = 0.0;

  /* "/home/jiba/src/soya/sound/sound.pyx":144 */
  (__pyx_v_pos[4]) = 1.0;

  /* "/home/jiba/src/soya/sound/sound.pyx":145 */
  (__pyx_v_pos[5]) = 0.0;

  /* "/home/jiba/src/soya/sound/sound.pyx":146 */
  vector_by_matrix((__pyx_v_pos + 3),((struct __pyx_vtabstruct_5_soya_CoordSyst *)__pyx_v_ear->__pyx_base.__pyx_base.__pyx_vtab)->_root_matrix(__pyx_v_ear));

  /* "/home/jiba/src/soya/sound/sound.pyx":147 */
  alListenerfv(AL_ORIENTATION,__pyx_v_pos);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_WriteUnraisable("_soya._update_sound_listener_position");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_ear);
}

static int __pyx_f_5_soya_6_Sound___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_6_Sound___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_v_kargs = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  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/sound/sound.pyx":159 */
  __pyx_1 = PyList_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_buffers);
  ((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_buffers = __pyx_1;
  __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_soya._Sound.__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_6_Sound___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_6_Sound___dealloc__(PyObject *__pyx_v_self) {
  ALuint __pyx_v_buffer;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  ALuint __pyx_3;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/sound/sound.pyx":163 */
  __pyx_1 = PyObject_GetIter(((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_buffers); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 163; 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 = 163; goto __pyx_L1;}
      break;
    }
    __pyx_3 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 163; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_v_buffer = __pyx_3;

    /* "/home/jiba/src/soya/sound/sound.pyx":164 */
    alDeleteBuffers(1,(&__pyx_v_buffer));
  }
  __pyx_L3:;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_soya._Sound.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static ALuint __pyx_f_5_soya_6_Sound__getbuffer(struct __pyx_obj_5_soya__Sound *__pyx_v_self,PyObject *__pyx_v_i) {
  ALuint __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_i);
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_NotImplementedError); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 166; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 166; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 166; 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[26]; __pyx_lineno = 166; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Sound._getbuffer");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_i);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_6_Sound_6stereo___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Sound_6stereo___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/sound/sound.pyx":170 */
  __pyx_1 = (((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_format == AL_FORMAT_STEREO16);
  if (!__pyx_1) {
    __pyx_1 = (((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_format == AL_FORMAT_STEREO8);
  }
  __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 170; 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._Sound.stereo.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_k410p;

static char (__pyx_k410[]) = "<%s %s>";

static PyObject *__pyx_f_5_soya_6_Sound___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_6_Sound___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/sound/sound.pyx":173 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 173; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 173; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 173; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  Py_INCREF(((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_filename);
  PyTuple_SET_ITEM(__pyx_1, 1, ((struct __pyx_obj_5_soya__Sound *)__pyx_v_self)->_filename);
  __pyx_2 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k410p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 173; 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._Sound.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_n_wave;
static PyObject *__pyx_n_getnchannels;
static PyObject *__pyx_n_getsampwidth;
static PyObject *__pyx_n_getframerate;


static int __pyx_f_5_soya_9_WAVSound___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_9_WAVSound___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_wave;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_filename);
  __pyx_v_wave = Py_None; Py_INCREF(__pyx_v_wave);

  /* "/home/jiba/src/soya/sound/sound.pyx":178 */
  __pyx_1 = __Pyx_Import(__pyx_n_wave, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 178; goto __pyx_L1;}
  Py_DECREF(__pyx_v_wave);
  __pyx_v_wave = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":179 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_wave, __pyx_n_open); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 179; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 179; 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[26]; __pyx_lineno = 179; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._file);
  ((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._file = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":181 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._file, __pyx_n_getnchannels); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 181; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 181; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_3, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 181; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/sound/sound.pyx":182 */
    __pyx_2 = PyObject_GetAttr(((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._file, __pyx_n_getsampwidth); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 182; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 182; goto __pyx_L1;}
    __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 182; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_2 = PyInt_FromLong(2); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 182; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_1, __pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 182; goto __pyx_L1;}
    __pyx_4 = __pyx_4 == 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_4) {
      ((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._format = AL_FORMAT_STEREO16;
      goto __pyx_L3;
    }
    /*else*/ {
      ((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._format = AL_FORMAT_STEREO8;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/sound/sound.pyx":185 */
    __pyx_3 = PyObject_GetAttr(((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._file, __pyx_n_getsampwidth); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
    __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_3 = PyInt_FromLong(2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 185; goto __pyx_L1;}
    __pyx_4 = __pyx_4 == 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {
      ((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._format = AL_FORMAT_MONO16;
      goto __pyx_L4;
    }
    /*else*/ {
      ((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._format = AL_FORMAT_MONO8;
    }
    __pyx_L4:;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":187 */
  __pyx_1 = PyObject_GetAttr(((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._file, __pyx_n_getframerate); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 187; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 187; 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 = 187; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  ((struct __pyx_obj_5_soya__WAVSound *)__pyx_v_self)->__pyx_base._framerate = __pyx_4;

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

static PyObject *__pyx_n_readframes;

static PyObject *__pyx_f_5_soya_9_WAVSound__getnextdata(struct __pyx_obj_5_soya__WAVSound *__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/sound/sound.pyx":190 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base._file, __pyx_n_readframes); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 190; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong((1024 * 64)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 190; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 190; 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 = 190; 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._WAVSound._getnextdata");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static ALuint __pyx_f_5_soya_9_WAVSound__getbuffer(struct __pyx_obj_5_soya__WAVSound *__pyx_v_self,PyObject *__pyx_v_i) {
  int __pyx_v_length;
  PyObject *__pyx_v_data;
  ALuint __pyx_v_buffer;
  ALuint __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  ALuint __pyx_3;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_i);
  __pyx_v_data = Py_None; Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/sound/sound.pyx":193 */
  __pyx_1 = PyObject_Length(__pyx_v_self->__pyx_base._buffers); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 193; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_v_i, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_1 = __pyx_1 < 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {
    __pyx_2 = PyObject_GetItem(__pyx_v_self->__pyx_base._buffers, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 193; goto __pyx_L1;}
    __pyx_3 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 193; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    __pyx_r = __pyx_3;
    goto __pyx_L0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":195 */
  __pyx_1 = __pyx_v_self->__pyx_base._file == Py_None;
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/sound/sound.pyx":197 */
  __pyx_1 = PyObject_Length(__pyx_v_self->__pyx_base._buffers); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_v_i, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
  __pyx_1 = __pyx_1 > 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (__pyx_1) {
    __pyx_2 = PyInt_FromLong(1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
    __pyx_4 = PyNumber_Subtract(__pyx_v_i, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 197; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    ((struct __pyx_vtabstruct_5_soya__WAVSound *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base._getbuffer(((struct __pyx_obj_5_soya__Sound *)__pyx_v_self),__pyx_4);
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/sound/sound.pyx":200 */
  __pyx_2 = ((struct __pyx_vtabstruct_5_soya__WAVSound *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_getnextdata(__pyx_v_self); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 200; goto __pyx_L1;}
  Py_DECREF(__pyx_v_data);
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":201 */
  __pyx_1 = PyObject_Length(__pyx_v_data); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 201; goto __pyx_L1;}
  __pyx_v_length = __pyx_1;

  /* "/home/jiba/src/soya/sound/sound.pyx":203 */
  __pyx_1 = (__pyx_v_length == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/sound/sound.pyx":204 */
    Py_INCREF(Py_None);
    Py_DECREF(__pyx_v_self->__pyx_base._file);
    __pyx_v_self->__pyx_base._file = Py_None;

    /* "/home/jiba/src/soya/sound/sound.pyx":205 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/sound/sound.pyx":208 */
  alGenBuffers(1,(&__pyx_v_buffer));

  /* "/home/jiba/src/soya/sound/sound.pyx":209 */
  alBufferData(__pyx_v_buffer,__pyx_v_self->__pyx_base._format,PyString_AS_STRING(__pyx_v_data),__pyx_v_length,__pyx_v_self->__pyx_base._framerate);

  /* "/home/jiba/src/soya/sound/sound.pyx":210 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_self->__pyx_base._buffers, __pyx_n_append); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 210; goto __pyx_L1;}
  __pyx_2 = PyInt_FromLong(__pyx_v_buffer); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 210; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 210; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 210; 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/sound/sound.pyx":212 */
  __pyx_r = __pyx_v_buffer;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_WriteUnraisable("_soya._WAVSound._getbuffer");
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_i);
  return __pyx_r;
}

static PyObject *__pyx_n_vorbis;
static PyObject *__pyx_n_VorbisFile;
static PyObject *__pyx_n_info;
static PyObject *__pyx_n_channels;
static PyObject *__pyx_n_rate;

static PyObject *__pyx_k412p;

static char (__pyx_k412[]) = "ogg.vorbis";

static int __pyx_f_5_soya_15_OGGVorbisSound___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_15_OGGVorbisSound___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_filename = 0;
  PyObject *__pyx_v_ogg;
  PyObject *__pyx_v_info;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  static char *__pyx_argnames[] = {"filename",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_filename)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_filename);
  __pyx_v_ogg = Py_None; Py_INCREF(__pyx_v_ogg);
  __pyx_v_info = Py_None; Py_INCREF(__pyx_v_info);

  /* "/home/jiba/src/soya/sound/sound.pyx":218 */
  __pyx_1 = __Pyx_Import(__pyx_k412p, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 218; goto __pyx_L1;}
  Py_DECREF(__pyx_v_ogg);
  __pyx_v_ogg = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":220 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_ogg, __pyx_n_vorbis); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 220; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_VorbisFile); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 220; 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 = 220; 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 = 220; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(((struct __pyx_obj_5_soya__OGGVorbisSound *)__pyx_v_self)->__pyx_base._file);
  ((struct __pyx_obj_5_soya__OGGVorbisSound *)__pyx_v_self)->__pyx_base._file = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":221 */
  __pyx_2 = PyObject_GetAttr(((struct __pyx_obj_5_soya__OGGVorbisSound *)__pyx_v_self)->__pyx_base._file, __pyx_n_info); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 221; goto __pyx_L1;}
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 221; goto __pyx_L1;}
  __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 221; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_info);
  __pyx_v_info = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":223 */
  __pyx_2 = PyObject_GetAttr(__pyx_v_info, __pyx_n_channels); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_1 = PyInt_FromLong(2); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 223; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_1, &__pyx_4) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 223; goto __pyx_L1;}
  __pyx_4 = __pyx_4 == 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (__pyx_4) {
    ((struct __pyx_obj_5_soya__OGGVorbisSound *)__pyx_v_self)->__pyx_base._format = AL_FORMAT_STEREO16;
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__OGGVorbisSound *)__pyx_v_self)->__pyx_base._format = AL_FORMAT_MONO16;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":225 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_info, __pyx_n_rate); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 225; goto __pyx_L1;}
  __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 225; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  ((struct __pyx_obj_5_soya__OGGVorbisSound *)__pyx_v_self)->__pyx_base._framerate = __pyx_4;

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

static PyObject *__pyx_n_StringIO;
static PyObject *__pyx_n_pcm_seek;
static PyObject *__pyx_n_getvalue;

static PyObject *__pyx_k414p;

static char (__pyx_k414[]) = "";

static PyObject *__pyx_f_5_soya_15_OGGVorbisSound__getdata(struct __pyx_obj_5_soya__OGGVorbisSound *__pyx_v_self,int __pyx_v_i) {
  int __pyx_v_length;
  int __pyx_v_size;
  PyObject *__pyx_v_StringIO;
  PyObject *__pyx_v_s;
  PyObject *__pyx_v_data;
  PyObject *__pyx_v_bytes;
  PyObject *__pyx_v_bit;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  int __pyx_2;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_StringIO = Py_None; Py_INCREF(__pyx_v_StringIO);
  __pyx_v_s = Py_None; Py_INCREF(__pyx_v_s);
  __pyx_v_data = Py_None; Py_INCREF(__pyx_v_data);
  __pyx_v_bytes = Py_None; Py_INCREF(__pyx_v_bytes);
  __pyx_v_bit = Py_None; Py_INCREF(__pyx_v_bit);

  /* "/home/jiba/src/soya/sound/sound.pyx":230 */
  __pyx_1 = __Pyx_Import(__pyx_n_StringIO, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 230; goto __pyx_L1;}
  Py_DECREF(__pyx_v_StringIO);
  __pyx_v_StringIO = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":232 */
  __pyx_2 = (__pyx_v_self->__pyx_base._format == AL_FORMAT_STEREO16);
  if (__pyx_2) {
    __pyx_v_size = (16384 * 2);
    goto __pyx_L2;
  }
  __pyx_2 = (__pyx_v_self->__pyx_base._format == AL_FORMAT_MONO16);
  if (__pyx_2) {
    __pyx_v_size = 16384;
    goto __pyx_L2;
  }
  __pyx_2 = (__pyx_v_self->__pyx_base._format == AL_FORMAT_STEREO8);
  if (__pyx_2) {
    __pyx_v_size = 16384;
    goto __pyx_L2;
  }
  __pyx_2 = (__pyx_v_self->__pyx_base._format == AL_FORMAT_MONO8);
  if (__pyx_2) {
    __pyx_v_size = (16384 / 2);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":237 */
  /*try:*/ {
    __pyx_1 = PyObject_GetAttr(__pyx_v_self->__pyx_base._file, __pyx_n_pcm_seek); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 237; goto __pyx_L3;}
    __pyx_3 = PyInt_FromLong((__pyx_v_i * 8192)); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 237; goto __pyx_L3;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 237; goto __pyx_L3;}
    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[26]; __pyx_lineno = 237; goto __pyx_L3;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
  }
  goto __pyx_L4;
  __pyx_L3:;
  Py_XDECREF(__pyx_1); __pyx_1 = 0;
  Py_XDECREF(__pyx_4); __pyx_4 = 0;
  Py_XDECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":238 */
  /*except:*/ {
    __Pyx_AddTraceback("_soya._getdata");
    __pyx_1 = __Pyx_GetExcValue(); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 238; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_INCREF(__pyx_k414p);
    __pyx_r = __pyx_k414p;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/sound/sound.pyx":240 */
  __pyx_4 = PyObject_GetAttr(__pyx_v_StringIO, __pyx_n_StringIO); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 240; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 240; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":241 */
  __pyx_v_length = __pyx_v_size;

  /* "/home/jiba/src/soya/sound/sound.pyx":242 */
  while (1) {
    __pyx_L5:;
    __pyx_2 = (__pyx_v_length > 0);
    if (!__pyx_2) break;

    /* "/home/jiba/src/soya/sound/sound.pyx":243 */
    __pyx_4 = PyObject_GetAttr(__pyx_v_self->__pyx_base._file, __pyx_n_read); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(__pyx_v_length); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_1, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_4 = __Pyx_UnpackItem(__pyx_3, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    Py_DECREF(__pyx_v_data);
    __pyx_v_data = __pyx_4;
    __pyx_4 = 0;
    __pyx_1 = __Pyx_UnpackItem(__pyx_3, 1); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    Py_DECREF(__pyx_v_bytes);
    __pyx_v_bytes = __pyx_1;
    __pyx_1 = 0;
    __pyx_5 = __Pyx_UnpackItem(__pyx_3, 2); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    Py_DECREF(__pyx_v_bit);
    __pyx_v_bit = __pyx_5;
    __pyx_5 = 0;
    if (__Pyx_EndUnpack(__pyx_3, 3) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 243; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":244 */
    __pyx_4 = PyInt_FromLong(__pyx_v_length); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 244; goto __pyx_L1;}
    __pyx_1 = PyNumber_Subtract(__pyx_4, __pyx_v_bytes); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 244; goto __pyx_L1;}
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    __pyx_2 = PyInt_AsLong(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 244; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_v_length = __pyx_2;

    /* "/home/jiba/src/soya/sound/sound.pyx":245 */
    __pyx_5 = PyObject_GetAttr(__pyx_v_s, __pyx_n_write); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 245; goto __pyx_L1;}
    __pyx_2 = PyInt_AsLong(__pyx_v_bytes); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 245; goto __pyx_L1;}
    __pyx_3 = PySequence_GetSlice(__pyx_v_data, 0, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 245; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 245; goto __pyx_L1;}
    PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
    __pyx_3 = 0;
    __pyx_1 = PyObject_CallObject(__pyx_5, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 245; goto __pyx_L1;}
    Py_DECREF(__pyx_5); __pyx_5 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":246 */
    __pyx_2 = PyObject_IsTrue(__pyx_v_bit); if (__pyx_2 < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 246; goto __pyx_L1;}
    if (__pyx_2) {
      goto __pyx_L6;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/sound/sound.pyx":248 */
  __pyx_3 = PyObject_GetAttr(__pyx_v_s, __pyx_n_getvalue); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
  __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 248; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 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_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_soya._OGGVorbisSound._getdata");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_StringIO);
  Py_DECREF(__pyx_v_s);
  Py_DECREF(__pyx_v_data);
  Py_DECREF(__pyx_v_bytes);
  Py_DECREF(__pyx_v_bit);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static ALuint __pyx_f_5_soya_15_OGGVorbisSound__getbuffer(struct __pyx_obj_5_soya__OGGVorbisSound *__pyx_v_self,PyObject *__pyx_v_i) {
  int __pyx_v_j;
  int __pyx_v_length;
  PyObject *__pyx_v_data;
  ALuint __pyx_v_buffer;
  ALuint __pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  ALuint __pyx_5;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_i);
  __pyx_v_data = Py_None; Py_INCREF(__pyx_v_data);

  /* "/home/jiba/src/soya/sound/sound.pyx":253 */
  while (1) {
    __pyx_L2:;
    __pyx_1 = PyObject_Length(__pyx_v_self->__pyx_base._buffers); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
    if (PyObject_Cmp(__pyx_v_i, __pyx_2, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
    __pyx_1 = __pyx_1 >= 0;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (!__pyx_1) break;
    __pyx_2 = PyObject_GetAttr(__pyx_v_self->__pyx_base._buffers, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
    __pyx_3 = PyInt_FromLong(0); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; goto __pyx_L1;}
    __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 253; 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 = 253; 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:;

  /* "/home/jiba/src/soya/sound/sound.pyx":255 */
  __pyx_2 = PyObject_GetItem(__pyx_v_self->__pyx_base._buffers, __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 255; goto __pyx_L1;}
  if (PyObject_Cmp(__pyx_2, __pyx_4, &__pyx_1) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 255; goto __pyx_L1;}
  __pyx_1 = __pyx_1 != 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (__pyx_1) {
    __pyx_3 = PyObject_GetItem(__pyx_v_self->__pyx_base._buffers, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 255; goto __pyx_L1;}
    __pyx_5 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 255; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    __pyx_r = __pyx_5;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/sound/sound.pyx":257 */
  __pyx_1 = __pyx_v_self->__pyx_base._file == Py_None;
  if (__pyx_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/jiba/src/soya/sound/sound.pyx":260 */
  __pyx_1 = PyInt_AsLong(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 260; goto __pyx_L1;}
  __pyx_2 = ((struct __pyx_vtabstruct_5_soya__OGGVorbisSound *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_vtab)->_getdata(__pyx_v_self,__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 260; goto __pyx_L1;}
  Py_DECREF(__pyx_v_data);
  __pyx_v_data = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":261 */
  __pyx_1 = PyObject_Length(__pyx_v_data); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 261; goto __pyx_L1;}
  __pyx_v_length = __pyx_1;

  /* "/home/jiba/src/soya/sound/sound.pyx":263 */
  __pyx_1 = (__pyx_v_length == 0);
  if (__pyx_1) {

    /* "/home/jiba/src/soya/sound/sound.pyx":264 */
    __pyx_4 = PyObject_GetIter(__pyx_v_self->__pyx_base._buffers); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 264; goto __pyx_L1;}
    for (;;) {
      __pyx_L7:;
      __pyx_3 = PyIter_Next(__pyx_4);
      if (!__pyx_3) {
        if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 264; goto __pyx_L1;}
        break;
      }
      __pyx_1 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 264; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_v_j = __pyx_1;

      /* "/home/jiba/src/soya/sound/sound.pyx":265 */
      __pyx_1 = (__pyx_v_j == 0);
      if (__pyx_1) {
        goto __pyx_L8;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/sound/sound.pyx":267 */
      Py_INCREF(Py_None);
      Py_DECREF(__pyx_v_self->__pyx_base._file);
      __pyx_v_self->__pyx_base._file = Py_None;
    }
    __pyx_L8:;
    Py_DECREF(__pyx_4); __pyx_4 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":268 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/home/jiba/src/soya/sound/sound.pyx":271 */
  alGenBuffers(1,(&__pyx_v_buffer));

  /* "/home/jiba/src/soya/sound/sound.pyx":272 */
  alBufferData(__pyx_v_buffer,__pyx_v_self->__pyx_base._format,PyString_AS_STRING(__pyx_v_data),__pyx_v_length,__pyx_v_self->__pyx_base._framerate);

  /* "/home/jiba/src/soya/sound/sound.pyx":273 */
  __pyx_2 = PyInt_FromLong(__pyx_v_buffer); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 273; goto __pyx_L1;}
  if (PyObject_SetItem(__pyx_v_self->__pyx_base._buffers, __pyx_v_i, __pyx_2) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 273; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":275 */
  __pyx_r = __pyx_v_buffer;
  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._OGGVorbisSound._getbuffer");
  __pyx_L0:;
  Py_DECREF(__pyx_v_data);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_i);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_SoundPlayer___new__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_12_SoundPlayer___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/sound/sound.pyx":285 */
  alGenSources(1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source));

  /* "/home/jiba/src/soya/sound/sound.pyx":286 */
  alSourcef(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_REFERENCE_DISTANCE,__pyx_v_5_soya__reference_distance);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SoundPlayer.__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_12_SoundPlayer___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_f_5_soya_12_SoundPlayer___dealloc__(PyObject *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/sound/sound.pyx":289 */
  alDeleteSources(1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source));

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_soya._SoundPlayer.__dealloc__");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_n_stereo;

static PyObject *__pyx_k415p;

static char (__pyx_k415[]) = "OpenAL cannot play stereo sound as 3D sound!";

static int __pyx_f_5_soya_12_SoundPlayer___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_12_SoundPlayer___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__Sound *__pyx_v_sound = 0;
  int __pyx_v_loop;
  int __pyx_v_play_in_3D;
  float __pyx_v_gain;
  int __pyx_v_auto_remove;
  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[] = {"parent","sound","loop","play_in_3D","gain","auto_remove",0};
  __pyx_v_parent = __pyx_k166;
  __pyx_v_sound = __pyx_k167;
  __pyx_v_loop = __pyx_k168;
  __pyx_v_play_in_3D = __pyx_k169;
  __pyx_v_gain = __pyx_k170;
  __pyx_v_auto_remove = __pyx_k171;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|OOiifi", __pyx_argnames, &__pyx_v_parent, &__pyx_v_sound, &__pyx_v_loop, &__pyx_v_play_in_3D, &__pyx_v_gain, &__pyx_v_auto_remove)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_parent);
  Py_INCREF((PyObject *)__pyx_v_sound);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_5_soya__World, 1, "parent")) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 291; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sound), __pyx_ptype_5_soya__Sound, 1, "sound")) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 291; goto __pyx_L1;}

  /* "/home/jiba/src/soya/sound/sound.pyx":292 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 292; 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[26]; __pyx_lineno = 292; 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/sound/sound.pyx":293 */
  Py_INCREF(((PyObject *)__pyx_v_sound));
  Py_DECREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound));
  ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound = ((PyObject *)__pyx_v_sound);

  /* "/home/jiba/src/soya/sound/sound.pyx":294 */
  alSourcef(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_GAIN,__pyx_v_gain);

  /* "/home/jiba/src/soya/sound/sound.pyx":296 */
  __pyx_4 = __pyx_v_loop;
  if (__pyx_4) {
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SOUND_LOOP);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":297 */
  __pyx_4 = __pyx_v_auto_remove;
  if (__pyx_4) {
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SOUND_AUTO_REMOVE);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/jiba/src/soya/sound/sound.pyx":299 */
  __pyx_4 = __pyx_v_play_in_3D;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/sound/sound.pyx":300 */
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SOUND_PLAY_IN_3D);

    /* "/home/jiba/src/soya/sound/sound.pyx":302 */
    ((struct __pyx_vtabstruct_5_soya__SoundPlayer *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)),((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_old_pos);

    /* "/home/jiba/src/soya/sound/sound.pyx":303 */
    alSourcefv(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_POSITION,((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_old_pos);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/home/jiba/src/soya/sound/sound.pyx":305 */
  __pyx_4 = ((PyObject *)__pyx_v_sound) == Py_None;
  __pyx_5 = (!__pyx_4);
  if (__pyx_5) {

    /* "/home/jiba/src/soya/sound/sound.pyx":306 */
    __pyx_4 = __pyx_v_play_in_3D;
    if (__pyx_4) {

      /* "/home/jiba/src/soya/sound/sound.pyx":307 */
      __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_sound), __pyx_n_stereo); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 307; goto __pyx_L1;}
      __pyx_5 = PyObject_IsTrue(__pyx_1); if (__pyx_5 < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 307; goto __pyx_L1;}
      Py_DECREF(__pyx_1); __pyx_1 = 0;
      if (__pyx_5) {
        __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 307; goto __pyx_L1;}
        __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 307; goto __pyx_L1;}
        Py_INCREF(__pyx_k415p);
        PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k415p);
        __pyx_1 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 307; goto __pyx_L1;}
        Py_DECREF(__pyx_2); __pyx_2 = 0;
        Py_DECREF(__pyx_3); __pyx_3 = 0;
        __Pyx_Raise(__pyx_1, 0, 0);
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        {__pyx_filename = __pyx_f[26]; __pyx_lineno = 307; goto __pyx_L1;}
        goto __pyx_L7;
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/sound/sound.pyx":309 */
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer_id = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":310 */
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 310; goto __pyx_L1;}
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)__pyx_v_sound->__pyx_base.__pyx_vtab)->_getbuffer(__pyx_v_sound,__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":311 */
    alSourceQueueBuffers(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer));

    /* "/home/jiba/src/soya/sound/sound.pyx":313 */
    __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 313; goto __pyx_L1;}
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)__pyx_v_sound->__pyx_base.__pyx_vtab)->_getbuffer(__pyx_v_sound,__pyx_3);
    Py_DECREF(__pyx_3); __pyx_3 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":314 */
    __pyx_4 = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer == 0);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/sound/sound.pyx":315 */
      __pyx_5 = __pyx_v_loop;
      if (__pyx_5) {

        /* "/home/jiba/src/soya/sound/sound.pyx":316 */
        ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer = ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer;

        /* "/home/jiba/src/soya/sound/sound.pyx":317 */
        alSourceQueueBuffers(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer));
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/home/jiba/src/soya/sound/sound.pyx":319 */
      alSourceQueueBuffers(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer));
    }
    __pyx_L8:;

    /* "/home/jiba/src/soya/sound/sound.pyx":321 */
    alSourcePlay(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source);
    goto __pyx_L5;
  }
  __pyx_L5:;

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

static PyObject *__pyx_f_5_soya_12_SoundPlayer___getcstate__(struct __pyx_obj_5_soya__SoundPlayer *__pyx_v_self) {
  float __pyx_v_x;
  __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/sound/sound.pyx":327 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/sound/sound.pyx":328 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._option);

  /* "/home/jiba/src/soya/sound/sound.pyx":329 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/sound/sound.pyx":330 */
  chunk_add_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_old_pos,3);

  /* "/home/jiba/src/soya/sound/sound.pyx":331 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_current_buffer_id);

  /* "/home/jiba/src/soya/sound/sound.pyx":333 */
  alGetSourcef(__pyx_v_self->_source,AL_GAIN,(&__pyx_v_x));

  /* "/home/jiba/src/soya/sound/sound.pyx":334 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_x);

  /* "/home/jiba/src/soya/sound/sound.pyx":336 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 336; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 336; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1);
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_sound));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_self->_sound));
  __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._SoundPlayer.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_12_SoundPlayer___setcstate__(struct __pyx_obj_5_soya__SoundPlayer *__pyx_v_self,PyObject *__pyx_v_cstate) {
  __pyx_t_5_soya_Chunk (*__pyx_v_chunk);
  float __pyx_v_x;
  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/sound/sound.pyx":339 */
  __pyx_1 = PyInt_FromLong(1); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 339; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 339; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Sound)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 339; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_sound));
  __pyx_v_self->_sound = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":341 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 341; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 341; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_v_cstate);
  __pyx_v_cstate = __pyx_2;
  __pyx_2 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":343 */
  __pyx_v_self->__pyx_base._validity = __pyx_e_5_soya_COORDSYS_INVALID;

  /* "/home/jiba/src/soya/sound/sound.pyx":346 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/sound/sound.pyx":347 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->__pyx_base._option));

  /* "/home/jiba/src/soya/sound/sound.pyx":348 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->__pyx_base._matrix,19);

  /* "/home/jiba/src/soya/sound/sound.pyx":349 */
  chunk_get_floats_endian_safe(__pyx_v_chunk,__pyx_v_self->_old_pos,3);

  /* "/home/jiba/src/soya/sound/sound.pyx":350 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_current_buffer_id));

  /* "/home/jiba/src/soya/sound/sound.pyx":352 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_x));

  /* "/home/jiba/src/soya/sound/sound.pyx":353 */
  alSourcef(__pyx_v_self->_source,AL_GAIN,__pyx_v_x);

  /* "/home/jiba/src/soya/sound/sound.pyx":355 */
  drop_chunk(__pyx_v_chunk);

  /* "/home/jiba/src/soya/sound/sound.pyx":357 */
  __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SOUND_PLAY_IN_3D);
  if (__pyx_3) {

    /* "/home/jiba/src/soya/sound/sound.pyx":358 */
    alSourcefv(__pyx_v_self->_source,AL_POSITION,__pyx_v_self->_old_pos);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":360 */
  __pyx_3 = PyObject_IsTrue(((PyObject *)__pyx_v_self->_sound)); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 360; goto __pyx_L1;}
  if (__pyx_3) {

    /* "/home/jiba/src/soya/sound/sound.pyx":361 */
    __pyx_1 = PyInt_FromLong(__pyx_v_self->_current_buffer_id); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 361; goto __pyx_L1;}
    __pyx_v_self->_current_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)__pyx_v_self->_sound->__pyx_base.__pyx_vtab)->_getbuffer(__pyx_v_self->_sound,__pyx_1);
    Py_DECREF(__pyx_1); __pyx_1 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":362 */
    alSourceQueueBuffers(__pyx_v_self->_source,1,(&__pyx_v_self->_current_buffer));

    /* "/home/jiba/src/soya/sound/sound.pyx":364 */
    __pyx_2 = PyInt_FromLong((__pyx_v_self->_current_buffer_id + 1)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 364; goto __pyx_L1;}
    __pyx_v_self->_pending_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)__pyx_v_self->_sound->__pyx_base.__pyx_vtab)->_getbuffer(__pyx_v_self->_sound,__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":365 */
    __pyx_3 = (__pyx_v_self->_pending_buffer == 0);
    if (__pyx_3) {

      /* "/home/jiba/src/soya/sound/sound.pyx":366 */
      __pyx_3 = (__pyx_v_self->__pyx_base._option & __pyx_e_5_soya_SOUND_LOOP);
      if (__pyx_3) {

        /* "/home/jiba/src/soya/sound/sound.pyx":367 */
        __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 367; goto __pyx_L1;}
        __pyx_v_self->_pending_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)__pyx_v_self->_sound->__pyx_base.__pyx_vtab)->_getbuffer(__pyx_v_self->_sound,__pyx_1);
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/home/jiba/src/soya/sound/sound.pyx":368 */
    alSourceQueueBuffers(__pyx_v_self->_source,1,(&__pyx_v_self->_pending_buffer));

    /* "/home/jiba/src/soya/sound/sound.pyx":370 */
    alSourcePlay(__pyx_v_self->_source);
    goto __pyx_L3;
  }
  __pyx_L3:;

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

static PyObject *__pyx_n_ended;

static PyObject *__pyx_f_5_soya_12_SoundPlayer_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SoundPlayer_begin_round(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_i;
  int __pyx_v_nb_queued;
  int __pyx_v_nb_processed;
  ALuint __pyx_v_buffer;
  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/sound/sound.pyx":373 */
  __pyx_1 = PyObject_GetAttr(((PyObject*)__pyx_ptype_5_soya_CoordSyst), __pyx_n_begin_round); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 373; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 373; 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[26]; __pyx_lineno = 373; 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/sound/sound.pyx":378 */
  __pyx_4 = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer == 0);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/sound/sound.pyx":379 */
    __pyx_4 = (!(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SOUND_LOOP));
    if (__pyx_4) {

      /* "/home/jiba/src/soya/sound/sound.pyx":380 */
      alGetSourcei(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_SOURCE_STATE,(&__pyx_v_i));

      /* "/home/jiba/src/soya/sound/sound.pyx":381 */
      __pyx_4 = (__pyx_v_i == AL_STOPPED);
      if (__pyx_4) {
        __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_ended); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 381; goto __pyx_L1;}
        __pyx_2 = PyTuple_New(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 381; goto __pyx_L1;}
        __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 381; 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_L4;
      }
      __pyx_L4:;
      goto __pyx_L3;
    }
    __pyx_L3:;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/sound/sound.pyx":383 */
  alGetSourcei(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_BUFFERS_QUEUED,(&__pyx_v_nb_queued));

  /* "/home/jiba/src/soya/sound/sound.pyx":384 */
  alGetSourcei(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_BUFFERS_PROCESSED,(&__pyx_v_nb_processed));

  /* "/home/jiba/src/soya/sound/sound.pyx":386 */
  __pyx_4 = (__pyx_v_nb_processed >= 1);
  if (__pyx_4) {

    /* "/home/jiba/src/soya/sound/sound.pyx":387 */
    alSourceUnqueueBuffers(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer));

    /* "/home/jiba/src/soya/sound/sound.pyx":389 */
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer = ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer;

    /* "/home/jiba/src/soya/sound/sound.pyx":391 */
    __pyx_1 = PyInt_FromLong(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 391; goto __pyx_L1;}
    __pyx_2 = PyInt_FromLong(0); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 391; goto __pyx_L1;}
    __pyx_3 = PyObject_GetItem(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound->_buffers, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (PyObject_Cmp(__pyx_1, __pyx_3, &__pyx_4) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 391; goto __pyx_L1;}
    __pyx_4 = __pyx_4 == 0;
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    if (__pyx_4) {
      ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer_id = 0;
      goto __pyx_L6;
    }
    /*else*/ {
      ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer_id = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer_id + 1);
    }
    __pyx_L6:;

    /* "/home/jiba/src/soya/sound/sound.pyx":394 */
    __pyx_2 = PyInt_FromLong((((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_current_buffer_id + 1)); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 394; goto __pyx_L1;}
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound->__pyx_base.__pyx_vtab)->_getbuffer(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound,__pyx_2);
    Py_DECREF(__pyx_2); __pyx_2 = 0;

    /* "/home/jiba/src/soya/sound/sound.pyx":396 */
    __pyx_4 = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer == 0);
    if (__pyx_4) {

      /* "/home/jiba/src/soya/sound/sound.pyx":397 */
      __pyx_4 = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SOUND_LOOP);
      if (__pyx_4) {
        __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 397; goto __pyx_L1;}
        ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer = ((struct __pyx_vtabstruct_5_soya__Sound *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound->__pyx_base.__pyx_vtab)->_getbuffer(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound,__pyx_1);
        Py_DECREF(__pyx_1); __pyx_1 = 0;
        goto __pyx_L8;
      }
      /*else*/ {
        __pyx_r = Py_None; Py_INCREF(__pyx_r);
        goto __pyx_L0;
      }
      __pyx_L8:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "/home/jiba/src/soya/sound/sound.pyx":400 */
    alSourceQueueBuffers(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,1,(&((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_pending_buffer));

    /* "/home/jiba/src/soya/sound/sound.pyx":402 */
    alGetSourcei(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_SOURCE_STATE,(&__pyx_v_i));

    /* "/home/jiba/src/soya/sound/sound.pyx":403 */
    __pyx_4 = (__pyx_v_i == AL_STOPPED);
    if (__pyx_4) {
      alSourcePlay(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source);
      goto __pyx_L9;
    }
    __pyx_L9:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  __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._SoundPlayer.begin_round");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SoundPlayer_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12_SoundPlayer_advance_time(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_proportion;
  float (__pyx_v_pos[3]);
  float __pyx_v_dt;
  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[] = {"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/sound/sound.pyx":410 */
  __pyx_1 = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SOUND_PLAY_IN_3D);
  if (__pyx_1) {
    __pyx_1 = (!(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_COORDSYS_STATIC));
  }
  if (__pyx_1) {

    /* "/home/jiba/src/soya/sound/sound.pyx":411 */
    __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 411; goto __pyx_L1;}
    __pyx_1 = __pyx_2 == Py_None;
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    if (__pyx_1) {
      __pyx_v_dt = (__pyx_v_proportion * 0.030);
      goto __pyx_L3;
    }
    /*else*/ {
      __pyx_2 = PyFloat_FromDouble(__pyx_v_proportion); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 412; goto __pyx_L1;}
      __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_MAIN_LOOP); if (!__pyx_3) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 412; goto __pyx_L1;}
      __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_round_duration); if (!__pyx_4) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 412; 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[26]; __pyx_lineno = 412; goto __pyx_L1;}
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      Py_DECREF(__pyx_4); __pyx_4 = 0;
      __pyx_5 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 412; goto __pyx_L1;}
      Py_DECREF(__pyx_3); __pyx_3 = 0;
      __pyx_v_dt = __pyx_5;
    }
    __pyx_L3:;

    /* "/home/jiba/src/soya/sound/sound.pyx":414 */
    ((struct __pyx_vtabstruct_5_soya__SoundPlayer *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base._out(((struct __pyx_obj_5_soya_Position *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)),__pyx_v_pos);

    /* "/home/jiba/src/soya/sound/sound.pyx":417 */
    alSourcefv(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_POSITION,__pyx_v_pos);

    /* "/home/jiba/src/soya/sound/sound.pyx":418 */
    alSource3f(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_VELOCITY,(((__pyx_v_pos[0]) - (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_old_pos[0])) / __pyx_v_dt),(((__pyx_v_pos[1]) - (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_old_pos[1])) / __pyx_v_dt),(((__pyx_v_pos[2]) - (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_old_pos[2])) / __pyx_v_dt));

    /* "/home/jiba/src/soya/sound/sound.pyx":424 */
    memcpy(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_old_pos,__pyx_v_pos,(3 * (sizeof(float ))));
    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._SoundPlayer.advance_time");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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

  /* "/home/jiba/src/soya/sound/sound.pyx":428 */
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound));
  __pyx_r = ((PyObject *)((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_sound);
  goto __pyx_L0;

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

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

  /* "/home/jiba/src/soya/sound/sound.pyx":432 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SOUND_LOOP)); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 432; 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._SoundPlayer.loop.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_SoundPlayer_4loop___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_12_SoundPlayer_4loop___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[26]; __pyx_lineno = 433; goto __pyx_L1;}

  /* "/home/jiba/src/soya/sound/sound.pyx":434 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SOUND_LOOP);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_SOUND_LOOP));
  }
  __pyx_L2:;

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

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

  /* "/home/jiba/src/soya/sound/sound.pyx":439 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SOUND_AUTO_REMOVE)); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 439; 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._SoundPlayer.auto_remove.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_SoundPlayer_11auto_remove___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_12_SoundPlayer_11auto_remove___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[26]; __pyx_lineno = 440; goto __pyx_L1;}

  /* "/home/jiba/src/soya/sound/sound.pyx":441 */
  __pyx_1 = __pyx_v_x;
  if (__pyx_1) {
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option | __pyx_e_5_soya_SOUND_AUTO_REMOVE);
    goto __pyx_L2;
  }
  /*else*/ {
    ((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option = (((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & (~__pyx_e_5_soya_SOUND_AUTO_REMOVE));
  }
  __pyx_L2:;

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

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

  /* "/home/jiba/src/soya/sound/sound.pyx":446 */
  __pyx_1 = PyInt_FromLong((((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->__pyx_base._option & __pyx_e_5_soya_SOUND_PLAY_IN_3D)); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 446; 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._SoundPlayer.play_in_3D.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12_SoundPlayer_4gain___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_12_SoundPlayer_4gain___get__(PyObject *__pyx_v_self) {
  float __pyx_v_x;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/sound/sound.pyx":454 */
  alGetSourcef(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_GAIN,(&__pyx_v_x));

  /* "/home/jiba/src/soya/sound/sound.pyx":455 */
  __pyx_1 = PyFloat_FromDouble(__pyx_v_x); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 455; 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._SoundPlayer.gain.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_12_SoundPlayer_4gain___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_12_SoundPlayer_4gain___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[26]; __pyx_lineno = 456; goto __pyx_L1;}

  /* "/home/jiba/src/soya/sound/sound.pyx":457 */
  alSourcef(((struct __pyx_obj_5_soya__SoundPlayer *)__pyx_v_self)->_source,AL_GAIN,__pyx_v_x);

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

static int __pyx_f_5_soya_7_Deform___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_5_soya_7_Deform___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/model/deform.pyx":28 */
  ((struct __pyx_obj_5_soya__Deform *)__pyx_v_self)->_time = 0.0;

  /* "/home/jiba/src/soya/model/deform.pyx":29 */
  ((struct __pyx_obj_5_soya__Deform *)__pyx_v_self)->_time_speed = 1.0;

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

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

  /* "/home/jiba/src/soya/model/deform.pyx":33 */
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_5_soya__Deform *)__pyx_v_self)->_time); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 33; 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._Deform.time.__get__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_5_soya_7_Deform_4time___set__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_5_soya_7_Deform_4time___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[27]; __pyx_lineno = 34; goto __pyx_L1;}

  /* "/home/jiba/src/soya/model/deform.pyx":35 */
  ((struct __pyx_obj_5_soya__Deform *)__pyx_v_self)->_time = __pyx_v_x;

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

static PyObject *__pyx_f_5_soya_7_Deform___getcstate__(struct __pyx_obj_5_soya__Deform *__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/deform.pyx":39 */
  __pyx_v_chunk = get_chunk();

  /* "/home/jiba/src/soya/model/deform.pyx":40 */
  chunk_add_int_endian_safe(__pyx_v_chunk,__pyx_v_self->_option);

  /* "/home/jiba/src/soya/model/deform.pyx":41 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_time);

  /* "/home/jiba/src/soya/model/deform.pyx":42 */
  chunk_add_float_endian_safe(__pyx_v_chunk,__pyx_v_self->_time_speed);

  /* "/home/jiba/src/soya/model/deform.pyx":43 */
  __pyx_1 = __pyx_f_5_soya_drop_chunk_to_string(__pyx_v_chunk); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 43; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 43; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_model));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_self->_model));
  PyTuple_SET_ITEM(__pyx_2, 1, __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._Deform.__getcstate__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Deform___setcstate__(struct __pyx_obj_5_soya__Deform *__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/deform.pyx":46 */
  __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_2 = PyObject_GetItem(__pyx_v_cstate, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 46; goto __pyx_L1;}
  __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Deform *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_set_model(__pyx_v_self,((struct __pyx_obj_5_soya__Model *)__pyx_2)); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/model/deform.pyx":48 */
  __pyx_v_chunk = __pyx_f_5_soya_string_to_chunk(__pyx_v_cstate);

  /* "/home/jiba/src/soya/model/deform.pyx":49 */
  chunk_get_int_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_option));

  /* "/home/jiba/src/soya/model/deform.pyx":50 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_time));

  /* "/home/jiba/src/soya/model/deform.pyx":51 */
  chunk_get_float_endian_safe(__pyx_v_chunk,(&__pyx_v_self->_time_speed));

  /* "/home/jiba/src/soya/model/deform.pyx":52 */
  drop_chunk(__pyx_v_chunk);

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

static PyObject *__pyx_f_5_soya_7_Deform__set_model(struct __pyx_obj_5_soya__Deform *__pyx_v_self,struct __pyx_obj_5_soya__Model *__pyx_v_model) {
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_model);

  /* "/home/jiba/src/soya/model/deform.pyx":55 */
  __pyx_1 = ((PyObject *)__pyx_v_model) == Py_None;
  if (__pyx_1) {

    /* "/home/jiba/src/soya/model/deform.pyx":56 */
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 56; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_model));
    __pyx_v_self->_model = Py_None;

    /* "/home/jiba/src/soya/model/deform.pyx":57 */
    if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 57; goto __pyx_L1;}
    Py_INCREF(Py_None);
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_data));
    __pyx_v_self->_data = Py_None;
    goto __pyx_L2;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/deform.pyx":60 */
    Py_INCREF(((PyObject *)__pyx_v_model));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_model));
    __pyx_v_self->_model = ((PyObject *)__pyx_v_model);

    /* "/home/jiba/src/soya/model/deform.pyx":61 */
    __pyx_2 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_model->__pyx_base.__pyx_vtab)->_create_deformed_data(__pyx_v_model)); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 61; goto __pyx_L1;}
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_self->_data));
    __pyx_v_self->_data = __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._Deform._set_model");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_model);
  return __pyx_r;
}

static struct __pyx_obj_5_soya__Model *__pyx_f_5_soya_7_Deform__create_deformed_data(struct __pyx_obj_5_soya__Deform *__pyx_v_self) {
  struct __pyx_obj_5_soya__Model *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = ((PyObject *)((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_create_deformed_data(__pyx_v_self->_data)); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 63; goto __pyx_L1;}
  __pyx_r = (struct __pyx_obj_5_soya__Model *)__pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

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

static void __pyx_f_5_soya_7_Deform__batch(struct __pyx_obj_5_soya__Deform *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  /* "/home/jiba/src/soya/model/deform.pyx":66 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_model) == Py_None;
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 66; goto __pyx_L1;}
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[27]; __pyx_lineno = 66; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/deform.pyx":67 */
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_batch(__pyx_v_self->_data,__pyx_v_body);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Deform._batch");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static void __pyx_f_5_soya_7_Deform__render(struct __pyx_obj_5_soya__Deform *__pyx_v_self,struct __pyx_obj_5_soya__Body *__pyx_v_body) {
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF((PyObject *)__pyx_v_body);

  /* "/home/jiba/src/soya/model/deform.pyx":69 */
  __pyx_1 = ((PyObject *)__pyx_v_self->_model) == Py_None;
  if (__pyx_1) {
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 69; goto __pyx_L1;}
    __Pyx_Raise(__pyx_2, 0, 0);
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    {__pyx_filename = __pyx_f[27]; __pyx_lineno = 69; goto __pyx_L1;}
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/deform.pyx":70 */
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_render(__pyx_v_self->_data,__pyx_v_body);

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_WriteUnraisable("_soya._Deform._render");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_body);
}

static int __pyx_f_5_soya_7_Deform__shadow(struct __pyx_obj_5_soya__Deform *__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);
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_shadow(__pyx_v_self->_data,__pyx_v_coord_syst,__pyx_v_light);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Deform._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_7_Deform__get_box(struct __pyx_obj_5_soya__Deform *__pyx_v_self,float (*__pyx_v_box),float (*__pyx_v_matrix)) {
  Py_INCREF((PyObject *)__pyx_v_self);
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_get_box(__pyx_v_self->_data,__pyx_v_box,__pyx_v_matrix);

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

static void __pyx_f_5_soya_7_Deform__raypick(struct __pyx_obj_5_soya__Deform *__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);
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_raypick(__pyx_v_self->_data,__pyx_v_raypick_data,__pyx_v_raypickable);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Deform._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_Deform__raypick_b(struct __pyx_obj_5_soya__Deform *__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);
  __pyx_r = ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_raypick_b(__pyx_v_self->_data,__pyx_v_raypick_data,__pyx_v_raypickable);
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Deform._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_Deform__collect_raypickables(struct __pyx_obj_5_soya__Deform *__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);
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_data->__pyx_base.__pyx_vtab)->_collect_raypickables(__pyx_v_self->_data,__pyx_v_items,__pyx_v_rsphere,__pyx_v_sphere,__pyx_v_parent);

  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_WriteUnraisable("_soya._Deform._collect_raypickables");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF((PyObject *)__pyx_v_parent);
}

static PyObject *__pyx_f_5_soya_7_Deform__deform_points(struct __pyx_obj_5_soya__Deform *__pyx_v_self,float (*__pyx_v_coords),float (*__pyx_v_r),int __pyx_v_nb) {
  int __pyx_v_i;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/deform.pyx":79 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nb; ++__pyx_v_i) {

    /* "/home/jiba/src/soya/model/deform.pyx":80 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Deform *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_deform_point(__pyx_v_self,(__pyx_v_coords + (3 * __pyx_v_i)),(__pyx_v_r + (3 * __pyx_v_i))); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 80; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    __pyx_L2:;
  }
  __pyx_L3:;

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

static PyObject *__pyx_f_5_soya_7_Deform__deform_point(struct __pyx_obj_5_soya__Deform *__pyx_v_self,float (*__pyx_v_coord),float (*__pyx_v_r)) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/deform.pyx":83 */
  (__pyx_v_r[0]) = (__pyx_v_coord[0]);

  /* "/home/jiba/src/soya/model/deform.pyx":84 */
  (__pyx_v_r[1]) = (__pyx_v_coord[1]);

  /* "/home/jiba/src/soya/model/deform.pyx":85 */
  (__pyx_v_r[2]) = (__pyx_v_coord[2]);

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

static PyObject *__pyx_k416p;

static char (__pyx_k416[]) = "<%s deforming %s>";

static PyObject *__pyx_f_5_soya_7_Deform___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_5_soya_7_Deform___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/deform.pyx":88 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 88; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 88; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 88; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2);
  Py_INCREF((PyObject *)((PyObject *)((struct __pyx_obj_5_soya__Deform *)__pyx_v_self)->_model));
  PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_5_soya__Deform *)__pyx_v_self)->_model));
  __pyx_2 = 0;
  __pyx_2 = PyNumber_Remainder(__pyx_k416p, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 88; 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._Deform.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static void __pyx_f_5_soya_7_Deform__begin_round(struct __pyx_obj_5_soya__Deform *__pyx_v_self) {
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/deform.pyx":93 */
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_model->__pyx_base.__pyx_vtab)->_begin_round(__pyx_v_self->_model);

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

static PyObject *__pyx_k417p;

static char (__pyx_k417[]) = "Cannot deform %s!";

static void __pyx_f_5_soya_7_Deform__advance_time(struct __pyx_obj_5_soya__Deform *__pyx_v_self,float __pyx_v_proportion) {
  struct __pyx_obj_5_soya__Model *__pyx_v_base;
  struct __pyx_obj_5_soya__Deform *__pyx_v_deform;
  struct __pyx_obj_5_soya__SimpleModel *__pyx_v_simple_model;
  struct __pyx_obj_5_soya__SimpleModel *__pyx_v_simple_data;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  int __pyx_4;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_base = Py_None; Py_INCREF((PyObject *) __pyx_v_base);
  __pyx_v_deform = Py_None; Py_INCREF((PyObject *) __pyx_v_deform);
  __pyx_v_simple_model = Py_None; Py_INCREF((PyObject *) __pyx_v_simple_model);
  __pyx_v_simple_data = Py_None; Py_INCREF((PyObject *) __pyx_v_simple_data);

  /* "/home/jiba/src/soya/model/deform.pyx":96 */
  ((struct __pyx_vtabstruct_5_soya__Model *)__pyx_v_self->_model->__pyx_base.__pyx_vtab)->_advance_time(__pyx_v_self->_model,__pyx_v_proportion);

  /* "/home/jiba/src/soya/model/deform.pyx":98 */
  __pyx_v_self->_time = (__pyx_v_self->_time + (__pyx_v_self->_time_speed * __pyx_v_proportion));

  /* "/home/jiba/src/soya/model/deform.pyx":104 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 104; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 104; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_self->_model));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_self->_model));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__Deform));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__Deform));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 104; 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[27]; __pyx_lineno = 104; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/deform.pyx":105 */
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_self->_model), __pyx_ptype_5_soya__Deform)) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 105; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_self->_model));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_deform));
    __pyx_v_deform = ((PyObject *)__pyx_v_self->_model);

    /* "/home/jiba/src/soya/model/deform.pyx":106 */
    Py_INCREF(((PyObject *)__pyx_v_deform->_data));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_base));
    __pyx_v_base = ((PyObject *)__pyx_v_deform->_data);
    goto __pyx_L2;
  }
  /*else*/ {
    Py_INCREF(((PyObject *)__pyx_v_self->_model));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_base));
    __pyx_v_base = ((PyObject *)__pyx_v_self->_model);
  }
  __pyx_L2:;

  /* "/home/jiba/src/soya/model/deform.pyx":109 */
  __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_isinstance); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 109; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 109; goto __pyx_L1;}
  Py_INCREF((PyObject *)((PyObject *)__pyx_v_base));
  PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_base));
  Py_INCREF(((PyObject*)__pyx_ptype_5_soya__SimpleModel));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject*)__pyx_ptype_5_soya__SimpleModel));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 109; 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[27]; __pyx_lineno = 109; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  if (__pyx_4) {

    /* "/home/jiba/src/soya/model/deform.pyx":110 */
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_base), __pyx_ptype_5_soya__SimpleModel)) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 110; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_base));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_simple_model));
    __pyx_v_simple_model = ((PyObject *)__pyx_v_base);

    /* "/home/jiba/src/soya/model/deform.pyx":111 */
    if (!__Pyx_TypeTest(((PyObject *)__pyx_v_self->_data), __pyx_ptype_5_soya__SimpleModel)) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 111; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_self->_data));
    Py_DECREF((PyObject *)((PyObject *)__pyx_v_simple_data));
    __pyx_v_simple_data = ((PyObject *)__pyx_v_self->_data);

    /* "/home/jiba/src/soya/model/deform.pyx":112 */
    __pyx_1 = ((struct __pyx_vtabstruct_5_soya__Deform *)__pyx_v_self->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab)->_deform_points(__pyx_v_self,__pyx_v_simple_model->_coords,__pyx_v_simple_data->_coords,__pyx_v_simple_model->_nb_coords); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 112; goto __pyx_L1;}
    Py_DECREF(__pyx_1); __pyx_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/home/jiba/src/soya/model/deform.pyx":115 */
    __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_ValueError); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 115; goto __pyx_L1;}
    __pyx_3 = PyNumber_Remainder(__pyx_k417p, ((PyObject *)__pyx_v_base)); if (!__pyx_3) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 115; goto __pyx_L1;}
    __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 115; 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[27]; __pyx_lineno = 115; 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[27]; __pyx_lineno = 115; goto __pyx_L1;}
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_WriteUnraisable("_soya._Deform._advance_time");
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_base);
  Py_DECREF((PyObject *)__pyx_v_deform);
  Py_DECREF((PyObject *)__pyx_v_simple_model);
  Py_DECREF((PyObject *)__pyx_v_simple_data);
  Py_DECREF((PyObject *)__pyx_v_self);
}

static PyObject *__pyx_f_5_soya_11_TestDeform__deform_point(struct __pyx_obj_5_soya__TestDeform *__pyx_v_self,float (*__pyx_v_coord),float (*__pyx_v_r)) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/deform.pyx":121 */
  (__pyx_v_r[0]) = ((__pyx_v_coord[0]) + (((__pyx_v_coord[1]) * __pyx_v_self->__pyx_base._time) * 0.1));

  /* "/home/jiba/src/soya/model/deform.pyx":122 */
  (__pyx_v_r[1]) = (__pyx_v_coord[1]);

  /* "/home/jiba/src/soya/model/deform.pyx":123 */
  (__pyx_v_r[2]) = (__pyx_v_coord[2]);

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

static PyObject *__pyx_n_deform_point;

static PyObject *__pyx_f_5_soya_12PythonDeform__deform_point(struct __pyx_obj_5_soya_PythonDeform *__pyx_v_self,float (*__pyx_v_coord),float (*__pyx_v_r)) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  float __pyx_6;
  float __pyx_7;
  float __pyx_8;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/home/jiba/src/soya/model/deform.pyx":128 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_deform_point); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble((__pyx_v_coord[0])); if (!__pyx_2) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble((__pyx_v_coord[1])); if (!__pyx_3) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble((__pyx_v_coord[2])); if (!__pyx_4) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; 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[27]; __pyx_lineno = 128; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_3 = __Pyx_UnpackItem(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_6 = PyFloat_AsDouble(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  (__pyx_v_r[0]) = __pyx_6;
  __pyx_4 = __Pyx_UnpackItem(__pyx_2, 1); if (!__pyx_4) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_7 = PyFloat_AsDouble(__pyx_4); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  (__pyx_v_r[1]) = __pyx_7;
  __pyx_1 = __Pyx_UnpackItem(__pyx_2, 2); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_8 = PyFloat_AsDouble(__pyx_1); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  (__pyx_v_r[2]) = __pyx_8;
  if (__Pyx_EndUnpack(__pyx_2, 3) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 128; goto __pyx_L1;}
  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.PythonDeform._deform_point");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_5_soya_12PythonDeform_deform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_5_soya_12PythonDeform_deform_point(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  PyObject *__pyx_v_z = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"x","y","z",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  Py_INCREF(__pyx_v_y);
  Py_INCREF(__pyx_v_z);

  /* "/home/jiba/src/soya/model/deform.pyx":131 */
  __pyx_1 = PyTuple_New(3); if (!__pyx_1) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 131; goto __pyx_L1;}
  Py_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_x);
  Py_INCREF(__pyx_v_y);
  PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_y);
  Py_INCREF(__pyx_v_z);
  PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_z);
  __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.PythonDeform.deform_point");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  Py_DECREF(__pyx_v_y);
  Py_DECREF(__pyx_v_z);
  return __pyx_r;
}

static __Pyx_InternTabEntry __pyx_intern_tab[] = {
  {&__pyx_n_ALC_INVALID_CONTEXT, "ALC_INVALID_CONTEXT"},
  {&__pyx_n_ALC_INVALID_DEVICE, "ALC_INVALID_DEVICE"},
  {&__pyx_n_ALC_INVALID_ENUM, "ALC_INVALID_ENUM"},
  {&__pyx_n_ALC_INVALID_VALUE, "ALC_INVALID_VALUE"},
  {&__pyx_n_ALC_OUT_OF_MEMORY, "ALC_OUT_OF_MEMORY"},
  {&__pyx_n_ALError, "ALError"},
  {&__pyx_n_ALL_EVENTS, "ALL_EVENTS"},
  {&__pyx_n_AL_INVALID_ENUM, "AL_INVALID_ENUM"},
  {&__pyx_n_AL_INVALID_NAME, "AL_INVALID_NAME"},
  {&__pyx_n_AL_INVALID_OPERATION, "AL_INVALID_OPERATION"},
  {&__pyx_n_AL_INVALID_VALUE, "AL_INVALID_VALUE"},
  {&__pyx_n_AL_OUT_OF_MEMORY, "AL_OUT_OF_MEMORY"},
  {&__pyx_n_AnimatedModel, "AnimatedModel"},
  {&__pyx_n_Atmosphere, "Atmosphere"},
  {&__pyx_n_BEFORE_RENDER, "BEFORE_RENDER"},
  {&__pyx_n_BLACK, "BLACK"},
  {&__pyx_n_Body, "Body"},
  {&__pyx_n_Cal3dBody, "Cal3dBody"},
  {&__pyx_n_Camera, "Camera"},
  {&__pyx_n_CellShadingModel, "CellShadingModel"},
  {&__pyx_n_ChunkError, "ChunkError"},
  {&__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_IDLER, "IDLER"},
  {&__pyx_n_Image, "Image"},
  {&__pyx_n_ImportError, "ImportError"},
  {&__pyx_n_L, "L"},
  {&__pyx_n_Light, "Light"},
  {&__pyx_n_MAIN_LOOP, "MAIN_LOOP"},
  {&__pyx_n_MAIN_LOOP_ITEMS, "MAIN_LOOP_ITEMS"},
  {&__pyx_n_Material, "Material"},
  {&__pyx_n_MemoryError, "MemoryError"},
  {&__pyx_n_Model, "Model"},
  {&__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_SimpleModel, "SimpleModel"},
  {&__pyx_n_SolidModel, "SolidModel"},
  {&__pyx_n_StandardError, "StandardError"},
  {&__pyx_n_StringIO, "StringIO"},
  {&__pyx_n_TRANSPARENT, "TRANSPARENT"},
  {&__pyx_n_TreeModel, "TreeModel"},
  {&__pyx_n_TypeError, "TypeError"},
  {&__pyx_n_VERSION, "VERSION"},
  {&__pyx_n_ValueError, "ValueError"},
  {&__pyx_n_Vector, "Vector"},
  {&__pyx_n_VorbisFile, "VorbisFile"},
  {&__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__chunk_check_error, "_chunk_check_error"},
  {&__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_model_builder, "_set_default_model_builder"},
  {&__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_back, "back"},
  {&__pyx_n_base_model, "base_model"},
  {&__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_channels, "channels"},
  {&__pyx_n_check_al_error, "check_al_error"},
  {&__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_coord_syst, "coord_syst"},
  {&__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_deform_point, "deform_point"},
  {&__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_ended, "ended"},
  {&__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_get_sound_volume, "get_sound_volume"},
  {&__pyx_n_getattr, "getattr"},
  {&__pyx_n_getframerate, "getframerate"},
  {&__pyx_n_getnchannels, "getnchannels"},
  {&__pyx_n_getsampwidth, "getsampwidth"},
  {&__pyx_n_getvalue, "getvalue"},
  {&__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_iii, "iii"},
  {&__pyx_n_image_from_pil, "image_from_pil"},
  {&__pyx_n_inactivated, "inactivated"},
  {&__pyx_n_index, "index"},
  {&__pyx_n_info, "info"},
  {&__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_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_main_loop, "main_loop"},
  {&__pyx_n_map, "map"},
  {&__pyx_n_material, "material"},
  {&__pyx_n_max, "max"},
  {&__pyx_n_mesh, "mesh"},
  {&__pyx_n_mesh_names, "mesh_names"},
  {&__pyx_n_meshes, "meshes"},
  {&__pyx_n_min, "min"},
  {&__pyx_n_mode, "mode"},
  {&__pyx_n_model, "model"},
  {&__pyx_n_model_builder, "model_builder"},
  {&__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_palette, "palette"},
  {&__pyx_n_parent, "parent"},
  {&__pyx_n_parse_cal3d_cfg_file, "parse_cal3d_cfg_file"},
  {&__pyx_n_path, "path"},
  {&__pyx_n_pcm_seek, "pcm_seek"},
  {&__pyx_n_pixels, "pixels"},
  {&__pyx_n_platform, "platform"},
  {&__pyx_n_pop, "pop"},
  {&__pyx_n_process_event, "process_event"},
  {&__pyx_n_putpalette, "putpalette"},
  {&__pyx_n_quit, "quit"},
  {&__pyx_n_random, "random"},
  {&__pyx_n_rate, "rate"},
  {&__pyx_n_raypick, "raypick"},
  {&__pyx_n_rb, "rb"},
  {&__pyx_n_read, "read"},
  {&__pyx_n_readframes, "readframes"},
  {&__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_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_sizes, "set_sizes"},
  {&__pyx_n_set_sound_volume, "set_sound_volume"},
  {&__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_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_static, "static"},
  {&__pyx_n_stereo, "stereo"},
  {&__pyx_n_struct, "struct"},
  {&__pyx_n_subgenerate, "subgenerate"},
  {&__pyx_n_sys, "sys"},
  {&__pyx_n_terrain, "terrain"},
  {&__pyx_n_terrain_free_patchs, "terrain_free_patchs"},
  {&__pyx_n_texture, "texture"},
  {&__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_vorbis, "vorbis"},
  {&__pyx_n_wave, "wave"},
  {&__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_k3p, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_k11p, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_k155p, __pyx_k155, sizeof(__pyx_k155)},
  {&__pyx_k174p, __pyx_k174, sizeof(__pyx_k174)},
  {&__pyx_k175p, __pyx_k175, sizeof(__pyx_k175)},
  {&__pyx_k176p, __pyx_k176, sizeof(__pyx_k176)},
  {&__pyx_k177p, __pyx_k177, sizeof(__pyx_k177)},
  {&__pyx_k178p, __pyx_k178, sizeof(__pyx_k178)},
  {&__pyx_k179p, __pyx_k179, sizeof(__pyx_k179)},
  {&__pyx_k180p, __pyx_k180, sizeof(__pyx_k180)},
  {&__pyx_k181p, __pyx_k181, sizeof(__pyx_k181)},
  {&__pyx_k182p, __pyx_k182, sizeof(__pyx_k182)},
  {&__pyx_k183p, __pyx_k183, sizeof(__pyx_k183)},
  {&__pyx_k186p, __pyx_k186, sizeof(__pyx_k186)},
  {&__pyx_k189p, __pyx_k189, sizeof(__pyx_k189)},
  {&__pyx_k190p, __pyx_k190, sizeof(__pyx_k190)},
  {&__pyx_k191p, __pyx_k191, sizeof(__pyx_k191)},
  {&__pyx_k195p, __pyx_k195, sizeof(__pyx_k195)},
  {&__pyx_k196p, __pyx_k196, sizeof(__pyx_k196)},
  {&__pyx_k207p, __pyx_k207, sizeof(__pyx_k207)},
  {&__pyx_k208p, __pyx_k208, sizeof(__pyx_k208)},
  {&__pyx_k214p, __pyx_k214, sizeof(__pyx_k214)},
  {&__pyx_k215p, __pyx_k215, sizeof(__pyx_k215)},
  {&__pyx_k216p, __pyx_k216, sizeof(__pyx_k216)},
  {&__pyx_k217p, __pyx_k217, sizeof(__pyx_k217)},
  {&__pyx_k218p, __pyx_k218, sizeof(__pyx_k218)},
  {&__pyx_k219p, __pyx_k219, sizeof(__pyx_k219)},
  {&__pyx_k220p, __pyx_k220, sizeof(__pyx_k220)},
  {&__pyx_k221p, __pyx_k221, sizeof(__pyx_k221)},
  {&__pyx_k222p, __pyx_k222, sizeof(__pyx_k222)},
  {&__pyx_k223p, __pyx_k223, sizeof(__pyx_k223)},
  {&__pyx_k224p, __pyx_k224, sizeof(__pyx_k224)},
  {&__pyx_k225p, __pyx_k225, sizeof(__pyx_k225)},
  {&__pyx_k226p, __pyx_k226, sizeof(__pyx_k226)},
  {&__pyx_k227p, __pyx_k227, sizeof(__pyx_k227)},
  {&__pyx_k228p, __pyx_k228, sizeof(__pyx_k228)},
  {&__pyx_k230p, __pyx_k230, sizeof(__pyx_k230)},
  {&__pyx_k231p, __pyx_k231, sizeof(__pyx_k231)},
  {&__pyx_k232p, __pyx_k232, sizeof(__pyx_k232)},
  {&__pyx_k237p, __pyx_k237, sizeof(__pyx_k237)},
  {&__pyx_k239p, __pyx_k239, sizeof(__pyx_k239)},
  {&__pyx_k244p, __pyx_k244, sizeof(__pyx_k244)},
  {&__pyx_k245p, __pyx_k245, sizeof(__pyx_k245)},
  {&__pyx_k249p, __pyx_k249, sizeof(__pyx_k249)},
  {&__pyx_k251p, __pyx_k251, sizeof(__pyx_k251)},
  {&__pyx_k252p, __pyx_k252, sizeof(__pyx_k252)},
  {&__pyx_k253p, __pyx_k253, sizeof(__pyx_k253)},
  {&__pyx_k259p, __pyx_k259, sizeof(__pyx_k259)},
  {&__pyx_k260p, __pyx_k260, sizeof(__pyx_k260)},
  {&__pyx_k267p, __pyx_k267, sizeof(__pyx_k267)},
  {&__pyx_k268p, __pyx_k268, sizeof(__pyx_k268)},
  {&__pyx_k272p, __pyx_k272, sizeof(__pyx_k272)},
  {&__pyx_k273p, __pyx_k273, sizeof(__pyx_k273)},
  {&__pyx_k274p, __pyx_k274, sizeof(__pyx_k274)},
  {&__pyx_k275p, __pyx_k275, sizeof(__pyx_k275)},
  {&__pyx_k276p, __pyx_k276, sizeof(__pyx_k276)},
  {&__pyx_k277p, __pyx_k277, sizeof(__pyx_k277)},
  {&__pyx_k278p, __pyx_k278, sizeof(__pyx_k278)},
  {&__pyx_k279p, __pyx_k279, sizeof(__pyx_k279)},
  {&__pyx_k280p, __pyx_k280, sizeof(__pyx_k280)},
  {&__pyx_k281p, __pyx_k281, sizeof(__pyx_k281)},
  {&__pyx_k282p, __pyx_k282, sizeof(__pyx_k282)},
  {&__pyx_k283p, __pyx_k283, sizeof(__pyx_k283)},
  {&__pyx_k284p, __pyx_k284, sizeof(__pyx_k284)},
  {&__pyx_k285p, __pyx_k285, sizeof(__pyx_k285)},
  {&__pyx_k286p, __pyx_k286, sizeof(__pyx_k286)},
  {&__pyx_k287p, __pyx_k287, sizeof(__pyx_k287)},
  {&__pyx_k288p, __pyx_k288, sizeof(__pyx_k288)},
  {&__pyx_k289p, __pyx_k289, sizeof(__pyx_k289)},
  {&__pyx_k290p, __pyx_k290, sizeof(__pyx_k290)},
  {&__pyx_k294p, __pyx_k294, sizeof(__pyx_k294)},
  {&__pyx_k295p, __pyx_k295, sizeof(__pyx_k295)},
  {&__pyx_k296p, __pyx_k296, sizeof(__pyx_k296)},
  {&__pyx_k297p, __pyx_k297, sizeof(__pyx_k297)},
  {&__pyx_k298p, __pyx_k298, sizeof(__pyx_k298)},
  {&__pyx_k299p, __pyx_k299, sizeof(__pyx_k299)},
  {&__pyx_k300p, __pyx_k300, sizeof(__pyx_k300)},
  {&__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_k314p, __pyx_k314, sizeof(__pyx_k314)},
  {&__pyx_k316p, __pyx_k316, sizeof(__pyx_k316)},
  {&__pyx_k317p, __pyx_k317, sizeof(__pyx_k317)},
  {&__pyx_k330p, __pyx_k330, sizeof(__pyx_k330)},
  {&__pyx_k331p, __pyx_k331, sizeof(__pyx_k331)},
  {&__pyx_k333p, __pyx_k333, sizeof(__pyx_k333)},
  {&__pyx_k335p, __pyx_k335, sizeof(__pyx_k335)},
  {&__pyx_k337p, __pyx_k337, sizeof(__pyx_k337)},
  {&__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_k353p, __pyx_k353, sizeof(__pyx_k353)},
  {&__pyx_k354p, __pyx_k354, sizeof(__pyx_k354)},
  {&__pyx_k355p, __pyx_k355, sizeof(__pyx_k355)},
  {&__pyx_k356p, __pyx_k356, sizeof(__pyx_k356)},
  {&__pyx_k357p, __pyx_k357, sizeof(__pyx_k357)},
  {&__pyx_k358p, __pyx_k358, sizeof(__pyx_k358)},
  {&__pyx_k359p, __pyx_k359, sizeof(__pyx_k359)},
  {&__pyx_k360p, __pyx_k360, sizeof(__pyx_k360)},
  {&__pyx_k361p, __pyx_k361, sizeof(__pyx_k361)},
  {&__pyx_k362p, __pyx_k362, sizeof(__pyx_k362)},
  {&__pyx_k363p, __pyx_k363, sizeof(__pyx_k363)},
  {&__pyx_k364p, __pyx_k364, sizeof(__pyx_k364)},
  {&__pyx_k365p, __pyx_k365, sizeof(__pyx_k365)},
  {&__pyx_k366p, __pyx_k366, sizeof(__pyx_k366)},
  {&__pyx_k367p, __pyx_k367, sizeof(__pyx_k367)},
  {&__pyx_k368p, __pyx_k368, sizeof(__pyx_k368)},
  {&__pyx_k370p, __pyx_k370, sizeof(__pyx_k370)},
  {&__pyx_k371p, __pyx_k371, sizeof(__pyx_k371)},
  {&__pyx_k372p, __pyx_k372, sizeof(__pyx_k372)},
  {&__pyx_k374p, __pyx_k374, sizeof(__pyx_k374)},
  {&__pyx_k375p, __pyx_k375, sizeof(__pyx_k375)},
  {&__pyx_k376p, __pyx_k376, sizeof(__pyx_k376)},
  {&__pyx_k377p, __pyx_k377, sizeof(__pyx_k377)},
  {&__pyx_k378p, __pyx_k378, sizeof(__pyx_k378)},
  {&__pyx_k379p, __pyx_k379, sizeof(__pyx_k379)},
  {&__pyx_k380p, __pyx_k380, sizeof(__pyx_k380)},
  {&__pyx_k381p, __pyx_k381, sizeof(__pyx_k381)},
  {&__pyx_k382p, __pyx_k382, sizeof(__pyx_k382)},
  {&__pyx_k383p, __pyx_k383, sizeof(__pyx_k383)},
  {&__pyx_k384p, __pyx_k384, sizeof(__pyx_k384)},
  {&__pyx_k385p, __pyx_k385, sizeof(__pyx_k385)},
  {&__pyx_k386p, __pyx_k386, sizeof(__pyx_k386)},
  {&__pyx_k387p, __pyx_k387, sizeof(__pyx_k387)},
  {&__pyx_k388p, __pyx_k388, sizeof(__pyx_k388)},
  {&__pyx_k389p, __pyx_k389, sizeof(__pyx_k389)},
  {&__pyx_k391p, __pyx_k391, sizeof(__pyx_k391)},
  {&__pyx_k403p, __pyx_k403, sizeof(__pyx_k403)},
  {&__pyx_k404p, __pyx_k404, sizeof(__pyx_k404)},
  {&__pyx_k405p, __pyx_k405, sizeof(__pyx_k405)},
  {&__pyx_k406p, __pyx_k406, sizeof(__pyx_k406)},
  {&__pyx_k407p, __pyx_k407, sizeof(__pyx_k407)},
  {&__pyx_k408p, __pyx_k408, sizeof(__pyx_k408)},
  {&__pyx_k409p, __pyx_k409, sizeof(__pyx_k409)},
  {&__pyx_k410p, __pyx_k410, sizeof(__pyx_k410)},
  {&__pyx_k412p, __pyx_k412, sizeof(__pyx_k412)},
  {&__pyx_k414p, __pyx_k414, sizeof(__pyx_k414)},
  {&__pyx_k415p, __pyx_k415, sizeof(__pyx_k415)},
  {&__pyx_k416p, __pyx_k416, sizeof(__pyx_k416)},
  {&__pyx_k417p, __pyx_k417, sizeof(__pyx_k417)},
  {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__Model __pyx_vtable_5_soya__Model;

static PyObject *__pyx_tp_new_5_soya__Model(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Model *p = (struct __pyx_obj_5_soya__Model *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Model *)__pyx_vtabptr_5_soya__Model;
  p->_filename = Py_None; Py_INCREF(p->_filename);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Model(PyObject *o) {
  struct __pyx_obj_5_soya__Model *p = (struct __pyx_obj_5_soya__Model *)o;
  Py_XDECREF(p->_filename);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Model(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Model *p = (struct __pyx_obj_5_soya__Model *)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__Model(PyObject *o) {
  struct __pyx_obj_5_soya__Model *p = (struct __pyx_obj_5_soya__Model *)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__Model[] = {
  {"__deepcopy__", (PyCFunction)__pyx_f_5_soya_6_Model___deepcopy__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_Model___deepcopy__},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__Model[] = {
  {"_filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya__Model, _filename), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Model = {
  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__Model = {
  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__Model = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Model = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Model = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Model", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Model), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Model, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_6_Model___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Model, /*tp_as_number*/
  &__pyx_tp_as_sequence__Model, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Model, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Model, /*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__Model, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Model, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Model, /*tp_methods*/
  __pyx_members_5_soya__Model, /*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__Model, /*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__SimpleModel __pyx_vtable_5_soya__SimpleModel;

static PyObject *__pyx_tp_new_5_soya__SimpleModel(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Model->tp_new(t, a, k);
  struct __pyx_obj_5_soya__SimpleModel *p = (struct __pyx_obj_5_soya__SimpleModel *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__SimpleModel *)__pyx_vtabptr_5_soya__SimpleModel;
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return o;
}

static void __pyx_tp_dealloc_5_soya__SimpleModel(PyObject *o) {
  struct __pyx_obj_5_soya__SimpleModel *p = (struct __pyx_obj_5_soya__SimpleModel *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_12_SimpleModel___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_materials);
  __pyx_ptype_5_soya__Model->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__SimpleModel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__SimpleModel *p = (struct __pyx_obj_5_soya__SimpleModel *)o;
  __pyx_ptype_5_soya__Model->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__SimpleModel(PyObject *o) {
  struct __pyx_obj_5_soya__SimpleModel *p = (struct __pyx_obj_5_soya__SimpleModel *)o;
  __pyx_ptype_5_soya__Model->tp_clear(o);
  Py_XDECREF(p->_materials);
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_12_SimpleModel_option(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleModel_6option___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleModel_materials(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleModel_9materials___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleModel_nb_coords(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleModel_9nb_coords___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleModel_nb_vertices(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleModel_11nb_vertices___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleModel_nb_faces(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleModel_8nb_faces___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SimpleModel_sphere(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SimpleModel_6sphere___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__SimpleModel[] = {
  {"get_face", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_face, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_SimpleModel_get_face},
  {"get_vertex_index", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_vertex_index, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_SimpleModel_get_vertex_index},
  {"get_vertex", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_vertex, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_12_SimpleModel_get_vertex},
  {"get_neighbor", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_neighbor, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_neighbor_side", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_neighbor_side, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_simple_neighbor", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_simple_neighbor, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_simple_neighbor_side", (PyCFunction)__pyx_f_5_soya_12_SimpleModel_get_simple_neighbor_side, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__SimpleModel[] = {
  {"option", __pyx_getprop_5_soya_12_SimpleModel_option, 0, 0, 0},
  {"materials", __pyx_getprop_5_soya_12_SimpleModel_materials, 0, 0, 0},
  {"nb_coords", __pyx_getprop_5_soya_12_SimpleModel_nb_coords, 0, 0, 0},
  {"nb_vertices", __pyx_getprop_5_soya_12_SimpleModel_nb_vertices, 0, 0, 0},
  {"nb_faces", __pyx_getprop_5_soya_12_SimpleModel_nb_faces, 0, 0, 0},
  {"sphere", __pyx_getprop_5_soya_12_SimpleModel_sphere, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SimpleModel = {
  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__SimpleModel = {
  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__SimpleModel = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SimpleModel = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__SimpleModel = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._SimpleModel", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__SimpleModel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__SimpleModel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SimpleModel, /*tp_as_number*/
  &__pyx_tp_as_sequence__SimpleModel, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SimpleModel, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SimpleModel, /*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__SimpleModel, /*tp_traverse*/
  __pyx_tp_clear_5_soya__SimpleModel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__SimpleModel, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__SimpleModel, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_12_SimpleModel___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__SimpleModel, /*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__CellShadingModel __pyx_vtable_5_soya__CellShadingModel;

static PyObject *__pyx_tp_new_5_soya__CellShadingModel(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__SimpleModel->tp_new(t, a, k);
  struct __pyx_obj_5_soya__CellShadingModel *p = (struct __pyx_obj_5_soya__CellShadingModel *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__CellShadingModel *)__pyx_vtabptr_5_soya__CellShadingModel;
  p->_shader = Py_None; Py_INCREF((PyObject *) p->_shader);
  return o;
}

static void __pyx_tp_dealloc_5_soya__CellShadingModel(PyObject *o) {
  struct __pyx_obj_5_soya__CellShadingModel *p = (struct __pyx_obj_5_soya__CellShadingModel *)o;
  Py_XDECREF((PyObject *)p->_shader);
  __pyx_ptype_5_soya__SimpleModel->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__CellShadingModel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__CellShadingModel *p = (struct __pyx_obj_5_soya__CellShadingModel *)o;
  __pyx_ptype_5_soya__SimpleModel->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__CellShadingModel(PyObject *o) {
  struct __pyx_obj_5_soya__CellShadingModel *p = (struct __pyx_obj_5_soya__CellShadingModel *)o;
  __pyx_ptype_5_soya__SimpleModel->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__CellShadingModel[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__CellShadingModel = {
  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__CellShadingModel = {
  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__CellShadingModel = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__CellShadingModel = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__CellShadingModel = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._CellShadingModel", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__CellShadingModel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__CellShadingModel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__CellShadingModel, /*tp_as_number*/
  &__pyx_tp_as_sequence__CellShadingModel, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__CellShadingModel, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__CellShadingModel, /*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__CellShadingModel, /*tp_traverse*/
  __pyx_tp_clear_5_soya__CellShadingModel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__CellShadingModel, /*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__CellShadingModel, /*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__TreeModel __pyx_vtable_5_soya__TreeModel;

static PyObject *__pyx_tp_new_5_soya__TreeModel(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__SimpleModel->tp_new(t, a, k);
  struct __pyx_obj_5_soya__TreeModel *p = (struct __pyx_obj_5_soya__TreeModel *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__TreeModel *)__pyx_vtabptr_5_soya__TreeModel;
  return o;
}

static void __pyx_tp_dealloc_5_soya__TreeModel(PyObject *o) {
  struct __pyx_obj_5_soya__TreeModel *p = (struct __pyx_obj_5_soya__TreeModel *)o;
  __pyx_ptype_5_soya__SimpleModel->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__TreeModel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__TreeModel *p = (struct __pyx_obj_5_soya__TreeModel *)o;
  __pyx_ptype_5_soya__SimpleModel->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__TreeModel(PyObject *o) {
  struct __pyx_obj_5_soya__TreeModel *p = (struct __pyx_obj_5_soya__TreeModel *)o;
  __pyx_ptype_5_soya__SimpleModel->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__TreeModel[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__TreeModel = {
  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__TreeModel = {
  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__TreeModel = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__TreeModel = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__TreeModel = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._TreeModel", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__TreeModel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__TreeModel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__TreeModel, /*tp_as_number*/
  &__pyx_tp_as_sequence__TreeModel, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__TreeModel, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__TreeModel, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__TreeModel, /*tp_traverse*/
  __pyx_tp_clear_5_soya__TreeModel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__TreeModel, /*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__TreeModel, /*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__ModelData __pyx_vtable_5_soya__ModelData;

static PyObject *__pyx_tp_new_5_soya__ModelData(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Model->tp_new(t, a, k);
  struct __pyx_obj_5_soya__ModelData *p = (struct __pyx_obj_5_soya__ModelData *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__ModelData *)__pyx_vtabptr_5_soya__ModelData;
  return o;
}

static void __pyx_tp_dealloc_5_soya__ModelData(PyObject *o) {
  struct __pyx_obj_5_soya__ModelData *p = (struct __pyx_obj_5_soya__ModelData *)o;
  __pyx_ptype_5_soya__Model->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__ModelData(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__ModelData *p = (struct __pyx_obj_5_soya__ModelData *)o;
  __pyx_ptype_5_soya__Model->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__ModelData(PyObject *o) {
  struct __pyx_obj_5_soya__ModelData *p = (struct __pyx_obj_5_soya__ModelData *)o;
  __pyx_ptype_5_soya__Model->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__ModelData[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__ModelData = {
  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__ModelData = {
  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__ModelData = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__ModelData = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__ModelData = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._ModelData", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__ModelData), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__ModelData, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__ModelData, /*tp_as_number*/
  &__pyx_tp_as_sequence__ModelData, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__ModelData, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__ModelData, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__ModelData, /*tp_traverse*/
  __pyx_tp_clear_5_soya__ModelData, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__ModelData, /*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_10_ModelData___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__ModelData, /*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__AnimatedModelData __pyx_vtable_5_soya__AnimatedModelData;

static PyObject *__pyx_tp_new_5_soya__AnimatedModelData(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__ModelData->tp_new(t, a, k);
  struct __pyx_obj_5_soya__AnimatedModelData *p = (struct __pyx_obj_5_soya__AnimatedModelData *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__AnimatedModelData *)__pyx_vtabptr_5_soya__AnimatedModelData;
  p->_body = Py_None; Py_INCREF((PyObject *) p->_body);
  p->_model = Py_None; Py_INCREF((PyObject *) p->_model);
  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__AnimatedModelData(PyObject *o) {
  struct __pyx_obj_5_soya__AnimatedModelData *p = (struct __pyx_obj_5_soya__AnimatedModelData *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_18_AnimatedModelData___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_body);
  Py_XDECREF((PyObject *)p->_model);
  Py_XDECREF(p->_attached_meshes);
  Py_XDECREF(p->_attached_coordsysts);
  __pyx_ptype_5_soya__ModelData->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__AnimatedModelData(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__AnimatedModelData *p = (struct __pyx_obj_5_soya__AnimatedModelData *)o;
  __pyx_ptype_5_soya__ModelData->tp_traverse(o, v, a);
  if (p->_body) {
    e = (*v)(((PyObject*)p->_body), a); if (e) return e;
  }
  if (p->_model) {
    e = (*v)(((PyObject*)p->_model), 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__AnimatedModelData(PyObject *o) {
  struct __pyx_obj_5_soya__AnimatedModelData *p = (struct __pyx_obj_5_soya__AnimatedModelData *)o;
  __pyx_ptype_5_soya__ModelData->tp_clear(o);
  Py_XDECREF((PyObject *)p->_body);
  p->_body = Py_None; Py_INCREF((PyObject *) p->_body);
  Py_XDECREF((PyObject *)p->_model);
  p->_model = Py_None; Py_INCREF((PyObject *) p->_model);
  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 struct PyMethodDef __pyx_methods_5_soya__AnimatedModelData[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__AnimatedModelData = {
  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__AnimatedModelData = {
  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__AnimatedModelData = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__AnimatedModelData = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__AnimatedModelData = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._AnimatedModelData", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__AnimatedModelData), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__AnimatedModelData, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__AnimatedModelData, /*tp_as_number*/
  &__pyx_tp_as_sequence__AnimatedModelData, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__AnimatedModelData, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__AnimatedModelData, /*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__AnimatedModelData, /*tp_traverse*/
  __pyx_tp_clear_5_soya__AnimatedModelData, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__AnimatedModelData, /*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_18_AnimatedModelData___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__AnimatedModelData, /*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_static(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_6static___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_static(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_6static___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_9CoordSyst_auto_static(PyObject *o, void *x) {
  return __pyx_f_5_soya_9CoordSyst_11auto_static___get__(o);
}

static int __pyx_setprop_5_soya_9CoordSyst_auto_static(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_9CoordSyst_11auto_static___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_y", (PyCFunction)__pyx_f_5_soya_9CoordSyst_turn_y, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_turn_y},
  {"turn_x", (PyCFunction)__pyx_f_5_soya_9CoordSyst_turn_x, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_turn_x},
  {"turn_z", (PyCFunction)__pyx_f_5_soya_9CoordSyst_turn_z, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_turn_z},
  {"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_y", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_y, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_y},
  {"rotate_x", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_x, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_x},
  {"rotate_z", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_z, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_z},
  {"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_axis", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_axis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_axis},
  {"rotate_axis_xyz", (PyCFunction)__pyx_f_5_soya_9CoordSyst_rotate_axis_xyz, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_9CoordSyst_rotate_axis_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},
  {"static", __pyx_getprop_5_soya_9CoordSyst_static, __pyx_setprop_5_soya_9CoordSyst_static, 0, 0},
  {"auto_static", __pyx_getprop_5_soya_9CoordSyst_auto_static, __pyx_setprop_5_soya_9CoordSyst_auto_static, 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_listen_sound(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Camera_12listen_sound___get__(o);
}

static int __pyx_setprop_5_soya_7_Camera_listen_sound(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Camera_12listen_sound___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},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_7_Camera_advance_time, 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},
  {"listen_sound", __pyx_getprop_5_soya_7_Camera_listen_sound, __pyx_setprop_5_soya_7_Camera_listen_sound, 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;
  p->_static_shadow_displaylists = Py_None; Py_INCREF(p->_static_shadow_displaylists);
  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;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_6_Light___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_static_shadow_displaylists);
  __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);
  if (p->_static_shadow_displaylists) {
    e = (*v)(p->_static_shadow_displaylists, a); if (e) return e;
  }
  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);
  Py_XDECREF(p->_static_shadow_displaylists);
  p->_static_shadow_displaylists = Py_None; Py_INCREF(p->_static_shadow_displaylists);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_6_Light_angle(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_5angle___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_angle(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_5angle___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_6_Light_exponent(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Light_8exponent___get__(o);
}

static int __pyx_setprop_5_soya_6_Light_exponent(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_Light_8exponent___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

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_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},
  {"_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[] = {
  {"angle", __pyx_getprop_5_soya_6_Light_angle, __pyx_setprop_5_soya_6_Light_angle, 0, 0},
  {"exponent", __pyx_getprop_5_soya_6_Light_exponent, __pyx_setprop_5_soya_6_Light_exponent, 0, 0},
  {"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},
  {"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|Py_TPFLAGS_HAVE_GC, /*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__Body __pyx_vtable_5_soya__Body;

static PyObject *__pyx_tp_new_5_soya__Body(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Body *p = (struct __pyx_obj_5_soya__Body *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Body *)__pyx_vtabptr_5_soya__Body;
  p->_model = Py_None; Py_INCREF((PyObject *) p->_model);
  p->_data = Py_None; Py_INCREF((PyObject *) p->_data);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Body(PyObject *o) {
  struct __pyx_obj_5_soya__Body *p = (struct __pyx_obj_5_soya__Body *)o;
  Py_XDECREF((PyObject *)p->_model);
  Py_XDECREF((PyObject *)p->_data);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Body(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Body *p = (struct __pyx_obj_5_soya__Body *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_model) {
    e = (*v)(((PyObject*)p->_model), a); if (e) return e;
  }
  if (p->_data) {
    e = (*v)(((PyObject*)p->_data), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Body(PyObject *o) {
  struct __pyx_obj_5_soya__Body *p = (struct __pyx_obj_5_soya__Body *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_model);
  p->_model = Py_None; Py_INCREF((PyObject *) p->_model);
  Py_XDECREF((PyObject *)p->_data);
  p->_data = Py_None; Py_INCREF((PyObject *) p->_data);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_5_Body_model(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Body_5model___get__(o);
}

static int __pyx_setprop_5_soya_5_Body_model(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_5_Body_5model___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_5_Body_deforms(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Body_7deforms___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Body_attached_meshes(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Body_15attached_meshes___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Body_attached_coordsysts(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Body_19attached_coordsysts___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Body[] = {
  {"set_model", (PyCFunction)__pyx_f_5_soya_5_Body_set_model, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_deform", (PyCFunction)__pyx_f_5_soya_5_Body_add_deform, METH_VARARGS|METH_KEYWORDS, 0},
  {"remove_deform", (PyCFunction)__pyx_f_5_soya_5_Body_remove_deform, METH_VARARGS|METH_KEYWORDS, 0},
  {"attach", (PyCFunction)__pyx_f_5_soya_5_Body_attach, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_attach},
  {"detach", (PyCFunction)__pyx_f_5_soya_5_Body_detach, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_detach},
  {"is_attached", (PyCFunction)__pyx_f_5_soya_5_Body_is_attached, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_is_attached},
  {"attach_to_bone", (PyCFunction)__pyx_f_5_soya_5_Body_attach_to_bone, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_attach_to_bone},
  {"detach_from_bone", (PyCFunction)__pyx_f_5_soya_5_Body_detach_from_bone, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_detach_from_bone},
  {"animate_blend_cycle", (PyCFunction)__pyx_f_5_soya_5_Body_animate_blend_cycle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_animate_blend_cycle},
  {"animate_clear_cycle", (PyCFunction)__pyx_f_5_soya_5_Body_animate_clear_cycle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_animate_clear_cycle},
  {"animate_execute_action", (PyCFunction)__pyx_f_5_soya_5_Body_animate_execute_action, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_animate_execute_action},
  {"animate_reset", (PyCFunction)__pyx_f_5_soya_5_Body_animate_reset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Body_animate_reset},
  {"set_lod_level", (PyCFunction)__pyx_f_5_soya_5_Body_set_lod_level, METH_VARARGS|METH_KEYWORDS, 0},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_5_Body_begin_round, METH_VARARGS|METH_KEYWORDS, 0},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_5_Body_advance_time, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Body[] = {
  {"model", __pyx_getprop_5_soya_5_Body_model, __pyx_setprop_5_soya_5_Body_model, 0, 0},
  {"deforms", __pyx_getprop_5_soya_5_Body_deforms, 0, 0, 0},
  {"attached_meshes", __pyx_getprop_5_soya_5_Body_attached_meshes, 0, 0, 0},
  {"attached_coordsysts", __pyx_getprop_5_soya_5_Body_attached_coordsysts, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Body = {
  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__Body = {
  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__Body = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Body = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Body = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Body", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Body), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Body, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_5_Body___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Body, /*tp_as_number*/
  &__pyx_tp_as_sequence__Body, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Body, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Body, /*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__Body, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Body, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Body, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Body, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_5_Body___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Body, /*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__Body->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->_model_builder = Py_None; Py_INCREF((PyObject *) p->_model_builder);
  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->_model_builder);
  __pyx_ptype_5_soya__Body->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__Body->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->_model_builder) {
    e = (*v)(((PyObject*)p->_model_builder), 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__Body->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->_model_builder);
  p->_model_builder = Py_None; Py_INCREF((PyObject *) p->_model_builder);
  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__Body->tp_as_mapping && __pyx_ptype_5_soya__Body->tp_as_mapping->mp_ass_subscript)
      return __pyx_ptype_5_soya__Body->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_model_builder(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_World_13model_builder___get__(o);
}

static int __pyx_setprop_5_soya_6_World_model_builder(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_6_World_13model_builder___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},
  {"to_model", (PyCFunction)__pyx_f_5_soya_6_World_to_model, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_6_World_to_model},
  {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[] = {
  {"model_builder", __pyx_getprop_5_soya_6_World_model_builder, __pyx_setprop_5_soya_6_World_model_builder, 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__AnimatedModel __pyx_vtable_5_soya__AnimatedModel;

static PyObject *__pyx_tp_new_5_soya__AnimatedModel(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Model->tp_new(t, a, k);
  struct __pyx_obj_5_soya__AnimatedModel *p = (struct __pyx_obj_5_soya__AnimatedModel *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__AnimatedModel *)__pyx_vtabptr_5_soya__AnimatedModel;
  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__AnimatedModel(PyObject *o) {
  struct __pyx_obj_5_soya__AnimatedModel *p = (struct __pyx_obj_5_soya__AnimatedModel *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_14_AnimatedModel___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__Model->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__AnimatedModel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__AnimatedModel *p = (struct __pyx_obj_5_soya__AnimatedModel *)o;
  __pyx_ptype_5_soya__Model->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__AnimatedModel(PyObject *o) {
  struct __pyx_obj_5_soya__AnimatedModel *p = (struct __pyx_obj_5_soya__AnimatedModel *)o;
  __pyx_ptype_5_soya__Model->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_14_AnimatedModel_filename(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_8filename___get__(o);
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_full_filename(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_13full_filename___get__(o);
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_materials(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_9materials___get__(o);
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_meshes(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_6meshes___get__(o);
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_animations(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_10animations___get__(o);
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_sphere(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_6sphere___get__(o);
}

static int __pyx_setprop_5_soya_14_AnimatedModel_sphere(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_AnimatedModel_6sphere___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_double_sided(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_12double_sided___get__(o);
}

static int __pyx_setprop_5_soya_14_AnimatedModel_double_sided(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_AnimatedModel_12double_sided___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_shadow(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_6shadow___get__(o);
}

static int __pyx_setprop_5_soya_14_AnimatedModel_shadow(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_14_AnimatedModel_6shadow___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_14_AnimatedModel_cellshading(PyObject *o, void *x) {
  return __pyx_f_5_soya_14_AnimatedModel_11cellshading___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__AnimatedModel[] = {
  {"set_cellshading", (PyCFunction)__pyx_f_5_soya_14_AnimatedModel_set_cellshading, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_skeleton", (PyCFunction)__pyx_f_5_soya_14_AnimatedModel_load_skeleton, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_mesh", (PyCFunction)__pyx_f_5_soya_14_AnimatedModel_load_mesh, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_material", (PyCFunction)__pyx_f_5_soya_14_AnimatedModel_load_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"load_animation", (PyCFunction)__pyx_f_5_soya_14_AnimatedModel_load_animation, METH_VARARGS|METH_KEYWORDS, 0},
  {"build_materials", (PyCFunction)__pyx_f_5_soya_14_AnimatedModel_build_materials, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__AnimatedModel[] = {
  {"filename", __pyx_getprop_5_soya_14_AnimatedModel_filename, 0, 0, 0},
  {"full_filename", __pyx_getprop_5_soya_14_AnimatedModel_full_filename, 0, 0, 0},
  {"materials", __pyx_getprop_5_soya_14_AnimatedModel_materials, 0, 0, 0},
  {"meshes", __pyx_getprop_5_soya_14_AnimatedModel_meshes, 0, 0, 0},
  {"animations", __pyx_getprop_5_soya_14_AnimatedModel_animations, 0, 0, 0},
  {"sphere", __pyx_getprop_5_soya_14_AnimatedModel_sphere, __pyx_setprop_5_soya_14_AnimatedModel_sphere, 0, 0},
  {"double_sided", __pyx_getprop_5_soya_14_AnimatedModel_double_sided, __pyx_setprop_5_soya_14_AnimatedModel_double_sided, 0, 0},
  {"shadow", __pyx_getprop_5_soya_14_AnimatedModel_shadow, __pyx_setprop_5_soya_14_AnimatedModel_shadow, 0, 0},
  {"cellshading", __pyx_getprop_5_soya_14_AnimatedModel_cellshading, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__AnimatedModel = {
  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__AnimatedModel = {
  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__AnimatedModel = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__AnimatedModel = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__AnimatedModel = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._AnimatedModel", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__AnimatedModel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__AnimatedModel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__AnimatedModel, /*tp_as_number*/
  &__pyx_tp_as_sequence__AnimatedModel, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__AnimatedModel, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__AnimatedModel, /*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__AnimatedModel, /*tp_traverse*/
  __pyx_tp_clear_5_soya__AnimatedModel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__AnimatedModel, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__AnimatedModel, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_14_AnimatedModel___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__AnimatedModel, /*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__Terrain __pyx_vtable_5_soya__Terrain;

static PyObject *__pyx_tp_new_5_soya__Terrain(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Terrain *p = (struct __pyx_obj_5_soya__Terrain *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Terrain *)__pyx_vtabptr_5_soya__Terrain;
  p->_materials = Py_None; Py_INCREF(p->_materials);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Terrain(PyObject *o) {
  struct __pyx_obj_5_soya__Terrain *p = (struct __pyx_obj_5_soya__Terrain *)o;
  Py_XDECREF(p->_materials);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Terrain(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Terrain *p = (struct __pyx_obj_5_soya__Terrain *)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__Terrain(PyObject *o) {
  struct __pyx_obj_5_soya__Terrain *p = (struct __pyx_obj_5_soya__Terrain *)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_8_Terrain_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_5width___get__(o);
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_depth(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_5depth___get__(o);
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_patch_size(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_10patch_size___get__(o);
}

static int __pyx_setprop_5_soya_8_Terrain_patch_size(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_8_Terrain_10patch_size___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_has_vertex_options(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_18has_vertex_options___get__(o);
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_split_factor(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_12split_factor___get__(o);
}

static int __pyx_setprop_5_soya_8_Terrain_split_factor(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_8_Terrain_12split_factor___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_scale_factor(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_12scale_factor___get__(o);
}

static int __pyx_setprop_5_soya_8_Terrain_scale_factor(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_8_Terrain_12scale_factor___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_texture_factor(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_14texture_factor___get__(o);
}

static int __pyx_setprop_5_soya_8_Terrain_texture_factor(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_8_Terrain_14texture_factor___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_8_Terrain_raypick_with_LOD(PyObject *o, void *x) {
  return __pyx_f_5_soya_8_Terrain_16raypick_with_LOD___get__(o);
}

static int __pyx_setprop_5_soya_8_Terrain_raypick_with_LOD(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_8_Terrain_16raypick_with_LOD___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Terrain[] = {
  {"from_image", (PyCFunction)__pyx_f_5_soya_8_Terrain_from_image, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material_from_image", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_material_from_image, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material_layer", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_material_layer, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material_layer_angle", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_material_layer_angle, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_normal", (PyCFunction)__pyx_f_5_soya_8_Terrain_get_normal, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_height", (PyCFunction)__pyx_f_5_soya_8_Terrain_get_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_material", (PyCFunction)__pyx_f_5_soya_8_Terrain_get_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_height", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"multiply_height", (PyCFunction)__pyx_f_5_soya_8_Terrain_multiply_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"add_height", (PyCFunction)__pyx_f_5_soya_8_Terrain_add_height, METH_VARARGS|METH_KEYWORDS, 0},
  {"set_material", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_material, METH_VARARGS|METH_KEYWORDS, 0},
  {"remove_colors", (PyCFunction)__pyx_f_5_soya_8_Terrain_remove_colors, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8_Terrain_remove_colors},
  {"get_vertex_option", (PyCFunction)__pyx_f_5_soya_8_Terrain_get_vertex_option, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8_Terrain_get_vertex_option},
  {"set_vertex_option", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_vertex_option, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8_Terrain_set_vertex_option},
  {"set_vertex_color", (PyCFunction)__pyx_f_5_soya_8_Terrain_set_vertex_color, METH_VARARGS|METH_KEYWORDS, 0},
  {"reinit", (PyCFunction)__pyx_f_5_soya_8_Terrain_reinit, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8_Terrain_reinit},
  {"compute_shadow_color", (PyCFunction)__pyx_f_5_soya_8_Terrain_compute_shadow_color, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_true_height_and_normal", (PyCFunction)__pyx_f_5_soya_8_Terrain_get_true_height_and_normal, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Terrain[] = {
  {"width", __pyx_getprop_5_soya_8_Terrain_width, 0, 0, 0},
  {"depth", __pyx_getprop_5_soya_8_Terrain_depth, 0, 0, 0},
  {"patch_size", __pyx_getprop_5_soya_8_Terrain_patch_size, __pyx_setprop_5_soya_8_Terrain_patch_size, 0, 0},
  {"has_vertex_options", __pyx_getprop_5_soya_8_Terrain_has_vertex_options, 0, 0, 0},
  {"split_factor", __pyx_getprop_5_soya_8_Terrain_split_factor, __pyx_setprop_5_soya_8_Terrain_split_factor, 0, 0},
  {"scale_factor", __pyx_getprop_5_soya_8_Terrain_scale_factor, __pyx_setprop_5_soya_8_Terrain_scale_factor, 0, 0},
  {"texture_factor", __pyx_getprop_5_soya_8_Terrain_texture_factor, __pyx_setprop_5_soya_8_Terrain_texture_factor, 0, 0},
  {"raypick_with_LOD", __pyx_getprop_5_soya_8_Terrain_raypick_with_LOD, __pyx_setprop_5_soya_8_Terrain_raypick_with_LOD, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Terrain = {
  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__Terrain = {
  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__Terrain = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Terrain = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Terrain = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Terrain", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Terrain), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Terrain, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__Terrain, /*tp_as_number*/
  &__pyx_tp_as_sequence__Terrain, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Terrain, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Terrain, /*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__Terrain, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Terrain, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Terrain, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Terrain, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_8_Terrain___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Terrain, /*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_MainLoop(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  struct __pyx_obj_5_soya_MainLoop *p = (struct __pyx_obj_5_soya_MainLoop *)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_MainLoop(PyObject *o) {
  struct __pyx_obj_5_soya_MainLoop *p = (struct __pyx_obj_5_soya_MainLoop *)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_MainLoop(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_MainLoop *p = (struct __pyx_obj_5_soya_MainLoop *)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_MainLoop(PyObject *o) {
  struct __pyx_obj_5_soya_MainLoop *p = (struct __pyx_obj_5_soya_MainLoop *)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_8MainLoop_scenes(PyObject *o, void *x) {
  return __pyx_f_5_soya_8MainLoop_6scenes___get__(o);
}

static PyObject *__pyx_getprop_5_soya_8MainLoop_next_round_tasks(PyObject *o, void *x) {
  return __pyx_f_5_soya_8MainLoop_16next_round_tasks___get__(o);
}

static PyObject *__pyx_getprop_5_soya_8MainLoop_return_value(PyObject *o, void *x) {
  return __pyx_f_5_soya_8MainLoop_12return_value___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya_MainLoop[] = {
  {"stop", (PyCFunction)__pyx_f_5_soya_8MainLoop_stop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_stop},
  {"reset", (PyCFunction)__pyx_f_5_soya_8MainLoop_reset, METH_VARARGS|METH_KEYWORDS, 0},
  {"idle", (PyCFunction)__pyx_f_5_soya_8MainLoop_idle, METH_VARARGS|METH_KEYWORDS, 0},
  {"main_loop", (PyCFunction)__pyx_f_5_soya_8MainLoop_main_loop, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_main_loop},
  {"update", (PyCFunction)__pyx_f_5_soya_8MainLoop_update, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_update},
  {"begin_round", (PyCFunction)__pyx_f_5_soya_8MainLoop_begin_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_begin_round},
  {"end_round", (PyCFunction)__pyx_f_5_soya_8MainLoop_end_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_end_round},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_8MainLoop_advance_time, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_advance_time},
  {"render", (PyCFunction)__pyx_f_5_soya_8MainLoop_render, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_8MainLoop_render},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya_MainLoop[] = {
  {"round_duration", T_DOUBLE, offsetof(struct __pyx_obj_5_soya_MainLoop, round_duration), 0, 0},
  {"min_frame_duration", T_DOUBLE, offsetof(struct __pyx_obj_5_soya_MainLoop, min_frame_duration), 0, 0},
  {"fps", T_DOUBLE, offsetof(struct __pyx_obj_5_soya_MainLoop, fps), READONLY, 0},
  {"running", T_INT, offsetof(struct __pyx_obj_5_soya_MainLoop, running), 0, 0},
  {"will_render", T_INT, offsetof(struct __pyx_obj_5_soya_MainLoop, will_render), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_MainLoop[] = {
  {"scenes", __pyx_getprop_5_soya_8MainLoop_scenes, 0, 0, 0},
  {"next_round_tasks", __pyx_getprop_5_soya_8MainLoop_next_round_tasks, 0, 0, 0},
  {"return_value", __pyx_getprop_5_soya_8MainLoop_return_value, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_MainLoop = {
  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_MainLoop = {
  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_MainLoop = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_MainLoop = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_MainLoop = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.MainLoop", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_MainLoop), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_MainLoop, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_MainLoop, /*tp_as_number*/
  &__pyx_tp_as_sequence_MainLoop, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_MainLoop, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_MainLoop, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "MainLoop\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 MainLoop 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 main_loop.\n\n - round_duration: The duration of a round. Round is the main_loop\'s time unit. The main_loop 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_MainLoop, /*tp_traverse*/
  __pyx_tp_clear_5_soya_MainLoop, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_MainLoop, /*tp_methods*/
  __pyx_members_5_soya_MainLoop, /*tp_members*/
  __pyx_getsets_5_soya_MainLoop, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_8MainLoop___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_MainLoop, /*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_5_Font___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_5_Font_height(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Font_6height___get__(o);
}

static PyObject *__pyx_getprop_5_soya_5_Font_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_5_Font_5width___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Font[] = {
  {"get_glyph", (PyCFunction)__pyx_f_5_soya_5_Font_get_glyph, METH_VARARGS|METH_KEYWORDS, 0},
  {"create_glyphs", (PyCFunction)__pyx_f_5_soya_5_Font_create_glyphs, METH_VARARGS|METH_KEYWORDS, 0},
  {"get_print_size", (PyCFunction)__pyx_f_5_soya_5_Font_get_print_size, METH_VARARGS|METH_KEYWORDS, 0},
  {"wordwrap", (PyCFunction)__pyx_f_5_soya_5_Font_wordwrap, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Font_wordwrap},
  {"wordwrap_line", (PyCFunction)__pyx_f_5_soya_5_Font_wordwrap_line, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Font_wordwrap_line},
  {"draw", (PyCFunction)__pyx_f_5_soya_5_Font_draw, METH_VARARGS|METH_KEYWORDS, 0},
  {"draw_area", (PyCFunction)__pyx_f_5_soya_5_Font_draw_area, METH_VARARGS|METH_KEYWORDS, 0},
  {"_image", (PyCFunction)__pyx_f_5_soya_5_Font__image, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_5_Font__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_5_Font_height, 0, 0, 0},
  {"width", __pyx_getprop_5_soya_5_Font_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_5_Font___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_5_Font___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_ModelBuilder __pyx_vtable_5_soya_ModelBuilder;

static PyObject *__pyx_tp_new_5_soya_ModelBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya_ModelBuilder *p = (struct __pyx_obj_5_soya_ModelBuilder *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_ModelBuilder *)__pyx_vtabptr_5_soya_ModelBuilder;
  return o;
}

static void __pyx_tp_dealloc_5_soya_ModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_ModelBuilder *p = (struct __pyx_obj_5_soya_ModelBuilder *)o;
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_ModelBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_ModelBuilder *p = (struct __pyx_obj_5_soya_ModelBuilder *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_ModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_ModelBuilder *p = (struct __pyx_obj_5_soya_ModelBuilder *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_ModelBuilder[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ModelBuilder = {
  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_ModelBuilder = {
  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_ModelBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ModelBuilder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_ModelBuilder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.ModelBuilder", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_ModelBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_ModelBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ModelBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_ModelBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ModelBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ModelBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_ModelBuilder, /*tp_traverse*/
  __pyx_tp_clear_5_soya_ModelBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_ModelBuilder, /*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_ModelBuilder, /*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__Deform __pyx_vtable_5_soya__Deform;

static PyObject *__pyx_tp_new_5_soya__Deform(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__ModelData->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Deform *p = (struct __pyx_obj_5_soya__Deform *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Deform *)__pyx_vtabptr_5_soya__Deform;
  p->_model = Py_None; Py_INCREF((PyObject *) p->_model);
  p->_data = Py_None; Py_INCREF((PyObject *) p->_data);
  return o;
}

static void __pyx_tp_dealloc_5_soya__Deform(PyObject *o) {
  struct __pyx_obj_5_soya__Deform *p = (struct __pyx_obj_5_soya__Deform *)o;
  Py_XDECREF((PyObject *)p->_model);
  Py_XDECREF((PyObject *)p->_data);
  __pyx_ptype_5_soya__ModelData->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Deform(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Deform *p = (struct __pyx_obj_5_soya__Deform *)o;
  __pyx_ptype_5_soya__ModelData->tp_traverse(o, v, a);
  if (p->_model) {
    e = (*v)(((PyObject*)p->_model), a); if (e) return e;
  }
  if (p->_data) {
    e = (*v)(((PyObject*)p->_data), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Deform(PyObject *o) {
  struct __pyx_obj_5_soya__Deform *p = (struct __pyx_obj_5_soya__Deform *)o;
  __pyx_ptype_5_soya__ModelData->tp_clear(o);
  Py_XDECREF((PyObject *)p->_model);
  p->_model = Py_None; Py_INCREF((PyObject *) p->_model);
  Py_XDECREF((PyObject *)p->_data);
  p->_data = Py_None; Py_INCREF((PyObject *) p->_data);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_7_Deform_time(PyObject *o, void *x) {
  return __pyx_f_5_soya_7_Deform_4time___get__(o);
}

static int __pyx_setprop_5_soya_7_Deform_time(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_7_Deform_4time___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__Deform[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Deform[] = {
  {"time", __pyx_getprop_5_soya_7_Deform_time, __pyx_setprop_5_soya_7_Deform_time, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Deform = {
  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__Deform = {
  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__Deform = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Deform = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Deform = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Deform", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Deform), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Deform, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_7_Deform___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Deform, /*tp_as_number*/
  &__pyx_tp_as_sequence__Deform, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Deform, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Deform, /*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__Deform, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Deform, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Deform, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__Deform, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_7_Deform___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__Deform, /*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_SimpleModelBuilder __pyx_vtable_5_soya_SimpleModelBuilder;

static PyObject *__pyx_tp_new_5_soya_SimpleModelBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_ModelBuilder->tp_new(t, a, k);
  struct __pyx_obj_5_soya_SimpleModelBuilder *p = (struct __pyx_obj_5_soya_SimpleModelBuilder *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_SimpleModelBuilder *)__pyx_vtabptr_5_soya_SimpleModelBuilder;
  return o;
}

static void __pyx_tp_dealloc_5_soya_SimpleModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_SimpleModelBuilder *p = (struct __pyx_obj_5_soya_SimpleModelBuilder *)o;
  __pyx_ptype_5_soya_ModelBuilder->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_SimpleModelBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_SimpleModelBuilder *p = (struct __pyx_obj_5_soya_SimpleModelBuilder *)o;
  __pyx_ptype_5_soya_ModelBuilder->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_SimpleModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_SimpleModelBuilder *p = (struct __pyx_obj_5_soya_SimpleModelBuilder *)o;
  __pyx_ptype_5_soya_ModelBuilder->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_18SimpleModelBuilder_shadow(PyObject *o, void *x) {
  return __pyx_f_5_soya_18SimpleModelBuilder_6shadow___get__(o);
}

static int __pyx_setprop_5_soya_18SimpleModelBuilder_shadow(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_18SimpleModelBuilder_6shadow___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_18SimpleModelBuilder_max_face_angle(PyObject *o, void *x) {
  return __pyx_f_5_soya_18SimpleModelBuilder_14max_face_angle___get__(o);
}

static int __pyx_setprop_5_soya_18SimpleModelBuilder_max_face_angle(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_18SimpleModelBuilder_14max_face_angle___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_SimpleModelBuilder[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_SimpleModelBuilder[] = {
  {"shadow", __pyx_getprop_5_soya_18SimpleModelBuilder_shadow, __pyx_setprop_5_soya_18SimpleModelBuilder_shadow, 0, 0},
  {"max_face_angle", __pyx_getprop_5_soya_18SimpleModelBuilder_max_face_angle, __pyx_setprop_5_soya_18SimpleModelBuilder_max_face_angle, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SimpleModelBuilder = {
  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_SimpleModelBuilder = {
  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_SimpleModelBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SimpleModelBuilder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_SimpleModelBuilder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.SimpleModelBuilder", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_SimpleModelBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_SimpleModelBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_SimpleModelBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_SimpleModelBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SimpleModelBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SimpleModelBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "SimpleModelBuilder\n\nModelBuilder for simple / normal / regular Model. The SimpleModelBuilder attributes allows to\ncustomize the World -> Model 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_SimpleModelBuilder, /*tp_traverse*/
  __pyx_tp_clear_5_soya_SimpleModelBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_SimpleModelBuilder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_SimpleModelBuilder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_18SimpleModelBuilder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_SimpleModelBuilder, /*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_TreeModelBuilder __pyx_vtable_5_soya_TreeModelBuilder;

static PyObject *__pyx_tp_new_5_soya_TreeModelBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_SimpleModelBuilder->tp_new(t, a, k);
  struct __pyx_obj_5_soya_TreeModelBuilder *p = (struct __pyx_obj_5_soya_TreeModelBuilder *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_TreeModelBuilder *)__pyx_vtabptr_5_soya_TreeModelBuilder;
  return o;
}

static void __pyx_tp_dealloc_5_soya_TreeModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_TreeModelBuilder *p = (struct __pyx_obj_5_soya_TreeModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_TreeModelBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_TreeModelBuilder *p = (struct __pyx_obj_5_soya_TreeModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_TreeModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_TreeModelBuilder *p = (struct __pyx_obj_5_soya_TreeModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_clear(o);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_16TreeModelBuilder_collapsing_distance(PyObject *o, void *x) {
  return __pyx_f_5_soya_16TreeModelBuilder_19collapsing_distance___get__(o);
}

static int __pyx_setprop_5_soya_16TreeModelBuilder_collapsing_distance(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_16TreeModelBuilder_19collapsing_distance___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_16TreeModelBuilder_quality(PyObject *o, void *x) {
  return __pyx_f_5_soya_16TreeModelBuilder_7quality___get__(o);
}

static int __pyx_setprop_5_soya_16TreeModelBuilder_quality(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_16TreeModelBuilder_7quality___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_16TreeModelBuilder_max_child_radius(PyObject *o, void *x) {
  return __pyx_f_5_soya_16TreeModelBuilder_16max_child_radius___get__(o);
}

static int __pyx_setprop_5_soya_16TreeModelBuilder_max_child_radius(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_16TreeModelBuilder_16max_child_radius___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_TreeModelBuilder[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_TreeModelBuilder[] = {
  {"collapsing_distance", __pyx_getprop_5_soya_16TreeModelBuilder_collapsing_distance, __pyx_setprop_5_soya_16TreeModelBuilder_collapsing_distance, 0, 0},
  {"quality", __pyx_getprop_5_soya_16TreeModelBuilder_quality, __pyx_setprop_5_soya_16TreeModelBuilder_quality, 0, 0},
  {"max_child_radius", __pyx_getprop_5_soya_16TreeModelBuilder_max_child_radius, __pyx_setprop_5_soya_16TreeModelBuilder_max_child_radius, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_TreeModelBuilder = {
  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_TreeModelBuilder = {
  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_TreeModelBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_TreeModelBuilder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_TreeModelBuilder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.TreeModelBuilder", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_TreeModelBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_TreeModelBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_TreeModelBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_TreeModelBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_TreeModelBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_TreeModelBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "TreeModelBuilder\n\nModelBuilder for tree-based Model. Yields a TreeModel instead of a SimpleModel.\nTreeModel are optimized for big model 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 model 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_TreeModelBuilder, /*tp_traverse*/
  __pyx_tp_clear_5_soya_TreeModelBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_TreeModelBuilder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_TreeModelBuilder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_16TreeModelBuilder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_TreeModelBuilder, /*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_CellShadingModelBuilder __pyx_vtable_5_soya_CellShadingModelBuilder;

static PyObject *__pyx_tp_new_5_soya_CellShadingModelBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_SimpleModelBuilder->tp_new(t, a, k);
  struct __pyx_obj_5_soya_CellShadingModelBuilder *p = (struct __pyx_obj_5_soya_CellShadingModelBuilder *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_CellShadingModelBuilder *)__pyx_vtabptr_5_soya_CellShadingModelBuilder;
  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_CellShadingModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_CellShadingModelBuilder *p = (struct __pyx_obj_5_soya_CellShadingModelBuilder *)o;
  Py_XDECREF((PyObject *)p->_shader);
  Py_XDECREF(p->_outline_color);
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_CellShadingModelBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_CellShadingModelBuilder *p = (struct __pyx_obj_5_soya_CellShadingModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->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_CellShadingModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_CellShadingModelBuilder *p = (struct __pyx_obj_5_soya_CellShadingModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->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_23CellShadingModelBuilder_shader(PyObject *o, void *x) {
  return __pyx_f_5_soya_23CellShadingModelBuilder_6shader___get__(o);
}

static int __pyx_setprop_5_soya_23CellShadingModelBuilder_shader(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_23CellShadingModelBuilder_6shader___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_23CellShadingModelBuilder_outline_color(PyObject *o, void *x) {
  return __pyx_f_5_soya_23CellShadingModelBuilder_13outline_color___get__(o);
}

static int __pyx_setprop_5_soya_23CellShadingModelBuilder_outline_color(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_23CellShadingModelBuilder_13outline_color___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_23CellShadingModelBuilder_outline_width(PyObject *o, void *x) {
  return __pyx_f_5_soya_23CellShadingModelBuilder_13outline_width___get__(o);
}

static int __pyx_setprop_5_soya_23CellShadingModelBuilder_outline_width(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_23CellShadingModelBuilder_13outline_width___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_23CellShadingModelBuilder_outline_attenuation(PyObject *o, void *x) {
  return __pyx_f_5_soya_23CellShadingModelBuilder_19outline_attenuation___get__(o);
}

static int __pyx_setprop_5_soya_23CellShadingModelBuilder_outline_attenuation(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_23CellShadingModelBuilder_19outline_attenuation___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya_CellShadingModelBuilder[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya_CellShadingModelBuilder[] = {
  {"shader", __pyx_getprop_5_soya_23CellShadingModelBuilder_shader, __pyx_setprop_5_soya_23CellShadingModelBuilder_shader, 0, 0},
  {"outline_color", __pyx_getprop_5_soya_23CellShadingModelBuilder_outline_color, __pyx_setprop_5_soya_23CellShadingModelBuilder_outline_color, 0, 0},
  {"outline_width", __pyx_getprop_5_soya_23CellShadingModelBuilder_outline_width, __pyx_setprop_5_soya_23CellShadingModelBuilder_outline_width, 0, 0},
  {"outline_attenuation", __pyx_getprop_5_soya_23CellShadingModelBuilder_outline_attenuation, __pyx_setprop_5_soya_23CellShadingModelBuilder_outline_attenuation, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_CellShadingModelBuilder = {
  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_CellShadingModelBuilder = {
  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_CellShadingModelBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_CellShadingModelBuilder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_CellShadingModelBuilder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.CellShadingModelBuilder", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_CellShadingModelBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_CellShadingModelBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_CellShadingModelBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_CellShadingModelBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_CellShadingModelBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_CellShadingModelBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "CellShadingModelBuilder\n\nModelBuilder for cell-shaded Model.\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 model\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_CellShadingModelBuilder, /*tp_traverse*/
  __pyx_tp_clear_5_soya_CellShadingModelBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_CellShadingModelBuilder, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya_CellShadingModelBuilder, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_23CellShadingModelBuilder___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya_CellShadingModelBuilder, /*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__MainLoopingMaterial __pyx_vtable_5_soya__MainLoopingMaterial;

static PyObject *__pyx_tp_new_5_soya__MainLoopingMaterial(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Material->tp_new(t, a, k);
  struct __pyx_obj_5_soya__MainLoopingMaterial *p = (struct __pyx_obj_5_soya__MainLoopingMaterial *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__MainLoopingMaterial *)__pyx_vtabptr_5_soya__MainLoopingMaterial;
  return o;
}

static void __pyx_tp_dealloc_5_soya__MainLoopingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__MainLoopingMaterial *p = (struct __pyx_obj_5_soya__MainLoopingMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__MainLoopingMaterial(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__MainLoopingMaterial *p = (struct __pyx_obj_5_soya__MainLoopingMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__MainLoopingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__MainLoopingMaterial *p = (struct __pyx_obj_5_soya__MainLoopingMaterial *)o;
  __pyx_ptype_5_soya__Material->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__MainLoopingMaterial[] = {
  {"begin_round", (PyCFunction)__pyx_f_5_soya_20_MainLoopingMaterial_begin_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_20_MainLoopingMaterial_begin_round},
  {"end_round", (PyCFunction)__pyx_f_5_soya_20_MainLoopingMaterial_end_round, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_20_MainLoopingMaterial_end_round},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_20_MainLoopingMaterial_advance_time, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_20_MainLoopingMaterial_advance_time},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__MainLoopingMaterial = {
  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__MainLoopingMaterial = {
  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__MainLoopingMaterial = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__MainLoopingMaterial = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__MainLoopingMaterial = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._MainLoopingMaterial", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__MainLoopingMaterial), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__MainLoopingMaterial, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__MainLoopingMaterial, /*tp_as_number*/
  &__pyx_tp_as_sequence__MainLoopingMaterial, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__MainLoopingMaterial, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__MainLoopingMaterial, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__MainLoopingMaterial, /*tp_traverse*/
  __pyx_tp_clear_5_soya__MainLoopingMaterial, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__MainLoopingMaterial, /*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_20_MainLoopingMaterial___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__MainLoopingMaterial, /*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__PythonMainLoopingMaterial __pyx_vtable_5_soya__PythonMainLoopingMaterial;

static PyObject *__pyx_tp_new_5_soya__PythonMainLoopingMaterial(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__MainLoopingMaterial->tp_new(t, a, k);
  struct __pyx_obj_5_soya__PythonMainLoopingMaterial *p = (struct __pyx_obj_5_soya__PythonMainLoopingMaterial *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__PythonMainLoopingMaterial *)__pyx_vtabptr_5_soya__PythonMainLoopingMaterial;
  return o;
}

static void __pyx_tp_dealloc_5_soya__PythonMainLoopingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__PythonMainLoopingMaterial *p = (struct __pyx_obj_5_soya__PythonMainLoopingMaterial *)o;
  __pyx_ptype_5_soya__MainLoopingMaterial->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__PythonMainLoopingMaterial(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__PythonMainLoopingMaterial *p = (struct __pyx_obj_5_soya__PythonMainLoopingMaterial *)o;
  __pyx_ptype_5_soya__MainLoopingMaterial->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__PythonMainLoopingMaterial(PyObject *o) {
  struct __pyx_obj_5_soya__PythonMainLoopingMaterial *p = (struct __pyx_obj_5_soya__PythonMainLoopingMaterial *)o;
  __pyx_ptype_5_soya__MainLoopingMaterial->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__PythonMainLoopingMaterial[] = {
  {"init_texture", (PyCFunction)__pyx_f_5_soya_26_PythonMainLoopingMaterial_init_texture, METH_VARARGS|METH_KEYWORDS, 0},
  {"activated", (PyCFunction)__pyx_f_5_soya_26_PythonMainLoopingMaterial_activated, METH_VARARGS|METH_KEYWORDS, 0},
  {"inactivated", (PyCFunction)__pyx_f_5_soya_26_PythonMainLoopingMaterial_inactivated, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__PythonMainLoopingMaterial = {
  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__PythonMainLoopingMaterial = {
  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__PythonMainLoopingMaterial = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__PythonMainLoopingMaterial = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__PythonMainLoopingMaterial = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._PythonMainLoopingMaterial", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__PythonMainLoopingMaterial), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__PythonMainLoopingMaterial, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__PythonMainLoopingMaterial, /*tp_as_number*/
  &__pyx_tp_as_sequence__PythonMainLoopingMaterial, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__PythonMainLoopingMaterial, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__PythonMainLoopingMaterial, /*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, PythonMainLoopingMaterial also has begin_round, advance_time and end_round method.", /*tp_doc*/
  __pyx_tp_traverse_5_soya__PythonMainLoopingMaterial, /*tp_traverse*/
  __pyx_tp_clear_5_soya__PythonMainLoopingMaterial, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__PythonMainLoopingMaterial, /*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__PythonMainLoopingMaterial, /*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__SolidModel __pyx_vtable_5_soya__SolidModel;

static PyObject *__pyx_tp_new_5_soya__SolidModel(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__SimpleModel->tp_new(t, a, k);
  struct __pyx_obj_5_soya__SolidModel *p = (struct __pyx_obj_5_soya__SolidModel *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__SolidModel *)__pyx_vtabptr_5_soya__SolidModel;
  return o;
}

static void __pyx_tp_dealloc_5_soya__SolidModel(PyObject *o) {
  struct __pyx_obj_5_soya__SolidModel *p = (struct __pyx_obj_5_soya__SolidModel *)o;
  __pyx_ptype_5_soya__SimpleModel->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__SolidModel(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__SolidModel *p = (struct __pyx_obj_5_soya__SolidModel *)o;
  __pyx_ptype_5_soya__SimpleModel->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__SolidModel(PyObject *o) {
  struct __pyx_obj_5_soya__SolidModel *p = (struct __pyx_obj_5_soya__SolidModel *)o;
  __pyx_ptype_5_soya__SimpleModel->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__SolidModel[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SolidModel = {
  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__SolidModel = {
  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__SolidModel = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SolidModel = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__SolidModel = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._SolidModel", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__SolidModel), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__SolidModel, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SolidModel, /*tp_as_number*/
  &__pyx_tp_as_sequence__SolidModel, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SolidModel, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SolidModel, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__SolidModel, /*tp_traverse*/
  __pyx_tp_clear_5_soya__SolidModel, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__SolidModel, /*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__SolidModel, /*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_SolidModelBuilder __pyx_vtable_5_soya_SolidModelBuilder;

static PyObject *__pyx_tp_new_5_soya_SolidModelBuilder(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_SimpleModelBuilder->tp_new(t, a, k);
  struct __pyx_obj_5_soya_SolidModelBuilder *p = (struct __pyx_obj_5_soya_SolidModelBuilder *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_SolidModelBuilder *)__pyx_vtabptr_5_soya_SolidModelBuilder;
  return o;
}

static void __pyx_tp_dealloc_5_soya_SolidModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_SolidModelBuilder *p = (struct __pyx_obj_5_soya_SolidModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_SolidModelBuilder(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_SolidModelBuilder *p = (struct __pyx_obj_5_soya_SolidModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_SolidModelBuilder(PyObject *o) {
  struct __pyx_obj_5_soya_SolidModelBuilder *p = (struct __pyx_obj_5_soya_SolidModelBuilder *)o;
  __pyx_ptype_5_soya_SimpleModelBuilder->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_SolidModelBuilder[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_SolidModelBuilder = {
  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_SolidModelBuilder = {
  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_SolidModelBuilder = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_SolidModelBuilder = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_SolidModelBuilder = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.SolidModelBuilder", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_SolidModelBuilder), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_SolidModelBuilder, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_SolidModelBuilder, /*tp_as_number*/
  &__pyx_tp_as_sequence_SolidModelBuilder, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_SolidModelBuilder, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_SolidModelBuilder, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  "SolidModelBuilder\n", /*tp_doc*/
  __pyx_tp_traverse_5_soya_SolidModelBuilder, /*tp_traverse*/
  __pyx_tp_clear_5_soya_SolidModelBuilder, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_SolidModelBuilder, /*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_SolidModelBuilder, /*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__Sound __pyx_vtable_5_soya__Sound;

static PyObject *__pyx_tp_new_5_soya__Sound(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__CObj->tp_new(t, a, k);
  struct __pyx_obj_5_soya__Sound *p = (struct __pyx_obj_5_soya__Sound *)o;
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__Sound *)__pyx_vtabptr_5_soya__Sound;
  p->_filename = Py_None; Py_INCREF(p->_filename);
  p->_buffers = Py_None; Py_INCREF(p->_buffers);
  p->_file = Py_None; Py_INCREF(p->_file);
  if (__pyx_f_5_soya_6_Sound___new__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5_soya__Sound(PyObject *o) {
  struct __pyx_obj_5_soya__Sound *p = (struct __pyx_obj_5_soya__Sound *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_6_Sound___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(p->_filename);
  Py_XDECREF(p->_buffers);
  Py_XDECREF(p->_file);
  __pyx_ptype_5_soya__CObj->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__Sound(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__Sound *p = (struct __pyx_obj_5_soya__Sound *)o;
  __pyx_ptype_5_soya__CObj->tp_traverse(o, v, a);
  if (p->_filename) {
    e = (*v)(p->_filename, a); if (e) return e;
  }
  if (p->_buffers) {
    e = (*v)(p->_buffers, a); if (e) return e;
  }
  if (p->_file) {
    e = (*v)(p->_file, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__Sound(PyObject *o) {
  struct __pyx_obj_5_soya__Sound *p = (struct __pyx_obj_5_soya__Sound *)o;
  __pyx_ptype_5_soya__CObj->tp_clear(o);
  Py_XDECREF(p->_filename);
  p->_filename = Py_None; Py_INCREF(p->_filename);
  Py_XDECREF(p->_buffers);
  p->_buffers = Py_None; Py_INCREF(p->_buffers);
  Py_XDECREF(p->_file);
  p->_file = Py_None; Py_INCREF(p->_file);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_6_Sound_stereo(PyObject *o, void *x) {
  return __pyx_f_5_soya_6_Sound_6stereo___get__(o);
}

static struct PyMethodDef __pyx_methods_5_soya__Sound[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_5_soya__Sound[] = {
  {"_filename", T_OBJECT, offsetof(struct __pyx_obj_5_soya__Sound, _filename), 0, 0},
  {0, 0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__Sound[] = {
  {"stereo", __pyx_getprop_5_soya_6_Sound_stereo, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__Sound = {
  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__Sound = {
  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__Sound = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__Sound = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__Sound = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._Sound", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__Sound), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__Sound, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_5_soya_6_Sound___repr__, /*tp_repr*/
  &__pyx_tp_as_number__Sound, /*tp_as_number*/
  &__pyx_tp_as_sequence__Sound, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__Sound, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__Sound, /*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__Sound, /*tp_traverse*/
  __pyx_tp_clear_5_soya__Sound, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__Sound, /*tp_methods*/
  __pyx_members_5_soya__Sound, /*tp_members*/
  __pyx_getsets_5_soya__Sound, /*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__Sound, /*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__WAVSound __pyx_vtable_5_soya__WAVSound;

static PyObject *__pyx_tp_new_5_soya__WAVSound(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Sound->tp_new(t, a, k);
  struct __pyx_obj_5_soya__WAVSound *p = (struct __pyx_obj_5_soya__WAVSound *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__WAVSound *)__pyx_vtabptr_5_soya__WAVSound;
  return o;
}

static void __pyx_tp_dealloc_5_soya__WAVSound(PyObject *o) {
  struct __pyx_obj_5_soya__WAVSound *p = (struct __pyx_obj_5_soya__WAVSound *)o;
  __pyx_ptype_5_soya__Sound->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__WAVSound(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__WAVSound *p = (struct __pyx_obj_5_soya__WAVSound *)o;
  __pyx_ptype_5_soya__Sound->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__WAVSound(PyObject *o) {
  struct __pyx_obj_5_soya__WAVSound *p = (struct __pyx_obj_5_soya__WAVSound *)o;
  __pyx_ptype_5_soya__Sound->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__WAVSound[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__WAVSound = {
  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__WAVSound = {
  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__WAVSound = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__WAVSound = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__WAVSound = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._WAVSound", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__WAVSound), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__WAVSound, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__WAVSound, /*tp_as_number*/
  &__pyx_tp_as_sequence__WAVSound, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__WAVSound, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__WAVSound, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__WAVSound, /*tp_traverse*/
  __pyx_tp_clear_5_soya__WAVSound, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__WAVSound, /*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_9_WAVSound___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__WAVSound, /*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__OGGVorbisSound __pyx_vtable_5_soya__OGGVorbisSound;

static PyObject *__pyx_tp_new_5_soya__OGGVorbisSound(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Sound->tp_new(t, a, k);
  struct __pyx_obj_5_soya__OGGVorbisSound *p = (struct __pyx_obj_5_soya__OGGVorbisSound *)o;
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__OGGVorbisSound *)__pyx_vtabptr_5_soya__OGGVorbisSound;
  return o;
}

static void __pyx_tp_dealloc_5_soya__OGGVorbisSound(PyObject *o) {
  struct __pyx_obj_5_soya__OGGVorbisSound *p = (struct __pyx_obj_5_soya__OGGVorbisSound *)o;
  __pyx_ptype_5_soya__Sound->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__OGGVorbisSound(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__OGGVorbisSound *p = (struct __pyx_obj_5_soya__OGGVorbisSound *)o;
  __pyx_ptype_5_soya__Sound->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__OGGVorbisSound(PyObject *o) {
  struct __pyx_obj_5_soya__OGGVorbisSound *p = (struct __pyx_obj_5_soya__OGGVorbisSound *)o;
  __pyx_ptype_5_soya__Sound->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__OGGVorbisSound[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__OGGVorbisSound = {
  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__OGGVorbisSound = {
  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__OGGVorbisSound = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__OGGVorbisSound = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__OGGVorbisSound = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._OGGVorbisSound", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__OGGVorbisSound), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__OGGVorbisSound, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__OGGVorbisSound, /*tp_as_number*/
  &__pyx_tp_as_sequence__OGGVorbisSound, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__OGGVorbisSound, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__OGGVorbisSound, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__OGGVorbisSound, /*tp_traverse*/
  __pyx_tp_clear_5_soya__OGGVorbisSound, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__OGGVorbisSound, /*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_15_OGGVorbisSound___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__OGGVorbisSound, /*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__SoundPlayer __pyx_vtable_5_soya__SoundPlayer;

static PyObject *__pyx_tp_new_5_soya__SoundPlayer(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya_CoordSyst->tp_new(t, a, k);
  struct __pyx_obj_5_soya__SoundPlayer *p = (struct __pyx_obj_5_soya__SoundPlayer *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__SoundPlayer *)__pyx_vtabptr_5_soya__SoundPlayer;
  p->_sound = Py_None; Py_INCREF((PyObject *) p->_sound);
  if (__pyx_f_5_soya_12_SoundPlayer___new__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_5_soya__SoundPlayer(PyObject *o) {
  struct __pyx_obj_5_soya__SoundPlayer *p = (struct __pyx_obj_5_soya__SoundPlayer *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++o->ob_refcnt;
    __pyx_f_5_soya_12_SoundPlayer___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --o->ob_refcnt;
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF((PyObject *)p->_sound);
  __pyx_ptype_5_soya_CoordSyst->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__SoundPlayer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__SoundPlayer *p = (struct __pyx_obj_5_soya__SoundPlayer *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_traverse(o, v, a);
  if (p->_sound) {
    e = (*v)(((PyObject*)p->_sound), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_5_soya__SoundPlayer(PyObject *o) {
  struct __pyx_obj_5_soya__SoundPlayer *p = (struct __pyx_obj_5_soya__SoundPlayer *)o;
  __pyx_ptype_5_soya_CoordSyst->tp_clear(o);
  Py_XDECREF((PyObject *)p->_sound);
  p->_sound = Py_None; Py_INCREF((PyObject *) p->_sound);
  return 0;
}

static PyObject *__pyx_getprop_5_soya_12_SoundPlayer_sound(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SoundPlayer_5sound___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SoundPlayer_loop(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SoundPlayer_4loop___get__(o);
}

static int __pyx_setprop_5_soya_12_SoundPlayer_loop(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_12_SoundPlayer_4loop___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_12_SoundPlayer_auto_remove(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SoundPlayer_11auto_remove___get__(o);
}

static int __pyx_setprop_5_soya_12_SoundPlayer_auto_remove(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_12_SoundPlayer_11auto_remove___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_5_soya_12_SoundPlayer_play_in_3D(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SoundPlayer_10play_in_3D___get__(o);
}

static PyObject *__pyx_getprop_5_soya_12_SoundPlayer_gain(PyObject *o, void *x) {
  return __pyx_f_5_soya_12_SoundPlayer_4gain___get__(o);
}

static int __pyx_setprop_5_soya_12_SoundPlayer_gain(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_f_5_soya_12_SoundPlayer_4gain___set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static struct PyMethodDef __pyx_methods_5_soya__SoundPlayer[] = {
  {"begin_round", (PyCFunction)__pyx_f_5_soya_12_SoundPlayer_begin_round, METH_VARARGS|METH_KEYWORDS, 0},
  {"advance_time", (PyCFunction)__pyx_f_5_soya_12_SoundPlayer_advance_time, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_5_soya__SoundPlayer[] = {
  {"sound", __pyx_getprop_5_soya_12_SoundPlayer_sound, 0, 0, 0},
  {"loop", __pyx_getprop_5_soya_12_SoundPlayer_loop, __pyx_setprop_5_soya_12_SoundPlayer_loop, 0, 0},
  {"auto_remove", __pyx_getprop_5_soya_12_SoundPlayer_auto_remove, __pyx_setprop_5_soya_12_SoundPlayer_auto_remove, 0, 0},
  {"play_in_3D", __pyx_getprop_5_soya_12_SoundPlayer_play_in_3D, 0, 0, 0},
  {"gain", __pyx_getprop_5_soya_12_SoundPlayer_gain, __pyx_setprop_5_soya_12_SoundPlayer_gain, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__SoundPlayer = {
  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__SoundPlayer = {
  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__SoundPlayer = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__SoundPlayer = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__SoundPlayer = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._SoundPlayer", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__SoundPlayer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__SoundPlayer, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__SoundPlayer, /*tp_as_number*/
  &__pyx_tp_as_sequence__SoundPlayer, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__SoundPlayer, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__SoundPlayer, /*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__SoundPlayer, /*tp_traverse*/
  __pyx_tp_clear_5_soya__SoundPlayer, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__SoundPlayer, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_5_soya__SoundPlayer, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_f_5_soya_12_SoundPlayer___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_5_soya__SoundPlayer, /*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__TestDeform __pyx_vtable_5_soya__TestDeform;

static PyObject *__pyx_tp_new_5_soya__TestDeform(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Deform->tp_new(t, a, k);
  struct __pyx_obj_5_soya__TestDeform *p = (struct __pyx_obj_5_soya__TestDeform *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya__TestDeform *)__pyx_vtabptr_5_soya__TestDeform;
  return o;
}

static void __pyx_tp_dealloc_5_soya__TestDeform(PyObject *o) {
  struct __pyx_obj_5_soya__TestDeform *p = (struct __pyx_obj_5_soya__TestDeform *)o;
  __pyx_ptype_5_soya__Deform->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya__TestDeform(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya__TestDeform *p = (struct __pyx_obj_5_soya__TestDeform *)o;
  __pyx_ptype_5_soya__Deform->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya__TestDeform(PyObject *o) {
  struct __pyx_obj_5_soya__TestDeform *p = (struct __pyx_obj_5_soya__TestDeform *)o;
  __pyx_ptype_5_soya__Deform->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya__TestDeform[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number__TestDeform = {
  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__TestDeform = {
  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__TestDeform = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer__TestDeform = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya__TestDeform = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya._TestDeform", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya__TestDeform), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya__TestDeform, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number__TestDeform, /*tp_as_number*/
  &__pyx_tp_as_sequence__TestDeform, /*tp_as_sequence*/
  &__pyx_tp_as_mapping__TestDeform, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer__TestDeform, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya__TestDeform, /*tp_traverse*/
  __pyx_tp_clear_5_soya__TestDeform, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya__TestDeform, /*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__TestDeform, /*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_PythonDeform __pyx_vtable_5_soya_PythonDeform;

static PyObject *__pyx_tp_new_5_soya_PythonDeform(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = __pyx_ptype_5_soya__Deform->tp_new(t, a, k);
  struct __pyx_obj_5_soya_PythonDeform *p = (struct __pyx_obj_5_soya_PythonDeform *)o;
  p->__pyx_base.__pyx_base.__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_5_soya_PythonDeform *)__pyx_vtabptr_5_soya_PythonDeform;
  return o;
}

static void __pyx_tp_dealloc_5_soya_PythonDeform(PyObject *o) {
  struct __pyx_obj_5_soya_PythonDeform *p = (struct __pyx_obj_5_soya_PythonDeform *)o;
  __pyx_ptype_5_soya__Deform->tp_dealloc(o);
}

static int __pyx_tp_traverse_5_soya_PythonDeform(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_5_soya_PythonDeform *p = (struct __pyx_obj_5_soya_PythonDeform *)o;
  __pyx_ptype_5_soya__Deform->tp_traverse(o, v, a);
  return 0;
}

static int __pyx_tp_clear_5_soya_PythonDeform(PyObject *o) {
  struct __pyx_obj_5_soya_PythonDeform *p = (struct __pyx_obj_5_soya_PythonDeform *)o;
  __pyx_ptype_5_soya__Deform->tp_clear(o);
  return 0;
}

static struct PyMethodDef __pyx_methods_5_soya_PythonDeform[] = {
  {"deform_point", (PyCFunction)__pyx_f_5_soya_12PythonDeform_deform_point, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PythonDeform = {
  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_PythonDeform = {
  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_PythonDeform = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PythonDeform = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

statichere PyTypeObject __pyx_type_5_soya_PythonDeform = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_soya.PythonDeform", /*tp_name*/
  sizeof(struct __pyx_obj_5_soya_PythonDeform), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_5_soya_PythonDeform, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_PythonDeform, /*tp_as_number*/
  &__pyx_tp_as_sequence_PythonDeform, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PythonDeform, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PythonDeform, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_5_soya_PythonDeform, /*tp_traverse*/
  __pyx_tp_clear_5_soya_PythonDeform, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_5_soya_PythonDeform, /*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_PythonDeform, /*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},
  {"_chunk_check_error", (PyCFunction)__pyx_f_5_soya__chunk_check_error, 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_model_builder", (PyCFunction)__pyx_f_5_soya__set_default_model_builder, 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},
  {"check_al_error", (PyCFunction)__pyx_f_5_soya_check_al_error, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_check_al_error},
  {"set_sound_volume", (PyCFunction)__pyx_f_5_soya_set_sound_volume, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_set_sound_volume},
  {"get_sound_volume", (PyCFunction)__pyx_f_5_soya_get_sound_volume, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5_soya_get_sound_volume},
  {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;
  PyObject *__pyx_6 = 0;
  __pyx_m = Py_InitModule4("_soya", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 26; goto __pyx_L1;};
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 26; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 26; goto __pyx_L1;};
  if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 26; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[28]; __pyx_lineno = 26; 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_MODEL_BUILDER = Py_None; Py_INCREF((PyObject *) __pyx_v_5_soya__DEFAULT_MODEL_BUILDER);
  __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 = 108; 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 = 108; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_CObj", (PyObject *)&__pyx_type_5_soya__CObj) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; 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 = 74; 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 = 74; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Image", (PyObject *)&__pyx_type_5_soya__Image) < 0) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 74; 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 = 22; 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 = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Material", (PyObject *)&__pyx_type_5_soya__Material) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_ptype_5_soya__Material = &__pyx_type_5_soya__Material;
  __pyx_vtabptr_5_soya__Model = &__pyx_vtable_5_soya__Model;
  __pyx_vtable_5_soya__Model.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya__Model._instanced = (void *)__pyx_f_5_soya_6_Model__instanced;
  __pyx_vtable_5_soya__Model._batch = (void *)__pyx_f_5_soya_6_Model__batch;
  __pyx_vtable_5_soya__Model._render = (void *)__pyx_f_5_soya_6_Model__render;
  __pyx_vtable_5_soya__Model._shadow = (void *)__pyx_f_5_soya_6_Model__shadow;
  __pyx_vtable_5_soya__Model._get_box = (void *)__pyx_f_5_soya_6_Model__get_box;
  __pyx_vtable_5_soya__Model._raypick = (void *)__pyx_f_5_soya_6_Model__raypick;
  __pyx_vtable_5_soya__Model._raypick_b = (void *)__pyx_f_5_soya_6_Model__raypick_b;
  __pyx_vtable_5_soya__Model._collect_raypickables = (void *)__pyx_f_5_soya_6_Model__collect_raypickables;
  __pyx_vtable_5_soya__Model._create_deformed_data = (void *)__pyx_f_5_soya_6_Model__create_deformed_data;
  __pyx_vtable_5_soya__Model._attach = (void *)__pyx_f_5_soya_6_Model__attach;
  __pyx_vtable_5_soya__Model._detach = (void *)__pyx_f_5_soya_6_Model__detach;
  __pyx_vtable_5_soya__Model._is_attached = (void *)__pyx_f_5_soya_6_Model__is_attached;
  __pyx_vtable_5_soya__Model._attach_to_bone = (void *)__pyx_f_5_soya_6_Model__attach_to_bone;
  __pyx_vtable_5_soya__Model._detach_from_bone = (void *)__pyx_f_5_soya_6_Model__detach_from_bone;
  __pyx_vtable_5_soya__Model._advance_time = (void *)__pyx_f_5_soya_6_Model__advance_time;
  __pyx_vtable_5_soya__Model._begin_round = (void *)__pyx_f_5_soya_6_Model__begin_round;
  __pyx_vtable_5_soya__Model._get_attached_meshes = (void *)__pyx_f_5_soya_6_Model__get_attached_meshes;
  __pyx_vtable_5_soya__Model._get_attached_coordsysts = (void *)__pyx_f_5_soya_6_Model__get_attached_coordsysts;
  __pyx_vtable_5_soya__Model._animate_blend_cycle = (void *)__pyx_f_5_soya_6_Model__animate_blend_cycle;
  __pyx_vtable_5_soya__Model._animate_clear_cycle = (void *)__pyx_f_5_soya_6_Model__animate_clear_cycle;
  __pyx_vtable_5_soya__Model._animate_execute_action = (void *)__pyx_f_5_soya_6_Model__animate_execute_action;
  __pyx_vtable_5_soya__Model._animate_reset = (void *)__pyx_f_5_soya_6_Model__animate_reset;
  __pyx_vtable_5_soya__Model._set_lod_level = (void *)__pyx_f_5_soya_6_Model__set_lod_level;
  __pyx_type_5_soya__Model.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya__Model.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Model) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Model.tp_dict, __pyx_vtabptr_5_soya__Model) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Model", (PyObject *)&__pyx_type_5_soya__Model) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__Model = &__pyx_type_5_soya__Model;
  __pyx_vtabptr_5_soya__SimpleModel = &__pyx_vtable_5_soya__SimpleModel;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base = *__pyx_vtabptr_5_soya__Model;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_12_SimpleModel___getcstate__;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_12_SimpleModel___setcstate__;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._batch = (void *)__pyx_f_5_soya_12_SimpleModel__batch;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._render = (void *)__pyx_f_5_soya_12_SimpleModel__render;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._shadow = (void *)__pyx_f_5_soya_12_SimpleModel__shadow;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._get_box = (void *)__pyx_f_5_soya_12_SimpleModel__get_box;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._raypick = (void *)__pyx_f_5_soya_12_SimpleModel__raypick;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_12_SimpleModel__raypick_b;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_12_SimpleModel__collect_raypickables;
  __pyx_vtable_5_soya__SimpleModel.__pyx_base._create_deformed_data = (void *)__pyx_f_5_soya_12_SimpleModel__create_deformed_data;
  __pyx_vtable_5_soya__SimpleModel.__setcstate_data__ = (void *)__pyx_f_5_soya_12_SimpleModel___setcstate_data__;
  __pyx_vtable_5_soya__SimpleModel._register_material = (void *)__pyx_f_5_soya_12_SimpleModel__register_material;
  __pyx_vtable_5_soya__SimpleModel._add_coord = (void *)__pyx_f_5_soya_12_SimpleModel__add_coord;
  __pyx_vtable_5_soya__SimpleModel._register_value = (void *)__pyx_f_5_soya_12_SimpleModel__register_value;
  __pyx_vtable_5_soya__SimpleModel._register_color = (void *)__pyx_f_5_soya_12_SimpleModel__register_color;
  __pyx_vtable_5_soya__SimpleModel._add_face = (void *)__pyx_f_5_soya_12_SimpleModel__add_face;
  __pyx_vtable_5_soya__SimpleModel._add_vertex = (void *)__pyx_f_5_soya_12_SimpleModel__add_vertex;
  __pyx_vtable_5_soya__SimpleModel._identify_vertices = (void *)__pyx_f_5_soya_12_SimpleModel__identify_vertices;
  __pyx_vtable_5_soya__SimpleModel._compute_face_normals = (void *)__pyx_f_5_soya_12_SimpleModel__compute_face_normals;
  __pyx_vtable_5_soya__SimpleModel._compute_vertex_normals = (void *)__pyx_f_5_soya_12_SimpleModel__compute_vertex_normals;
  __pyx_vtable_5_soya__SimpleModel._compute_face_neighbors = (void *)__pyx_f_5_soya_12_SimpleModel__compute_face_neighbors;
  __pyx_vtable_5_soya__SimpleModel._build_sphere = (void *)__pyx_f_5_soya_12_SimpleModel__build_sphere;
  __pyx_vtable_5_soya__SimpleModel._build_display_list = (void *)__pyx_f_5_soya_12_SimpleModel__build_display_list;
  __pyx_vtable_5_soya__SimpleModel._init_display_list = (void *)__pyx_f_5_soya_12_SimpleModel__init_display_list;
  __pyx_vtable_5_soya__SimpleModel._batch_face = (void *)__pyx_f_5_soya_12_SimpleModel__batch_face;
  __pyx_vtable_5_soya__SimpleModel._face_raypick = (void *)__pyx_f_5_soya_12_SimpleModel__face_raypick;
  __pyx_vtable_5_soya__SimpleModel._face_raypick_b = (void *)__pyx_f_5_soya_12_SimpleModel__face_raypick_b;
  __pyx_vtable_5_soya__SimpleModel._render_triangle = (void *)__pyx_f_5_soya_12_SimpleModel__render_triangle;
  __pyx_vtable_5_soya__SimpleModel._render_quad = (void *)__pyx_f_5_soya_12_SimpleModel__render_quad;
  __pyx_vtable_5_soya__SimpleModel._render_vertex = (void *)__pyx_f_5_soya_12_SimpleModel__render_vertex;
  __pyx_vtable_5_soya__SimpleModel._build_shadow = (void *)__pyx_f_5_soya_12_SimpleModel__build_shadow;
  __pyx_type_5_soya__SimpleModel.tp_base = __pyx_ptype_5_soya__Model;
  __pyx_type_5_soya__SimpleModel.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__SimpleModel) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 84; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__SimpleModel.tp_dict, __pyx_vtabptr_5_soya__SimpleModel) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 84; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SimpleModel", (PyObject *)&__pyx_type_5_soya__SimpleModel) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 84; goto __pyx_L1;}
  __pyx_ptype_5_soya__SimpleModel = &__pyx_type_5_soya__SimpleModel;
  __pyx_vtabptr_5_soya__CellShadingModel = &__pyx_vtable_5_soya__CellShadingModel;
  __pyx_vtable_5_soya__CellShadingModel.__pyx_base = *__pyx_vtabptr_5_soya__SimpleModel;
  __pyx_vtable_5_soya__CellShadingModel.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_17_CellShadingModel___getcstate__;
  __pyx_vtable_5_soya__CellShadingModel.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_17_CellShadingModel___setcstate__;
  __pyx_vtable_5_soya__CellShadingModel.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_17_CellShadingModel__batch;
  __pyx_vtable_5_soya__CellShadingModel.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_17_CellShadingModel__render;
  __pyx_vtable_5_soya__CellShadingModel._build_cellshading = (void *)__pyx_f_5_soya_17_CellShadingModel__build_cellshading;
  __pyx_vtable_5_soya__CellShadingModel._render_outline = (void *)__pyx_f_5_soya_17_CellShadingModel__render_outline;
  __pyx_vtable_5_soya__CellShadingModel._prepare_cellshading_shades = (void *)__pyx_f_5_soya_17_CellShadingModel__prepare_cellshading_shades;
  __pyx_vtable_5_soya__CellShadingModel._prepare_cellshading = (void *)__pyx_f_5_soya_17_CellShadingModel__prepare_cellshading;
  __pyx_vtable_5_soya__CellShadingModel._vertex_compute_cellshading = (void *)__pyx_f_5_soya_17_CellShadingModel__vertex_compute_cellshading;
  __pyx_vtable_5_soya__CellShadingModel._render_triangle_cellshading = (void *)__pyx_f_5_soya_17_CellShadingModel__render_triangle_cellshading;
  __pyx_vtable_5_soya__CellShadingModel._render_quad_cellshading = (void *)__pyx_f_5_soya_17_CellShadingModel__render_quad_cellshading;
  __pyx_vtable_5_soya__CellShadingModel._render_vertex_cellshading_smoothlit = (void *)__pyx_f_5_soya_17_CellShadingModel__render_vertex_cellshading_smoothlit;
  __pyx_vtable_5_soya__CellShadingModel._render_vertex_cellshading = (void *)__pyx_f_5_soya_17_CellShadingModel__render_vertex_cellshading;
  __pyx_type_5_soya__CellShadingModel.tp_base = __pyx_ptype_5_soya__SimpleModel;
  __pyx_type_5_soya__CellShadingModel.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__CellShadingModel) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 21; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__CellShadingModel.tp_dict, __pyx_vtabptr_5_soya__CellShadingModel) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 21; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_CellShadingModel", (PyObject *)&__pyx_type_5_soya__CellShadingModel) < 0) {__pyx_filename = __pyx_f[18]; __pyx_lineno = 21; goto __pyx_L1;}
  __pyx_ptype_5_soya__CellShadingModel = &__pyx_type_5_soya__CellShadingModel;
  __pyx_vtabptr_5_soya__TreeModel = &__pyx_vtable_5_soya__TreeModel;
  __pyx_vtable_5_soya__TreeModel.__pyx_base = *__pyx_vtabptr_5_soya__SimpleModel;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_10_TreeModel___getcstate__;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_10_TreeModel___setcstate__;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_10_TreeModel__batch;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_10_TreeModel__render;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base._raypick = (void *)__pyx_f_5_soya_10_TreeModel__raypick;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_10_TreeModel__raypick_b;
  __pyx_vtable_5_soya__TreeModel.__pyx_base.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_10_TreeModel__collect_raypickables;
  __pyx_vtable_5_soya__TreeModel._node2chunk = (void *)__pyx_f_5_soya_10_TreeModel__node2chunk;
  __pyx_vtable_5_soya__TreeModel._chunk2node = (void *)__pyx_f_5_soya_10_TreeModel__chunk2node;
  __pyx_vtable_5_soya__TreeModel._build_tree = (void *)__pyx_f_5_soya_10_TreeModel__build_tree;
  __pyx_vtable_5_soya__TreeModel._optimize_tree = (void *)__pyx_f_5_soya_10_TreeModel__optimize_tree;
  __pyx_vtable_5_soya__TreeModel.compute_sphere = (void *)__pyx_f_5_soya_10_TreeModel_compute_sphere;
  __pyx_vtable_5_soya__TreeModel._batch_node = (void *)__pyx_f_5_soya_10_TreeModel__batch_node;
  __pyx_vtable_5_soya__TreeModel._node_raypick = (void *)__pyx_f_5_soya_10_TreeModel__node_raypick;
  __pyx_vtable_5_soya__TreeModel._node_raypick_b = (void *)__pyx_f_5_soya_10_TreeModel__node_raypick_b;
  __pyx_vtable_5_soya__TreeModel._raypick_from_context = (void *)__pyx_f_5_soya_10_TreeModel__raypick_from_context;
  __pyx_vtable_5_soya__TreeModel._raypick_from_context_b = (void *)__pyx_f_5_soya_10_TreeModel__raypick_from_context_b;
  __pyx_type_5_soya__TreeModel.tp_base = __pyx_ptype_5_soya__SimpleModel;
  if (PyType_Ready(&__pyx_type_5_soya__TreeModel) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 236; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__TreeModel.tp_dict, __pyx_vtabptr_5_soya__TreeModel) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 236; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_TreeModel", (PyObject *)&__pyx_type_5_soya__TreeModel) < 0) {__pyx_filename = __pyx_f[19]; __pyx_lineno = 236; goto __pyx_L1;}
  __pyx_ptype_5_soya__TreeModel = &__pyx_type_5_soya__TreeModel;
  __pyx_vtabptr_5_soya__ModelData = &__pyx_vtable_5_soya__ModelData;
  __pyx_vtable_5_soya__ModelData.__pyx_base = *__pyx_vtabptr_5_soya__Model;
  __pyx_type_5_soya__ModelData.tp_base = __pyx_ptype_5_soya__Model;
  if (PyType_Ready(&__pyx_type_5_soya__ModelData) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1546; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__ModelData.tp_dict, __pyx_vtabptr_5_soya__ModelData) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1546; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_ModelData", (PyObject *)&__pyx_type_5_soya__ModelData) < 0) {__pyx_filename = __pyx_f[17]; __pyx_lineno = 1546; goto __pyx_L1;}
  __pyx_ptype_5_soya__ModelData = &__pyx_type_5_soya__ModelData;
  __pyx_vtabptr_5_soya__AnimatedModelData = &__pyx_vtable_5_soya__AnimatedModelData;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base = *__pyx_vtabptr_5_soya__ModelData;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_18_AnimatedModelData___getcstate__;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_18_AnimatedModelData___setcstate__;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_18_AnimatedModelData__batch;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_18_AnimatedModelData__render;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._shadow = (void *)__pyx_f_5_soya_18_AnimatedModelData__shadow;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._get_box = (void *)__pyx_f_5_soya_18_AnimatedModelData__get_box;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._raypick = (void *)__pyx_f_5_soya_18_AnimatedModelData__raypick;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_18_AnimatedModelData__raypick_b;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_18_AnimatedModelData__collect_raypickables;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._attach = (void *)__pyx_f_5_soya_18_AnimatedModelData__attach;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._detach = (void *)__pyx_f_5_soya_18_AnimatedModelData__detach;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._is_attached = (void *)__pyx_f_5_soya_18_AnimatedModelData__is_attached;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._attach_to_bone = (void *)__pyx_f_5_soya_18_AnimatedModelData__attach_to_bone;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._detach_from_bone = (void *)__pyx_f_5_soya_18_AnimatedModelData__detach_from_bone;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._advance_time = (void *)__pyx_f_5_soya_18_AnimatedModelData__advance_time;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._begin_round = (void *)__pyx_f_5_soya_18_AnimatedModelData__begin_round;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._get_attached_meshes = (void *)__pyx_f_5_soya_18_AnimatedModelData__get_attached_meshes;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._get_attached_coordsysts = (void *)__pyx_f_5_soya_18_AnimatedModelData__get_attached_coordsysts;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._animate_blend_cycle = (void *)__pyx_f_5_soya_18_AnimatedModelData__animate_blend_cycle;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._animate_clear_cycle = (void *)__pyx_f_5_soya_18_AnimatedModelData__animate_clear_cycle;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._animate_execute_action = (void *)__pyx_f_5_soya_18_AnimatedModelData__animate_execute_action;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._animate_reset = (void *)__pyx_f_5_soya_18_AnimatedModelData__animate_reset;
  __pyx_vtable_5_soya__AnimatedModelData.__pyx_base.__pyx_base._set_lod_level = (void *)__pyx_f_5_soya_18_AnimatedModelData__set_lod_level;
  __pyx_vtable_5_soya__AnimatedModelData._build_submeshes = (void *)__pyx_f_5_soya_18_AnimatedModelData__build_submeshes;
  __pyx_vtable_5_soya__AnimatedModelData._build_face_planes = (void *)__pyx_f_5_soya_18_AnimatedModelData__build_face_planes;
  __pyx_vtable_5_soya__AnimatedModelData._build_vertices = (void *)__pyx_f_5_soya_18_AnimatedModelData__build_vertices;
  __pyx_vtable_5_soya__AnimatedModelData._attach_all = (void *)__pyx_f_5_soya_18_AnimatedModelData__attach_all;
  __pyx_type_5_soya__AnimatedModelData.tp_base = __pyx_ptype_5_soya__ModelData;
  __pyx_type_5_soya__AnimatedModelData.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__AnimatedModelData) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1125; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__AnimatedModelData.tp_dict, __pyx_vtabptr_5_soya__AnimatedModelData) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1125; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_AnimatedModelData", (PyObject *)&__pyx_type_5_soya__AnimatedModelData) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 1125; goto __pyx_L1;}
  __pyx_ptype_5_soya__AnimatedModelData = &__pyx_type_5_soya__AnimatedModelData;
  __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 = 20; 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 = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Position", (PyObject *)&__pyx_type_5_soya_Position) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; 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 = 63; 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 = 63; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Point", (PyObject *)&__pyx_type_5_soya__Point) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; 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 = 290; 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 = 290; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Vector", (PyObject *)&__pyx_type_5_soya__Vector) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 290; 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 = 20; 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 = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Vertex", (PyObject *)&__pyx_type_5_soya__Vertex) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 20; 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_vtable_5_soya_CoordSyst._go_static = (void *)__pyx_f_5_soya_9CoordSyst__go_static;
  __pyx_vtable_5_soya_CoordSyst._go_not_static = (void *)__pyx_f_5_soya_9CoordSyst__go_not_static;
  __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 = 73; 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 = 73; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "CoordSyst", (PyObject *)&__pyx_type_5_soya_CoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 73; 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 = 21; 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 = 21; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Camera", (PyObject *)&__pyx_type_5_soya__Camera) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 21; 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;
  __pyx_type_5_soya__Light.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Light) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 26; 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 = 26; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Light", (PyObject *)&__pyx_type_5_soya__Light) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 26; goto __pyx_L1;}
  __pyx_ptype_5_soya__Light = &__pyx_type_5_soya__Light;
  __pyx_vtabptr_5_soya__Body = &__pyx_vtable_5_soya__Body;
  __pyx_vtable_5_soya__Body.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Body.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_5_Body___getcstate__;
  __pyx_vtable_5_soya__Body.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_5_Body___setcstate__;
  __pyx_vtable_5_soya__Body.__pyx_base._batch = (void *)__pyx_f_5_soya_5_Body__batch;
  __pyx_vtable_5_soya__Body.__pyx_base._shadow = (void *)__pyx_f_5_soya_5_Body__shadow;
  __pyx_vtable_5_soya__Body.__pyx_base._raypick = (void *)__pyx_f_5_soya_5_Body__raypick;
  __pyx_vtable_5_soya__Body.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_5_Body__raypick_b;
  __pyx_vtable_5_soya__Body.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_5_Body__collect_raypickables;
  __pyx_vtable_5_soya__Body.__pyx_base._contains = (void *)__pyx_f_5_soya_5_Body__contains;
  __pyx_vtable_5_soya__Body.__pyx_base._get_box = (void *)__pyx_f_5_soya_5_Body__get_box;
  __pyx_vtable_5_soya__Body.__pyx_base._get_sphere = (void *)__pyx_f_5_soya_5_Body__get_sphere;
  __pyx_type_5_soya__Body.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Body.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Body) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 22; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Body.tp_dict, __pyx_vtabptr_5_soya__Body) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Body", (PyObject *)&__pyx_type_5_soya__Body) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 22; goto __pyx_L1;}
  __pyx_ptype_5_soya__Body = &__pyx_type_5_soya__Body;
  __pyx_vtabptr_5_soya__World = &__pyx_vtable_5_soya__World;
  __pyx_vtable_5_soya__World.__pyx_base = *__pyx_vtabptr_5_soya__Body;
  __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__Body;
  __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 = 22; 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 = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_World", (PyObject *)&__pyx_type_5_soya__World) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 22; 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 = 128; 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 = 128; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Face", (PyObject *)&__pyx_type_5_soya__Face) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 128; goto __pyx_L1;}
  __pyx_ptype_5_soya__Face = &__pyx_type_5_soya__Face;
  __pyx_vtabptr_5_soya__AnimatedModel = &__pyx_vtable_5_soya__AnimatedModel;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base = *__pyx_vtabptr_5_soya__Model;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._instanced = (void *)__pyx_f_5_soya_14_AnimatedModel__instanced;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._batch = (void *)__pyx_f_5_soya_14_AnimatedModel__batch;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._render = (void *)__pyx_f_5_soya_14_AnimatedModel__render;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._shadow = (void *)__pyx_f_5_soya_14_AnimatedModel__shadow;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._raypick = (void *)__pyx_f_5_soya_14_AnimatedModel__raypick;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_14_AnimatedModel__raypick_b;
  __pyx_vtable_5_soya__AnimatedModel.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_14_AnimatedModel__collect_raypickables;
  __pyx_vtable_5_soya__AnimatedModel._build_submeshes = (void *)__pyx_f_5_soya_14_AnimatedModel__build_submeshes;
  __pyx_vtable_5_soya__AnimatedModel._set_face_neighborhood = (void *)__pyx_f_5_soya_14_AnimatedModel__set_face_neighborhood;
  __pyx_vtable_5_soya__AnimatedModel._set_cell_shading = (void *)__pyx_f_5_soya_14_AnimatedModel__set_cell_shading;
  __pyx_vtable_5_soya__AnimatedModel._prepare_cellshading = (void *)__pyx_f_5_soya_14_AnimatedModel__prepare_cellshading;
  __pyx_vtable_5_soya__AnimatedModel._prepare_cellshading_shades = (void *)__pyx_f_5_soya_14_AnimatedModel__prepare_cellshading_shades;
  __pyx_vtable_5_soya__AnimatedModel._render_outline = (void *)__pyx_f_5_soya_14_AnimatedModel__render_outline;
  __pyx_vtable_5_soya__AnimatedModel._get_material_4_cal3d = (void *)__pyx_f_5_soya_14_AnimatedModel__get_material_4_cal3d;
  __pyx_vtable_5_soya__AnimatedModel._create_material_4_cal3d = (void *)__pyx_f_5_soya_14_AnimatedModel__create_material_4_cal3d;
  __pyx_vtable_5_soya__AnimatedModel._set_texture_from_model = (void *)__pyx_f_5_soya_14_AnimatedModel__set_texture_from_model;
  __pyx_vtable_5_soya__AnimatedModel._shadow2 = (void *)__pyx_f_5_soya_14_AnimatedModel__shadow2;
  __pyx_vtable_5_soya__AnimatedModel._build_vertices = (void *)__pyx_f_5_soya_14_AnimatedModel__build_vertices;
  __pyx_type_5_soya__AnimatedModel.tp_base = __pyx_ptype_5_soya__Model;
  __pyx_type_5_soya__AnimatedModel.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__AnimatedModel) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__AnimatedModel.tp_dict, __pyx_vtabptr_5_soya__AnimatedModel) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_AnimatedModel", (PyObject *)&__pyx_type_5_soya__AnimatedModel) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 201; goto __pyx_L1;}
  __pyx_ptype_5_soya__AnimatedModel = &__pyx_type_5_soya__AnimatedModel;
  __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 = 27; 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 = 27; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Sprite", (PyObject *)&__pyx_type_5_soya__Sprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 27; 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 = 20; 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 = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Portal", (PyObject *)&__pyx_type_5_soya__Portal) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__Portal = &__pyx_type_5_soya__Portal;
  __pyx_vtabptr_5_soya__Terrain = &__pyx_vtable_5_soya__Terrain;
  __pyx_vtable_5_soya__Terrain.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__Terrain.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_8_Terrain___getcstate__;
  __pyx_vtable_5_soya__Terrain.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_8_Terrain___setcstate__;
  __pyx_vtable_5_soya__Terrain.__pyx_base._batch = (void *)__pyx_f_5_soya_8_Terrain__batch;
  __pyx_vtable_5_soya__Terrain.__pyx_base._render = (void *)__pyx_f_5_soya_8_Terrain__render;
  __pyx_vtable_5_soya__Terrain.__pyx_base._raypick = (void *)__pyx_f_5_soya_8_Terrain__raypick;
  __pyx_vtable_5_soya__Terrain.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_8_Terrain__raypick_b;
  __pyx_vtable_5_soya__Terrain.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_8_Terrain__collect_raypickables;
  __pyx_vtable_5_soya__Terrain._get_vertex = (void *)__pyx_f_5_soya_8_Terrain__get_vertex;
  __pyx_vtable_5_soya__Terrain._check_size = (void *)__pyx_f_5_soya_8_Terrain__check_size;
  __pyx_vtable_5_soya__Terrain._free_patchs = (void *)__pyx_f_5_soya_8_Terrain__free_patchs;
  __pyx_vtable_5_soya__Terrain.__del__ = (void *)__pyx_f_5_soya_8_Terrain___del__;
  __pyx_vtable_5_soya__Terrain._add_material = (void *)__pyx_f_5_soya_8_Terrain__add_material;
  __pyx_vtable_5_soya__Terrain._get_height = (void *)__pyx_f_5_soya_8_Terrain__get_height;
  __pyx_vtable_5_soya__Terrain._set_height = (void *)__pyx_f_5_soya_8_Terrain__set_height;
  __pyx_vtable_5_soya__Terrain._init = (void *)__pyx_f_5_soya_8_Terrain__init;
  __pyx_vtable_5_soya__Terrain._compute_normal = (void *)__pyx_f_5_soya_8_Terrain__compute_normal;
  __pyx_vtable_5_soya__Terrain._compute_normals = (void *)__pyx_f_5_soya_8_Terrain__compute_normals;
  __pyx_vtable_5_soya__Terrain._compute_coords = (void *)__pyx_f_5_soya_8_Terrain__compute_coords;
  __pyx_vtable_5_soya__Terrain._create_patch = (void *)__pyx_f_5_soya_8_Terrain__create_patch;
  __pyx_vtable_5_soya__Terrain._create_patchs = (void *)__pyx_f_5_soya_8_Terrain__create_patchs;
  __pyx_vtable_5_soya__Terrain._register_color = (void *)__pyx_f_5_soya_8_Terrain__register_color;
  __pyx_vtable_5_soya__Terrain._tri_split = (void *)__pyx_f_5_soya_8_Terrain__tri_split;
  __pyx_vtable_5_soya__Terrain._tri_merge_child = (void *)__pyx_f_5_soya_8_Terrain__tri_merge_child;
  __pyx_vtable_5_soya__Terrain._tri_set_level = (void *)__pyx_f_5_soya_8_Terrain__tri_set_level;
  __pyx_vtable_5_soya__Terrain._patch_set_level = (void *)__pyx_f_5_soya_8_Terrain__patch_set_level;
  __pyx_vtable_5_soya__Terrain._patch_update = (void *)__pyx_f_5_soya_8_Terrain__patch_update;
  __pyx_vtable_5_soya__Terrain._tri_force_presence = (void *)__pyx_f_5_soya_8_Terrain__tri_force_presence;
  __pyx_vtable_5_soya__Terrain._force_presence = (void *)__pyx_f_5_soya_8_Terrain__force_presence;
  __pyx_vtable_5_soya__Terrain._tri_batch = (void *)__pyx_f_5_soya_8_Terrain__tri_batch;
  __pyx_vtable_5_soya__Terrain._patch_batch = (void *)__pyx_f_5_soya_8_Terrain__patch_batch;
  __pyx_vtable_5_soya__Terrain._tri_render_middle = (void *)__pyx_f_5_soya_8_Terrain__tri_render_middle;
  __pyx_vtable_5_soya__Terrain._tri_render_secondpass = (void *)__pyx_f_5_soya_8_Terrain__tri_render_secondpass;
  __pyx_vtable_5_soya__Terrain._tri_raypick = (void *)__pyx_f_5_soya_8_Terrain__tri_raypick;
  __pyx_vtable_5_soya__Terrain._tri_raypick_b = (void *)__pyx_f_5_soya_8_Terrain__tri_raypick_b;
  __pyx_vtable_5_soya__Terrain._full_raypick = (void *)__pyx_f_5_soya_8_Terrain__full_raypick;
  __pyx_vtable_5_soya__Terrain._full_raypick_rect = (void *)__pyx_f_5_soya_8_Terrain__full_raypick_rect;
  __pyx_vtable_5_soya__Terrain._full_raypick_b = (void *)__pyx_f_5_soya_8_Terrain__full_raypick_b;
  __pyx_vtable_5_soya__Terrain._full_raypick_rect_b = (void *)__pyx_f_5_soya_8_Terrain__full_raypick_rect_b;
  __pyx_vtable_5_soya__Terrain._check_vertex_options = (void *)__pyx_f_5_soya_8_Terrain__check_vertex_options;
  __pyx_vtable_5_soya__Terrain._check_color = (void *)__pyx_f_5_soya_8_Terrain__check_color;
  __pyx_vtable_5_soya__Terrain._vertex_render_special = (void *)__pyx_f_5_soya_8_Terrain__vertex_render_special;
  __pyx_type_5_soya__Terrain.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__Terrain.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Terrain) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 251; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Terrain.tp_dict, __pyx_vtabptr_5_soya__Terrain) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 251; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Terrain", (PyObject *)&__pyx_type_5_soya__Terrain) < 0) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 251; goto __pyx_L1;}
  __pyx_ptype_5_soya__Terrain = &__pyx_type_5_soya__Terrain;
  __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 = 20; 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 = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Atmosphere", (PyObject *)&__pyx_type_5_soya__Atmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 20; 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 = 31; 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 = 31; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Renderer", (PyObject *)&__pyx_type_5_soya_Renderer) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; 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 = 22; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_5_soya_Context) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; 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 = 41; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RaypickData", (PyObject *)&__pyx_type_5_soya_RaypickData) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 41; 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 = 66; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RaypickContext", (PyObject *)&__pyx_type_5_soya_RaypickContext) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 66; goto __pyx_L1;}
  __pyx_ptype_5_soya_RaypickContext = &__pyx_type_5_soya_RaypickContext;
  __pyx_type_5_soya_MainLoop.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_MainLoop) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "MainLoop", (PyObject *)&__pyx_type_5_soya_MainLoop) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; goto __pyx_L1;}
  __pyx_ptype_5_soya_MainLoop = &__pyx_type_5_soya_MainLoop;
  __pyx_type_5_soya_Glyph.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_Glyph) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 28; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Glyph", (PyObject *)&__pyx_type_5_soya_Glyph) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 28; 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_5_Font__get_glyph;
  __pyx_vtable_5_soya__Font._gen_glyph = (void *)__pyx_f_5_soya_5_Font__gen_glyph;
  __pyx_vtable_5_soya__Font._sizeup_pixel = (void *)__pyx_f_5_soya_5_Font__sizeup_pixel;
  __pyx_vtable_5_soya__Font._init = (void *)__pyx_f_5_soya_5_Font__init;
  __pyx_type_5_soya__Font.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Font) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 39; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Font.tp_dict, __pyx_vtabptr_5_soya__Font) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 39; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Font", (PyObject *)&__pyx_type_5_soya__Font) < 0) {__pyx_filename = __pyx_f[25]; __pyx_lineno = 39; goto __pyx_L1;}
  __pyx_ptype_5_soya__Font = &__pyx_type_5_soya__Font;
  __pyx_vtabptr_5_soya_ModelBuilder = &__pyx_vtable_5_soya_ModelBuilder;
  __pyx_vtable_5_soya_ModelBuilder.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya_ModelBuilder._to_model = (void *)__pyx_f_5_soya_12ModelBuilder__to_model;
  __pyx_type_5_soya_ModelBuilder.tp_base = __pyx_ptype_5_soya__CObj;
  if (PyType_Ready(&__pyx_type_5_soya_ModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 24; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_ModelBuilder.tp_dict, __pyx_vtabptr_5_soya_ModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 24; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "ModelBuilder", (PyObject *)&__pyx_type_5_soya_ModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 24; goto __pyx_L1;}
  __pyx_ptype_5_soya_ModelBuilder = &__pyx_type_5_soya_ModelBuilder;
  __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 = 165; 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 = 165; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Traveling", (PyObject *)&__pyx_type_5_soya_Traveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; 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 = 20; 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 = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_TravelingCamera", (PyObject *)&__pyx_type_5_soya__TravelingCamera) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__TravelingCamera = &__pyx_type_5_soya__TravelingCamera;
  __pyx_vtabptr_5_soya__Deform = &__pyx_vtable_5_soya__Deform;
  __pyx_vtable_5_soya__Deform.__pyx_base = *__pyx_vtabptr_5_soya__ModelData;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_7_Deform___getcstate__;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_7_Deform___setcstate__;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._batch = (void *)__pyx_f_5_soya_7_Deform__batch;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_7_Deform__render;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._shadow = (void *)__pyx_f_5_soya_7_Deform__shadow;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._get_box = (void *)__pyx_f_5_soya_7_Deform__get_box;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._raypick = (void *)__pyx_f_5_soya_7_Deform__raypick;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._raypick_b = (void *)__pyx_f_5_soya_7_Deform__raypick_b;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._collect_raypickables = (void *)__pyx_f_5_soya_7_Deform__collect_raypickables;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._create_deformed_data = (void *)__pyx_f_5_soya_7_Deform__create_deformed_data;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._advance_time = (void *)__pyx_f_5_soya_7_Deform__advance_time;
  __pyx_vtable_5_soya__Deform.__pyx_base.__pyx_base._begin_round = (void *)__pyx_f_5_soya_7_Deform__begin_round;
  __pyx_vtable_5_soya__Deform._set_model = (void *)__pyx_f_5_soya_7_Deform__set_model;
  __pyx_vtable_5_soya__Deform._deform_points = (void *)__pyx_f_5_soya_7_Deform__deform_points;
  __pyx_vtable_5_soya__Deform._deform_point = (void *)__pyx_f_5_soya_7_Deform__deform_point;
  __pyx_type_5_soya__Deform.tp_base = __pyx_ptype_5_soya__ModelData;
  __pyx_type_5_soya__Deform.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Deform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 20; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Deform.tp_dict, __pyx_vtabptr_5_soya__Deform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Deform", (PyObject *)&__pyx_type_5_soya__Deform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__Deform = &__pyx_type_5_soya__Deform;
  __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 = 177; 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 = 177; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_NoBackgroundAtmosphere", (PyObject *)&__pyx_type_5_soya__NoBackgroundAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 177; 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 = 182; 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 = 182; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SkyAtmosphere", (PyObject *)&__pyx_type_5_soya__SkyAtmosphere) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 182; 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 = 888; 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 = 888; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "PythonCoordSyst", (PyObject *)&__pyx_type_5_soya_PythonCoordSyst) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 888; 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 = 848; 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 = 848; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "CoordSystState", (PyObject *)&__pyx_type_5_soya_CoordSystState) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 848; 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 = 194; 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 = 194; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_FixTraveling", (PyObject *)&__pyx_type_5_soya__FixTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 194; 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 = 229; 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 = 229; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_ThirdPersonTraveling", (PyObject *)&__pyx_type_5_soya__ThirdPersonTraveling) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 229; 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 = 407; 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 = 407; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_PythonMaterial", (PyObject *)&__pyx_type_5_soya__PythonMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 407; 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 = 140; 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 = 140; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_CylinderSprite", (PyObject *)&__pyx_type_5_soya__CylinderSprite) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 140; 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 = 219; 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 = 219; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Bonus", (PyObject *)&__pyx_type_5_soya__Bonus) < 0) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 219; 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 = 26; 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 = 26; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Particles", (PyObject *)&__pyx_type_5_soya__Particles) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 26; 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 = 529; 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 = 529; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "FlagFirework", (PyObject *)&__pyx_type_5_soya_FlagFirework) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 529; goto __pyx_L1;}
  __pyx_ptype_5_soya_FlagFirework = &__pyx_type_5_soya_FlagFirework;
  __pyx_vtabptr_5_soya_SimpleModelBuilder = &__pyx_vtable_5_soya_SimpleModelBuilder;
  __pyx_vtable_5_soya_SimpleModelBuilder.__pyx_base = *__pyx_vtabptr_5_soya_ModelBuilder;
  __pyx_vtable_5_soya_SimpleModelBuilder.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_18SimpleModelBuilder___getcstate__;
  __pyx_vtable_5_soya_SimpleModelBuilder.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_18SimpleModelBuilder___setcstate__;
  __pyx_vtable_5_soya_SimpleModelBuilder.__pyx_base._to_model = (void *)__pyx_f_5_soya_18SimpleModelBuilder__to_model;
  __pyx_type_5_soya_SimpleModelBuilder.tp_base = __pyx_ptype_5_soya_ModelBuilder;
  if (PyType_Ready(&__pyx_type_5_soya_SimpleModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 29; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_SimpleModelBuilder.tp_dict, __pyx_vtabptr_5_soya_SimpleModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 29; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "SimpleModelBuilder", (PyObject *)&__pyx_type_5_soya_SimpleModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 29; goto __pyx_L1;}
  __pyx_ptype_5_soya_SimpleModelBuilder = &__pyx_type_5_soya_SimpleModelBuilder;
  __pyx_vtabptr_5_soya_TreeModelBuilder = &__pyx_vtable_5_soya_TreeModelBuilder;
  __pyx_vtable_5_soya_TreeModelBuilder.__pyx_base = *__pyx_vtabptr_5_soya_SimpleModelBuilder;
  __pyx_vtable_5_soya_TreeModelBuilder.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_16TreeModelBuilder___getcstate__;
  __pyx_vtable_5_soya_TreeModelBuilder.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_16TreeModelBuilder___setcstate__;
  __pyx_vtable_5_soya_TreeModelBuilder.__pyx_base.__pyx_base._to_model = (void *)__pyx_f_5_soya_16TreeModelBuilder__to_model;
  __pyx_type_5_soya_TreeModelBuilder.tp_base = __pyx_ptype_5_soya_SimpleModelBuilder;
  if (PyType_Ready(&__pyx_type_5_soya_TreeModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 97; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_TreeModelBuilder.tp_dict, __pyx_vtabptr_5_soya_TreeModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 97; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "TreeModelBuilder", (PyObject *)&__pyx_type_5_soya_TreeModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 97; goto __pyx_L1;}
  __pyx_ptype_5_soya_TreeModelBuilder = &__pyx_type_5_soya_TreeModelBuilder;
  __pyx_vtabptr_5_soya_CellShadingModelBuilder = &__pyx_vtable_5_soya_CellShadingModelBuilder;
  __pyx_vtable_5_soya_CellShadingModelBuilder.__pyx_base = *__pyx_vtabptr_5_soya_SimpleModelBuilder;
  __pyx_vtable_5_soya_CellShadingModelBuilder.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_23CellShadingModelBuilder___getcstate__;
  __pyx_vtable_5_soya_CellShadingModelBuilder.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_23CellShadingModelBuilder___setcstate__;
  __pyx_vtable_5_soya_CellShadingModelBuilder.__pyx_base.__pyx_base._to_model = (void *)__pyx_f_5_soya_23CellShadingModelBuilder__to_model;
  __pyx_type_5_soya_CellShadingModelBuilder.tp_base = __pyx_ptype_5_soya_SimpleModelBuilder;
  __pyx_type_5_soya_CellShadingModelBuilder.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya_CellShadingModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 167; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_CellShadingModelBuilder.tp_dict, __pyx_vtabptr_5_soya_CellShadingModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 167; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "CellShadingModelBuilder", (PyObject *)&__pyx_type_5_soya_CellShadingModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 167; goto __pyx_L1;}
  __pyx_ptype_5_soya_CellShadingModelBuilder = &__pyx_type_5_soya_CellShadingModelBuilder;
  __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 = 100; 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 = 100; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Cal3dSubMesh", (PyObject *)&__pyx_type_5_soya__Cal3dSubMesh) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 100; goto __pyx_L1;}
  __pyx_ptype_5_soya__Cal3dSubMesh = &__pyx_type_5_soya__Cal3dSubMesh;
  __pyx_vtabptr_5_soya__MainLoopingMaterial = &__pyx_vtable_5_soya__MainLoopingMaterial;
  __pyx_vtable_5_soya__MainLoopingMaterial.__pyx_base = *__pyx_vtabptr_5_soya__Material;
  __pyx_vtable_5_soya__MainLoopingMaterial.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_20_MainLoopingMaterial___setcstate__;
  __pyx_type_5_soya__MainLoopingMaterial.tp_base = __pyx_ptype_5_soya__Material;
  if (PyType_Ready(&__pyx_type_5_soya__MainLoopingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 377; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__MainLoopingMaterial.tp_dict, __pyx_vtabptr_5_soya__MainLoopingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 377; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_MainLoopingMaterial", (PyObject *)&__pyx_type_5_soya__MainLoopingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 377; goto __pyx_L1;}
  __pyx_ptype_5_soya__MainLoopingMaterial = &__pyx_type_5_soya__MainLoopingMaterial;
  __pyx_vtabptr_5_soya__PythonMainLoopingMaterial = &__pyx_vtable_5_soya__PythonMainLoopingMaterial;
  __pyx_vtable_5_soya__PythonMainLoopingMaterial.__pyx_base = *__pyx_vtabptr_5_soya__MainLoopingMaterial;
  __pyx_vtable_5_soya__PythonMainLoopingMaterial.__pyx_base.__pyx_base._init_texture = (void *)__pyx_f_5_soya_26_PythonMainLoopingMaterial__init_texture;
  __pyx_vtable_5_soya__PythonMainLoopingMaterial.__pyx_base.__pyx_base._activate = (void *)__pyx_f_5_soya_26_PythonMainLoopingMaterial__activate;
  __pyx_vtable_5_soya__PythonMainLoopingMaterial.__pyx_base.__pyx_base._inactivate = (void *)__pyx_f_5_soya_26_PythonMainLoopingMaterial__inactivate;
  __pyx_type_5_soya__PythonMainLoopingMaterial.tp_base = __pyx_ptype_5_soya__MainLoopingMaterial;
  if (PyType_Ready(&__pyx_type_5_soya__PythonMainLoopingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 435; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__PythonMainLoopingMaterial.tp_dict, __pyx_vtabptr_5_soya__PythonMainLoopingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 435; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_PythonMainLoopingMaterial", (PyObject *)&__pyx_type_5_soya__PythonMainLoopingMaterial) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 435; goto __pyx_L1;}
  __pyx_ptype_5_soya__PythonMainLoopingMaterial = &__pyx_type_5_soya__PythonMainLoopingMaterial;
  __pyx_vtabptr_5_soya__SolidModel = &__pyx_vtable_5_soya__SolidModel;
  __pyx_vtable_5_soya__SolidModel.__pyx_base = *__pyx_vtabptr_5_soya__SimpleModel;
  __pyx_vtable_5_soya__SolidModel.__pyx_base.__pyx_base._render = (void *)__pyx_f_5_soya_11_SolidModel__render;
  __pyx_vtable_5_soya__SolidModel._render_triangle_solid = (void *)__pyx_f_5_soya_11_SolidModel__render_triangle_solid;
  __pyx_type_5_soya__SolidModel.tp_base = __pyx_ptype_5_soya__SimpleModel;
  if (PyType_Ready(&__pyx_type_5_soya__SolidModel) < 0) {__pyx_filename = __pyx_f[29]; __pyx_lineno = 20; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__SolidModel.tp_dict, __pyx_vtabptr_5_soya__SolidModel) < 0) {__pyx_filename = __pyx_f[29]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SolidModel", (PyObject *)&__pyx_type_5_soya__SolidModel) < 0) {__pyx_filename = __pyx_f[29]; __pyx_lineno = 20; goto __pyx_L1;}
  __pyx_ptype_5_soya__SolidModel = &__pyx_type_5_soya__SolidModel;
  __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 = 472; 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 = 472; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Fountain", (PyObject *)&__pyx_type_5_soya_Fountain) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 472; 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 = 488; 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 = 488; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Smoke", (PyObject *)&__pyx_type_5_soya_Smoke) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 488; 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 = 505; 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 = 505; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "FlagSubFire", (PyObject *)&__pyx_type_5_soya_FlagSubFire) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 505; goto __pyx_L1;}
  __pyx_ptype_5_soya_FlagSubFire = &__pyx_type_5_soya_FlagSubFire;
  __pyx_vtabptr_5_soya_SolidModelBuilder = &__pyx_vtable_5_soya_SolidModelBuilder;
  __pyx_vtable_5_soya_SolidModelBuilder.__pyx_base = *__pyx_vtabptr_5_soya_SimpleModelBuilder;
  __pyx_vtable_5_soya_SolidModelBuilder.__pyx_base.__pyx_base._to_model = (void *)__pyx_f_5_soya_17SolidModelBuilder__to_model;
  __pyx_type_5_soya_SolidModelBuilder.tp_base = __pyx_ptype_5_soya_SimpleModelBuilder;
  if (PyType_Ready(&__pyx_type_5_soya_SolidModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 82; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_SolidModelBuilder.tp_dict, __pyx_vtabptr_5_soya_SolidModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 82; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "SolidModelBuilder", (PyObject *)&__pyx_type_5_soya_SolidModelBuilder) < 0) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 82; goto __pyx_L1;}
  __pyx_ptype_5_soya_SolidModelBuilder = &__pyx_type_5_soya_SolidModelBuilder;
  __pyx_vtabptr_5_soya__Sound = &__pyx_vtable_5_soya__Sound;
  __pyx_vtable_5_soya__Sound.__pyx_base = *__pyx_vtabptr_5_soya__CObj;
  __pyx_vtable_5_soya__Sound._getbuffer = (void *)__pyx_f_5_soya_6_Sound__getbuffer;
  __pyx_type_5_soya__Sound.tp_base = __pyx_ptype_5_soya__CObj;
  __pyx_type_5_soya__Sound.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__Sound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 151; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__Sound.tp_dict, __pyx_vtabptr_5_soya__Sound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 151; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_Sound", (PyObject *)&__pyx_type_5_soya__Sound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 151; goto __pyx_L1;}
  __pyx_ptype_5_soya__Sound = &__pyx_type_5_soya__Sound;
  __pyx_vtabptr_5_soya__WAVSound = &__pyx_vtable_5_soya__WAVSound;
  __pyx_vtable_5_soya__WAVSound.__pyx_base = *__pyx_vtabptr_5_soya__Sound;
  __pyx_vtable_5_soya__WAVSound.__pyx_base._getbuffer = (void *)__pyx_f_5_soya_9_WAVSound__getbuffer;
  __pyx_vtable_5_soya__WAVSound._getnextdata = (void *)__pyx_f_5_soya_9_WAVSound__getnextdata;
  __pyx_type_5_soya__WAVSound.tp_base = __pyx_ptype_5_soya__Sound;
  if (PyType_Ready(&__pyx_type_5_soya__WAVSound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 176; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__WAVSound.tp_dict, __pyx_vtabptr_5_soya__WAVSound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 176; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_WAVSound", (PyObject *)&__pyx_type_5_soya__WAVSound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 176; goto __pyx_L1;}
  __pyx_ptype_5_soya__WAVSound = &__pyx_type_5_soya__WAVSound;
  __pyx_vtabptr_5_soya__OGGVorbisSound = &__pyx_vtable_5_soya__OGGVorbisSound;
  __pyx_vtable_5_soya__OGGVorbisSound.__pyx_base = *__pyx_vtabptr_5_soya__Sound;
  __pyx_vtable_5_soya__OGGVorbisSound.__pyx_base._getbuffer = (void *)__pyx_f_5_soya_15_OGGVorbisSound__getbuffer;
  __pyx_vtable_5_soya__OGGVorbisSound._getdata = (void *)__pyx_f_5_soya_15_OGGVorbisSound__getdata;
  __pyx_type_5_soya__OGGVorbisSound.tp_base = __pyx_ptype_5_soya__Sound;
  if (PyType_Ready(&__pyx_type_5_soya__OGGVorbisSound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 216; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__OGGVorbisSound.tp_dict, __pyx_vtabptr_5_soya__OGGVorbisSound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 216; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_OGGVorbisSound", (PyObject *)&__pyx_type_5_soya__OGGVorbisSound) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 216; goto __pyx_L1;}
  __pyx_ptype_5_soya__OGGVorbisSound = &__pyx_type_5_soya__OGGVorbisSound;
  __pyx_vtabptr_5_soya__SoundPlayer = &__pyx_vtable_5_soya__SoundPlayer;
  __pyx_vtable_5_soya__SoundPlayer.__pyx_base = *__pyx_vtabptr_5_soya_CoordSyst;
  __pyx_vtable_5_soya__SoundPlayer.__pyx_base.__pyx_base.__pyx_base.__getcstate__ = (void *)__pyx_f_5_soya_12_SoundPlayer___getcstate__;
  __pyx_vtable_5_soya__SoundPlayer.__pyx_base.__pyx_base.__pyx_base.__setcstate__ = (void *)__pyx_f_5_soya_12_SoundPlayer___setcstate__;
  __pyx_type_5_soya__SoundPlayer.tp_base = __pyx_ptype_5_soya_CoordSyst;
  __pyx_type_5_soya__SoundPlayer.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_5_soya__SoundPlayer) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 278; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__SoundPlayer.tp_dict, __pyx_vtabptr_5_soya__SoundPlayer) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 278; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_SoundPlayer", (PyObject *)&__pyx_type_5_soya__SoundPlayer) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 278; goto __pyx_L1;}
  __pyx_ptype_5_soya__SoundPlayer = &__pyx_type_5_soya__SoundPlayer;
  __pyx_vtabptr_5_soya__TestDeform = &__pyx_vtable_5_soya__TestDeform;
  __pyx_vtable_5_soya__TestDeform.__pyx_base = *__pyx_vtabptr_5_soya__Deform;
  __pyx_vtable_5_soya__TestDeform.__pyx_base._deform_point = (void *)__pyx_f_5_soya_11_TestDeform__deform_point;
  __pyx_type_5_soya__TestDeform.tp_base = __pyx_ptype_5_soya__Deform;
  if (PyType_Ready(&__pyx_type_5_soya__TestDeform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 119; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya__TestDeform.tp_dict, __pyx_vtabptr_5_soya__TestDeform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 119; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "_TestDeform", (PyObject *)&__pyx_type_5_soya__TestDeform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 119; goto __pyx_L1;}
  __pyx_ptype_5_soya__TestDeform = &__pyx_type_5_soya__TestDeform;
  __pyx_vtabptr_5_soya_PythonDeform = &__pyx_vtable_5_soya_PythonDeform;
  __pyx_vtable_5_soya_PythonDeform.__pyx_base = *__pyx_vtabptr_5_soya__Deform;
  __pyx_vtable_5_soya_PythonDeform.__pyx_base._deform_point = (void *)__pyx_f_5_soya_12PythonDeform__deform_point;
  __pyx_type_5_soya_PythonDeform.tp_base = __pyx_ptype_5_soya__Deform;
  if (PyType_Ready(&__pyx_type_5_soya_PythonDeform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 126; goto __pyx_L1;}
  if (__Pyx_SetVtable(__pyx_type_5_soya_PythonDeform.tp_dict, __pyx_vtabptr_5_soya_PythonDeform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 126; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "PythonDeform", (PyObject *)&__pyx_type_5_soya_PythonDeform) < 0) {__pyx_filename = __pyx_f[27]; __pyx_lineno = 126; goto __pyx_L1;}
  __pyx_ptype_5_soya_PythonDeform = &__pyx_type_5_soya_PythonDeform;

  /* "/home/jiba/src/soya/base.pyx":37 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Image, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Material, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Model, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SimpleModel, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SolidModel, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_TreeModel, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_CellShadingModel, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Point, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Vector, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Camera, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Light, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Body, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_World, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Cal3dBody, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_AnimatedModel, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Portal, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_WaterCube, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Face, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Atmosphere, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_Particles, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":45 */
  __pyx_v_5_soya_LIGHT_NULL_ATTENUATION = 0.05;

  /* "/home/jiba/src/soya/base.pyx":47 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_VERSION, __pyx_k1p) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;}

  /* "/home/jiba/src/soya/base.pyx":49 */
  __pyx_1 = PyFloat_FromDouble(0.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(0.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(0.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; 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 = 49; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/base.pyx":50 */
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(1.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; 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 = 50; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/base.pyx":51 */
  __pyx_1 = PyFloat_FromDouble(1.0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(1.0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(1.0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(0.0); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; 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 = 51; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/base.pyx":54 */
  __pyx_v_5_soya_quality = __pyx_e_5_soya_QUALITY_MEDIUM;

  /* "/home/jiba/src/soya/base.pyx":59 */
  __pyx_v_5_soya_CAN_USE_TEX_BORDER = 1;

  /* "/home/jiba/src/soya/base.pyx":73 */
  (__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/base.pyx":95 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_MemoryError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_4 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_ChunkError, "_soya"); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/home/jiba/src/soya/base.pyx":96 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_ChunkError, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/init.pyx":317 */
  Py_INCREF(__pyx_k3p);
  __pyx_k4 = __pyx_k3p;
  __pyx_k5 = 640;
  __pyx_k6 = 480;
  __pyx_k7 = 0;
  __pyx_k8 = 1;
  __pyx_k9 = 1;
  __pyx_k10 = 0;
  Py_INCREF(__pyx_k11p);
  __pyx_k12 = __pyx_k11p;
  __pyx_k13 = 44100;
  __pyx_k14 = 1.0;
  __pyx_k15 = 0.01;

  /* "/home/jiba/src/soya/init.pyx":426 */
  __pyx_5 = PyInt_FromLong(4294967295); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_SDL_ALLEVENTS, __pyx_5) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 426; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/init.pyx":427 */
  __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_SDL_ALLEVENTS); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 427; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_ALL_EVENTS, __pyx_2) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 427; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/init.pyx":453 */
  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_ALL_EVENTS); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 453; goto __pyx_L1;}
  __pyx_k16 = __pyx_3;
  __pyx_3 = 0;

  /* "/home/jiba/src/soya/math3d.pyx":121 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k17 = Py_None;
  __pyx_k18 = 0.0;
  __pyx_k19 = 0.0;
  __pyx_k20 = 0.0;

  /* "/home/jiba/src/soya/math3d.pyx":308 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 308; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k21 = Py_None;

  /* "/home/jiba/src/soya/renderer.pyx":386 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_root_widget, Py_None) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 386; goto __pyx_L1;}

  /* "/home/jiba/src/soya/renderer.pyx":389 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; goto __pyx_L1;}
  __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_StandardError); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_4);
  __pyx_4 = 0;
  __pyx_2 = __Pyx_CreateClass(__pyx_5, __pyx_1, __pyx_n_GLError, "_soya"); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":390 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_GLError, __pyx_2) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 389; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/renderer.pyx":418 */
  __pyx_k23 = 1;

  /* "/home/jiba/src/soya/main_loop.pyx":20 */
  __pyx_4 = __Pyx_Import(__pyx_n_weakref, 0); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_weakref, __pyx_4) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 20; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":22 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_MAIN_LOOP, Py_None) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; goto __pyx_L1;}

  /* "/home/jiba/src/soya/main_loop.pyx":23 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_IDLER, Py_None) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;}

  /* "/home/jiba/src/soya/main_loop.pyx":24 */
  __pyx_5 = PyList_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_BEFORE_RENDER, __pyx_5) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":26 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_weakref); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_WeakKeyDictionary); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_4 = PyTuple_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; goto __pyx_L1;}
  __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_MAIN_LOOP_ITEMS, __pyx_5) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;

  /* "/home/jiba/src/soya/main_loop.pyx":97 */
  Py_INCREF(Py_None);
  __pyx_k25 = Py_None;

  /* "/home/jiba/src/soya/soya3d/atmosphere.pyx":236 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 236; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k26 = Py_None;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":57 */
  __pyx_1 = PyTuple_New(0); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 57; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_RaypickData), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 57; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_5_soya_RaypickData)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 57; 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":77 */
  __pyx_k27 = (-1.0);
  __pyx_k28 = 1;
  __pyx_k29 = 1;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 77; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k30 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 77; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k31 = Py_None;

  /* "/home/jiba/src/soya/soya3d/raypick.pyx":116 */
  __pyx_k32 = (-1.0);
  __pyx_k33 = 1;
  __pyx_k34 = 1;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 116; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k35 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 116; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k36 = Py_None;

  /* "/home/jiba/src/soya/soya3d/coordsyst.pyx":88 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 88; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k37 = Py_None;

  /* "/home/jiba/src/soya/soya3d/body.pyx":26 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k38 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k39 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k40 = Py_None;

  /* "/home/jiba/src/soya/soya3d/body.pyx":40 */
  Py_INCREF(Py_None);
  __pyx_k41 = Py_None;

  /* "/home/jiba/src/soya/soya3d/body.pyx":234 */
  __pyx_k42 = 1.0;
  __pyx_k43 = 0.2;

  /* "/home/jiba/src/soya/soya3d/body.pyx":252 */
  __pyx_k44 = 0.2;

  /* "/home/jiba/src/soya/soya3d/body.pyx":263 */
  __pyx_k45 = 0.2;
  __pyx_k46 = 0.2;

  /* "/home/jiba/src/soya/soya3d/world.pyx":40 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k47 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Model)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 40; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k48 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k49 = Py_None;

  /* "/home/jiba/src/soya/soya3d/world.pyx":162 */
  __pyx_k50 = (-1.0);
  __pyx_k51 = 1;
  __pyx_k52 = 1;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 162; 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[9]; __pyx_lineno = 162; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k54 = Py_None;

  /* "/home/jiba/src/soya/soya3d/world.pyx":213 */
  __pyx_k55 = (-1.0);
  __pyx_k56 = 1;
  __pyx_k57 = 1;

  /* "/home/jiba/src/soya/soya3d/world.pyx":381 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_RaypickContext)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 381; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k58 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k59 = Py_None;

  /* "/home/jiba/src/soya/soya3d/light.pyx":21 */
  __pyx_4 = PyList_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_DECREF(__pyx_v_5_soya_LIGHTS);
  __pyx_v_5_soya_LIGHTS = __pyx_4;
  __pyx_4 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":22 */
  __pyx_5 = PyList_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 22; goto __pyx_L1;}
  Py_DECREF(__pyx_v_5_soya_LAST_LIGHTS);
  __pyx_v_5_soya_LAST_LIGHTS = __pyx_5;
  __pyx_5 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":24 */
  __pyx_1 = __Pyx_Import(__pyx_n_weakref, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 24; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_weakref, __pyx_1) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 24; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/soya3d/light.pyx":46 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 46; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k61 = Py_None;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":38 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 38; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k62 = Py_None;

  /* "/home/jiba/src/soya/soya3d/camera.pyx":358 */
  __pyx_k63 = (-1.0);
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Point)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 358; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k64 = Py_None;

  /* "/home/jiba/src/soya/soya3d/portal.pyx":77 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 77; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k65 = Py_None;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":36 */
  Py_INCREF(Py_None);
  __pyx_k66 = Py_None;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":211 */
  __pyx_k67 = 1;
  __pyx_k68 = 0;

  /* "/home/jiba/src/soya/soya3d/traveling_camera.pyx":287 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_Position)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k69 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Vector)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 287; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k70 = Py_None;
  __pyx_k71 = 1;
  __pyx_k72 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":49 */
  Py_INCREF(Py_None);
  __pyx_k73 = Py_None;
  __pyx_k74 = 0;
  __pyx_k75 = 0;
  __pyx_k76 = 0;
  __pyx_k77 = 0;

  /* "/home/jiba/src/soya/model/image.pyx":81 */
  Py_INCREF(Py_None);
  __pyx_k78 = Py_None;
  __pyx_k79 = 0;
  __pyx_k80 = 0;
  __pyx_k81 = 0;

  /* "/home/jiba/src/soya/model/material.pyx":32 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 32; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k82 = Py_None;

  /* "/home/jiba/src/soya/model/material.pyx":378 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Image)) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 378; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k83 = Py_None;

  /* "/home/jiba/src/soya/model/face.pyx":93 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya_CoordSyst)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 93; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k84 = Py_None;
  __pyx_k85 = 0.0;
  __pyx_k86 = 0.0;
  __pyx_k87 = 0.0;
  __pyx_k88 = 0.0;
  __pyx_k89 = 0.0;
  Py_INCREF(Py_None);
  __pyx_k90 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k91 = Py_None;

  /* "/home/jiba/src/soya/model/face.pyx":176 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 176; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k92 = Py_None;
  Py_INCREF(Py_None);
  __pyx_k93 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 176; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k94 = Py_None;

  /* "/home/jiba/src/soya/model/face.pyx":243 */
  __pyx_k95 = 0.005;

  /* "/home/jiba/src/soya/model/sprite.pyx":21 */
  (__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":22 */
  (__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":24 */
  (__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":25 */
  (__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":63 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 63; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k96 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 63; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k97 = Py_None;

  /* "/home/jiba/src/soya/model/sprite.pyx":272 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k98 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k99 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[20]; __pyx_lineno = 272; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k100 = Py_None;

  /* "/home/jiba/src/soya/model/particle.pyx":139 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 139; 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 = 139; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k102 = Py_None;
  __pyx_k103 = 50;
  __pyx_k104 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":166 */
  __pyx_k105 = (-1);

  /* "/home/jiba/src/soya/model/particle.pyx":357 */
  __pyx_k106 = 0.0;
  __pyx_k107 = 0.0;
  __pyx_k108 = 0.0;

  /* "/home/jiba/src/soya/model/particle.pyx":376 */
  __pyx_k109 = 0.0;
  __pyx_k110 = 0.0;
  __pyx_k111 = 0.0;

  /* "/home/jiba/src/soya/model/particle.pyx":460 */
  __pyx_2 = __Pyx_Import(__pyx_n_random, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 460; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_random, __pyx_2) < 0) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 460; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":473 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 473; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k113 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 473; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k114 = Py_None;
  __pyx_k115 = 12;
  __pyx_k116 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":489 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 489; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k117 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 489; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k118 = Py_None;
  __pyx_k119 = 12;
  __pyx_k120 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":506 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k121 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 506; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k122 = Py_None;
  __pyx_k123 = 12;
  __pyx_k124 = 0;

  /* "/home/jiba/src/soya/model/particle.pyx":511 */
  __pyx_k125 = 0.0;
  __pyx_k126 = 0.0;
  __pyx_k127 = 0.0;

  /* "/home/jiba/src/soya/model/particle.pyx":533 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k128 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[21]; __pyx_lineno = 533; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k129 = Py_None;
  __pyx_k130 = 6;
  __pyx_k131 = 0;
  Py_INCREF(Py_None);
  __pyx_k132 = Py_None;
  __pyx_k133 = 8;

  /* "/home/jiba/src/soya/model/particle.pyx":545 */
  __pyx_k134 = (-1);

  /* "/home/jiba/src/soya/model/terrain.pyx":228 */
  __pyx_v_5_soya_terrain_drawColor = glColor4fv;

  /* "/home/jiba/src/soya/model/terrain.pyx":229 */
  __pyx_v_5_soya_terrain_disableColor = __pyx_f_5_soya_noop;

  /* "/home/jiba/src/soya/model/terrain.pyx":230 */
  __pyx_v_5_soya_terrain_enableColor = __pyx_f_5_soya_noop;

  /* "/home/jiba/src/soya/model/terrain.pyx":341 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[22]; __pyx_lineno = 341; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k135 = Py_None;
  __pyx_k136 = 0;
  __pyx_k137 = 0;
  __pyx_k138 = 1.0;

  /* "/home/jiba/src/soya/model/terrain.pyx":546 */
  __pyx_k139 = 0;
  __pyx_k140 = 0;
  __pyx_k141 = 0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":57 */
  __pyx_k142 = 0;
  __pyx_k143 = 80.0;

  /* "/home/jiba/src/soya/model/model_builder.pyx":141 */
  __pyx_k144 = 0;
  __pyx_k145 = 200.0;
  __pyx_k146 = 0.9;
  __pyx_k147 = 0;
  __pyx_k148 = 0.5;

  /* "/home/jiba/src/soya/model/model_builder.pyx":215 */
  __pyx_k149 = 0;
  __pyx_k150 = 80.0;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 215; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k151 = Py_None;
  __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_BLACK); if (!__pyx_4) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 215; goto __pyx_L1;}
  __pyx_k152 = __pyx_4;
  __pyx_4 = 0;
  __pyx_k153 = 4.0;
  __pyx_k154 = 0.3;

  /* "/home/jiba/src/soya/model/model_builder.pyx":244 */
  __pyx_5 = PyTuple_New(0); if (!__pyx_5) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 244; goto __pyx_L1;}
  __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_5_soya_SimpleModelBuilder), __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_5_soya_ModelBuilder)) {__pyx_filename = __pyx_f[23]; __pyx_lineno = 244; goto __pyx_L1;}
  Py_DECREF((PyObject *)((PyObject *)__pyx_v_5_soya__DEFAULT_MODEL_BUILDER));
  __pyx_v_5_soya__DEFAULT_MODEL_BUILDER = __pyx_1;
  __pyx_1 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":20 */
  __pyx_2 = __Pyx_Import(__pyx_k155p, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 20; goto __pyx_L1;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_os, __pyx_2) < 0) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 20; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":25 */
  __pyx_v_5_soya_cal3d_nb_vertices = 0;
  __pyx_v_5_soya_cal3d_nb_faces = 0;

  /* "/home/jiba/src/soya/cal3d/model.pyx":26 */
  __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/model.pyx":274 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Material)) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 274; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k156 = Py_None;
  __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_BLACK); if (!__pyx_5) {__pyx_filename = __pyx_f[24]; __pyx_lineno = 274; goto __pyx_L1;}
  __pyx_k157 = __pyx_5;
  __pyx_5 = 0;
  __pyx_k158 = 4.0;
  __pyx_k159 = 0.3;

  /* "/home/jiba/src/soya/cal3d/model.pyx":1134 */
  Py_INCREF(Py_None);
  __pyx_k160 = Py_None;

  /* "/home/jiba/src/soya/text/text.pyx":26 */
  __pyx_v_5_soya_library_inited = 0;

  /* "/home/jiba/src/soya/text/text.pyx":59 */
  __pyx_k161 = 20;
  __pyx_k162 = 30;

  /* "/home/jiba/src/soya/text/text.pyx":300 */
  __pyx_k163 = 0.0;
  __pyx_k164 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":21 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 21; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_StandardError); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 21; goto __pyx_L1;}
  __pyx_6 = PyTuple_New(1); if (!__pyx_6) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 21; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_6, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = __Pyx_CreateClass(__pyx_6, __pyx_1, __pyx_n_ALError, "_soya"); if (!__pyx_2) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_DECREF(__pyx_6); __pyx_6 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":22 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_ALError, __pyx_2) < 0) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 21; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":53 */
  __pyx_v_5_soya__SOUND_INITED = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":56 */
  __pyx_v_5_soya__device = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":59 */
  __pyx_v_5_soya__context = 0;

  /* "/home/jiba/src/soya/sound/sound.pyx":291 */
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__World)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k166 = Py_None;
  if (!__Pyx_TypeTest(Py_None, __pyx_ptype_5_soya__Sound)) {__pyx_filename = __pyx_f[26]; __pyx_lineno = 291; goto __pyx_L1;}
  Py_INCREF(Py_None);
  __pyx_k167 = Py_None;
  __pyx_k168 = 0;
  __pyx_k169 = 1;
  __pyx_k170 = 1.0;
  __pyx_k171 = 1;

  /* "/home/jiba/src/soya/model/deform.pyx":130 */
  return;
  __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");
}

static char *__pyx_filenames[] = {
  "base.pyx",
  "init.pyx",
  "math3d.pyx",
  "renderer.pyx",
  "main_loop.pyx",
  "atmosphere.pyx",
  "raypick.pyx",
  "coordsyst.pyx",
  "body.pyx",
  "world.pyx",
  "light.pyx",
  "camera.pyx",
  "portal.pyx",
  "traveling_camera.pyx",
  "image.pyx",
  "material.pyx",
  "face.pyx",
  "model.pyx",
  "cellshading.pyx",
  "tree.pyx",
  "sprite.pyx",
  "particle.pyx",
  "terrain.pyx",
  "model_builder.pyx",
  "model.pyx",
  "text.pyx",
  "sound.pyx",
  "deform.pyx",
  "_soya.pyx",
  "solid_model.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 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 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_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 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 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_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);
}
