本文整理汇总了C++中PolyObject类的典型用法代码示例。如果您正苦于以下问题:C++ PolyObject类的具体用法?C++ PolyObject怎么用?C++ PolyObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PolyObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OBJ_OBJECT_LENGTH
void SortVector::hashAndSortAllTask(GCTaskId*, void *a, void *b)
{
SortVector *s = (SortVector *)a;
// Hash the contents of the base object then sort them.
for (unsigned i = 0; i < 256; i++)
{
// Clear the entries in the hash table but not the sharing count.
s->processObjects[i].objList = ENDOFLIST;
s->processObjects[i].objCount = 0;
}
PolyObject *h = s->baseObject.objList;
POLYUNSIGNED bytes = OBJ_OBJECT_LENGTH(s->lengthWord)*sizeof(PolyWord);
while (h != ENDOFLIST)
{
PolyObject *next = h->GetForwardingPtr();
unsigned char hash = 0;
for (POLYUNSIGNED j = 0; j < bytes; j++)
hash += h->AsBytePtr()[j];
h->SetForwardingPtr(s->processObjects[hash].objList);
s->processObjects[hash].objList = h;
s->processObjects[hash].objCount++;
h = next;
}
s->SortData();
}
示例2: ModifyObject
void MatMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{
Interval valid = FOREVER;
int id;
pblock->GetValue(PB_MATID,t,id,valid);
id--;
if (id<0) id = 0;
if (id>0xffff) id = 0xffff;
// For version 4 and later, we process patch meshes as they are and pass them on. Earlier
// versions converted to TriMeshes (done below). For adding other new types of objects, add
// them here!
#ifndef NO_PATCHES
if(version >= MATMOD_VER4 && os->obj->IsSubClassOf(patchObjectClassID)) {
PatchObject *patchOb = (PatchObject *)os->obj;
PatchMesh &pmesh = patchOb->GetPatchMesh(t);
BOOL useSel = pmesh.selLevel >= PO_PATCH;
for (int i=0; i<pmesh.getNumPatches(); i++) {
if (!useSel || pmesh.patchSel[i]) {
pmesh.setPatchMtlIndex(i,(MtlID)id);
}
}
pmesh.InvalidateGeomCache(); // Do this because there isn't a topo cache in PatchMesh
patchOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else
#endif // NO_PATCHES
// Process PolyObjects
if(os->obj->IsSubClassOf(polyObjectClassID)) {
PolyObject *polyOb = (PolyObject *)os->obj;
MNMesh &mesh = polyOb->GetMesh();
BOOL useSel = mesh.selLevel == MNM_SL_FACE;
for (int i=0; i<mesh.numf; i++) {
if (!useSel || mesh.f[i].GetFlag(MN_SEL)) {
mesh.f[i].material = (MtlID)id;
}
}
polyOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else // If it's a TriObject, process it
if(os->obj->IsSubClassOf(triObjectClassID)) {
TriObject *triOb = (TriObject *)os->obj;
DoMaterialSet(triOb, id);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else // Fallback position: If it can convert to a TriObject, do it!
if(os->obj->CanConvertToType(triObjectClassID)) {
TriObject *triOb = (TriObject *)os->obj->ConvertToType(t, triObjectClassID);
// Now stuff this into the pipeline!
os->obj = triOb;
DoMaterialSet(triOb, id);
triOb->UpdateValidity(TOPO_CHAN_NUM,valid);
}
else
return; // Do nothing if it can't convert to triObject
}
示例3: TestForScan
bool GetSharing::TestForScan(PolyWord *pt)
{
PolyObject *obj;
// This may be a forwarding pointer left over from a minor GC that did
// not complete or it may be a sharing chain pointer that we've set up.
while (1)
{
PolyWord p = *pt;
ASSERT(p.IsDataPtr());
obj = p.AsObjPtr();
PolyWord *lengthWord = ((PolyWord*)obj) - 1;
LocalMemSpace *space = gMem.LocalSpaceForAddress(lengthWord);
if (space == 0)
return false; // Ignore it if it points to a permanent area
if (space->bitmap.TestBit(space->wordNo(lengthWord)))
return false;
// Wasn't marked - must be a forwarding pointer.
if (obj->ContainsForwardingPtr())
{
obj = obj->GetForwardingPtr();
*pt = obj;
}
else break;
}
ASSERT(obj->ContainsNormalLengthWord());
totalVisited += 1;
totalSize += obj->Length() + 1;
return true;
}
示例4: CheckAddress
static void CheckAddress(PolyWord *pt)
{
MemSpace *space = gMem.SpaceForAddress(pt-1);
if (space == 0)
{
Log("Check: Bad pointer %p (no space found)\n", pt);
ASSERT(space != 0);
}
if (space->spaceType == ST_STACK) // This may not have valid length words.
return;
PolyObject *obj = (PolyObject*)pt;
ASSERT(obj->ContainsNormalLengthWord());
POLYUNSIGNED length = obj->Length();
if (pt+length > space->top)
{
Log("Check: Bad pointer %p (space %p) length %" POLYUFMT "\n", pt, space, length);
ASSERT(pt+length <= space->top);
}
if (space->spaceType == ST_LOCAL)
{
LocalMemSpace *lSpace = (LocalMemSpace*)space;
if (!((pt > lSpace->bottom && pt+length <= lSpace->lowerAllocPtr) ||
(pt > lSpace->upperAllocPtr && pt+length <= space->top)))
{
Log("Check: Bad pointer %p (space %p) length %" POLYUFMT " outside allocated area\n", pt, space, length);
ASSERT((pt > lSpace->bottom && pt+length <= lSpace->lowerAllocPtr) ||
(pt > lSpace->upperAllocPtr && pt+length <= space->top));
}
}
}
示例5: TestForScan
// Tests if this needs to be scanned. It marks it if it has not been marked
// unless it has to be scanned.
bool MTGCProcessMarkPointers::TestForScan(PolyWord *pt)
{
if ((*pt).IsTagged())
return false;
// This could contain a forwarding pointer if it points into an
// allocation area and has been moved by the minor GC.
// We have to be a little careful. Another thread could also
// be following any forwarding pointers here. However it's safe
// because they will update it with the same value.
PolyObject *obj = (*pt).AsObjPtr();
if (obj->ContainsForwardingPtr())
{
obj = FollowForwarding(obj);
*pt = obj;
}
if (gMem.LocalSpaceForAddress(obj) == 0)
return false; // Ignore it if it points to a permanent area
POLYUNSIGNED L = obj->LengthWord();
if (L & _OBJ_GC_MARK)
return false; // Already marked
if (debugOptions & DEBUG_GC_DETAIL)
Log("GC: Mark: %p %" POLYUFMT " %u\n", obj, OBJ_OBJECT_LENGTH(L), GetTypeBits(L));
if (OBJ_IS_BYTE_OBJECT(L))
{
obj->SetLengthWord(L | _OBJ_GC_MARK); // Mark it
return false; // We've done as much as we need
}
return true;
}
示例6: MarkAndTestForScan
void MTGCProcessMarkPointers::MarkAndTestForScan(PolyWord *pt)
{
if (TestForScan(pt))
{
PolyObject *obj = (*pt).AsObjPtr();
obj->SetLengthWord(obj->LengthWord() | _OBJ_GC_MARK);
}
}
示例7: getc
bool PImport::GetValue(PolyWord *result)
{
int ch = getc(f);
if (ch == '@')
{
/* Address of an object. */
POLYUNSIGNED obj;
fscanf(f, "%" POLYUFMT, &obj);
ASSERT(obj < nObjects);
*result = objMap[obj];
}
else if (ch == '$')
{
/* Code address. */
POLYUNSIGNED obj, offset;
fscanf(f, "%" POLYUFMT "+%" POLYUFMT, &obj, &offset);
ASSERT(obj < nObjects);
PolyObject *q = objMap[obj];
ASSERT(q->IsCodeObject());
*result = PolyWord::FromCodePtr((PolyWord(q)).AsCodePtr() + offset); /* The offset is in bytes. */
}
else if ((ch >= '0' && ch <= '9') || ch == '-')
{
/* Tagged integer. */
POLYSIGNED j;
ungetc(ch, f);
fscanf(f, "%" POLYSFMT, &j);
/* The assertion may be false if we are porting to a machine
with a shorter tagged representation. */
ASSERT(j >= -MAXTAGGED-1 && j <= MAXTAGGED);
*result = TAGGED(j);
}
else if (ch == 'I')
{
/* IO entry number. */
POLYUNSIGNED j;
fscanf(f, "%" POLYUFMT, &j);
ASSERT(j < POLY_SYS_vecsize);
*result = (PolyObject*)&gMem.ioSpace->bottom[j * IO_SPACING];
}
else if (ch == 'J')
{
/* IO entry number with offset. */
POLYUNSIGNED j, offset;
fscanf(f, "%" POLYUFMT "+%" POLYUFMT, &j, &offset);
ASSERT(j < POLY_SYS_vecsize);
PolyWord base = (PolyObject*)&gMem.ioSpace->bottom[j * IO_SPACING];
*result = PolyWord::FromCodePtr(base.AsCodePtr() + offset);
}
else
{
fprintf(stderr, "Unexpected character in stream");
return false;
}
return true;
}
示例8: while
void ScanAddress::ScanAddressesInRegion(PolyWord *region, PolyWord *end)
{
PolyWord *pt = region;
while (pt < end)
{
pt++; // Skip length word.
// pt actually points AT the object here.
PolyObject *obj = (PolyObject*)pt;
if (obj->ContainsForwardingPtr()) /* skip over moved object */
{
// We can now get multiple forwarding pointers as a result
// of applying ShareData repeatedly. Perhaps we should
// turn the forwarding pointers back into normal words in
// an extra pass.
while (obj->ContainsForwardingPtr())
obj = obj->GetForwardingPtr();
ASSERT(obj->ContainsNormalLengthWord());
CheckObject(obj);
pt += obj->Length();
}
else
{
ASSERT(obj->ContainsNormalLengthWord());
POLYUNSIGNED length = obj->Length();
if (pt+length > end)
Crash("Malformed object at %p - length %lu\n", pt, length);
if (length != 0)
ScanAddressesInObject(obj);
pt += length;
}
}
}
示例9: real_result
Handle real_result(TaskData *mdTaskData, double x)
{
union db argx;
argx.dble = x;
PolyObject *v = alloc(mdTaskData, DBLE/sizeof(PolyWord), F_BYTE_OBJ);
/* Copy as words in case the alignment is wrong. */
for(unsigned i = 0; i < DBLE; i++)
{
v->AsBytePtr()[i] = argx.bytes[i];
}
return mdTaskData->saveVec.push(v);
}
示例10: DoCheckPointer
void DoCheckPointer (const PolyWord pt)
{
if (pt == PolyWord::FromUnsigned(0)) return;
if (OBJ_IS_AN_INTEGER(pt)) return;
DoCheck (pt);
if (pt.IsDataPtr())
{
PolyObject *obj = pt.AsObjPtr();
DoCheckObject (obj, obj->LengthWord());
}
}
示例11: free
ProcessAddToVector::~ProcessAddToVector()
{
// Normally the stack will be empty. However if we have run out of
// memory and thrown an exception we may well have items left.
// We have to remove the mark bits otherwise it will mess up any
// subsequent GC.
for (unsigned i = 0; i < asp; i++)
{
PolyObject *obj = addStack[i];
if (obj->LengthWord() & _OBJ_GC_MARK)
obj->SetLengthWord(obj->LengthWord() & (~_OBJ_GC_MARK));
}
free(addStack); // Now free the stack
}
示例12: AverageVertexNormals
void AFRMod::ModifyObject (TimeValue t, ModContext &mc, ObjectState *os, INode *node) {
Interval iv = FOREVER;
float f, p, b;
int backface;
Point3 pt1, pt2;
pblock->GetValue(PB_FALLOFF,t,f,iv);
pblock->GetValue(PB_PINCH,t,p,iv);
pblock->GetValue(PB_BUBBLE,t,b,iv);
pblock->GetValue(PB_BACKFACE,t,backface,iv);
p1->GetValue(t,&pt1,iv,CTRL_ABSOLUTE);
p2->GetValue(t,&pt2,iv,CTRL_ABSOLUTE);
if (f==0.0) {
os->obj->UpdateValidity(GEOM_CHAN_NUM,iv);
return;
}
Tab<Point3> normals;
if (backface) {
// Need to get vertex normals.
if (os->obj->IsSubClassOf(triObjectClassID)) {
TriObject *tobj = (TriObject*)os->obj;
AverageVertexNormals (tobj->GetMesh(), normals);
} else if (os->obj->IsSubClassOf (polyObjectClassID)) {
PolyObject *pobj = (PolyObject *) os->obj;
MNMesh &mesh = pobj->GetMesh();
normals.SetCount (mesh.numv);
Point3 *vn = normals.Addr(0);
for (int i=0; i<mesh.numv; i++) {
if (mesh.v[i].GetFlag (MN_DEAD)) vn[i]=Point3(0,0,0);
else vn[i] = mesh.GetVertexNormal (i);
}
#ifndef NO_PATCHES
} else if (os->obj->IsSubClassOf (patchObjectClassID)) {
PatchObject *pobj = (PatchObject *) os->obj;
normals.SetCount (pobj->NumPoints ());
Point3 *vn = normals.Addr(0);
for (int i=0; i<pobj->NumPoints(); i++) vn[i] = pobj->VertexNormal (i);
#endif
}
}
if (normals.Count()) {
AFRDeformer deformer(mc,f,p,b,pt1,pt2,&normals);
os->obj->Deform(&deformer, TRUE);
} else {
AFRDeformer deformer(mc,f,p,b,pt1,pt2);
os->obj->Deform(&deformer, TRUE);
}
os->obj->UpdateValidity(GEOM_CHAN_NUM,iv);
}
示例13: TypeReturned
IGeometryChecker::ReturnVal FlippedFacesChecker::GeometryCheck(TimeValue t,INode *nodeToCheck, IGeometryChecker::OutputVal &val)
{
val.mIndex.ZeroCount();
if(IsSupported(nodeToCheck))
{
ObjectState os = nodeToCheck->EvalWorldState(t);
Object *obj = os.obj;
if(os.obj->IsSubClassOf(triObjectClassID))
{
TriObject *tri = dynamic_cast<TriObject *>(os.obj);
if(tri&&tri->mesh.numFaces>0)
{
tri->mesh.checkNormals(TRUE);
for(int i=0;i<tri->mesh.numFaces;++i)
{
val.mIndex.Append(1,&i);
}
return TypeReturned();
}
else return IGeometryChecker::eFail;
}
else if(os.obj->IsSubClassOf(polyObjectClassID))
{
PolyObject *poly = dynamic_cast<PolyObject *>(os.obj);
if(poly&&poly->GetMesh().numf>0)
{
IGeometryChecker::ReturnVal returnval=IGeometryChecker::eFail;
MNMesh &mnMesh = poly->GetMesh();
for(int i=0;i<mnMesh.numf;++i)
{
val.mIndex.Append(1,&i);
}
return TypeReturned();
}
else return IGeometryChecker::eFail;
}
return TypeReturned();
}
return IGeometryChecker::eFail;
}
示例14: Real_strc
Handle Real_strc(TaskData *mdTaskData, Handle hDigits, Handle hMode, Handle arg)
{
double dx = real_arg(arg);
int decpt, sign;
int mode = get_C_int(mdTaskData, DEREFWORDHANDLE(hMode));
int digits = get_C_int(mdTaskData, DEREFWORDHANDLE(hDigits));
/* Compute the shortest string which gives the required value. */
/* */
char *chars = poly_dtoa(dx, mode, digits, &decpt, &sign, NULL);
/* We have to be careful in case an allocation causes a
garbage collection. */
PolyWord pStr = C_string_to_Poly(mdTaskData, chars);
poly_freedtoa(chars);
Handle ppStr = mdTaskData->saveVec.push(pStr);
/* Allocate a triple for the results. */
PolyObject *result = alloc(mdTaskData, 3);
result->Set(0, DEREFWORDHANDLE(ppStr));
result->Set(1, TAGGED(decpt));
result->Set(2, TAGGED(sign));
return mdTaskData->saveVec.push(result);
}
示例15: ObjCodePtrToPtr
// Returns the new address if the argument is the address of an object that
// has moved, otherwise returns the original.
PolyWord SaveFixupAddress::GetNewAddress(PolyWord old)
{
if (old.IsTagged() || old == PolyWord::FromUnsigned(0) || gMem.IsIOPointer(old.AsAddress()))
return old; // Nothing to do.
// When we are updating addresses in the stack or in code segments we may have
// code pointers.
if (old.IsCodePtr())
{
// Find the start of the code segment
PolyObject *oldObject = ObjCodePtrToPtr(old.AsCodePtr());
// Calculate the byte offset of this value within the code object.
POLYUNSIGNED offset = old.AsCodePtr() - (byte*)oldObject;
PolyWord newObject = GetNewAddress(oldObject);
return PolyWord::FromCodePtr(newObject.AsCodePtr() + offset);
}
ASSERT(old.IsDataPtr());
PolyObject *obj = old.AsObjPtr();
if (obj->ContainsForwardingPtr()) // tombstone is a pointer to a moved object
{
PolyObject *newp = obj->GetForwardingPtr();
ASSERT (newp->ContainsNormalLengthWord());
return newp;
}
ASSERT (obj->ContainsNormalLengthWord()); // object is not moved
return old;
}