void spring::divideDeformationsAndReset( spring &in ) { // find current spring lengths pReal aLen( ( secondary().position() - primary().position() ).length() ); pReal bLen( ( in.secondary().position() - in.primary().position() ).length() ); // find the total length pReal totalLength( aLen + bLen ); //Initial Rest Length { // find the length we are aiming at pReal aimLength( _initialRestLength ); pReal totalLength( aLen + bLen ); // divide the length between them _initialRestLength = ( aimLength / totalLength ) * aLen; in._initialRestLength = ( aimLength / totalLength ) * bLen; } //Rest Length { pReal aimLength( restLength() ); // divide the length between them restLength( ( aimLength / totalLength ) * aLen ); in.restLength( ( aimLength / totalLength ) * bLen ); } }
vespalib::ConstBufferRef Chunk::getLid(uint32_t lid) const { vespalib::ConstBufferRef buf; for (LidList::const_iterator it(_lids.begin()), mt(_lids.end()); it != mt; it++) { if (it->getLid() == lid) { #if 1 uint32_t bLid(0), bLen(0); vespalib::nbostream is(getData().c_str()+it->getOffset(), it->size()); is >> bLid >> bLen; assert(bLid == lid); assert(bLen == it->netSize()); assert((bLen + 2*sizeof(uint32_t)) == it->size()); #endif buf = vespalib::ConstBufferRef(getData().c_str() + it->getNetOffset(), it->netSize()); } }