• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ utArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中utArray的典型用法代码示例。如果您正苦于以下问题:C++ utArray类的具体用法?C++ utArray怎么用?C++ utArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了utArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: finalizeAssemblyLoad

void LSLuaState::finalizeAssemblyLoad(Assembly *assembly, utArray<Type *>& types)
{
    for (UTsize j = 0; j < types.size(); j++)
    {
        Type *type = types.at(j);

        if (type->isNative() || type->hasStaticNativeMember())
        {
            // we're native
            NativeInterface::resolveScriptType(type);
        }
    }

    declareLuaTypes(types);
    initializeLuaTypes(types);

    // we avoid runtime validation on mobile, this works but should be unnecessary
    // as issues with be caught on OSX/WINDOWS development platforms
#if LOOM_PLATFORM == LOOM_PLATFORM_OSX || LOOM_PLATFORM == LOOM_PLATFORM_WIN32
    for (UTsize j = 0; j < types.size(); j++)
    {
        Type            *type = types.at(j);
        TypeValidatorRT tv(this, type);
        tv.validate();
    }
#endif

    assembly->bootstrap();
}
开发者ID:Bewolf2,项目名称:LoomSDK,代码行数:29,代码来源:lsLuaState.cpp


示例2: initializeLuaTypes

void LSLuaState::initializeLuaTypes(const utArray<Type *>& types)
{
    for (UTsize i = 0; i < types.size(); i++)
    {
        types[i]->cache();
    }

    // initialize all classes
    for (UTsize i = 0; i < types.size(); i++)
    {
        initializeClass(types[i]);
    }

    // run static initializers now that all classes have been initialized
    for (UTsize i = 0; i < types.size(); i++)
    {
        lsr_classinitializestatic(VM(), types[i]);
    }
}
开发者ID:Bewolf2,项目名称:LoomSDK,代码行数:19,代码来源:lsLuaState.cpp


示例3: akMeshLoaderUtils_getVertexGroups

void akMeshLoaderUtils_getVertexGroups(Blender::Mesh* bmesh, Blender::Object* bobj, utArray<utString>& vgroups)
{
    if(bmesh->dvert)
    {
        Blender::bDeformGroup* dg = (Blender::bDeformGroup*)bobj->defbase.first;
        while(dg)
        {
            vgroups.push_back(dg->name);
            dg = dg->next;
        }
    }
}
开发者ID:erwincoumans,项目名称:astojilj_animkit,代码行数:12,代码来源:akMeshLoader.cpp


示例4: findMembers

void Type::findMembers(const MemberTypes& memberTypes,
                       utArray<MemberInfo *>& membersOut, bool includeBases, bool includePropertyGetterSetters)
{
    if (!includeBases)
    {
        membersOut.clear();
    }

    for (size_t i = 0; i < members.size(); i++)
    {
        MemberInfo *m = members.at((int)i);

        if (m->isConstructor() && memberTypes.constructor)
        {
            membersOut.push_back(m);
        }

        if (m->isMethod() && memberTypes.method)
        {
            membersOut.push_back(m);
        }

        if (m->isField() && memberTypes.field)
        {
            membersOut.push_back(m);
        }

        if (m->isProperty() && memberTypes.property)
        {
            membersOut.push_back(m);

            if (includePropertyGetterSetters)
            {
                PropertyInfo *p = (PropertyInfo *)m;

                if (p->getter && (p->getter->getDeclaringType() == p->getDeclaringType()))
                {
                    membersOut.push_back(p->getter);
                }

                if (p->setter && (p->setter->getDeclaringType() == p->getDeclaringType()))
                {
                    membersOut.push_back(p->setter);
                }
            }
        }
    }

    if (baseType && includeBases)
    {
        baseType->findMembers(memberTypes, membersOut, true, includePropertyGetterSetters);
    }
}
开发者ID:Ivory27,项目名称:LoomSDK,代码行数:53,代码来源:lsType.cpp


示例5: declareLuaTypes

void LSLuaState::declareLuaTypes(const utArray<Type *>& types)
{
    for (UTsize i = 0; i < types.size(); i++)
    {
        declareClass(types[i]);
    }

    // validate/initialize native types
    for (UTsize i = 0; i < types.size(); i++)
    {
        Type *type = types.at(i);

        if (type->isNative() || type->hasStaticNativeMember())
        {
            NativeTypeBase *ntb = NativeInterface::getNativeType(type);

            if (!ntb)
            {
                LSError("Unable to get NativeTypeBase for type %s", type->getFullName().c_str());
            }

            if (type->isNativeManaged() != ntb->isManaged())
            {
                if (type->isNativeManaged())
                {
                    LSError("Managed mismatch for type %s, script declaration specifies native while native bindings are unmanaged", type->getFullName().c_str());
                }
                else
                {
                    LSError("Managed mismatch for type %s, script declaration specifies unmanaged while native bindings are managed", type->getFullName().c_str());
                }
            }

            ntb->validate(type);
            type->setCTypeName(ntb->getCTypeName());
        }
    }
}
开发者ID:Bewolf2,项目名称:LoomSDK,代码行数:38,代码来源:lsLuaState.cpp


示例6: akMeshLoaderUtils_getSmoothFaces

void akMeshLoaderUtils_getSmoothFaces(Blender::Mesh* bmesh, utArray<utArray<UTuint32> >& faces)
{
    faces.resize(bmesh->totvert);
    for (int i = 0; i< bmesh->totvert; i++)
    {
        for (int j = 0; j< bmesh->totface; j++)
        {
            const Blender::MFace& bface = bmesh->mface[j];
            if( (bface.flag & ME_SMOOTH) &&
                    (bface.v1 == i ||
                     bface.v2 == i ||
                     bface.v3 == i ||
                     bface.v4 == i ))
            {
                faces[i].push_back(j);
            }
        }
    }
}
开发者ID:erwincoumans,项目名称:astojilj_animkit,代码行数:19,代码来源:akMeshLoader.cpp


示例7: postAllFiles

/**
 * Post all known files to all clients, or if specified, a single client.
 *
 * Useful for fully synching client with the current asset state.
 *
 * TODO: Optimize to use hashes to only transmit modified data, based on
 * client's starting assets.
 */
static void postAllFiles(int clientId = -1)
{
    lmLog(gAssetAgentLogGroup, "Queueing all files for client %d.", clientId);

    loom_mutex_lock(gFileScannerLock);

    // Walk all the files.
    utArray<FileEntry> *list = lmNew(NULL) utArray<FileEntry>();
    platform_walkFiles(".", handleFileStateWalkCallback, list);

    // Queue them all to be sent.
    for (UTsize i = 0; i < list->size(); i++)
    {
        FileModificationNote note;
        note.path          = stringtable_insert((*list)[i].path.c_str());
        note.lastSeenTime  = 0;
        note.onlyForClient = clientId;
        gPendingModifications.push_back(note);
    }

    loom_mutex_unlock(gFileScannerLock);
}
开发者ID:Y-way,项目名称:LoomSDK,代码行数:30,代码来源:main.cpp


示例8: akMeshLoaderUtils_getShapeKeysNormals

void akMeshLoaderUtils_getShapeKeysNormals(Blender::Mesh* bmesh, UTuint32 numshape, utArray<btAlignedObjectArray<akVector3> >& shapenormals)
{
    Blender::Key* bk = bmesh->key;
    if(bk)
    {

        shapenormals.resize(numshape);
        Blender::KeyBlock* bkb = (Blender::KeyBlock*)bk->block.first;

        // skip first shape key (basis)
        UTuint32 shape=0;
        if(bkb) bkb = bkb->next;
        while(bkb)
        {
            if(bkb->type == KEY_RELATIVE)
            {
                Blender::KeyBlock* basis = (Blender::KeyBlock*)bk->block.first;
                for(int i=0; basis && i<bkb->relative; i++)
                    basis = basis->next;

                if(basis)
                {
                    float* pos = (float*)bkb->data;
                    shapenormals[shape].resize(bmesh->totface);
                    for(int i=0; i<bmesh->totface; i++)
                    {
                        const Blender::MFace& bface = bmesh->mface[i];
                        akVector3 normal = akMeshLoaderUtils_calcMorphNormal(bface, pos);
                        shapenormals[shape][i]=normal;
                    }
                    shape++;
                }
            }
            bkb = bkb->next;
        }
    }
}
开发者ID:erwincoumans,项目名称:astojilj_animkit,代码行数:37,代码来源:akMeshLoader.cpp


示例9: akMeshLoaderUtils_getShapeKeys

void akMeshLoaderUtils_getShapeKeys(Blender::Mesh* bmesh, utArray<utString>& shapes)
{
    Blender::Key* bk = bmesh->key;
    if(bk)
    {
        Blender::KeyBlock* bkb = (Blender::KeyBlock*)bk->block.first;

        // skip first shape key (basis)
        if(bkb) bkb = bkb->next;
        while(bkb)
        {
            if(bkb->type == KEY_RELATIVE)
            {
                Blender::KeyBlock* basis = (Blender::KeyBlock*)bk->block.first;
                for(int i=0; basis && i<bkb->relative; i++)
                    basis = basis->next;

                if(basis)
                    shapes.push_back(bkb->name);
            }
            bkb = bkb->next;
        }
    }
}
开发者ID:erwincoumans,项目名称:astojilj_animkit,代码行数:24,代码来源:akMeshLoader.cpp


示例10: lua_rawgeti

void LSLuaState::cacheAssemblyTypes(Assembly *assembly, utArray<Type *>& types)
{
    // setup assembly type lookup field
    lua_rawgeti(L, LUA_GLOBALSINDEX, LSASSEMBLYLOOKUP);
    lua_pushlightuserdata(L, assembly);
    lua_setfield(L, -2, assembly->getName().c_str());
    lua_pop(L, 1);

    assembly->ordinalTypes = new Type *[types.size() + 1];

    for (UTsize j = 0; j < types.size(); j++)
    {
        Type *type = types.at(j);

        assembly->types.insert(type->getName(), type);

        lmAssert(type->getTypeID() > 0 && type->getTypeID() <= (LSTYPEID)types.size(), "LSLuaState::cacheAssemblyTypes TypeID out of range");

        assembly->ordinalTypes[type->getTypeID()] = type;

        const char *typeName = type->getFullName().c_str();

        // fast access cache
        if (!strcmp(typeName, "system.Object"))
        {
            objectType = type;
        }
        else if (!strcmp(typeName, "system.Null"))
        {
            nullType = type;
        }
        else if (!strcmp(typeName, "system.Boolean"))
        {
            booleanType = type;
        }
        else if (!strcmp(typeName, "system.Number"))
        {
            numberType = type;
        }
        else if (!strcmp(typeName, "system.String"))
        {
            stringType = type;
        }
        else if (!strcmp(typeName, "system.Function"))
        {
            functionType = type;
        }
        else if (!strcmp(typeName, "system.Vector"))
        {
            vectorType = type;
        }

        lua_rawgeti(L, LUA_GLOBALSINDEX, LSINDEXMEMBERINFONAME);
        lua_pushlightuserdata(L, type);
        lua_gettable(L, -2);

        // cache all members for fast lookup of memberinfo -> pre-interned
        // lua string (interning strings is the devil's work)
        if (lua_isnil(L, -1))
        {
            lua_pop(L, 1);

            utArray<MemberInfo *> members;
            MemberTypes           types;
            types.method   = true;
            types.field    = true;
            types.property = true;
            type->findMembers(types, members, false);

            // cache the type to member info table
            lua_pushlightuserdata(L, type);
            lua_pushstring(L, type->getName());
            lua_settable(L, -3);

            for (UTsize i = 0; i < members.size(); i++)
            {
                MemberInfo *mi = members.at(i);

                lua_pushlightuserdata(L, mi);
                lua_pushstring(L, mi->getName());
                lua_settable(L, -3);
            }
        }
        else
        {
            lua_pop(L, 1);
        }

        lua_pop(L, 1);

        // if we weren't cached during assembly load, cache now
        if (!typeCache.get(type->getFullName()))
        {
            typeCache.insert(type->getFullName(), type);
        }
    }

    lmAssert(nullType, "LSLuaState::cacheAssemblyTypes - system.Null not found");
    lmAssert(booleanType, "LSLuaState::cacheAssemblyTypes - system.Boolean not found");
    lmAssert(numberType, "LSLuaState::cacheAssemblyTypes - system.Number not found");
//.........这里部分代码省略.........
开发者ID:Bewolf2,项目名称:LoomSDK,代码行数:101,代码来源:lsLuaState.cpp


示例11: processFileEntryDeltas

// Take a difference report from compareFileEntries and issue appropriate
// file modification notes, and check whether they have settled. If so,
// transmit updates to clients.
static void processFileEntryDeltas(utArray<FileEntryDelta> *deltas)
{
    int curTime = platform_getMilliseconds();

    loom_mutex_lock(gFileScannerLock);

    // Update the pending list with all the stuff we've seen.
    for (UTsize i = 0; i < deltas->size(); i++)
    {
        // Get the delta.
        const FileEntryDelta& fed = deltas->at(i);

        // If it's removal, we don't currently send a notification.
        if (fed.action == FileEntryDelta::Removed)
        {
            continue;
        }

        // If it's not whitelisted, ignore it.
        if (!checkInWhitelist(fed.path))
        {
            continue;
        }

        // Note it in the pending modification list.
        bool sawInList = false;
        for (UTsize i = 0; i < gPendingModifications.size(); i++)
        {
            FileModificationNote& fmn = gPendingModifications.at(i);
            if (strcmp(fmn.path, fed.path.c_str()))
            {
                continue;
            }

            // Match - update time.
            lmLogDebug(gAssetAgentLogGroup, "FILE CHANGING - '%s'", fed.path.c_str());
            fmn.lastSeenTime = curTime;
            sawInList        = true;
        }

        if (!sawInList)
        {
            FileModificationNote fmn;
            fmn.path         = stringtable_insert(fed.path.c_str());
            fmn.lastSeenTime = curTime;
            gPendingModifications.push_back(fmn);
            lmLogDebug(gAssetAgentLogGroup, "FILE CHANGED  - '%s'", fed.path.c_str());
        }
    }

    // Now, walk the pending list and send everyone who hasn't been touched for the settling period.

    // See how many files we're sending and note that state.
    const int settleTimeMs = 750;

    int transferStartTime     = platform_getMilliseconds();
    int totalPendingTransfers = 0;
    for (UTsize i = 0; i < gPendingModifications.size(); i++)
    {
        // Only consider pending items that have aged out.
        FileModificationNote& fmn = gPendingModifications.at(i);
        if (curTime - fmn.lastSeenTime < settleTimeMs)
        {
            continue;
        }

        totalPendingTransfers++;
    }

    bool didWeNotifyUserAboutPending = false;

    for (UTsize i = 0; i < gPendingModifications.size(); i++)
    {
        // Only consider pending items that have aged out.
        FileModificationNote& fmn = gPendingModifications.at(i);
        if (curTime - fmn.lastSeenTime < settleTimeMs)
        {
            continue;
        }

        // Make the path canonical.
        utString filename = fmn.path;
        char     canonicalFile[MAXPATHLEN];
        makeAssetPathCanonical(filename.c_str(), canonicalFile);

        // Note: we don't deal with deleted files properly (by uploading new state) because realpath
        // only works right when the file exists. So we just skip doing anything about it.
        // Note we are using gActiveHandlers.size() outside of a lock, but this is ok as it's a word.
        if ((strstr(canonicalFile, ".loom") || strstr(canonicalFile, ".ls")) && (gActiveHandlers.size() > 0))
        {
            lmLog(gAssetAgentLogGroup, "Changed '%s'", canonicalFile);
        }

        if (canonicalFile[0] == 0)
        {
            lmLog(gAssetAgentLogGroup, "   o Ignoring file missing from the asset folder!");

//.........这里部分代码省略.........
开发者ID:Y-way,项目名称:LoomSDK,代码行数:101,代码来源:main.cpp


示例12: addVertex

    void addVertex(unsigned int fi, unsigned int bindex, const akMeshLoader::TempVert& ref)
    {
        utArray<float> uvs;
        for(int j=0; j<AK_UV_MAX; j++)
        {
            uvs.push_back(ref.uv[j][0]);
            uvs.push_back(ref.uv[j][1]);
        }
        UTuint32 id = item->addVertex(ref.co, ref.no, ref.vcol, uvs);
        idxmap.push_back(bindex);

        // vgroups
        if(m_bmesh->dvert)
        {
            Blender::MDeformVert& dv = m_bmesh->dvert[bindex];
            for(int j=0; j<dv.totweight; j++)
            {
                UTuint32 vgi = dv.dw[j].def_nr;
                if( vgi < item->getNumVertexGroups() )
                {
                    akVertexGroup* vg = item->getVertexGroup(vgi);
                    vg->add(id, dv.dw[j].weight);
                }
            }
        }

        // morphtargets
        if(m_bmesh->key)
        {
            Blender::KeyBlock* bkb = (Blender::KeyBlock*)m_bmesh->key->block.first;

            // skip first shape key (basis)
            int mti=0;
            if(bkb) bkb = bkb->next;
            while(bkb)
            {
                if(bkb->type == KEY_RELATIVE)
                {
                    Blender::KeyBlock* basis = (Blender::KeyBlock*)m_bmesh->key->block.first;
                    for(int i=0; basis && i<bkb->relative; i++)
                        basis = basis->next;

                    if(basis)
                    {
                        //akMorphTarget* mt = item->getMorphTarget(bkb->name);
                        akMorphTarget* mt = item->getMorphTarget(mti);

                        float* kpos = (float*)bkb->data;
                        float* bpos = (float*)basis->data;

                        akVector3 k(kpos[3*bindex+0], kpos[3*bindex+1], kpos[3*bindex+2]);
                        akVector3 b(bpos[3*bindex+0], bpos[3*bindex+1], bpos[3*bindex+2]);
                        k = k-b;

                        btAlignedObjectArray<akVector3>& norms = shapekeysnormals->at(mti);
                        akVector3 normal(0,0,0);

                        const Blender::MFace& bface = m_bmesh->mface[fi];

                        if(bface.flag & ME_SMOOTH)
                        {
                            utArray<UTuint32>& smoothfaces = smoothfacesarray->at(bindex);
                            for (int j = 0; j< smoothfaces.size(); j++)
                            {
                                UTuint32 bface2id = smoothfaces[j];
                                normal += norms.at(bface2id);

                            }
                            normal = normalize(normal);
                        }
                        else
                        {
                            normal = norms.at(fi);
                        }
                        normal = normal - ref.no;

                        if(!akFuzzyT(lengthSqr(k), 1e-10f) || !akFuzzyT(lengthSqr(normal), 1e-10f))
                            mt->add(id, k, normal);

                        mti++;
                    }
                }
                bkb = bkb->next;
            }
        }
    }
开发者ID:erwincoumans,项目名称:astojilj_animkit,代码行数:86,代码来源:akMeshLoader.cpp


示例13: ensureQueueInit

void NativeDelegate::executeDeferredCalls(lua_State *L)
{
    ensureQueueInit();
    loom_mutex_lock(gCallNoteMutex);

    // Try to resolve the delegate pointer.
    utArray<NativeDelegate *> *delegates = NULL;
    if (sActiveNativeDelegates.find(L) != UT_NPOS)
    {
        delegates = *(sActiveNativeDelegates.get(L));
    }
    else
    {
        // No delegate list, can't do it.
        loom_mutex_unlock(gCallNoteMutex);
        return;
    }

    for(unsigned int i=0; i<gNDCallNoteQueue.size(); i++)
    {
        NativeDelegateCallNote *ndcn = gNDCallNoteQueue[i];

        bool found = false;
        for(unsigned int i=0; i<delegates->size(); i++)
        {
            // Look for our delegate.
            if((*delegates)[i] != ndcn->delegate)
                continue;

            // If key mismatches, warn and bail.
            if((*delegates)[i]->_key != ndcn->delegateKey)
            {
                lmLogError(gNativeDelegateGroup, "Found delegate call note with key mismatch (delegate=%x actualKey=%x expectedKey=%x), ignoring...", (*delegates)[i], (*delegates)[i]->_key, ndcn->delegateKey);
                break;
            }

            // Match!
            found = true;
            break;
        }

        // Bail if no match.
        if(!found)
            continue;

        // Otherwise, let's call it.
        const NativeDelegate *theDelegate = ndcn->delegate;
        for(;;)
        {
            unsigned char actionType = ndcn->readByte();
            bool done = false;
            char *str = NULL;
            utByteArray *bytes;
            switch(actionType)
            {
                case MSG_Nop:
                    lmLogError(gNativeDelegateGroup, "Got a nop in delegate data stream.");
                break;

                case MSG_PushString:
                    str = ndcn->readString();
                    theDelegate->pushArgument(str);
                    free(str);
                    break;

                case MSG_PushByteArray:
                    bytes = ndcn->readByteArray();
                    theDelegate->pushArgument(bytes);
                    free(bytes);
                    break;

                case MSG_PushDouble:
                    theDelegate->pushArgument(ndcn->readDouble());
                    break;

                case MSG_PushFloat:
                    theDelegate->pushArgument(ndcn->readFloat());
                    break;
                
                case MSG_PushInt:
                    theDelegate->pushArgument((int)ndcn->readInt());
                    break;
                
                case MSG_PushBool:
                    theDelegate->pushArgument(ndcn->readBool());
                    break;

                case MSG_Invoke:
                    theDelegate->invoke();
                    done = true;
                    break;
            }

            if(done)
                break;
        }

    }

    // Purge queue.
//.........这里部分代码省略.........
开发者ID:24BitGames,项目名称:LoomSDK,代码行数:101,代码来源:lsNativeDelegate.cpp


示例14: while

void gkBlenderSceneConverter::convertGroups(utArray<Blender::Object*> &groups)
{
	gkGroupManager* mgr = gkGroupManager::getSingletonPtr();

	// This is a complete list of groups & containing objects.
	// The gkGameObjectGroup is a containter, the gkGameObjectGroupInstance
	// is where the object should be added / removed from the scene.
	
	//	for (Blender::Group* bgrp = (Blender::Group*)m_file->_getInternalFile()->m_group.first; bgrp != 0; 
	//	bgrp = (Blender::Group*)bgrp->id.next)

	gkBlendListIterator iter = m_file->_getInternalFile()->getGroupList();
	while (iter.hasMoreElements())
	{
		Blender::Group* bgrp = (Blender::Group*)iter.getNext();


		const gkResourceName groupName(GKB_IDNAME(bgrp), m_groupName);

		if (mgr->exists(groupName))
		{
			// Can most likely assert here
			continue;
		}

		gkGameObjectGroup* group = (gkGameObjectGroup*)mgr->create(groupName);


		for (Blender::GroupObject* bgobj = (Blender::GroupObject*)bgrp->gobject.first; bgobj; bgobj = bgobj->next)
		{
			if (bgobj->ob)
			{
				Blender::Object* bobj = bgobj->ob;

				if (!validObject(bobj))
					continue;

				gkGameObject* gobj = m_gscene->getObject(GKB_IDNAME(bobj));

				// add it to the list
				if (gobj)
					group->addObject(gobj);
			}
		}

		// Destroy if empty
		if (group->isEmpty())
			mgr->destroy(group);
		else
			mgr->attachGroupToScene(m_gscene, group);

	}

	// Process user created groups.
	utArray<Blender::Object*>::Iterator it = groups.iterator();
	while (it.hasMoreElements())
	{
		Blender::Object* bobj = it.getNext();


		// Should not fail
		GK_ASSERT((bobj->transflag& OB_DUPLIGROUP && bobj->dup_group != 0));


		// Owning group
		Blender::Group* bgobj = bobj->dup_group;
		const gkResourceName groupName(GKB_IDNAME(bgobj), m_groupName);


		if (mgr->exists(groupName))
		{
			gkGameObjectGroup* ggobj = (gkGameObjectGroup*)mgr->getByName(groupName);


			gkGameObjectInstance* inst = ggobj->createGroupInstance(m_gscene, gkResourceName(GKB_IDNAME(bobj), m_groupName));
			if (inst)
				convertObject(bobj, inst->getRoot());
		}
	}
}
开发者ID:Draion,项目名称:Gamekit,代码行数:80,代码来源:gkBlenderSceneConverter.cpp


示例15: NativeDelegateCallNote

namespace LS {
utHashTable<utPointerHashKey, utArray<NativeDelegate *> *> NativeDelegate::sActiveNativeDelegates;
static const int scmBadThreadID = 0xBAADF00D;
int              NativeDelegate::smMainThreadID = scmBadThreadID;

/**
 * Responsible for storing and recalling serialized NativeDelegate calls.
 *
 * Used internally by NativeDelegate for "async" delegate calls.
 */
struct NativeDelegateCallNote
{
    // Keep a reference to the delegate we're working with. This is used as a key
    // and verified against the global list of valid nativedelegates before being
    // dereferenced. The delegateKey is used to disambiguate new allocations at 
    // the same memory location.
    const NativeDelegate *delegate;
    int delegateKey;

    // Storage for serialized parameters.
    unsigned char *data;
    unsigned int ndata;

    // Current offset in data for read or write.
    unsigned int offset;

    NativeDelegateCallNote(const NativeDelegate *target)
    {
        // Note our target delegate.
        delegate = target;
        delegateKey = target->_key;

        // Start with enough buffer space we won't need to realloc in most cases.
        ndata = 512; 
        data = (unsigned char*)lmAlloc(NULL, ndata);
        offset = 0;
    }

    ~NativeDelegateCallNote()
    {
        delegate = NULL;
        delegateKey = -1;
        
        if(data)
        {        
            free(data);
            data = NULL;
        }
        ndata = -1;
        
        offset = -1;
    }

    // Make sure we have enough room to write freeBytes, and grow the buffer
    // if we don't.
    void ensureBuffer(unsigned int freeBytes)
    {
        // Nop if enough free space.
        if(offset+freeBytes<ndata)
            return;

        ndata = offset + freeBytes; // Resize to requested size
        ndata += ndata / 2; // Allocate 0.5x more
        if (ndata < 4096) ndata = 4096;

        data = (unsigned char*)lmRealloc(NULL, data, ndata);

    }

    void writeByte(unsigned char value)
    {
        ensureBuffer(1);
        data[offset] = value;
        offset++;
    }

    void writeBytes(const char* value, UTsize size)
    {
        ensureBuffer(size);
        memcpy(data + sizeof(unsigned char)*offset, value, size);
        offset += size;
    }

    void writeInt(unsigned int value)
    {
        ensureBuffer(4);
        memcpy(&data[offset], &value, sizeof(unsigned int));
        offset += 4;
    }

    void writeFloat(float value)
    {
        ensureBuffer(4);
        memcpy(&data[offset], &value, sizeof(float));
        offset += 4;
    }

    void writeDouble(double value)
    {
        ensureBuffer(8);
//.........这里部分代码省略.........
开发者ID:24BitGames,项目名称:LoomSDK,代码行数:101,代码来源:lsNativeDelegate.cpp


示例16: assetAgent_command

void DLLEXPORT assetAgent_command(const char *cmd)
{
    if (strstr(cmd, ".sendall") != 0)
    {
        postAllFiles();
    }
    else if (strstr(cmd, ".clients") != 0)
    {
        listClients();
    }
    else if (strstr(cmd, ".telemetry") != 0)
    {
        TelemetryServer::isRunning() ? TelemetryServer::stop() : TelemetryServer::start();
        assetAgent_command(TelemetryServer::isRunning() ? "telemetryEnable" : "telemetryDisable");
    }
    else if (cmd[0] != 0)
    {
        loom_mutex_lock(gActiveSocketsMutex);

        if (gActiveHandlers.size() == 0)
        {
            if (strcmp(cmd, "terminate") != 0) sendIgnoredError();
        }

        for (UTsize i = 0; i < gActiveHandlers.size(); i++)
        {
            gActiveHandlers[i]->sendCommand(cmd);
        }

        loom_mutex_unlock(gActiveSocketsMutex);
    }
}
开发者ID:Y-way,项目名称:LoomSDK,代码行数:32,代码来源:main.cpp


示例17: loom_asset_pump

void loom_asset_pump()
{
   // Currently we only want to do this on the main thread so piggy back on the
   // native delegate sanity check to bail if on secondary thread.
   if(platform_getCurrentThreadId() != LS::NativeDelegate::smMainThreadID && LS::NativeDelegate::smMainThreadID != 0xBAADF00D)
      return;

   loom_mutex_lock(gAssetLock);

   // Talk to the asset server.
   loom_asset_serviceServer();

   // For now just blast all the data from each file into the asset.
   while(gAssetLoadQueue.size())
   {
      loom_asset_t *asset = gAssetLoadQueue.front();

      // Figure out the type from the path.
      utString path = asset->name;
      int type = loom_asset_recognizeAssetTypeFromPath(path);
      
      if(type == 0)
      {
         lmLog(gAssetLogGroup, "Could not infer type of resource '%s', skipping it...", path.c_str());
         asset->state = loom_asset_t::Unloaded;
         gAssetLoadQueue.erase((UTsize)0, true);
         continue;
      }

      // Open the file.
      void *ptr;
      long size;
      if(!platform_mapFile(asset->name.c_str(), &ptr, &size))
      {
         lmAssert(false, "Could not open file '%s'.", asset->name.c_str());
      }

      // Deserialize it.
      LoomAssetCleanupCallback dtor = NULL;
      void *assetBits = loom_asset_deserializeAsset(path, type, size, ptr, &dtor);

      // Close the file.
      platform_unmapFile(ptr);

      // Instate the asset.
      asset->instate(type, assetBits, dtor);

      // Done! Update queue.
      gAssetLoadQueue.erase((UTsize)0, true);
   }

   loom_mutex_unlock(gAssetLock);
}
开发者ID:Bewolf2,项目名称:LoomSDK,代码行数:53,代码来源:assets.cpp


示例18: loom_asset_registerType

void loom_asset_registerType(unsigned int type, LoomAssetDeserializeCallback deserializer, LoomAssetRecognizerCallback recognizer)
{
    lmAssert(gAssetDeserializerMap.find(type) == UT_NPOS, "Asset type already registered!");

    gAssetDeserializerMap.insert(type, deserializer);
    gRecognizerList.push_back(recognizer);
}
开发者ID:RichardRanft,项目名称:LoomSDK,代码行数:7,代码来源:assets.cpp


示例19: loom_asset_initialize

void loom_asset_initialize(const char *rootUri)
{
    // Set up the lock for the mutex.
    lmAssert(gAssetLock == NULL, "Double initialization!");
    gAssetLock = loom_mutex_create();

    // Note the CWD.
    char tmpBuff[1024];
    platform_getCurrentWorkingDir(tmpBuff, 1024);
    lmLog(gAssetLogGroup, "Current working directory ='%s'", tmpBuff);

    // And the allocator.
    //gAssetAllocator = loom_allocator_initializeTrackerProxyAllocator(loom_allocator_getGlobalHeap());
    gAssetAllocator = (loom_allocator_getGlobalHeap());

    // Clear, it might have been filled up before (for unit tests)
    gAssetLoadQueue.clear();
    gAssetHash.clear();

    // Asset server connection state.
    gAssetServerSocketLock = loom_mutex_create();

    // And set up some default asset types.
    loom_asset_registerType(LATText, loom_asset_textDeserializer, loom_asset_textRecognizer);
    loom_asset_registerType(LATBinary, loom_asset_binaryDeserializer, loom_asset_binaryRecognizer);

    loom_asset_registerImageAsset();
    loom_asset_registerSoundAsset();
    loom_asset_registerScriptAsset();

    // Listen to log and send it if we have a connection.
    loom_log_addListener(loom_asset_logListener, NULL);
}
开发者ID:RichardRanft,项目名称:LoomSDK,代码行数:33,代码来源:assets.cpp


示例20: loom_asset_reload

void loom_asset_reload(const char *name)
{
    loom_mutex_lock(gAssetLock);

    loom_asset_t *asset = loom_asset_getAssetByName(name, 1);

    // Put it in the queue, this will trigger a new blob to be loaded.
    gAssetLoadQueue.push_back(asset);

    loom_mutex_unlock(gAssetLock);
}
开发者ID:RichardRanft,项目名称:LoomSDK,代码行数:11,代码来源:assets.cpp



注:本文中的utArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ utHashTable类代码示例发布时间:2022-05-31
下一篇:
C++ ustring类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap