Beispiel #1
0
int RigidObject::deserialize(DataBuffer * data)
{
	if (!physInit || data == NULL || data->getSize() != getSerializedSize()) return -1;

	btVector3 pos = body->getCenterOfMassPosition();
	btVector3 linVel = body->getLinearVelocity();
	btQuaternion orient = body->getOrientation();
	btVector3 angVel = body->getAngularVelocity();

	float floatData[13];
	memcpy(&floatData[0],	&data->getData()[8],	4);
	memcpy(&floatData[1],	&data->getData()[12],	4);
	memcpy(&floatData[2],	&data->getData()[16],	4);
	memcpy(&floatData[3],	&data->getData()[20],	4);
	memcpy(&floatData[4],	&data->getData()[24],	4);
	memcpy(&floatData[5],	&data->getData()[28],	4);
	memcpy(&floatData[6],	&data->getData()[32],	4);
	memcpy(&floatData[7],	&data->getData()[36],	4);
	memcpy(&floatData[8],	&data->getData()[40],	4);
	memcpy(&floatData[9],	&data->getData()[44],	4);
	memcpy(&floatData[10],	&data->getData()[48],	4);
	memcpy(&floatData[11],	&data->getData()[52],	4);
	memcpy(&floatData[12],	&data->getData()[56],	4);

	btTransform newTransform = btTransform(btQuaternion(floatData[6], floatData[7], floatData[8], floatData[9]), btVector3(floatData[0], floatData[1], floatData[2]));
	body->setWorldTransform(newTransform);
	body->setLinearVelocity(btVector3(floatData[3], floatData[4], floatData[5]));
	body->setAngularVelocity(btVector3(floatData[10], floatData[11], floatData[12]));

	return 0;
}
Beispiel #2
0
	/**
	* Processes the first message of the Zero Knowledge protocol:
	*  "COMPUTE the first message a in sigma, using (x,w) as input
	*	SEND a to V".
	* @param input
	*/
	void processFirstMsg(shared_ptr<SigmaProverInput>  input) {
		// compute the first message by the underlying proverComputation.
		auto a = sProver->computeFirstMsg(input);
		auto msg = a->toByteArray();
		int len = a->getSerializedSize();
		// send the first message.
		sendMsgToVerifier(msg.get(), len);
	}
Beispiel #3
0
   UInt8 *serialize()
   {
 	    UInt32 size = getSerializedSize();
       UInt8 * result = new UInt8[size];
       int pos = 0;
       iviLink::stringToBuffer(mName, result);
       pos += iviLink::stringInBufSize(mName);
       iviLink::stringToBuffer(mAddress, result + pos);
       pos += iviLink::stringInBufSize(mAddress);
       *(reinterpret_cast<UInt32*>(result+pos))=ByteOrder::hton32(mConnection);
       pos += sizeof(UInt32);
       iviLink::stringToBuffer(mUid.value(), result + pos);
       pos += iviLink::stringInBufSize(mUid.value());
       *(reinterpret_cast<UInt64*>(result+pos))=ByteOrder::hton64(static_cast<UInt64>(mLastSeenTime));
       pos += sizeof(UInt64);
       *(reinterpret_cast<UInt32*>(result+pos))=ByteOrder::hton32(mOS);
       pos += sizeof(UInt32);
       return result;
   }
std::vector<EntryInfo> ConcurrentTableSharedStore::getEntriesInfo() {
    auto entries = std::vector<EntryInfo> {};

    int64_t curr_time = time(nullptr);
    entries.reserve(m_vars.size() + 1000);

    {
        WriteLock l(m_lock);
        for (Map::iterator iter = m_vars.begin(); iter != m_vars.end(); ++iter) {
            const auto key = iter->first;
            const auto sval = &iter->second;

            int32_t size;
            auto type = EntryInfo::Type::Unknown;
            auto const inMem = sval->data.match(
            [&] (APCHandle* handle) {
                size = sval->dataSize;
                type = EntryInfo::getAPCType(handle);
                return true;
            },
            [&] (char*) {
                size = sval->getSerializedSize();
                return false;
            }
                               );

            int64_t ttl = 0;
            if (inMem && sval->expire) {
                ttl = sval->expire - curr_time;
                if (ttl == 0) ttl = 1; // don't want to confuse with primed keys
            }

            entries.emplace_back(key, inMem, size, ttl, type);
        }
    }
    std::sort(entries.begin(), entries.end(),
    [] (const EntryInfo& e1, const EntryInfo& e2) {
        return e1.key < e2.key;
    });
    return entries;
}
Beispiel #5
0
DataBuffer * RigidObject::serialize()
{
	if (!physInit) return NULL;

	btVector3 pos = body->getCenterOfMassPosition();
	btVector3 linVel = body->getLinearVelocity();
	btQuaternion orient = body->getOrientation();
	btVector3 angVel = body->getAngularVelocity();

	DataBuffer * tempBuffer = new DataBuffer(getSerializedSize());

	float test = 1.0f;
	memcpy(&test, &pos.x(), 4);

	int uninit = -1;
	tempBuffer->copy(0, &uninit, 4); //function ID
	
	unsigned long netID = getNetID();
	tempBuffer->copy(4, &netID, 4);
	tempBuffer->copy(8,		&pos.x(),		4);
	tempBuffer->copy(12,	&pos.y(),		4);
	tempBuffer->copy(16,	&pos.z(),		4);
	tempBuffer->copy(20,	&linVel.x(),	4);
	tempBuffer->copy(24,	&linVel.y(),	4);
	tempBuffer->copy(28,	&linVel.z(),	4);
	tempBuffer->copy(32,	&orient.x(),	4);
	tempBuffer->copy(36,	&orient.y(),	4);
	tempBuffer->copy(40,	&orient.z(),	4);
	tempBuffer->copy(44,	&orient.w(),	4);
	tempBuffer->copy(48,	&angVel.x(),	4);
	tempBuffer->copy(52,	&angVel.y(),	4);
	tempBuffer->copy(56,	&angVel.z(),	4);

	tempBuffer->copy(60, "\n", 1);

	return tempBuffer;
}