Tachyon (current)  Current Main Branch
Macros | Functions | Variables
grid.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stddef.h>
#include "tachyon.h"
#include "macros.h"
#include "vector.h"
#include "intersect.h"
#include "util.h"
#include "ui.h"
#include "parallel.h"
#include "grid.h"

Go to the source code of this file.

Macros

#define TACHYON_INTERNAL   1
 
#define GRID_PRIVATE
 
#define cbrt(x)
 

Functions

object * newgrid (scenedef *scene, int xsize, int ysize, int zsize, vector min, vector max)
 
static int grid_bbox (void *obj, vector *min, vector *max)
 
static void grid_free (void *v)
 
static void globalbound (object **rootlist, vector *gmin, vector *gmax)
 
static ptrdiff_t cellbound (const grid *g, const gridindex *index, vector *cmin, vector *cmax)
 
static int countobj (object *root)
 
static void gridstats (int xs, int ys, int zs, int numobj)
 
int engrid_scene (scenedef *scene, int boundthresh)
 
static ptrdiff_t engrid_objlist (grid *g, object **list)
 
static int engrid_cell (scenedef *scene, int boundthresh, grid *gold, gridindex *index)
 
static int engrid_objectlist (grid *g, objectlist **list)
 
static int engrid_object (grid *g, object *obj, int addtolist)
 
static int pos2grid (grid *g, vector *pos, gridindex *index)
 
static void grid_intersect (const grid *g, ray *ry)
 
static int grid_bounds_intersect (const grid *g, const ray *ry, flt *hitnear, flt *hitfar)
 

Variables

static object_methods grid_methods
 

Macro Definition Documentation

◆ cbrt

#define cbrt (   x)
Value:
((x) > 0.0 ? pow((double)(x), 1.0/3.0) : \
((x) < 0.0 ? -pow((double)-(x), 1.0/3.0) : 0.0))

Definition at line 30 of file grid.c.

Referenced by engrid_cell(), and engrid_scene().

◆ GRID_PRIVATE

#define GRID_PRIVATE

Definition at line 26 of file grid.c.

◆ TACHYON_INTERNAL

#define TACHYON_INTERNAL   1

Definition at line 17 of file grid.c.

Function Documentation

◆ cellbound()

static ptrdiff_t cellbound ( const grid *  g,
const gridindex *  index,
vector *  cmin,
vector *  cmax 
)
static

Definition at line 137 of file grid.c.

References MYMAX, and MYMIN.

Referenced by engrid_cell().

◆ countobj()

static int countobj ( object *  root)
static

Definition at line 202 of file grid.c.

Referenced by engrid_scene().

◆ engrid_cell()

static int engrid_cell ( scenedef *  scene,
int  boundthresh,
grid *  gold,
gridindex *  index 
)
static

Definition at line 315 of file grid.c.

References cbrt, cellbound(), engrid_objectlist(), gridstats(), MYMAX, newgrid(), and VSub().

Referenced by engrid_scene().

◆ engrid_object()

static int engrid_object ( grid *  g,
object *  obj,
int  addtolist 
)
static

Definition at line 396 of file grid.c.

References pos2grid().

Referenced by engrid_objectlist(), and engrid_objlist().

◆ engrid_objectlist()

static int engrid_objectlist ( grid *  g,
objectlist **  list 
)
static

Definition at line 368 of file grid.c.

References engrid_object().

Referenced by engrid_cell().

◆ engrid_objlist()

static ptrdiff_t engrid_objlist ( grid *  g,
object **  list 
)
static

Definition at line 288 of file grid.c.

References engrid_object().

Referenced by engrid_scene().

◆ engrid_scene()

int engrid_scene ( scenedef *  scene,
int  boundthresh 
)

Definition at line 224 of file grid.c.

References cbrt, countobj(), engrid_cell(), engrid_objlist(), globalbound(), gridstats(), MSG_0, newgrid(), and rt_ui_message().

Referenced by rendercheck().

◆ globalbound()

static void globalbound ( object **  rootlist,
vector *  gmin,
vector *  gmax 
)
static

Definition at line 107 of file grid.c.

References MYMAX, and MYMIN.

Referenced by engrid_scene().

◆ grid_bbox()

static int grid_bbox ( void *  obj,
vector *  min,
vector *  max 
)
static

Definition at line 71 of file grid.c.

◆ grid_bounds_intersect()

static int grid_bounds_intersect ( const grid *  g,
const ray *  ry,
flt hitnear,
flt hitfar 
)
static

Definition at line 638 of file grid.c.

Referenced by grid_intersect().

◆ grid_free()

static void grid_free ( void *  v)
static

Definition at line 80 of file grid.c.

References free_objects().

◆ grid_intersect()

static void grid_intersect ( const grid *  g,
ray *  ry 
)
static

Definition at line 479 of file grid.c.

References grid_bounds_intersect().

◆ gridstats()

static void gridstats ( int  xs,
int  ys,
int  zs,
int  numobj 
)
static

Definition at line 216 of file grid.c.

References MSG_0, and rt_ui_message().

Referenced by engrid_cell(), and engrid_scene().

◆ newgrid()

object* newgrid ( scenedef *  scene,
int  xsize,
int  ysize,
int  zsize,
vector  min,
vector  max 
)

Definition at line 41 of file grid.c.

References grid_methods, new_objectid(), and VSub().

Referenced by engrid_cell(), and engrid_scene().

◆ pos2grid()

static int pos2grid ( grid *  g,
vector *  pos,
gridindex *  index 
)
static

Definition at line 452 of file grid.c.

Referenced by engrid_object().

Variable Documentation

◆ grid_methods

object_methods grid_methods
static
Initial value:
= {
(void (*)(const void *, void *))(grid_intersect),
(void (*)(const void *, const void *, const void *, void *))(NULL),
}
static void grid_free(void *v)
Definition: grid.c:80
static void grid_intersect(const grid *g, ray *ry)
Definition: grid.c:479
static int grid_bbox(void *obj, vector *min, vector *max)
Definition: grid.c:71

Definition at line 34 of file grid.c.

Referenced by newgrid().