BRL-CAD
Level-of-Detail Geometry Generation
Collaboration diagram for Level-of-Detail Geometry Generation:

Data Structures

struct  bg_mesh_lod_context
 

Functions

void bg_view_bounds (struct bview *v)
 Functions for generating view dependent level-of-detail data, particularly for meshes. More...
 
int bg_view_objs_select (struct bv_scene_obj ***set, struct bview *v, int x, int y)
 
int bg_view_objs_rect_select (struct bv_scene_obj ***set, struct bview *v, int x1, int y1, int x2, int y2)
 
struct bg_mesh_lod_contextbg_mesh_lod_context_create (const char *name)
 
void bg_mesh_lod_context_destroy (struct bg_mesh_lod_context *c)
 
void bg_mesh_lod_clear_cache (struct bg_mesh_lod_context *c, unsigned long long key)
 
unsigned long long bg_mesh_lod_cache (struct bg_mesh_lod_context *c, const point_t *v, size_t vcnt, const vect_t *vn, int *f, size_t fcnt, unsigned long long user_key, fastf_t fratio)
 
unsigned long long bg_mesh_lod_custom_key (void *data, size_t data_size)
 
unsigned long long bg_mesh_lod_key_get (struct bg_mesh_lod_context *c, const char *name)
 
int bg_mesh_lod_key_put (struct bg_mesh_lod_context *c, const char *name, unsigned long long key)
 
struct bv_mesh_lodbg_mesh_lod_create (struct bg_mesh_lod_context *c, unsigned long long key)
 
void bg_mesh_lod_destroy (struct bv_mesh_lod *l)
 
void bg_mesh_lod_memshrink (struct bv_scene_obj *s)
 
int bg_mesh_lod_view (struct bv_scene_obj *s, struct bview *v, int reset)
 
int bg_mesh_lod_level (struct bv_scene_obj *s, int level, int reset)
 
void bg_mesh_lod_free (struct bv_scene_obj *s)
 
void bg_mesh_lod_detail_setup_clbk (struct bv_mesh_lod *lod, int(*clbk)(struct bv_mesh_lod *, void *), void *cb_data)
 
void bg_mesh_lod_detail_clear_clbk (struct bv_mesh_lod *lod, int(*clbk)(struct bv_mesh_lod *, void *))
 
void bg_mesh_lod_detail_free_clbk (struct bv_mesh_lod *lod, int(*clbk)(struct bv_mesh_lod *, void *))
 

Detailed Description

Function Documentation

◆ bg_view_bounds()

void bg_view_bounds ( struct bview v)

Functions for generating view dependent level-of-detail data, particularly for meshes.

◆ bg_view_objs_select()

int bg_view_objs_select ( struct bv_scene_obj ***  set,
struct bview v,
int  x,
int  y 
)

◆ bg_view_objs_rect_select()

int bg_view_objs_rect_select ( struct bv_scene_obj ***  set,
struct bview v,
int  x1,
int  y1,
int  x2,
int  y2 
)

◆ bg_mesh_lod_context_create()

struct bg_mesh_lod_context * bg_mesh_lod_context_create ( const char *  name)

◆ bg_mesh_lod_context_destroy()

void bg_mesh_lod_context_destroy ( struct bg_mesh_lod_context c)

◆ bg_mesh_lod_clear_cache()

void bg_mesh_lod_clear_cache ( struct bg_mesh_lod_context c,
unsigned long long  key 
)

◆ bg_mesh_lod_cache()

unsigned long long bg_mesh_lod_cache ( struct bg_mesh_lod_context c,
const point_t v,
size_t  vcnt,
const vect_t vn,
int *  f,
size_t  fcnt,
unsigned long long  user_key,
fastf_t  fratio 
)

Given a set of points and faces, calculate a lookup key and determine if the cache has the LoD data for this particular mesh. If it does not, do the initial calculations to generate the cached LoD data needed for subsequent lookups, otherwise just return the calculated key.

This is potentially an expensive operation, particularly if the LoD data set must be generated for the mesh.

If user_key != 0, it will be used instead of the mesh data hash as the db key to be used for subsequent lookups. Typically calculated with bg_mesh_lod_custom_key from user supplied data, if the mesh data is not the desired source of the key.

Note: to clear pre-existing cached data, run bg_mesh_lod_clear_cache();

Returns
the lookup key calculated from the data

◆ bg_mesh_lod_custom_key()

unsigned long long bg_mesh_lod_custom_key ( void *  data,
size_t  data_size 
)

Given a user specified data stream, calculate a cache key from it. This is done if the users wishes to use some data other than the mesh information on which to base a look-up key (for example, mesh data being used to represent a non-mesh object.

◆ bg_mesh_lod_key_get()

unsigned long long bg_mesh_lod_key_get ( struct bg_mesh_lod_context c,
const char *  name 
)

Given a name, see if the context has a key associated with that name. If so return it, else return zero.

Users of this feature need to be aware that it is the responsibility of the application to maintain the LoD cache data and keep it current - it is quite possible, in a data sense, for the LoD data to be out of date if something has changed the named geometry object and not updated the cache.

The advantage of this feature, if the application does maintain the data correctly, is to make it possible to load a high level view of a large model without having to hash the full mesh data of the model to retrieve the data.

◆ bg_mesh_lod_key_put()

int bg_mesh_lod_key_put ( struct bg_mesh_lod_context c,
const char *  name,
unsigned long long  key 
)

Given a name and a key, instruct the context to associate that name with the key.

Returns 0 if successful, else error

◆ bg_mesh_lod_create()

struct bv_mesh_lod * bg_mesh_lod_create ( struct bg_mesh_lod_context c,
unsigned long long  key 
)

Set up the bg_mesh_lod container using cached LoD information associated with key. If no cached data has been prepared, a NULL container is returned - to prepare cached data, call bg_mesh_lod_cache with the original mesh input data. This call is intended to be usable in situations where we don't want to pull the full mesh data set into memory, so we can't assume the original data is present.

Note: bg_mesh_lod assumes a non-changing mesh - if the mesh is changed after it is created, the internal container does NOT automatically update. In that case the old struct should be destroyed and a new one created.

A bg_mesh_lod return from this function will be initialized only to the lowest level of data (i.e. the coarsest possible representation of the object.) To tailor the data, use the bg_mesh_lod_view function. For lower level control, the bg_mesh_lod_level function may be used to explicitly manipulate the loaded LoD (usually used for debugging, but also useful if an application wishes to visualize levels explicitly.)

◆ bg_mesh_lod_destroy()

void bg_mesh_lod_destroy ( struct bv_mesh_lod l)

◆ bg_mesh_lod_memshrink()

void bg_mesh_lod_memshrink ( struct bv_scene_obj s)

Given a scene object with mesh LoD data stored in s->draw_data, reduce memory footprint (for use after client codes have completed use of a particular level's info, but aren't done with the object. Main use case currently is OpenGL display lists - once generated, we can clear the internally stored LoD data until the level changes. Note that there is a re-loading performance penalty as a trade-off to the memory savings.

◆ bg_mesh_lod_view()

int bg_mesh_lod_view ( struct bv_scene_obj s,
struct bview v,
int  reset 
)

Given a scene object with mesh LoD data stored in s->draw_data and a bview, load the appropriate level of detail for displaying the mesh in that view. Set reset == 1 if the caller wants to undo a memshrink operation even if the level isn't changed by the current view settings.

Returns the level selected. If v == NULL, return current level of l. If there is an error or l == NULL, return -1;

◆ bg_mesh_lod_level()

int bg_mesh_lod_level ( struct bv_scene_obj s,
int  level,
int  reset 
)

Given a scene object with mesh LoD data stored in s->draw_data and a detail level, load the appropriate data. This is not normally used by client codes directly, but may be needed if an app needs manipulate the level of detail without a view. Set reset == 1 if the caller wants to undo a memshrink operation even if the level isn't changed by the current view settings.

Returns the level selected. If level == -1, return current level of l. If there is an error, return -1;

◆ bg_mesh_lod_free()

void bg_mesh_lod_free ( struct bv_scene_obj s)

◆ bg_mesh_lod_detail_setup_clbk()

void bg_mesh_lod_detail_setup_clbk ( struct bv_mesh_lod lod,
int(*)(struct bv_mesh_lod *, void *)  clbk,
void *  cb_data 
)

◆ bg_mesh_lod_detail_clear_clbk()

void bg_mesh_lod_detail_clear_clbk ( struct bv_mesh_lod lod,
int(*)(struct bv_mesh_lod *, void *)  clbk 
)

◆ bg_mesh_lod_detail_free_clbk()

void bg_mesh_lod_detail_free_clbk ( struct bv_mesh_lod lod,
int(*)(struct bv_mesh_lod *, void *)  clbk 
)