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"
|
#include "../MultiThreading/b3ThreadSupportInterface.h"
|
||||||
void UDPThreadFunc(void* userPtr, void* lsMemory);
|
void UDPThreadFunc(void* userPtr, void* lsMemory);
|
||||||
void* UDPlsMemoryFunc();
|
void* UDPlsMemoryFunc();
|
||||||
|
bool gVerboseNetworkMessagesClient = false;
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include "../MultiThreading/b3PosixThreadSupport.h"
|
#include "../MultiThreading/b3PosixThreadSupport.h"
|
||||||
@@ -101,6 +102,7 @@ struct UdpNetworkedInternalData
|
|||||||
if (enet_initialize() != 0)
|
if (enet_initialize() != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error initialising enet");
|
fprintf(stderr, "Error initialising enet");
|
||||||
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -165,13 +167,16 @@ struct UdpNetworkedInternalData
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_RECEIVE:
|
case ENET_EVENT_TYPE_RECEIVE:
|
||||||
|
|
||||||
|
if (gVerboseNetworkMessagesClient)
|
||||||
|
{
|
||||||
printf("A packet of length %u containing '%s' was "
|
printf("A packet of length %u containing '%s' was "
|
||||||
"received from %s on channel %u.\n",
|
"received from %s on channel %u.\n",
|
||||||
m_event.packet->dataLength,
|
m_event.packet->dataLength,
|
||||||
m_event.packet->data,
|
m_event.packet->data,
|
||||||
m_event.peer->data,
|
m_event.peer->data,
|
||||||
m_event.channelID);
|
m_event.channelID);
|
||||||
|
}
|
||||||
/* Clean up the packet now that we're done using it.
|
/* Clean up the packet now that we're done using it.
|
||||||
> */
|
> */
|
||||||
enet_packet_destroy(m_event.packet);
|
enet_packet_destroy(m_event.packet);
|
||||||
@@ -198,7 +203,7 @@ struct UdpNetworkedInternalData
|
|||||||
{
|
{
|
||||||
bool hasStatus = false;
|
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)
|
if (serviceResult > 0)
|
||||||
{
|
{
|
||||||
@@ -213,6 +218,8 @@ struct UdpNetworkedInternalData
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_RECEIVE:
|
case ENET_EVENT_TYPE_RECEIVE:
|
||||||
|
{
|
||||||
|
if (gVerboseNetworkMessagesClient)
|
||||||
{
|
{
|
||||||
printf("A packet of length %u containing '%s' was "
|
printf("A packet of length %u containing '%s' was "
|
||||||
"received from %s on channel %u.\n",
|
"received from %s on channel %u.\n",
|
||||||
@@ -220,7 +227,7 @@ struct UdpNetworkedInternalData
|
|||||||
m_event.packet->data,
|
m_event.packet->data,
|
||||||
m_event.peer->data,
|
m_event.peer->data,
|
||||||
m_event.channelID);
|
m_event.channelID);
|
||||||
|
}
|
||||||
|
|
||||||
int packetSizeInBytes = b3DeserializeInt(m_event.packet->data);
|
int packetSizeInBytes = b3DeserializeInt(m_event.packet->data);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
/* server.cpp */
|
/* server.cpp */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <enet/enet.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 "SharedMemoryCommands.h"
|
||||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||||
#include "PhysicsServerCommandProcessor.h"
|
#include "PhysicsServerCommandProcessor.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool gVerboseNetworkMessagesServer = false;
|
||||||
|
|
||||||
void MySerializeInt(unsigned int sz, unsigned char* output)
|
void MySerializeInt(unsigned int sz, unsigned char* output)
|
||||||
{
|
{
|
||||||
unsigned int tmp = sz;
|
unsigned int tmp = sz;
|
||||||
@@ -22,10 +32,10 @@ void MySerializeInt(unsigned int sz, unsigned char* output)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
unsigned char buf[4];
|
|
||||||
|
|
||||||
|
DummyGUIHelper guiHelper;
|
||||||
SharedMemoryCommandProcessor* sm = new SharedMemoryCommandProcessor;
|
PhysicsCommandProcessorInterface* sm = new MyCommandProcessor;
|
||||||
|
sm->setGuiHelper(&guiHelper);
|
||||||
|
|
||||||
// PhysicsDirect* sm = new PhysicsDirect(sdk);
|
// PhysicsDirect* sm = new PhysicsDirect(sdk);
|
||||||
|
|
||||||
@@ -95,13 +105,15 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_RECEIVE:
|
case ENET_EVENT_TYPE_RECEIVE:
|
||||||
|
if (gVerboseNetworkMessagesServer)
|
||||||
|
{
|
||||||
printf("A packet of length %u containing '%s' was "
|
printf("A packet of length %u containing '%s' was "
|
||||||
"received from %s on channel %u.\n",
|
"received from %s on channel %u.\n",
|
||||||
event.packet->dataLength,
|
event.packet->dataLength,
|
||||||
event.packet->data,
|
event.packet->data,
|
||||||
event.peer->data,
|
event.peer->data,
|
||||||
event.channelID);
|
event.channelID);
|
||||||
|
}
|
||||||
if (event.packet->dataLength == sizeof(SharedMemoryCommand))
|
if (event.packet->dataLength == sizeof(SharedMemoryCommand))
|
||||||
{
|
{
|
||||||
SharedMemoryCommand* cmdPtr = (SharedMemoryCommand*)event.packet->data;
|
SharedMemoryCommand* cmdPtr = (SharedMemoryCommand*)event.packet->data;
|
||||||
@@ -117,8 +129,11 @@ int main(int argc, char *argv[])
|
|||||||
hasStatus = sm->receiveStatus(serverStatus, &buffer[0], buffer.size());
|
hasStatus = sm->receiveStatus(serverStatus, &buffer[0], buffer.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (gVerboseNetworkMessagesServer)
|
||||||
|
{
|
||||||
printf("buffer.size = %d\n", buffer.size());
|
printf("buffer.size = %d\n", buffer.size());
|
||||||
printf("serverStatus.m_numDataStreamBytes = %d\n", serverStatus.m_numDataStreamBytes);
|
printf("serverStatus.m_numDataStreamBytes = %d\n", serverStatus.m_numDataStreamBytes);
|
||||||
|
}
|
||||||
if (hasStatus)
|
if (hasStatus)
|
||||||
{
|
{
|
||||||
//create packetData with [int packetSizeInBytes, status, streamBytes)
|
//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++)
|
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);
|
ENetPacket *packet = enet_packet_create(&packetData[0], packetData.size() , ENET_PACKET_FLAG_RELIABLE);
|
||||||
//enet_peer_send(peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
|
//enet_host_broadcast(server, 0, packet);
|
||||||
enet_host_broadcast(server, 0, packet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
project ("App_PhysicsServerUDP")
|
project ("App_PhysicsServerSharedMemoryBridgeUDP")
|
||||||
|
|
||||||
language "C++"
|
language "C++"
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ project ("App_PhysicsServerUDP")
|
|||||||
if os.is("Windows") then
|
if os.is("Windows") then
|
||||||
defines { "WIN32" }
|
defines { "WIN32" }
|
||||||
|
|
||||||
|
|
||||||
links {"Ws2_32","Winmm"}
|
links {"Ws2_32","Winmm"}
|
||||||
end
|
end
|
||||||
if os.is("Linux") then
|
if os.is("Linux") then
|
||||||
@@ -44,3 +45,82 @@ project ("App_PhysicsServerUDP")
|
|||||||
"../../Utils/b3ResourcePath.h",
|
"../../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