本文整理汇总了C++中TArray::AddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::AddItem方法的具体用法?C++ TArray::AddItem怎么用?C++ TArray::AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::AddItem方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillGameList
// Fill list of game titles made with selected engine
void UIStartupDialog::FillGameList()
{
OverrideGameCombo->RemoveAllItems();
const char* selectedEngine = OverrideEngineCombo->GetSelectionText();
TArray<const char*> gameNames;
int numEngineEntries = 0;
int i;
for (i = 0; /* empty */; i++)
{
const GameInfo &info = GListOfGames[i];
if (!info.Name) break;
const char* engine = GetEngineName(info.Enum);
if (!strcmp(engine, selectedEngine))
{
gameNames.AddItem(info.Name);
if (!strnicmp(info.Name, "Unreal engine ", 14))
numEngineEntries++;
}
}
if (gameNames.Num() > numEngineEntries + 1)
{
// sort items, keep 1st numEngineEntries items (engine name) in place
QSort(&gameNames[numEngineEntries], gameNames.Num() - numEngineEntries, CompareStrings);
}
for (i = 0; i < gameNames.Num(); i++)
OverrideGameCombo->AddItem(gameNames[i]);
// select engine item
OverrideGameCombo->SelectItem(0);
}
示例2: GetColumnNames
/**
* Returns the set of column names for this Recordset. This is useful for determining
* what you can actually ask the record set for without having to hard code those ahead of time.
*/
virtual TArray<FDatabaseColumnInfo> GetColumnNames() const
{
TArray<FDatabaseColumnInfo> Retval;
if( !ADORecordSet->BOF || !ADORecordSet->ADOEOF )
{
ADORecordSet->MoveFirst();
for( SWORD i = 0; i < ADORecordSet->Fields->Count; ++i )
{
_bstr_t bstrName = ADORecordSet->Fields->Item[i]->Name;
_variant_t varValue = ADORecordSet->Fields->Item[i]->Value;
ADODB::DataTypeEnum DataType = ADORecordSet->Fields->Item[i]->Type;
FDatabaseColumnInfo NewInfo;
NewInfo.ColumnName = FString((TCHAR*)_bstr_t(bstrName));
// from http://www.w3schools.com/ado/prop_field_type.asp#datatypeenum
switch( DataType )
{
case ADODB::adInteger:
case ADODB::adBigInt:
NewInfo.DataType = DBT_INT;
break;
case ADODB::adSingle:
case ADODB::adDouble:
NewInfo.DataType = DBT_FLOAT;
break;
case ADODB::adWChar:
case ADODB::adVarWChar:
NewInfo.DataType = DBT_STRING;
break;
default:
warnf( NAME_DevDataBase, TEXT("Unable to find a EDataBaseUE3Types (%s) from DODB::DataTypeEnum DataType: %d "), *NewInfo.ColumnName, static_cast<INT>(DataType) );
NewInfo.DataType = DBT_UNKOWN;
break;
}
Retval.AddItem( NewInfo );
}
}
// here for debugging as this code is new.
for( INT i = 0; i < Retval.Num(); ++ i )
{
warnf( TEXT( "ColumnName %d: Name: %s Type: %d"), i, *Retval(i).ColumnName, static_cast<INT>(Retval(i).DataType) );
}
return Retval;
}
示例3: AddHash
void Physics::AddHash( DActor *Actor, SBox Bound )
{
DLogWriteSystem("Func AddHash Actor = %p, Bound=(%f,%f,%f ~ %f,%f,%f)", Actor, Bound.Min.X, Bound.Min.Y, Bound.Min.Z, Bound.Max.X, Bound.Max.Y, Bound.Max.Z );
int SX = CalcGrid( Bound.Min, X ), SY = CalcGrid( Bound.Min, Y ), SZ = CalcGrid( Bound.Min, Z );
int EX = CalcGrid( Bound.Max, X ), EY = CalcGrid( Bound.Max, Y ), EZ = CalcGrid( Bound.Max, Z );
For( int X = SX; X <= EX; ++X ) For( int Y = SY; Y <= EY; ++Y ) For( int Z = SZ; Z <= EZ; ++Z )
{
// allocate memory if neccesary
if( !Available )
{
AllocatedMemory.AddItem( Available = (SHashNode*) appMalloc( ONCE_ALLOC_NUM*sizeof(SHashNode), "Collision Hash" ) );
For( int i = 0; i < ONCE_ALLOC_NUM-1; ++i )
Available[i].Next = Available + i + 1;
Available[ONCE_ALLOC_NUM-1].Next = NULL;
}
// Hash link
SHashNode *Node = Available;
Available = Available->Next;
SHashNode *&Head = GetHashNode( X, Y, Z );
Node->Next = Head;
Head = Node;
// set new node
#ifdef _DISABLE_REPMODE
Node->nX = X;
Node->nY = Y;
Node->nZ = Z;
#else
Node->Represent = CalcRepresent( X, Y, Z );
#endif
Node->Actor = Actor;
}
示例4: astr
static int
luaCallFunction(lua_State *L)
{
int numparams = lua_gettop(L);
lua_getglobal(L, "__unlua");
AActor* unlua = (AActor*) lua_topointer(L, -1);
lua_remove(L, -1);
AActor* actor = (AActor*) lua_topointer(L, lua_upvalueindex(1));
UFunction* func = (UFunction*) lua_topointer(L, lua_upvalueindex(2));
const char* funcName_s = lua_tostring(L, lua_upvalueindex(3));
if (func->NumParms == 0) {
actor->ProcessEvent(func, NULL, NULL);
return 0;
}
TFieldIterator<UProperty> It (func);
char params[1024];
memset(params, 0, sizeof(params));
char* parptr = params;
TArray<FString*> allocatedStrings;
for (int i = 0; i < func->NumParms; ++i) {
if (i >= numparams) {
if (It->PropertyFlags & CPF_OptionalParm) {
break;
} else {
lua_pushfstring(L, "Too few parameters for call to %s", funcName_s);
lua_error(L);
}
}
if (It->IsA(UIntProperty::StaticClass())) {
int anint = lua_tointeger(L, i + 1);
memcpy(parptr, &anint, It->ElementSize);
} else if (It->IsA(UStrProperty::StaticClass())) {
FString* astr = new FString(lua_tostring(L, i + 1));
allocatedStrings.AddItem(astr);
memcpy(parptr, astr, It->ElementSize);
} else if (It->IsA(UNameProperty::StaticClass())) {
FString astr(lua_tostring(L, i + 1));
FName aname(*astr, FNAME_Add);
memcpy(parptr, &aname, It->ElementSize);
} else if (It->IsA(UByteProperty::StaticClass())) {
*parptr = (char) lua_tointeger(L, i + 1);
} else if (It->IsA(UBoolProperty::StaticClass())) {
int bval = lua_toboolean(L, i + 1);
memcpy(parptr, &bval, It->ElementSize);
} else if (It->IsA(UFloatProperty::StaticClass())) {
float fval = (float)lua_tonumber(L, i + 1);
memcpy(parptr, &fval, It->ElementSize);
} else if (It->IsA(UObjectProperty::StaticClass())) {
UObjectProperty *uop = (UObjectProperty*) *It;
struct UnLuaActor* ula = (struct UnLuaActor*)
luaL_testudata(L, i + 1, "UnrealActor");
struct UnrealClass* ulc = (struct UnrealClass*)
luaL_testudata(L, i + 1, "UnrealClass");
UObject** uobj = (UObject**) parptr;
if ((ula == NULL) && (ulc == NULL))
*uobj = NULL;
else {
if (uop->PropertyClass == UClass::StaticClass()) {
if (ulc == NULL) {
lua_pushfstring(L, "Invalid type for parameter %d", i+1);
lua_error(L);
}
*uobj = ulc->uclass;
} else {
if (ula->actor->IsA(uop->PropertyClass)) {
//memcpy(parptr, ula->actor, It->ElementSize);
*uobj = ula->actor;
} else {
lua_pushfstring(L, "Invalid type for parameter %d", i+1);
lua_error(L);
}
}
}
} else {
lua_pushfstring(L, "luaCallFunction: Unreal function %s requires "
"parameter type not yet supported by UnLua", funcName_s);
lua_error(L);
}
parptr += It->ElementSize;
++It;
}
actor->ProcessEvent(func, params, NULL);
free(params);
while(allocatedStrings.Num())
delete allocatedStrings.Pop();
return 0;
}
示例5: Triangulate
bool FSwTriangulator::Triangulate( UModel* model )
{
guard(FSwTriangulator::Triangulate);
// Triangulate convex polygons
// Reset
Points.Empty();
Triangles.Empty();
// Get points
Points = model->Points;
// Get faces
FBspSurf surf;
FBspNode node;
for( TTransArray<FBspSurf>::TIterator it_surfs(model->Surfs); it_surfs; ++it_surfs )
{
surf = *it_surfs;
FVector vert_adjust = FVector(0,0,0);//model->Vectors(surf.vNormal)*1.0;
for( TArray<INT>::TIterator it_nodes(surf.Nodes); it_nodes; ++it_nodes )
{
node = model->Nodes(*it_nodes);
// skip invalid nodes
int vert_count = node.NumVertices;
if( vert_count < 3 )
continue;
int vert_offset = node.iVertPool;
unsigned int point1 = model->Verts(vert_offset).pVertex;
unsigned int point2 = model->Verts(vert_offset+1).pVertex;
unsigned int point3 = model->Verts(vert_offset+2).pVertex;
Triangles.AddItem( point1 );
Triangles.AddItem( point2 );
Triangles.AddItem( point3 );
Points( point1 ) += vert_adjust;
Points( point2 ) += vert_adjust;
Points( point3 ) += vert_adjust;
for( int j=3; j!=vert_count; ++j )
{
point2 = point3;
point3 = model->Verts(vert_offset+j).pVertex;
Triangles.AddItem( point1 );
Triangles.AddItem( point2 );
Triangles.AddItem( point3 );
Points( point3 ) += vert_adjust;
}
}
}
// Remove unused points
// init translation table
TArray<int> translation;
translation.AddZeroed( Points.Num() );
for( int i=0; i!=Points.Num(); ++i )
{
translation(i) = -1;
// calc bounding box
Box += Points(i);
}
// used points list
TArray<FVector> points_list;
INT point_old;
INT point_new;
INT point_trn;
for( TArray<INT>::TIterator it_triangle(Triangles); it_triangle; ++it_triangle )
{
point_old = *it_triangle;
point_trn = translation(point_old);
if( point_trn == -1 )
{
// unique index
point_new = points_list.Num(); // get new index
translation(point_old) = point_new; // save index translation
points_list.AddItem( Points(point_old) ); // save point at new index
*it_triangle = point_new; // update Trangles item
}
else
{
// shared index
*it_triangle = point_trn; // update Trangles item
}
}
if( Points.Num() != points_list.Num() )
{
SWF_LOG( SWF_NAME, TEXT("%s -- %s :: CULLED %d UNUSED POINTS! %d->%d"), SWF_PLOG, (Points.Num()-points_list.Num()), Points.Num(), points_list.Num() );
//.........这里部分代码省略.........
示例6: AddAcceleratorTableEntries
/**
* Adds entries to the browser's accelerator key table. Derived classes should call up to their parents.
*/
void WxBrowser::AddAcceleratorTableEntries(TArray<wxAcceleratorEntry>& Entries)
{
// Bind F5 to refresh.
Entries.AddItem( wxAcceleratorEntry(wxACCEL_NORMAL,WXK_F5,IDM_RefreshBrowser) );
}
示例7: CreateLevel
void FPxScene::CreateLevel( ULevel* level )
{
pxguard(FPxScene::CreateLevel);
PX_LOG( PX_NAME, TEXT("%s >> %s ::"), PX_LOGP );
if( !level )
{
PX_ERR( PX_NAME, TEXT("%s !! %s :: No level provided"), PX_LOGP );
return;
}
if( mLevel )
{
PX_ERR( PX_NAME, TEXT("%s !! %s :: Level already loaded"), PX_LOGP );
return;
}
mLevel = level;
// Triangulate level mesh
PX_LOG( PX_NAME, TEXT("%s .. %s :: Triangulating Level"), PX_LOGP );
FPxTriangulator tor;
tor.Triangulate(mLevel->Model);
TArray<INT>& tris = tor.Triangles;
TArray<NxVec3> verts;
for( TArray<FVector>::TIterator it_point(tor.Points); it_point; ++it_point )
{
verts.AddItem( ToNVS(*it_point) );
}
// Build physical model
NxTriangleMeshDesc levelDesc;
levelDesc.numVertices = verts.Num();
levelDesc.numTriangles = tris.Num() / 3;
levelDesc.pointStrideBytes = sizeof(NxVec3);
levelDesc.triangleStrideBytes = 3*sizeof(INT);
levelDesc.points = verts.GetData();
levelDesc.triangles = tris.GetData();
levelDesc.flags = NX_MF_FLIPNORMALS;
// Cooking
PX_LOG( PX_NAME, TEXT("%s .. %s :: Cooking Level"), PX_LOGP );
NxInitCooking();
FPxMemWriteBuffer buf;
bool status = NxCookTriangleMesh(levelDesc, buf);
NxTriangleMeshShapeDesc levelShapeDesc;
levelShapeDesc.meshData = GPxPhysics.GetSDK().createTriangleMesh(FPxMemReadBuffer(buf.data));
NxCloseCooking();
// Calc level bounding box
NxVec3 bmin, bmax;
NxComputeBounds( bmin, bmax, verts.Num(), static_cast<NxVec3*>(verts.GetData()) );
mBounds.set(bmin,bmax);
// Update scene limits
mSceneLimits.maxNbActors = 1;
mSceneLimits.maxNbBodies = 1;
mSceneLimits.maxNbStaticShapes = 1;
mSceneLimits.maxNbDynamicShapes = 0;
mSceneLimits.maxNbJoints = 0;
// Update scene descriptor
mSceneDesc.limits = &mSceneLimits;
mSceneDesc.maxBounds = &mBounds;
mSceneDesc.upAxis = 1; // Y
mSceneDesc.staticStructure = NX_PRUNING_STATIC_AABB_TREE;
mSceneDesc.dynamicStructure = NX_PRUNING_NONE; //NX_PRUNING_DYNAMIC_AABB_TREE;
// create scene
if( !mScene )
{
CreateScene();
}
if( !mScene )
{
PX_ERR( PX_NAME, TEXT("%s !! %s :: Scene could not be created"), PX_LOGP );
return;
}
// default material
NxMaterial* defaultMaterial = mScene->getMaterialFromIndex(0);
defaultMaterial->setRestitution(0.1f);
defaultMaterial->setStaticFriction(0.9f);
defaultMaterial->setDynamicFriction(0.85f);
// Create static level actor
PX_LOG( PX_NAME, TEXT("%s .. %s :: Creating level mesh"), PX_LOGP );
NxActorDesc actorDesc;
actorDesc.shapes.pushBack(&levelShapeDesc);
// Add level actor to the scene
PX_LOG( PX_NAME, TEXT("%s .. %s :: Creating level actor"), PX_LOGP );
NxActor* actor = mScene->createActor(actorDesc);
actor->userData = (void*)level->GetLevelInfo();
PX_LOG( PX_NAME, TEXT("%s << %s ::"), PX_LOGP );
unguard;
}