fix uninitialized camera position in 'VR' / 'camera rendering' mode (causing broken specular reflections in VR)
use debug visualizer camera viewmatrix/projection matrix if not provided, in ER_BULLET_HARDWARE_OPENGL mode. fix broken changeRGBAColor implementation, thanks to Laura for the report!
This commit is contained in:
@@ -64,6 +64,20 @@ SimpleCamera::~SimpleCamera()
|
|||||||
void SimpleCamera::setVRCamera(const float viewMat[16], const float projectionMatrix[16])
|
void SimpleCamera::setVRCamera(const float viewMat[16], const float projectionMatrix[16])
|
||||||
{
|
{
|
||||||
m_data->m_enableVR = true;
|
m_data->m_enableVR = true;
|
||||||
|
|
||||||
|
b3Matrix3x3 vm;
|
||||||
|
vm.setValue(viewMat[0],viewMat[4],viewMat[8],
|
||||||
|
viewMat[1],viewMat[5],viewMat[9],
|
||||||
|
viewMat[2],viewMat[6],viewMat[10]);
|
||||||
|
|
||||||
|
b3Vector3 vp = b3MakeVector3(viewMat[12],viewMat[13],viewMat[14]);
|
||||||
|
b3Transform tr;
|
||||||
|
tr.setBasis(vm);
|
||||||
|
tr.setOrigin(vp);
|
||||||
|
b3Transform cp = tr.inverse();
|
||||||
|
m_data->m_cameraPosition = cp.getOrigin();
|
||||||
|
|
||||||
|
|
||||||
for (int i=0;i<16;i++)
|
for (int i=0;i<16;i++)
|
||||||
{
|
{
|
||||||
m_data->m_viewMatrixVR[i] = viewMat[i];
|
m_data->m_viewMatrixVR[i] = viewMat[i];
|
||||||
|
|||||||
@@ -3509,17 +3509,50 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
int* segmentationMaskBuffer = (int*)(bufferServerToClient+numRequestedPixels*8);
|
int* segmentationMaskBuffer = (int*)(bufferServerToClient+numRequestedPixels*8);
|
||||||
|
|
||||||
serverStatusOut.m_numDataStreamBytes = numRequestedPixels * totalBytesPerPixel;
|
serverStatusOut.m_numDataStreamBytes = numRequestedPixels * totalBytesPerPixel;
|
||||||
|
float viewMat[16];
|
||||||
|
float projMat[16];
|
||||||
|
for (int i=0;i<16;i++)
|
||||||
|
{
|
||||||
|
viewMat[i] = clientCmd.m_requestPixelDataArguments.m_viewMatrix[i];
|
||||||
|
projMat[i] = clientCmd.m_requestPixelDataArguments.m_projectionMatrix[i];
|
||||||
|
}
|
||||||
|
if ((clientCmd.m_updateFlags & REQUEST_PIXEL_ARGS_HAS_CAMERA_MATRICES)==0)
|
||||||
|
{
|
||||||
|
b3OpenGLVisualizerCameraInfo tmpCamResult;
|
||||||
|
bool result = this->m_data->m_guiHelper->getCameraInfo(
|
||||||
|
&tmpCamResult.m_width,
|
||||||
|
&tmpCamResult.m_height,
|
||||||
|
tmpCamResult.m_viewMatrix,
|
||||||
|
tmpCamResult.m_projectionMatrix,
|
||||||
|
tmpCamResult.m_camUp,
|
||||||
|
tmpCamResult.m_camForward,
|
||||||
|
tmpCamResult.m_horizontal,
|
||||||
|
tmpCamResult.m_vertical,
|
||||||
|
&tmpCamResult.m_yaw,
|
||||||
|
&tmpCamResult.m_pitch,
|
||||||
|
&tmpCamResult.m_dist,
|
||||||
|
tmpCamResult.m_target);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
for (int i=0;i<16;i++)
|
||||||
|
{
|
||||||
|
viewMat[i] = tmpCamResult.m_viewMatrix[i];
|
||||||
|
projMat[i] = tmpCamResult.m_projectionMatrix[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((clientCmd.m_updateFlags & ER_BULLET_HARDWARE_OPENGL)!=0)
|
if ((clientCmd.m_updateFlags & ER_BULLET_HARDWARE_OPENGL)!=0)
|
||||||
{
|
{
|
||||||
m_data->m_guiHelper->copyCameraImageData(clientCmd.m_requestPixelDataArguments.m_viewMatrix,
|
|
||||||
clientCmd.m_requestPixelDataArguments.m_projectionMatrix,pixelRGBA,numRequestedPixels,
|
m_data->m_guiHelper->copyCameraImageData(viewMat,
|
||||||
|
projMat,pixelRGBA,numRequestedPixels,
|
||||||
depthBuffer,numRequestedPixels,
|
depthBuffer,numRequestedPixels,
|
||||||
segmentationMaskBuffer, numRequestedPixels,
|
segmentationMaskBuffer, numRequestedPixels,
|
||||||
startPixelIndex,width,height,&numPixelsCopied);
|
startPixelIndex,width,height,&numPixelsCopied);
|
||||||
|
|
||||||
m_data->m_guiHelper->debugDisplayCameraImageData(clientCmd.m_requestPixelDataArguments.m_viewMatrix,
|
m_data->m_guiHelper->debugDisplayCameraImageData(viewMat,
|
||||||
clientCmd.m_requestPixelDataArguments.m_projectionMatrix,pixelRGBA,numRequestedPixels,
|
projMat,pixelRGBA,numRequestedPixels,
|
||||||
depthBuffer,numRequestedPixels,
|
depthBuffer,numRequestedPixels,
|
||||||
0, numRequestedPixels,
|
0, numRequestedPixels,
|
||||||
startPixelIndex,width,height,&numPixelsCopied);
|
startPixelIndex,width,height,&numPixelsCopied);
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ struct MyTexture2
|
|||||||
struct TinyRendererObjectArray
|
struct TinyRendererObjectArray
|
||||||
{
|
{
|
||||||
btAlignedObjectArray< TinyRenderObjectData*> m_renderObjects;
|
btAlignedObjectArray< TinyRenderObjectData*> m_renderObjects;
|
||||||
|
int m_objectUniqueId;
|
||||||
|
int m_linkIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define START_WIDTH 640
|
#define START_WIDTH 640
|
||||||
@@ -596,8 +598,11 @@ void TinyRendererVisualShapeConverter::convertVisualShapes(
|
|||||||
m_data->m_swRenderInstances.insert(colObj,new TinyRendererObjectArray);
|
m_data->m_swRenderInstances.insert(colObj,new TinyRendererObjectArray);
|
||||||
}
|
}
|
||||||
visualsPtr = m_data->m_swRenderInstances[colObj];
|
visualsPtr = m_data->m_swRenderInstances[colObj];
|
||||||
|
|
||||||
btAssert(visualsPtr);
|
btAssert(visualsPtr);
|
||||||
TinyRendererObjectArray* visuals = *visualsPtr;
|
TinyRendererObjectArray* visuals = *visualsPtr;
|
||||||
|
visuals->m_objectUniqueId = bodyUniqueId;
|
||||||
|
visuals->m_linkIndex = linkIndex;
|
||||||
|
|
||||||
b3VisualShapeData visualShape;
|
b3VisualShapeData visualShape;
|
||||||
visualShape.m_objectUniqueId = bodyUniqueId;
|
visualShape.m_objectUniqueId = bodyUniqueId;
|
||||||
@@ -699,6 +704,8 @@ int TinyRendererVisualShapeConverter::getVisualShapesData(int bodyUniqueId, int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4])
|
void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int linkIndex, const double rgbaColor[4])
|
||||||
{
|
{
|
||||||
int start = -1;
|
int start = -1;
|
||||||
@@ -706,33 +713,32 @@ void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int lin
|
|||||||
{
|
{
|
||||||
if (m_data->m_visualShapes[i].m_objectUniqueId == bodyUniqueId && m_data->m_visualShapes[i].m_linkIndex == linkIndex)
|
if (m_data->m_visualShapes[i].m_objectUniqueId == bodyUniqueId && m_data->m_visualShapes[i].m_linkIndex == linkIndex)
|
||||||
{
|
{
|
||||||
start = i;
|
|
||||||
m_data->m_visualShapes[i].m_rgbaColor[0] = rgbaColor[0];
|
m_data->m_visualShapes[i].m_rgbaColor[0] = rgbaColor[0];
|
||||||
m_data->m_visualShapes[i].m_rgbaColor[1] = rgbaColor[1];
|
m_data->m_visualShapes[i].m_rgbaColor[1] = rgbaColor[1];
|
||||||
m_data->m_visualShapes[i].m_rgbaColor[2] = rgbaColor[2];
|
m_data->m_visualShapes[i].m_rgbaColor[2] = rgbaColor[2];
|
||||||
m_data->m_visualShapes[i].m_rgbaColor[3] = rgbaColor[3];
|
m_data->m_visualShapes[i].m_rgbaColor[3] = rgbaColor[3];
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (start>=0)
|
|
||||||
{
|
|
||||||
TinyRendererObjectArray** visualArrayPtr = m_data->m_swRenderInstances.getAtIndex(start);
|
|
||||||
if (visualArrayPtr && *visualArrayPtr)
|
|
||||||
{
|
|
||||||
TinyRendererObjectArray* visualArray = *visualArrayPtr;
|
|
||||||
|
|
||||||
btHashPtr colObjHash = m_data->m_swRenderInstances.getKeyAtIndex(start);
|
|
||||||
const btCollisionObject* colObj = (btCollisionObject*) colObjHash.getPointer();
|
|
||||||
|
|
||||||
|
for (int i=0;i<m_data->m_swRenderInstances.size();i++)
|
||||||
|
{
|
||||||
|
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(i);
|
||||||
|
if (ptrptr && *ptrptr)
|
||||||
|
{
|
||||||
float rgba[4] = {rgbaColor[0], rgbaColor[1], rgbaColor[2], rgbaColor[3]};
|
float rgba[4] = {rgbaColor[0], rgbaColor[1], rgbaColor[2], rgbaColor[3]};
|
||||||
for (int v=0;v<visualArray->m_renderObjects.size();v++)
|
TinyRendererObjectArray* visuals = *ptrptr;
|
||||||
|
if ((bodyUniqueId == visuals->m_objectUniqueId) && (linkIndex == visuals->m_linkIndex))
|
||||||
{
|
{
|
||||||
visualArray->m_renderObjects[v]->m_model->setColorRGBA(rgba);
|
for (int q=0;q<visuals->m_renderObjects.size();q++)
|
||||||
|
{
|
||||||
|
visuals->m_renderObjects[q]->m_model->setColorRGBA(rgba);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TinyRendererVisualShapeConverter::setUpAxis(int axis)
|
void TinyRendererVisualShapeConverter::setUpAxis(int axis)
|
||||||
{
|
{
|
||||||
m_data->m_upAxis = axis;
|
m_data->m_upAxis = axis;
|
||||||
|
|||||||
Reference in New Issue
Block a user