Ejemplo n.º 1
0
void CClipVolumeProxy::UpdateRenderMesh(IRenderMesh* pRenderMesh, const DynArray<Vec3>& meshFaces)
{
	m_pRenderMesh = pRenderMesh;
	gEnv->pEntitySystem->ReleaseBSPTree3D(m_pBspTree);

	const size_t nFaceCount = meshFaces.size() / 3;
	if(nFaceCount > 0)
	{
		IBSPTree3D::FaceList faceList;
		faceList.reserve(nFaceCount);

		for(int i=0; i<meshFaces.size(); i+=3)
		{
			IBSPTree3D::CFace face;
			face.push_back(meshFaces[i + 0]);
			face.push_back(meshFaces[i + 1]);
			face.push_back(meshFaces[i + 2]);

			faceList.push_back(face);
		}

		m_pBspTree = gEnv->pEntitySystem->CreateBSPTree3D(faceList);
	}


	if(m_pEntity && m_pClipVolume)
		gEnv->p3DEngine->UpdateClipVolume(m_pClipVolume, m_pRenderMesh, m_pBspTree, m_pEntity->GetWorldTM(), !m_pEntity->IsHidden(), m_pEntity->GetName());
}
Ejemplo n.º 2
0
void CEditorGame::InitLevelTypesEnums(IGameToEditorInterface* pGTE)
{
	DynArray<string>* levelTypes;
	levelTypes = g_pGame->GetIGameFramework()->GetILevelSystem()->GetLevelTypeList();
	
	const char** allLevelTypes = new const char*[levelTypes->size()];
	for (int i = 0; i < levelTypes->size(); i++)
	{
		PREFAST_ASSUME(i > 0 && i < levelTypes->size());
		allLevelTypes[i] = (*levelTypes)[i];
	}

	pGTE->SetUIEnums("level_types", allLevelTypes, levelTypes->size());
	delete[] allLevelTypes;
}
Ejemplo n.º 3
0
  // ---------------------------------------------------------------- //
  bool CommandInterpreter::parse( CommandProcessor& cp, const char* command )
  {
    if (!command)
      return false;
    if(command[0] == '#') //Comment
      return true;
    
    // Split the command into full command name and parameter list
    DynArray<string> split;
    { FOREACH_TOKEN( token, command, "()" ) split.add( token ); }
    if( split.size() < 1 || split.size() > 2 ) return false;

    const char* strFullCommandName = "EMPTY";
    const char* strParams          = "EMPTY";
    if(split.size() >= 1) {
      strFullCommandName = split[0].c_str();
      if(split.size() == 2)
        strParams = split[1].c_str();
    }

    // Request the command
    CommandRef commandRef = cp.requestCommand( strFullCommandName );
    if( commandRef && commandRef->object )
    {
      CommandParameters* cmdParams;
      parseParams( cp, commandRef, strParams, cmdParams );

      // Call the command
      commandRef->action->call( commandRef->object, *cmdParams );

      delete cmdParams;
      return true;
    }

    parseErrors.add("Command not found.");
    return false;
  }
Ejemplo n.º 4
0
    // guarda permutación perm de tamaño sz, del conjunto charset, en array
void save_perm(DynArray<string> & array, const string & perm, 
	       char * charset, const size_t & sz)
{
  const size_t array_size = array.size();

  if (array_size > 0)
    {
      int i = binary_search(array, perm); // verifica si la
					  // permutación no ha sido
					  // generada previamente

      if (array.access(i) == perm)
	return; // la permutación ya fue generada (hay símbolos repetidos)
    }

  if (is_a_permutation(perm, charset, sz))
    array[array_size] = perm;
}
Ejemplo n.º 5
0
  // ---------------------------------------------------------------- //
  bool CommandInterpreter::parseParams( CommandProcessor&            cp
                                      , CommandCached const * const  cmd
                                      , const char*                  strParams
                                      , CommandParameters*&          out )
  {
    // Now split the parameter list
    DynArray<const char*> params;
    { FOREACH_TOKEN( token, strParams, "," ) params.add( token ); }

    // Make sure the parameter list is the expected size
    if( params.size() < cmd->input.size() )
    {
      parseErrors.add("Not enough parameters.");
      return false;
    }

    // Loop through the signature and pack all of the parameters into the command parameters class
    out = new CommandParameters( cmd->getSignatureSize( cp, params ) );
    int offset = 0;
    for( int i=0; i<cmd->input.size(); ++i )
      parseAndPack( cp, cmd->input[i], params[i], *out, offset );

    return true;
  }
Ejemplo n.º 6
0
double take_time(DynArray<T> & a, Now & timer)
{
	timer.start();
	insertion_sort(a,0,a.size());
	return timer.elapsed();
}
Ejemplo n.º 7
0
 * ---------------------------------------------------------------------
 */

#include <KarenCore/array.h>
#include <KarenCore/parsing.h>
#include <KarenCore/test.h>

using namespace karen;

KAREN_BEGIN_UNIT_TEST(ArrayTestSuite);
   
   KAREN_DECL_TEST(shouldCreateEmptyArray,
   {
      DynArray<int> a;
      assertTrue(a.isEmpty());
      assertEquals<int>(0, a.size());
   });
   
   KAREN_DECL_TEST(shouldNotIndexWhenEmpty,
   {
      DynArray<int> a;
      try
      {
         a[0];
         assertionFailed("expected exception not raised");
      }
      catch (OutOfBoundsException&) {}
   });
   
   KAREN_DECL_TEST(shouldCreateFromRawArray,
   {
Ejemplo n.º 8
0
#include "sfz/PopWarnings.hpp"

#include "sfz/containers/DynArray.hpp"
#include "sfz/math/Vector.hpp"
#include "sfz/memory/DebugAllocator.hpp"
#include "sfz/memory/New.hpp"
#include "sfz/memory/SmartPointers.hpp"

using namespace sfz;

TEST_CASE("Default constructor", "[sfz::DynArray]")
{
	sfz::setContext(sfz::getStandardContext());

	DynArray<float> floatArray;
	REQUIRE(floatArray.size() == 0);
	REQUIRE(floatArray.capacity() == 0);
	REQUIRE(floatArray.data() == nullptr);
}

TEST_CASE("Fill constructor", "[sfz::DynArray]")
{
	sfz::setContext(sfz::getStandardContext());

	DynArray<UniquePtr<int>> nullptrs;
	nullptrs.addMany(8);
	for (uint32_t i = 0; i < 8; ++i) {
		REQUIRE(nullptrs.data()[i] == nullptr);
	}
	REQUIRE(nullptrs.size() == 8);
	REQUIRE(nullptrs.capacity() == 8);