本文整理汇总了C++中List::CreateNew方法的典型用法代码示例。如果您正苦于以下问题:C++ List::CreateNew方法的具体用法?C++ List::CreateNew怎么用?C++ List::CreateNew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List::CreateNew方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateHotkey
UINT OBSAPIInterface::CreateHotkey(DWORD hotkey, OBSHOTKEYPROC hotkeyProc, UPARAM param)
{
if(!hotkey)
return 0;
//FIXME: vk and fsModifiers aren't used?
DWORD vk = LOBYTE(hotkey);
DWORD modifier = HIBYTE(hotkey);
DWORD fsModifiers = 0;
if(modifier & HOTKEYF_ALT)
fsModifiers |= MOD_ALT;
if(modifier & HOTKEYF_CONTROL)
fsModifiers |= MOD_CONTROL;
if(modifier & HOTKEYF_SHIFT)
fsModifiers |= MOD_SHIFT;
OSEnterMutex(App->hHotkeyMutex);
HotkeyInfo &hi = *hotkeys.CreateNew();
hi.hotkeyID = ++curHotkeyIDVal;
hi.hotkey = hotkey;
hi.hotkeyProc = hotkeyProc;
hi.param = param;
hi.bModifiersDown = false;
hi.bHotkeyDown = false;
OSLeaveMutex(App->hHotkeyMutex);
return curHotkeyIDVal;
}
示例2: SendPacket
void SendPacket(BYTE *data, UINT size, DWORD timestamp, PacketType type)
{
ProcessDelayedPackets(timestamp);
NetworkPacket *newPacket = delayedPackets.CreateNew();
newPacket->data.CopyArray(data, size);
newPacket->timestamp = timestamp;
newPacket->type = type;
lastTimestamp = timestamp;
}
示例3: MergeProfileInfo
void MergeProfileInfo(ProfileNodeInfo *info, DWORD rootLastCall, DWORD updatedLastCall)
{
bSingular = info->bSingular;
numCalls += info->numCalls;
if(lastCall == rootLastCall) lastCall = updatedLastCall;
totalTimeElapsed += info->totalTimeElapsed;
lastTimeElapsed = info->lastTimeElapsed;
cpuTimeElapsed += info->cpuTimeElapsed;
lastCpuTimeElapsed = info->lastCpuTimeElapsed;
numParallelCalls = info->numParallelCalls;
for(UINT i = 0; i < info->Children.Num(); i++)
{
ProfileNodeInfo &child = info->Children[i];
ProfileNodeInfo *sumChild = FindSubProfile(child.lpName);
if(!sumChild)
{
sumChild = Children.CreateNew();
sumChild->lpName = child.lpName;
}
sumChild->MergeProfileInfo(&child, rootLastCall, updatedLastCall);
}
}
示例4: LoadAnimations
//.........这里部分代码省略.........
for(int l=0; l<info.weights.Num(); l++)
info.weights[l] *= weightAdjust;
}
bones.Remove(removeBoneID);
bestVertWeights.Remove(removeBoneID);
}
}
}
//---------
// sort out sections of triangles that are influenced up to a max of 4 bones
// also, duplicate shared verts
VBData *newVBD = new VBData;
newVBD->CopyList(*vbd);
newVBD->TVList.SetSize(2);
newVBD->TVList[1].SetWidth(4);
newVBD->TVList[1].SetSize(nVerts);
List<SubSectionInfo> newSubSections;
for(int i=0; i<nSections; i++)
{
List<TriBoneInfo> triInfo;
DrawSection §ion = SectionList[i];
if(!section.numFaces) continue;
for(int j=0; j<section.numFaces; j++)
{
UINT *triVertIDs = &indices[(section.startFace+j)*3];
TriBoneInfo &newTri = *triInfo.CreateNew();
for(int k=0; k<3; k++)
{
VertAnimInfo &info = vertInfo[triVertIDs[k]];
for(int l=0; l<info.bones.Num(); l++)
newTri.bones.SafeAdd(info.bones[l]);
}
}
BitList UsedTris;
UsedTris.SetSize(section.numFaces);
DWORD nUsedTris = 0;
while(nUsedTris != section.numFaces)
{
DWORD triSectionID = newSubSections.Num();
SubSectionInfo *curSubSecInfo = newSubSections.CreateNew();
curSubSecInfo->section = i;
for(int j=0; j<triInfo.Num(); j++)
{
if(UsedTris[j]) continue;
TriBoneInfo &tri = triInfo[j];
List<UINT> secBones;
secBones.CopyList(curSubSecInfo->bones);
BOOL bBadTri = FALSE;
for(int k=0; k<tri.bones.Num(); k++)
{
示例5: Encode
bool Encode(LPVOID picInPtr, List<DataPacket> &packets, List<PacketType> &packetTypes, DWORD outputTimestamp)
{
x264_picture_t *picIn = (x264_picture_t*)picInPtr;
x264_nal_t *nalOut;
int nalNum;
packets.Clear();
ClearPackets();
if(bRequestKeyframe && picIn)
picIn->i_type = X264_TYPE_IDR;
if(x264_encoder_encode(x264, &nalOut, &nalNum, picIn, &picOut) < 0)
{
AppWarning(TEXT("x264 encode failed"));
return false;
}
if(bRequestKeyframe && picIn)
{
picIn->i_type = X264_TYPE_AUTO;
bRequestKeyframe = false;
}
if(!bFirstFrameProcessed && nalNum)
{
delayOffset = -picOut.i_dts;
bFirstFrameProcessed = true;
}
INT64 ts = INT64(outputTimestamp);
int timeOffset;
//if frame duplication is being used, the shift will be insignificant, so just don't bother adjusting audio
timeOffset = int(picOut.i_pts-picOut.i_dts);
timeOffset += frameShift;
if(nalNum && timeOffset < 0)
{
frameShift -= timeOffset;
timeOffset = 0;
}
//Log(TEXT("inpts: %005d, dts: %005d, pts: %005d, timestamp: %005d, offset: %005d, newoffset: %005d"), picIn->i_pts, picOut.i_dts, picOut.i_pts, outputTimestamp, timeOffset, picOut.i_pts-picOut.i_dts);
timeOffset = htonl(timeOffset);
BYTE *timeOffsetAddr = ((BYTE*)&timeOffset)+1;
VideoPacket *newPacket = NULL;
PacketType bestType = PacketType_VideoDisposable;
bool bFoundFrame = false;
for(int i=0; i<nalNum; i++)
{
x264_nal_t &nal = nalOut[i];
if(nal.i_type == NAL_SEI)
{
BYTE *skip = nal.p_payload;
while(*(skip++) != 0x1);
int skipBytes = (int)(skip-nal.p_payload);
int newPayloadSize = (nal.i_payload-skipBytes);
if (nal.p_payload[skipBytes+1] == 0x5) {
SEIData.Clear();
BufferOutputSerializer packetOut(SEIData);
packetOut.OutputDword(htonl(newPayloadSize));
packetOut.Serialize(nal.p_payload+skipBytes, newPayloadSize);
} else {
if (!newPacket)
newPacket = CurrentPackets.CreateNew();
BufferOutputSerializer packetOut(newPacket->Packet);
packetOut.OutputDword(htonl(newPayloadSize));
packetOut.Serialize(nal.p_payload+skipBytes, newPayloadSize);
}
}
else if(nal.i_type == NAL_FILLER)
{
BYTE *skip = nal.p_payload;
while(*(skip++) != 0x1);
int skipBytes = (int)(skip-nal.p_payload);
int newPayloadSize = (nal.i_payload-skipBytes);
if (!newPacket)
newPacket = CurrentPackets.CreateNew();
BufferOutputSerializer packetOut(newPacket->Packet);
packetOut.OutputDword(htonl(newPayloadSize));
packetOut.Serialize(nal.p_payload+skipBytes, newPayloadSize);
}
else if(nal.i_type == NAL_SLICE_IDR || nal.i_type == NAL_SLICE)
//.........这里部分代码省略.........
示例6: BuildLightmapUVs
void EditorMesh::BuildLightmapUVs(float maxAngle, float adjVal, int seperationUnits)
{
Vect maxSize = bounds.Max-bounds.Min;
//adjVal *= MAX(maxSize.x, MAX(maxSize.y, maxSize.z));
adjVal *= bounds.GetDiamater();
int i, j;
MakePolyEdges();
maxAngle = cosf(RAD(maxAngle));
BitList ProcessedPolys, ProcessedEdges, ProcessedVerts;
List<UINT> UnprocessedPolys;
ProcessedPolys.SetSize(PolyList.Num());
ProcessedEdges.SetSize(PolyEdgeList.Num());
ProcessedVerts.SetSize(VertList.Num());
UnprocessedPolys.SetSize(PolyList.Num());
for(i=0; i<UnprocessedPolys.Num(); i++)
UnprocessedPolys[i] = i;
List<UVSection> Sections;
BitList SplitVerts;
SplitVerts.SetSize(VertList.Num());
//go through each polygon and find neighboring polygons
while(UnprocessedPolys.Num())
{
UINT curPoly = UnprocessedPolys[0];
List<UINT> SectionPolys;
UVSection §ion = *Sections.CreateNew();
section.mapDir = GetPolyDir(curPoly);
List<Vect> PolyLines;
// calling this recursively will build us up a section based upon this poly
AddLMPolyInfo info(curPoly, maxAngle, section.mapDir, SectionPolys, PolyLines, UnprocessedPolys, ProcessedPolys, ProcessedEdges);
AddLightmapUVPoly(info);
section.mapDir.Norm();
//find best mapping direction
Vect XDir, YDir;
BitList addedLines;
addedLines.SetSize(PolyLines.Num());
float bestLength = 0.0f;
Vect bestDir;
for(i=0; i<PolyLines.Num(); i++)
{
if(addedLines[i]) continue;
addedLines.Set(i);
Vect &line1 = PolyLines[i];
Vect line1Norm = (line1 + (section.mapDir * -section.mapDir.Dot(line1))).Norm();
Vect lineTotal = line1;
for(j=i+1; j<PolyLines.Num(); j++)
{
if(addedLines[j]) continue;
Vect &line2 = PolyLines[j];
Vect line2Norm = (line2 + (section.mapDir * -section.mapDir.Dot(line2))).Norm();
if(line1Norm.Dot(line2Norm) > 0.9f) //about 10 degrees
{
lineTotal += line2;
addedLines.Set(j);
}
}
float length = lineTotal.Len();
if(length > bestLength)
{
bestDir = lineTotal.Norm();
bestLength = length;
}
}
if(section.mapDir.CloseTo(bestDir) || (-section.mapDir).CloseTo(bestDir))
{
if(bestDir.x > bestDir.y)
{
if(bestDir.x > bestDir.z)
*(DWORD*)&bestDir.x |= 0x80000000;
else
*(DWORD*)&bestDir.z |= 0x80000000;
}
else
{
if(bestDir.y > bestDir.z)
//.........这里部分代码省略.........
示例7: GetNextBuffer
//.........这里部分代码省略.........
}
if(data.input_frames_used != numAudioFrames)
{
RUNONCE AppWarning(TEXT("Failed to downsample buffer completely, which shouldn't actually happen because it should be using 10ms of samples"));
return NoAudioAvailable;
}
numAudioFrames = data.output_frames_gen;
}
//-----------------------------------------------------------------------------
// sort all audio frames into 10 millisecond increments (done because not all devices output in 10ms increments)
// NOTE: 0.457+ - instead of using the timestamps from windows, just compare and make sure it stays within a 100ms of their timestamps
float *newBuffer = (bResample) ? tempResampleBuffer.Array() : tempBuffer.Array();
if(storageBuffer.Num() == 0 && numAudioFrames == 441)
{
lastUsedTimestamp += 10;
if(!bBrokenTimestamp)
{
QWORD difVal = GetQWDif(newTimestamp, lastUsedTimestamp);
if(difVal > 70)
lastUsedTimestamp = newTimestamp;
}
if(lastUsedTimestamp > lastSentTimestamp)
{
QWORD adjustVal = (lastUsedTimestamp-lastSentTimestamp);
if(adjustVal < 10)
lastUsedTimestamp += 10-adjustVal;
AudioSegment &newSegment = *audioSegments.CreateNew();
newSegment.audioData.CopyArray(newBuffer, numAudioFrames*2);
newSegment.timestamp = lastUsedTimestamp;
MultiplyAudioBuffer(newSegment.audioData.Array(), numAudioFrames*2, curVolume);
lastSentTimestamp = lastUsedTimestamp;
}
}
else
{
UINT storedFrames = storageBuffer.Num();
storageBuffer.AppendArray(newBuffer, numAudioFrames*2);
if(storageBuffer.Num() >= (441*2))
{
lastUsedTimestamp += 10;
if(!bBrokenTimestamp)
{
QWORD difVal = GetQWDif(newTimestamp, lastUsedTimestamp);
if(difVal > 70)
lastUsedTimestamp = newTimestamp - (QWORD(storedFrames)/2*1000/44100);
}
//------------------------
// add new data
if(lastUsedTimestamp > lastSentTimestamp)
{
QWORD adjustVal = (lastUsedTimestamp-lastSentTimestamp);
if(adjustVal < 10)
lastUsedTimestamp += 10-adjustVal;
AudioSegment &newSegment = *audioSegments.CreateNew();
示例8: ConnectChibiLoops
//.........这里部分代码省略.........
for(k=0; k<childLoop.Num(); k++)
{
if(AlreadyUsed.FindValueIndex(childLoop[k].v1) != INVALID)
continue;
Vect2 &v2 = Verts[childLoop[k].v1];
BOOL bBadChoice = LineIntersectsShape(v1, v2, CurLoop);
if(bBadChoice)
continue;
for(l=0; l<CurChildren.Num(); l++)
{
if(LineIntersectsShape(v1, v2, LoopList[loopNode.Children[CurChildren[l]].loop]))
{
bBadChoice = TRUE;
break;
}
}
if(bBadChoice)
continue;
float dist = v2.Dist(v1);
if((curBestChoiceLoop1 != INVALID) && (dist > closestPos))
continue;
closestPos = dist;
curBestChoiceLoop1 = j;
curBestChoiceLoop2 = k;
}
}
if(curBestChoiceLoop1 == INVALID)
{
i = (i == CurChildren.Num()-1) ? 0 : (i+1);
if(i == 0)
{
AppWarning(TEXT("...almost infinitely looped there. Fortunately I have measures against such devious things."));
break;
}
continue;
}
AlreadyUsed << CurLoop[curBestChoiceLoop1].v1;
AlreadyUsed << childLoop[curBestChoiceLoop2].v1;
//---------------------------------------------
// connect loops
if(CurLoop[0].lineData && !childLoop[0].lineData)
{
for(j=0; j<childLoop.Num(); j++)
childLoop[j].lineData = CurLoop[0].lineData;
}
SetNewLoopStartPosition(CurLoop, curBestChoiceLoop1);
SetNewLoopStartPosition(childLoop, curBestChoiceLoop2);
if(!CurLoop[0].lineData && childLoop[0].lineData)
{
for(j=0; j<CurLoop.Num(); j++)
CurLoop[j].lineData = childLoop[0].lineData;
}
PolyLine &lastLine = CurLoop.Last();
PolyLine *pLine = CurLoop.CreateNew();
pLine->v1 = lastLine.v2;
pLine->v2 = childLoop[0].v1;
CurLoop.AppendList(childLoop);
pLine = CurLoop.CreateNew();
pLine->v1 = childLoop[0].v1;
pLine->v2 = CurLoop[0].v1;
/*for(j=0; j<CurLoop.Num(); j++)
{
String chong;
chong << long(j) << TEXT(": x: ") << FormattedString(TEXT("%0.4f"), Verts[CurLoop[j].v1].x) << TEXT("\ty: ") << FormattedString(TEXT("%0.4f"), Verts[CurLoop[j].v1].y) << TEXT("\r\n");
OutputDebugString(chong);
}
OutputDebugString(TEXT("====================================\r\n"));*/
CurChildren.Remove(i);
i = 0;
}
NewLoopList.CreateNew()->CopyList(CurLoop);
CurLoop.Clear();
for(i=0; i<loopNode.Children.Num(); i++)
{
ChibiLoopNode &childNode = loopNode.Children[i];
for(j=0; j<childNode.Children.Num(); j++)
ConnectChibiLoops(childNode.Children[j], LoopList, NewLoopList);
}
}
示例9: CreateChibiLoopTree
void Triangulator::CreateChibiLoopTree(List<ChibiLoopNode> &LoopNodeList, List<DWORD> &LoopRefs, List<LoopVerts> &LoopList)
{
int i, j;
// find top loops
/*for(i=0; i<LoopRefs.Num(); i++)
{
LoopVerts &loop1 = LoopList[LoopRefs[i]];
BOOL bTopLoop = TRUE;
//Vect2 &testVert = Verts[LoopList[LoopRefs[i]][0].v1];
List<DWORD> ChildRefs;
for(j=0; j<LoopRefs.Num(); j++)
{
if(j == i)
continue;
LoopVerts &loop2 = LoopList[LoopRefs[j]];
DWORD val = LoopInsideLoop(loop2, loop1);
if(val == 2)
{
if(!ChibiLoopFacingUp(loop2))
val = 1;
}
if(val == 1)
{
bTopLoop = FALSE;
break;
}
else if(LoopInsideLoop(loop1, loop2))
ChildRefs << LoopRefs[j];
}
if(bTopLoop)
{
ChibiLoopNode &chibiLoopNode = *LoopNodeList.CreateNew();
chibiLoopNode.loop = LoopRefs[i];
CreateChibiLoopTree(chibiLoopNode.Children, ChildRefs, LoopList);
}
}*/
for(i=0; LoopRefs.Num(); i++) //works like a while(LoopRefs.Num())
{
LoopVerts &loop1 = LoopList[LoopRefs[i]];
BOOL bTopLoop = TRUE;
List<DWORD> ChildRefs;
ChildRefs.Clear();
for(j=0; j<LoopRefs.Num(); j++)
{
if(j == i)
continue;
LoopVerts &loop2 = LoopList[LoopRefs[j]];
DWORD val = LoopInsideLoop(loop2, loop1);
if(val == 2)
{
if(!ChibiLoopFacingUp(loop2))
val = 1;
}
if(val == 1)
{
bTopLoop = FALSE;
break;
}
else
{
DWORD val2 = LoopInsideLoop(loop1, loop2);
if((val2 == 1) || ((val2 & val) == 2))
ChildRefs << LoopRefs[j];
}
}
if(bTopLoop)
{
ChibiLoopNode &chibiLoopNode = *LoopNodeList.CreateNew();
chibiLoopNode.loop = LoopRefs[i];
LoopRefs.Remove(i);
if(ChildRefs.Num())
{
for(j=0; j<ChildRefs.Num(); j++)
LoopRefs.RemoveItem(ChildRefs[j]);
CreateChibiLoopTree(chibiLoopNode.Children, ChildRefs, LoopList);
}
i=-1; //because it'll do the i++
//.........这里部分代码省略.........
示例10: Triangulate
void Triangulator::Triangulate()
{
assert(Verts.Num());
if(!Verts.Num())
return;
DWORD i;
//if no lines available, build lines list from vert list
if(!Lines.Num())
{
Lines.SetSize(Verts.Num());
for(i=0; i<Verts.Num(); i++)
{
PolyLine &line = Lines[i];
int ip1 = (i == Verts.Num()-1) ? 0 : (i+1);
line.v1 = i;
line.v2 = ip1;
}
}
List<ChibiLoopNode> ChibiLoopTree;
List<LoopVerts> LoopList;
DWORD curLoop=0;
//-----------------------------------------------------------
// find loops!
if(blablabla == 1)
blablabla = 0;
List<DWORD> LineIDs;
LineIDs.SetSize(Lines.Num());
for(i=0; i<LineIDs.Num(); i++) LineIDs[i] = i;
while(LineIDs.Num())
{
LoopVerts &CurLoop = *LoopList.CreateNew();
DWORD lastLine = 0;
CurLoop.Clear();
while(TRUE)
{
PolyLine &line1 = Lines[LineIDs[lastLine]];
LineIDs.Remove(lastLine);
CurLoop << line1;
BOOL bNoResults = TRUE;
if(line1.v2 == CurLoop[0].v1)
break;
for(i=0; i<LineIDs.Num(); i++)
{
PolyLine &line2 = Lines[LineIDs[i]];
if((line2.v1 == line1.v2) && (line2.v2 != line1.v1) && (!line2.lineData || (line1.lineData == line2.lineData)))
{
lastLine = i;
line2.lineData = line1.lineData;
bNoResults = FALSE;
break;
}
}
if(bNoResults)
{
AppWarning(TEXT("Invalid Loop data sent to triangulation."));
LineIDs.Clear();
break;
}
}
}
//-----------------------------------------------------------
// sort loops!
List<DWORD> LoopRefs;
LoopRefs.SetSize(LoopList.Num());
for(i=0; i<LoopList.Num(); i++) LoopRefs[i] = i;
CreateChibiLoopTree(ChibiLoopTree, LoopRefs, LoopList);
LoopRefs.Clear();
//-----------------------------------------------------------
// connect loops
//SpreadLoopData(ChibiLoopTree, LoopList, 0);
List<LoopVerts> NewLoopList;
for(i=0; i<ChibiLoopTree.Num(); i++)
ConnectChibiLoops(ChibiLoopTree[i], LoopList, NewLoopList);
//.........这里部分代码省略.........