Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions

strand.c File Reference

#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_memarena.h"
#include "BLI_rand.h"
#include "BKE_DerivedMesh.h"
#include "BKE_key.h"
#include "render_types.h"
#include "initrender.h"
#include "rendercore.h"
#include "renderdatabase.h"
#include "renderpipeline.h"
#include "pixelblending.h"
#include "shading.h"
#include "strand.h"
#include "zbuf.h"

Go to the source code of this file.

Classes

struct  StrandShadeCache
struct  StrandPart
struct  StrandSortSegment

Defines

#define MAX_ZROW   2000
#define CHECK_ADD(n)
#define CHECK_ASSIGN(n)

Typedefs

typedef struct StrandPart StrandPart
typedef struct StrandSortSegment StrandSortSegment

Functions

void hoco_to_zco (ZSpan *zspan, float *zco, float *hoco)
void zspan_scanconvert_strand (ZSpan *zspan, void *handle, float *v1, float *v2, float *v3, void(*func)(void *, int, int, float, float, float))
void zbufsinglewire (ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2)
static float strand_eval_width (Material *ma, float strandco)
void strand_eval_point (StrandSegment *sseg, StrandPoint *spoint)
static void interpolate_vec1 (float *v1, float *v2, float t, float negt, float *v)
static void interpolate_vec3 (float *v1, float *v2, float t, float negt, float *v)
static void interpolate_vec4 (float *v1, float *v2, float t, float negt, float *v)
static void interpolate_shade_result (ShadeResult *shr1, ShadeResult *shr2, float t, ShadeResult *shr, int addpassflag)
static void strand_apply_shaderesult_alpha (ShadeResult *shr, float alpha)
static void strand_shade_point (Render *re, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert, StrandPoint *spoint)
StrandShadeCachestrand_shade_cache_create (void)
void strand_shade_cache_free (StrandShadeCache *cache)
static void strand_shade_get (Render *re, StrandShadeCache *cache, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert)
void strand_shade_segment (Render *re, StrandShadeCache *cache, StrandSegment *sseg, ShadeSample *ssamp, float t, float s, int addpassflag)
void strand_shade_unref (StrandShadeCache *cache, StrandVert *svert)
static void strand_shade_refcount (StrandShadeCache *cache, StrandVert *svert)
static int compare_strand_segment (const void *poin1, const void *poin2)
static void do_strand_point_project (float winmat[][4], ZSpan *zspan, float *co, float *hoco, float *zco)
static void strand_project_point (float winmat[][4], float winx, float winy, StrandPoint *spoint)
static APixstrandaddpsmainAstrand (ListBase *lb)
static APixstrandaddpsAstrand (ZSpan *zspan)
static void do_strand_fillac (void *handle, int x, int y, float u, float v, float z)
static int strand_test_clip (float winmat[][4], ZSpan *UNUSED(zspan), float *bounds, float *co, float *zcomp, float widthx, float widthy)
static void do_scanconvert_strand (Render *UNUSED(re), StrandPart *spart, ZSpan *zspan, float t, float dt, float *co1, float *co2, float *co3, float *co4, int sample)
static void strand_render (Render *re, StrandSegment *sseg, float winmat[][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandPoint *p1, StrandPoint *p2)
static int strand_segment_recursive (Render *re, float winmat[][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandSegment *sseg, StrandPoint *p1, StrandPoint *p2, int depth)
void render_strand_segment (Render *re, float winmat[][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandSegment *sseg)
int zbuffer_strands_abuf (Render *re, RenderPart *pa, APixstrand *apixbuf, ListBase *apsmbase, unsigned int lay, int UNUSED(negzmask), float winmat[][4], int winx, int winy, int UNUSED(sample), float(*jit)[2], float clipcrop, int shadow, StrandShadeCache *cache)
StrandSurfacecache_strand_surface (Render *re, ObjectRen *obr, DerivedMesh *dm, float mat[][4], int timeoffset)
void free_strand_surface (Render *re)
void strand_minmax (StrandRen *strand, float *min, float *max, float width)

Detailed Description

Definition in file strand.c.


Define Documentation

#define CHECK_ADD (   n)
Value:
if(apn->p[n]==strnr && apn->obi[n]==obi && apn->seg[n]==seg) \
    { if(!(apn->mask[n] & mask)) { apn->mask[n] |= mask; apn->v[n] += t; apn->u[n] += s; } break; }

Referenced by do_strand_fillac().

#define CHECK_ASSIGN (   n)
Value:
if(apn->p[n]==0) \
    {apn->obi[n]= obi; apn->p[n]= strnr; apn->z[n]= zverg; apn->mask[n]= mask; apn->v[n]= t; apn->u[n]= s; apn->seg[n]= seg; break; }

Referenced by do_strand_fillac().

#define MAX_ZROW   2000

Definition at line 507 of file strand.c.

Referenced by do_strand_fillac().


Typedef Documentation

typedef struct StrandPart StrandPart

Function Documentation

static APixstrand* addpsAstrand ( ZSpan zspan) [static]

Definition at line 493 of file strand.c.

References addpsmainAstrand(), ZSpan::apsmbase, ZSpan::apstrandmcounter, and ZSpan::curpstrand.

Referenced by do_strand_fillac().

static APixstrand* addpsmainAstrand ( ListBase lb) [static]

Definition at line 482 of file strand.c.

References BLI_addtail(), MEM_callocN(), MEM_mallocN(), and APixstrMain::ps.

Referenced by addpsAstrand().

StrandSurface* cache_strand_surface ( Render re,
ObjectRen obr,
DerivedMesh dm,
float  mat[][4],
int  timeoffset 
) [read]
static int compare_strand_segment ( const void *  poin1,
const void *  poin2 
) [static]

Definition at line 452 of file strand.c.

References StrandSortSegment::z.

Referenced by zbuffer_strands_abuf().

static void do_scanconvert_strand ( Render UNUSEDre,
StrandPart spart,
ZSpan zspan,
float  t,
float  dt,
float *  co1,
float *  co2,
float *  co3,
float *  co4,
int  sample 
) [static]
static void do_strand_fillac ( void *  handle,
int  x,
int  y,
float  u,
float  v,
float  z 
) [static]
static void do_strand_point_project ( float  winmat[][4],
ZSpan zspan,
float *  co,
float *  hoco,
float *  zco 
) [static]

Definition at line 465 of file strand.c.

References hoco_to_zco(), and projectvert().

Referenced by render_strand_segment(), and strand_segment_recursive().

void free_strand_surface ( Render re)
void hoco_to_zco ( ZSpan zspan,
float *  zco,
float *  hoco 
)
static void interpolate_shade_result ( ShadeResult shr1,
ShadeResult shr2,
float  t,
ShadeResult shr,
int  addpassflag 
) [static]
static void interpolate_vec1 ( float *  v1,
float *  v2,
float  t,
float  negt,
float *  v 
) [static]

Definition at line 188 of file strand.c.

Referenced by interpolate_shade_result().

static void interpolate_vec3 ( float *  v1,
float *  v2,
float  t,
float  negt,
float *  v 
) [static]

Definition at line 193 of file strand.c.

Referenced by interpolate_shade_result().

static void interpolate_vec4 ( float *  v1,
float *  v2,
float  t,
float  negt,
float *  v 
) [static]

Definition at line 200 of file strand.c.

Referenced by interpolate_shade_result().

void render_strand_segment ( Render re,
float  winmat[][4],
StrandPart spart,
ZSpan zspan,
int  totzspan,
StrandSegment sseg 
)
static void strand_apply_shaderesult_alpha ( ShadeResult shr,
float  alpha 
) [static]

Definition at line 250 of file strand.c.

References ShadeResult::alpha, ShadeResult::col, and ShadeResult::combined.

Referenced by strand_shade_point(), and strand_shade_segment().

void strand_eval_point ( StrandSegment sseg,
StrandPoint spoint 
)
static float strand_eval_width ( Material ma,
float  strandco 
) [static]

Definition at line 71 of file strand.c.

References pow(), Material::strand_ease, Material::strand_end, and Material::strand_sta.

Referenced by strand_eval_point().

void strand_minmax ( StrandRen strand,
float *  min,
float *  max,
float  width 
)

Definition at line 1039 of file strand.c.

References StrandVert::co, copy_v3_v3(), DO_MINMAX, and StrandRen::vert.

Referenced by finalize_render_object().

static void strand_project_point ( float  winmat[][4],
float  winx,
float  winy,
StrandPoint spoint 
) [static]
static void strand_render ( Render re,
StrandSegment sseg,
float  winmat[][4],
StrandPart spart,
ZSpan zspan,
int  totzspan,
StrandPoint p1,
StrandPoint p2 
) [static]
static int strand_segment_recursive ( Render re,
float  winmat[][4],
StrandPart spart,
ZSpan zspan,
int  totzspan,
StrandSegment sseg,
StrandPoint p1,
StrandPoint p2,
int  depth 
) [static]
StrandShadeCache* strand_shade_cache_create ( void  ) [read]
void strand_shade_cache_free ( StrandShadeCache cache)
static void strand_shade_get ( Render re,
StrandShadeCache cache,
ShadeSample ssamp,
StrandSegment sseg,
StrandVert svert 
) [static]
static void strand_shade_point ( Render re,
ShadeSample ssamp,
StrandSegment sseg,
StrandVert svert,
StrandPoint spoint 
) [static]
static void strand_shade_refcount ( StrandShadeCache cache,
StrandVert svert 
) [static]
void strand_shade_segment ( Render re,
StrandShadeCache cache,
StrandSegment sseg,
ShadeSample ssamp,
float  t,
float  s,
int  addpassflag 
)
void strand_shade_unref ( StrandShadeCache cache,
StrandVert svert 
)
static int strand_test_clip ( float  winmat[][4],
ZSpan UNUSEDzspan,
float *  bounds,
float *  co,
float *  zcomp,
float  widthx,
float  widthy 
) [static]

Definition at line 592 of file strand.c.

References projectvert(), and testclip().

Referenced by zbuffer_strands_abuf().

int zbuffer_strands_abuf ( Render re,
RenderPart pa,
APixstrand apixbuf,
ListBase apsmbase,
unsigned int  lay,
int   UNUSEDnegzmask,
float  winmat[][4],
int  winx,
int  winy,
int   UNUSEDsample,
float(*)  jit[2],
float  clipcrop,
int  shadow,
StrandShadeCache cache 
)

Definition at line 776 of file strand.c.

References StrandBuffer::adaptcos, StrandPart::apixbuf, ZSpan::apsmbase, BLI_memarena_alloc(), BLI_memarena_free(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, StrandBuffer::bound, StrandBound::boundbox, ObjectRen::boundbox, bounds(), StrandRen::buffer, StrandSegment::buffer, StrandPart::cache, clip_render_object(), co, StrandVert::co, compare_strand_segment(), copy_m4_m4(), RenderPart::disprect, ListBase::first, ObjectInstanceRen::flag, i, StrandRen::index, Render::instancetable, jit, StrandPart::jit, StrandBuffer::lay, StrandBuffer::ma, MA_ONLYCAST, MA_SHADBUF, ObjectInstanceRen::mat, StrandBuffer::maxwidth, MEM_callocN(), MEM_freeN(), MEM_mallocN(), Material::mode, mult_m4_m4m4(), StrandSortSegment::next, ObjectInstanceRen::next, NULL, StrandSegment::obi, StrandSortSegment::obi, Render::objectinstance, ObjectInstanceRen::obr, R_TRANSFORMED, StrandPart::re, RE_findOrAddStrand(), RenderPart::rectdaps, StrandPart::rectdaps, RenderPart::rectmask, StrandPart::rectmask, RenderPart::rectx, StrandPart::rectx, RenderPart::recty, StrandPart::recty, RenderPart::rectz, StrandPart::rectz, render_strand_segment(), StrandPart::segment, StrandSegment::shaded, StrandPart::shadow, StrandSegment::sqadaptcos, StrandBound::start, StrandSegment::strand, StrandSortSegment::strand, strand_test_clip(), ObjectRen::strandbuf, Render::tbh, Render::test_break, StrandPart::totapixbuf, StrandBuffer::totbound, Render::totstrand, StrandRen::totvert, StrandSegment::v, StrandRen::vert, rcti::xmax, rcti::xmin, rcti::ymax, rcti::ymin, StrandSortSegment::z, zbuf_alloc_span(), zbuf_free_span(), ZSpan::zmulx, ZSpan::zmuly, ZSpan::zofsx, ZSpan::zofsy, and StrandPart::zspan.

void zbufsinglewire ( ZSpan zspan,
int  obi,
int  zvlnr,
float *  ho1,
float *  ho2 
)

Referenced by strand_render().

void zspan_scanconvert_strand ( ZSpan zspan,
void *  handle,
float *  v1,
float *  v2,
float *  v3,
void(*)(void *, int, int, float, float, float)  func 
)