add proper 'App_PhysicsServerUDP' without shared memory usage, and renamed previous one into 'App_PhysicsServerSharedMemoryBridgeUDP'
(premake only, no cmake build rules yet)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "../MultiThreading/b3ThreadSupportInterface.h"
|
||||
void UDPThreadFunc(void* userPtr, void* lsMemory);
|
||||
void* UDPlsMemoryFunc();
|
||||
bool gVerboseNetworkMessagesClient = false;
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "../MultiThreading/b3PosixThreadSupport.h"
|
||||
@@ -101,6 +102,7 @@ struct UdpNetworkedInternalData
|
||||
if (enet_initialize() != 0)
|
||||
{
|
||||
fprintf(stderr, "Error initialising enet");
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
}
|
||||
@@ -165,13 +167,16 @@ struct UdpNetworkedInternalData
|
||||
break;
|
||||
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
printf("A packet of length %u containing '%s' was "
|
||||
"received from %s on channel %u.\n",
|
||||
m_event.packet->dataLength,
|
||||
m_event.packet->data,
|
||||
m_event.peer->data,
|
||||
m_event.channelID);
|
||||
|
||||
|
||||
if (gVerboseNetworkMessagesClient)
|
||||
{
|
||||
printf("A packet of length %u containing '%s' was "
|
||||
"received from %s on channel %u.\n",
|
||||
m_event.packet->dataLength,
|
||||
m_event.packet->data,
|
||||
m_event.peer->data,
|
||||
m_event.channelID);
|
||||
}
|
||||
/* Clean up the packet now that we're done using it.
|
||||
> */
|
||||
enet_packet_destroy(m_event.packet);
|
||||
@@ -198,7 +203,7 @@ struct UdpNetworkedInternalData
|
||||
{
|
||||
bool hasStatus = false;
|
||||
|
||||
int serviceResult = enet_host_service(m_client, &m_event, 100);
|
||||
int serviceResult = enet_host_service(m_client, &m_event, 0);
|
||||
|
||||
if (serviceResult > 0)
|
||||
{
|
||||
@@ -214,13 +219,15 @@ struct UdpNetworkedInternalData
|
||||
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
{
|
||||
printf("A packet of length %u containing '%s' was "
|
||||
"received from %s on channel %u.\n",
|
||||
m_event.packet->dataLength,
|
||||
m_event.packet->data,
|
||||
m_event.peer->data,
|
||||
m_event.channelID);
|
||||
|
||||
if (gVerboseNetworkMessagesClient)
|
||||
{
|
||||
printf("A packet of length %u containing '%s' was "
|
||||
"received from %s on channel %u.\n",
|
||||
m_event.packet->dataLength,
|
||||
m_event.packet->data,
|
||||
m_event.peer->data,
|
||||
m_event.channelID);
|
||||
}
|
||||
|
||||
int packetSizeInBytes = b3DeserializeInt(m_event.packet->data);
|
||||
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
/* server.cpp */
|
||||
#include <stdio.h>
|
||||
#include <enet/enet.h>
|
||||
#include "SharedMemoryCommandProcessor.h"
|
||||
#include "../../CommonInterfaces/CommonGUIHelperInterface.h"
|
||||
#ifdef NO_SHARED_MEMORY
|
||||
#include "PhysicsServerCommandProcessor.h"
|
||||
typedef PhysicsServerCommandProcessor MyCommandProcessor;
|
||||
#else
|
||||
#include "SharedMemoryCommandProcessor.h"
|
||||
typedef SharedMemoryCommandProcessor MyCommandProcessor ;
|
||||
#endif //NO_SHARED_MEMORY
|
||||
#include "SharedMemoryCommands.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "PhysicsServerCommandProcessor.h"
|
||||
|
||||
|
||||
bool gVerboseNetworkMessagesServer = false;
|
||||
|
||||
void MySerializeInt(unsigned int sz, unsigned char* output)
|
||||
{
|
||||
@@ -22,10 +32,10 @@ void MySerializeInt(unsigned int sz, unsigned char* output)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char buf[4];
|
||||
|
||||
|
||||
SharedMemoryCommandProcessor* sm = new SharedMemoryCommandProcessor;
|
||||
DummyGUIHelper guiHelper;
|
||||
PhysicsCommandProcessorInterface* sm = new MyCommandProcessor;
|
||||
sm->setGuiHelper(&guiHelper);
|
||||
|
||||
// PhysicsDirect* sm = new PhysicsDirect(sdk);
|
||||
|
||||
@@ -95,13 +105,15 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
printf("A packet of length %u containing '%s' was "
|
||||
"received from %s on channel %u.\n",
|
||||
event.packet->dataLength,
|
||||
event.packet->data,
|
||||
event.peer->data,
|
||||
event.channelID);
|
||||
|
||||
if (gVerboseNetworkMessagesServer)
|
||||
{
|
||||
printf("A packet of length %u containing '%s' was "
|
||||
"received from %s on channel %u.\n",
|
||||
event.packet->dataLength,
|
||||
event.packet->data,
|
||||
event.peer->data,
|
||||
event.channelID);
|
||||
}
|
||||
if (event.packet->dataLength == sizeof(SharedMemoryCommand))
|
||||
{
|
||||
SharedMemoryCommand* cmdPtr = (SharedMemoryCommand*)event.packet->data;
|
||||
@@ -117,8 +129,11 @@ int main(int argc, char *argv[])
|
||||
hasStatus = sm->receiveStatus(serverStatus, &buffer[0], buffer.size());
|
||||
|
||||
}
|
||||
printf("buffer.size = %d\n", buffer.size());
|
||||
printf("serverStatus.m_numDataStreamBytes = %d\n", serverStatus.m_numDataStreamBytes);
|
||||
if (gVerboseNetworkMessagesServer)
|
||||
{
|
||||
printf("buffer.size = %d\n", buffer.size());
|
||||
printf("serverStatus.m_numDataStreamBytes = %d\n", serverStatus.m_numDataStreamBytes);
|
||||
}
|
||||
if (hasStatus)
|
||||
{
|
||||
//create packetData with [int packetSizeInBytes, status, streamBytes)
|
||||
@@ -138,13 +153,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (int i = 0; i < serverStatus.m_numDataStreamBytes; i++)
|
||||
{
|
||||
packetData[i + curPos] = serverStatus.m_dataStream[i];
|
||||
packetData[i + curPos] = buffer[i];
|
||||
}
|
||||
|
||||
ENetPacket *packet = enet_packet_create(&packetData[0], packetData.size() , ENET_PACKET_FLAG_RELIABLE);
|
||||
//enet_peer_send(peer, 0, packet);
|
||||
|
||||
enet_host_broadcast(server, 0, packet);
|
||||
enet_peer_send(event.peer, 0, packet);
|
||||
//enet_host_broadcast(server, 0, packet);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
project ("App_PhysicsServerUDP")
|
||||
project ("App_PhysicsServerSharedMemoryBridgeUDP")
|
||||
|
||||
language "C++"
|
||||
|
||||
@@ -9,6 +9,7 @@ project ("App_PhysicsServerUDP")
|
||||
|
||||
if os.is("Windows") then
|
||||
defines { "WIN32" }
|
||||
|
||||
|
||||
links {"Ws2_32","Winmm"}
|
||||
end
|
||||
@@ -44,3 +45,82 @@ project ("App_PhysicsServerUDP")
|
||||
"../../Utils/b3ResourcePath.h",
|
||||
}
|
||||
|
||||
|
||||
project "App_PhysicsServerUDP"
|
||||
|
||||
if _OPTIONS["ios"] then
|
||||
kind "WindowedApp"
|
||||
else
|
||||
kind "ConsoleApp"
|
||||
end
|
||||
|
||||
defines { "NO_SHARED_MEMORY" }
|
||||
|
||||
includedirs {"..","../../../src", "../../ThirdPartyLibs","../../ThirdPartyLibs/enet/include"}
|
||||
|
||||
links {
|
||||
"enet","Bullet3Common","BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision", "LinearMath", "BussIK"
|
||||
}
|
||||
|
||||
if os.is("Windows") then
|
||||
defines { "WIN32" }
|
||||
links {"Ws2_32","Winmm"}
|
||||
end
|
||||
|
||||
language "C++"
|
||||
|
||||
myfiles =
|
||||
{
|
||||
"../IKTrajectoryHelper.cpp",
|
||||
"../IKTrajectoryHelper.h",
|
||||
"../SharedMemoryCommands.h",
|
||||
"../SharedMemoryPublic.h",
|
||||
"../PhysicsServerCommandProcessor.cpp",
|
||||
"../PhysicsServerCommandProcessor.h",
|
||||
"../TinyRendererVisualShapeConverter.cpp",
|
||||
"../TinyRendererVisualShapeConverter.h",
|
||||
"../../TinyRenderer/geometry.cpp",
|
||||
"../../TinyRenderer/model.cpp",
|
||||
"../../TinyRenderer/tgaimage.cpp",
|
||||
"../../TinyRenderer/our_gl.cpp",
|
||||
"../../TinyRenderer/TinyRenderer.cpp",
|
||||
"../../OpenGLWindow/SimpleCamera.cpp",
|
||||
"../../OpenGLWindow/SimpleCamera.h",
|
||||
"../../Importers/ImportURDFDemo/ConvertRigidBodies2MultiBody.h",
|
||||
"../../Importers/ImportURDFDemo/MultiBodyCreationInterface.h",
|
||||
"../../Importers/ImportURDFDemo/MyMultiBodyCreator.cpp",
|
||||
"../../Importers/ImportURDFDemo/MyMultiBodyCreator.h",
|
||||
"../../Importers/ImportURDFDemo/BulletUrdfImporter.cpp",
|
||||
"../../Importers/ImportURDFDemo/BulletUrdfImporter.h",
|
||||
"../../Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||
"../../Importers/ImportURDFDemo/urdfStringSplit.cpp",
|
||||
"../../Importers/ImportURDFDemo/UrdfParser.cpp",
|
||||
"../../Importers/ImportURDFDemo/UrdfParser.h",
|
||||
"../../Importers/ImportURDFDemo/URDF2Bullet.cpp",
|
||||
"../../Importers/ImportURDFDemo/URDF2Bullet.h",
|
||||
"../../Utils/b3ResourcePath.cpp",
|
||||
"../../Utils/b3Clock.cpp",
|
||||
"../../../Extras/Serialize/BulletWorldImporter/*",
|
||||
"../../../Extras/Serialize/BulletFileLoader/*",
|
||||
"../../Importers/ImportURDFDemo/URDFImporterInterface.h",
|
||||
"../../Importers/ImportURDFDemo/URDFJointTypes.h",
|
||||
"../../Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
|
||||
"../../Importers/ImportObjDemo/LoadMeshFromObj.cpp",
|
||||
"../../Importers/ImportSTLDemo/ImportSTLSetup.h",
|
||||
"../../Importers/ImportSTLDemo/LoadMeshFromSTL.h",
|
||||
"../../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
|
||||
"../../Importers/ImportColladaDemo/ColladaGraphicsInstance.h",
|
||||
"../../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
|
||||
"../../ThirdPartyLibs/tinyxml/tinystr.cpp",
|
||||
"../../ThirdPartyLibs/tinyxml/tinyxml.cpp",
|
||||
"../../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
|
||||
"../../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
|
||||
"../../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
|
||||
"../../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
}
|
||||
|
||||
files {
|
||||
myfiles,
|
||||
"main.cpp",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user