Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-24 14:54:25 +0000
committerStijn Buys <ingar@osirion.org>2008-03-24 14:54:25 +0000
commitb4f77d62eae0b0a6781f853b0f8f85b29a088007 (patch)
tree43aa0c279c1f231a4b2a280b375af00cd554fa6b /src/render/draw.cc
parentb32c086a9b9deed4c34ade6e2447861a9c4bfc46 (diff)
support for detail brushes
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 55f173c..c3aed94 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -37,6 +37,22 @@ const float drawfxdistance = 32.0f;
math::Vector3f camera_target;
float angle = 0;
+
+/* ----- Distance test functions ----------------------------------- */
+
+inline bool test_draw_distance(core::Entity *entity)
+{
+ return (entity->model() &&
+ (math::distancesquared(camera_target, entity->location()) <= (drawdistance*drawdistance*entity->model()->radius())));
+}
+
+inline bool test_drawfx_distance(core::Entity *entity)
+{
+ return (entity->model() &&
+ (math::distancesquared(camera_target, entity->location()) <= (drawfxdistance*drawfxdistance*entity->model()->radius())));
+}
+
+
/* ----- Default Entity shapes ------------------------------------- */
void draw_sphere(math::Color const & color, float radius)
@@ -140,10 +156,13 @@ void draw_entity_axis(core::Entity *entity)
void draw_model_vertex(core::Entity *entity)
{
+ size_t count = entity->model()->vertex_structural();
+ if (test_drawfx_distance(entity))
+ count += entity->model()->vertex_detail();
+
// draw model vertices
- if (entity->model()->vertex_count()) {
+ if (count) {
size_t index = entity->model()->first_vertex();
- size_t count = entity->model()->vertex_count();
if (r_drawwireframe && r_drawwireframe->value()) {
glDrawArrays(gl::LineLoop, index, count);
@@ -157,10 +176,13 @@ void draw_model_vertex(core::Entity *entity)
void draw_model_evertex(core::Entity *entity)
{
+ size_t count = entity->model()->evertex_structural();
+ if (test_drawfx_distance(entity))
+ count += entity->model()->evertex_detail();
+
// draw model evertices
- if (entity->model()->evertex_count()) {
+ if (count) {
size_t index = entity->model()->first_evertex();
- size_t count = entity->model()->evertex_count();
render::gl::color(entity->color());
@@ -260,23 +282,6 @@ void draw_model_shield(core::EntityControlable *entity)
/* ----- Render passes --------------------------------------------- */
-
-inline bool test_draw_distance(core::Entity *entity)
-{
- if (!entity->model())
- return false;
- else
- return (math::distancesquared(camera_target, entity->location()) <= (drawdistance*drawdistance*entity->model()->radius()));
-}
-
-inline bool test_drawfx_distance(core::Entity *entity)
-{
- if (!entity->model())
- return false;
- else
- return (math::distancesquared(camera_target, entity->location()) <= (drawfxdistance*drawfxdistance*entity->model()->radius()));
-}
-
/* Draw entities without model */
void draw_pass_default()
{