/** * Move the right side to the given @param newEnd if possible, else returns zero. * Adding the indices is not possible if a node that needs to be changed has a reference-count higher than * zero, because that means that it is referenced from multiple positions. * Since a once referenced node must never be changed, we cannot expand it then. * * The first appended index will have the index this nodes "end" member had before appendIndices was called. * @note newEnd must be bigger then the old end(indices can only be added) * */ bool expandEnd(Index newEnd) { Q_ASSERT(newEnd >= end); if(ref <= 1) { if(right) { if(right->expandEnd(newEnd)) { end = newEnd; return true; }else{ if(ref <= 1) { //We can expand by adding an intermediate node to the right. SetNode::Ptr newRight(new SetNode); newRight->left = right; newRight->inRepository = inRepository; newRight->contiguous = right->contiguous; newRight->right = SetNode::Ptr(new SetNode); newRight->right->start = right->end; newRight->right->end = newEnd; newRight->right->inRepository = newRight->inRepository; newRight->start = right->start; newRight->end = newEnd; right = newRight; end = newEnd; newRight->right->parentInRepository = newRight.data(); newRight->left->parentInRepository = newRight.data(); newRight->parentInRepository = this; ifDebug(check()); return true; }else{ return false; } } }else{ end = newEnd; return true; } }else{ //The node cannot be changed, because the ref-count is higher than zero return false; } }
void Camera::rotateZ(float amount) { Vec3 target(up); Vec3 newRight(right); up.set( (cos((M_PI/2)+amount)*target.x)+(cos((float)amount)*newRight.x), (cos((M_PI/2)+amount)*target.y)+(cos((float)amount)*newRight.y), (cos((M_PI/2)+amount)*target.z)+(cos((float)amount)*newRight.z)); right.set( (cos((float)amount)*target.x)+(cos((M_PI/2)-amount)*newRight.x), (cos((float)amount)*target.y)+(cos((M_PI/2)-amount)*newRight.y), (cos((float)amount)*target.z)+(cos((M_PI/2)-amount)*newRight.z)); direction.normalize(); right.normalize(); }
void Camera::rotateX(float amount) { Vec3 target(direction); Vec3 newRight(up); SetFocus(Vec3( (cos((M_PI/2)+amount)*target.x)+(cos((float)amount)*newRight.x), (cos((M_PI/2)+amount)*target.y)+(cos((float)amount)*newRight.y), (cos((M_PI/2)+amount)*target.z)+(cos((float)amount)*newRight.z))); up.set( (cos((float)amount)*target.x)+(cos((M_PI/2)-amount)*newRight.x), (cos((float)amount)*target.y)+(cos((M_PI/2)-amount)*newRight.y), (cos((float)amount)*target.z)+(cos((M_PI/2)-amount)*newRight.z)); //pointOfFocus.normalize(); up.normalize(); }