Added new Johan Code
This commit is contained in:
+13
@@ -8,6 +8,8 @@
|
||||
Entity::Entity()
|
||||
{
|
||||
model = NULL;
|
||||
scale = 1;
|
||||
canCollide = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,3 +36,14 @@ void Entity::draw()
|
||||
|
||||
}
|
||||
|
||||
bool Entity::inObject(const Vec3f & point)
|
||||
{
|
||||
if (!model)
|
||||
return false;
|
||||
Vec3f center = position + model->center;
|
||||
float distance = sqrt((point.x - center.x) * (point.x - center.x) + (point.z - center.z)*(point.z - center.z));
|
||||
if (distance < model->radius*scale)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user