#if 1 // removing deprecated senders, set to 0 when FastFlag RemoveUnusedPhysicsSenders is set to true and removed (delete this file) #pragma once #include "PhysicsSender.h" #include "BoostAppend.h" #include "V8DataModel/PartInstance.h" #include #include #include #include #include "rbx/signal.h" #include "boost/pool/pool_alloc.hpp" #include "boost/intrusive/set.hpp" using boost::multi_index_container; using namespace boost::multi_index; namespace RBX { class Instance; class PhysicsService; class ModelInstance; namespace Network { class Replicator; class PhysicsPacketCache; class ErrorCompPhysicsSender : public PhysicsSender { class Nugget; // custom containers typedef std::list, boost::fast_pool_allocator > > NewMovingAssemblies; NewMovingAssemblies newMovingAssemblies; // new moving assemblies for current step typedef boost::intrusive::set_base_hook, boost::intrusive::link_mode > NuggetHook; typedef boost::intrusive::multiset >, boost::intrusive::base_hook > SortedNuggetList; typedef std::list NuggetList; typedef boost::unordered_map, Nugget> NuggetMap; NuggetMap nuggetMap; NuggetList nuggetUpdateList; SortedNuggetList nuggetSendList; class Nugget : public NuggetHook { public: shared_ptr part; double error; int errorStepId; // "stepId" of the last send (-1 means uninitialized. 0 means we just got sent and need updating) Nugget(shared_ptr part); static void onSent(Nugget& nugget); void computeError(const CoordinateFrame& focus, const ModelInstance* focusModel, int timestamp); CoordinateFrame lastSent; // the CF last sent bool sendDetailed; // Should this send detailed (uncompressed) physics info float biggestSize; // May change for an articulated assembly.... float radius; // cached assembly radius static float minDistance(); static float maxDistance(); static float minSize(); static float maxSize(); friend bool operator > (const Nugget &a, const Nugget& b) { return a.error > b.error; } NuggetList::iterator updateListIter; // iterator into update list }; int stepId; shared_ptr physicsService; shared_ptr physicsPacketCache; bool sendDetailed; rbx::signals::scoped_connection addingAssemblyConnection; rbx::signals::scoped_connection removedAssemblyConnection; public: ErrorCompPhysicsSender(Replicator& replicator); ~ErrorCompPhysicsSender(); virtual void step(); virtual int sendPacket(int maxPackets, PacketPriority packetPriority, ReplicatorStats::PhysicsSenderStats* stats); protected: virtual void writeAssembly(RakNet::BitStream& bitStream, const Assembly* assembly, Compressor::CompressionType compressionType, bool crossPacketCompression = false); private: void updateErrors(); bool sendPhysicsData(RakNet::BitStream& bitStream, const Nugget& nugget); void addNugget(PartInstance& part); void addNugget2(shared_ptr part); void onAddingAssembly(shared_ptr assembly); void onRemovedAssembly(shared_ptr assembly); void removeNugget(shared_ptr part); }; } } #endif // removing deprecated senders