Пример #1
0
void ETHBucketManager::GetIntersectingEntities(const Vector2 &point, ETHEntityArray &outVector, const bool screenSpace, const ETHSceneProperties& props)
{
    ETHEntityArray temp;
    const Vector2 v2Bucket(ETHBucketManager::GetBucket(point, GetBucketSize()));
    GetEntitiesAroundBucket(v2Bucket, temp);

    for (unsigned int t=0; t<temp.size(); t++)
    {
        ETHEntityProperties::VIEW_RECT rect = temp[t]->GetScreenRect(props);

        if (!screenSpace)
        {
            const Vector2 cameraPos = m_provider->GetVideo()->GetCameraPos();
            rect.max += cameraPos;
            rect.min += cameraPos;
        }

        if (point.x < rect.min.x)
            continue;
        if (point.y < rect.min.y)
            continue;
        if (point.x > rect.max.x)
            continue;
        if (point.y > rect.max.y)
            continue;
        outVector.push_back(temp[t]);
    }
}
Пример #2
0
void ETHScene::ClearLightmaps()
{
	ETHEntityArray entities;
	m_buckets.GetEntityArray(entities);
	for (unsigned int t = 0; t < entities.size(); t++)
	{
		entities[t]->ReleaseLightmap();
	}
}
Пример #3
0
void ETHScene::RecoverResources()
{
	ETHEntityArray entities;
	m_buckets.GetEntityArray(entities);
	for (std::size_t t = 0; t < entities.size(); t++)
	{
		entities[t]->RecoverResources();
	}
}
Пример #4
0
void ETHPhysicsSimulator::ResolveJoints(ETHEntityArray& entities)
{
	const unsigned int numEntities = entities.size();
	for (unsigned int t = 0; t < numEntities; t++)
	{
		ETHPhysicsEntityControllerPtr controller = boost::dynamic_pointer_cast<ETHPhysicsEntityController>(entities[t]->GetController());
		if (controller)
		{
			controller->ResolveJoints(entities, *entities[t]->GetProperties(), *this);
		}
	}
}
bool ETHPhysicsEntityController::ResolveJoints(ETHEntityArray& entities, const ETHEntityProperties& properties, ETHPhysicsSimulator& simulator)
{
	if (properties.enmlJointDefinitions == GS_L(""))
		return false;

	const std::size_t numEntities = entities.size();
	const enml::File file(properties.enmlJointDefinitions);
	std::list<str_type::string> jointNames;
	file.GetEntityNameList(jointNames);
	for (std::list<str_type::string>::const_iterator iter = jointNames.begin(); iter != jointNames.end(); ++iter)
	{
		const str_type::string& jointName = *iter;

		// get the other entity name from the joint definition
		str_type::string otherEntityName = ETHJoint::GetOtherEntityName(jointName, file);
		int otherEntityID = -1;

		// if the other entity name is not declared in the joint definition, look for it into the custom data
		if (otherEntityName == GS_L(""))
		{
			if (properties.Check(jointName) == ETHCustomData::DT_STRING)
			{
				properties.GetString(jointName, otherEntityName);
			}
			else if (properties.Check(jointName) == ETHCustomData::DT_INT)
			{
				properties.GetInt(jointName, otherEntityID);
			}
			else
			{
				continue;
			}
		}

		// iterate over entities to find the other-entity
		for (std::size_t t = 0; t < numEntities; t++)
		{
			const unsigned int idx = static_cast<unsigned int>(t);
			if (entities[idx]->GetEntityName() == otherEntityName || entities[idx]->GetID() == otherEntityID)
			{
				boost::shared_ptr<ETHJoint> joint =
					ETHJoint::CreateJoint(jointName, file, simulator, static_cast<ETHEntity*>(m_body->GetUserData()), (entities[idx]));
				if (joint)
					m_joints.push_back(joint);
				break;
			}
		}
	}
	return true;
}
Пример #6
0
void ETHScene::ScaleEntities(const float scale, const bool scalePosition)
{
	if (scale == 1.0f)
		return;

	ETHEntityArray entities;
	m_buckets.GetEntityArray(entities);
	for (unsigned int t = 0; t < entities.size(); t++)
	{
		entities[t]->Scale(scale);
		if (scalePosition)
		{
			entities[t]->SetPosition(entities[t]->GetPosition() * scale, m_buckets);
		}
	}
}