Skip to content

Commit

Permalink
UPDATE to last commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederico authored and Frederico committed Oct 30, 2009
1 parent f2b9157 commit 24749e5
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/world/chunk.cc
Expand Up @@ -334,7 +334,7 @@ void chunk::objects_in_bbox (const vector3<s_int32> & min, const vector3<s_int32
std::list<chunk_info>::const_iterator i;
for (i = Objects.begin (); i != Objects.end(); i++)
{
if (type & i->get_object()->type() && in_bbox (min, max, i->real_min(), i->real_max()))
if (type & i->get_object()->type() && in_bbox (min, max, i->solid_min(), i->solid_max()))
{
result.push_back ((chunk_info*) &(*i));
}
Expand Down
35 changes: 35 additions & 0 deletions src/world/chunk_info.h
Expand Up @@ -53,6 +53,7 @@ namespace world
chunk_info (entity *e, const vector3<s_int32> & min, const vector3<s_int32> & max)
: Min (min), Max (max), Entity (e)
{
calc_solid_max();
}

/**
Expand All @@ -62,6 +63,7 @@ namespace world
chunk_info (const chunk_info & ci)
: Min (ci.Min), Max (ci.Max), Entity (ci.Entity), Shadow (ci.Shadow)
{
calc_solid_max();
}

/**
Expand Down Expand Up @@ -108,6 +110,26 @@ namespace world
return Max + vector3<s_int32>(object->min_x(), object->min_y(), object->min_z());
}

/**
* Return "real" position, taking only solid placeable shape offset into account.
* @return lower coordinate of bounding box
*/
vector3<s_int32> solid_min () const
{
const placeable *object = Entity->get_object();
return Min + vector3<s_int32>(object->solid_min_x(), object->solid_min_y(), object->solid_min_z());
}

/**
* Return "real" position, taking only solid placeable shape offset into account.
* @return upper coordinate of bounding box
*/
vector3<s_int32> solid_max () const
{
const placeable *object = Entity->get_object();
return SolidMax + vector3<s_int32>(object->solid_min_x(), object->solid_min_y(), object->solid_min_z());
}

/**
* @name Object shadow
*
Expand Down Expand Up @@ -164,10 +186,23 @@ namespace world
#endif

private:
/**
* Calculate constant SolidMax
*/
void calc_solid_max()
{
const placeable *object = Entity->get_object();
SolidMax = vector3<s_int32>(Min.x() + object->solid_max_length(),
Min.y() + object->solid_max_width(),
Min.z() + object->solid_max_height());
}

/// pointer to map object
entity * Entity;
/// shadow cast on this object
std::vector<shadow_info> Shadow;
/// extend of the solid portion of the object
vector3<s_int32> SolidMax;
};
}

Expand Down
60 changes: 30 additions & 30 deletions src/world/placeable.h
Expand Up @@ -149,84 +149,84 @@ namespace world
* Get maximum placeable length.
* @return max extension of placeable in x direction.
*/
u_int16 max_length () const { return SolidMaxSize.x(); }
u_int16 max_length () const { return EntireMaxSize.x(); }
/**
* Get maximum placeable width.
* @return max extension of placeable in y direction.
*/
u_int16 max_width () const { return SolidMaxSize.y(); }
u_int16 max_width () const { return EntireMaxSize.y(); }
/**
* Get maximum placeable height.
* @return max extension of placeable in z direction.
*/
u_int16 max_height () const { return SolidMaxSize.z(); }
u_int16 max_height () const { return EntireMaxSize.z(); }

s_int16 min_x () const { return SolidMinPos.x(); }
s_int16 min_y () const { return SolidMinPos.y(); }
s_int16 min_z () const { return SolidMinPos.z(); }
s_int16 min_x () const { return EntireMinPos.x(); }
s_int16 min_y () const { return EntireMinPos.y(); }
s_int16 min_z () const { return EntireMinPos.z(); }

/**
* Get placeable's current length.
* @return actual extension of placeable in x direction.
*/
u_int16 length () const { return SolidCurSize.x(); }
u_int16 length () const { return EntireCurSize.x(); }
/**
* Get placeable's current width.
* @return actual extension of placeable in y direction.
*/
u_int16 width () const { return SolidCurSize.y(); }
u_int16 width () const { return EntireCurSize.y(); }
/**
* Get placeable's current height.
* @return actual extension of placeable in z direction.
*/
u_int16 height () const { return SolidCurSize.z(); }
u_int16 height () const { return EntireCurSize.z(); }
//@}

s_int16 cur_x () const { return SolidCurPos.x(); }
s_int16 cur_y () const { return SolidCurPos.y(); }
s_int16 cur_z () const { return SolidCurPos.z(); }
s_int16 cur_x () const { return EntireCurPos.x(); }
s_int16 cur_y () const { return EntireCurPos.y(); }
s_int16 cur_z () const { return EntireCurPos.z(); }


/**
* Get maximum placeable length accounting for both solid and non-solid shapes.
* Get maximum placeable length only accounting for solid shapes.
* @return max extension of placeable in x direction.
*/
u_int16 entire_max_length () const { return EntireMaxSize.x(); }
u_int16 solid_max_length () const { return SolidMaxSize.x(); }
/**
* Get maximum placeable width accounting for both solid and non-solid shapes.
* Get maximum placeable width only accounting for solid shapes.
* @return max extension of placeable in y direction.
*/
u_int16 entire_max_width () const { return EntireMaxSize.y(); }
u_int16 solid_max_width () const { return SolidMaxSize.y(); }
/**
* Get maximum placeable height accounting for both solid and non-solid shapes.
* Get maximum placeable height only accounting for solid shapes.
* @return max extension of placeable in z direction.
*/
u_int16 entire_max_height () const { return EntireMaxSize.z(); }
u_int16 solid_max_height () const { return SolidMaxSize.z(); }

s_int16 entire_min_x () const { return EntireMinPos.x(); }
s_int16 entire_min_y () const { return EntireMinPos.y(); }
s_int16 entire_min_z () const { return EntireMinPos.z(); }
s_int16 solid_min_x () const { return SolidMinPos.x(); }
s_int16 solid_min_y () const { return SolidMinPos.y(); }
s_int16 solid_min_z () const { return SolidMinPos.z(); }

/**
* Get placeable's current length accounting for both solid and non-solid shapes.
* Get placeable's current length only accounting for solid shapes
* @return actual extension of placeable in x direction.
*/
u_int16 entire_length () const { return EntireCurSize.x(); }
u_int16 solid_length () const { return SolidCurSize.x(); }
/**
* Get placeable's current width accounting for both solid and non-solid shapes.
* Get placeable's current width only accounting for solid shapes
* @return actual extension of placeable in y direction.
*/
u_int16 entire_width () const { return EntireCurSize.y(); }
u_int16 solid_width () const { return SolidCurSize.y(); }
/**
* Get placeable's current height accounting for both solid and non-solid shapes.
* Get placeable's current height only accounting for solid shapes
* @return actual extension of placeable in z direction.
*/
u_int16 entire_height () const { return EntireCurSize.z(); }
u_int16 solid_height () const { return SolidCurSize.z(); }
//@}

s_int16 entire_cur_x () const { return EntireCurPos.x(); }
s_int16 entire_cur_y () const { return EntireCurPos.y(); }
s_int16 entire_cur_z () const { return EntireCurPos.z(); }
s_int16 solid_cur_x () const { return SolidCurPos.x(); }
s_int16 solid_cur_y () const { return SolidCurPos.y(); }
s_int16 solid_cur_z () const { return SolidCurPos.z(); }

/**
* Get placeable's map
Expand Down

0 comments on commit 24749e5

Please sign in to comment.