[Bf-blender-cvs] [3774a42] HMD_viewport: Implemented initial support for using HMD projection matrices in blender viewport. Also did some general cleaning
Joey Ferwerda
noreply at git.blender.org
Sun Jul 31 21:25:37 CEST 2016
Commit: 3774a424ea00c7d2a22e48e209dbe4f33840e2f1
Author: Joey Ferwerda
Date: Sun Jul 31 21:24:55 2016 +0200
Branches: HMD_viewport
https://developer.blender.org/rB3774a424ea00c7d2a22e48e209dbe4f33840e2f1
Implemented initial support for using HMD projection matrices in blender viewport.
Also did some general cleaning
===================================================================
M intern/cycles/render/camera.h
M intern/ghost/GHOST_C-api.h
M intern/ghost/intern/GHOST_C-api.cpp
M source/blender/blenkernel/BKE_camera.h
M source/blender/blenkernel/intern/camera.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/gpu/shaders/gpu_shader_fx_lensdistortion_frag.glsl
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_device.c
===================================================================
diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h
index 141ef9c..0caa06f 100644
--- a/intern/cycles/render/camera.h
+++ b/intern/cycles/render/camera.h
@@ -172,7 +172,7 @@ public:
/* functions */
Camera();
~Camera();
-
+
void compute_auto_viewplane();
void update();
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 672de91..2a88e15 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -937,6 +937,10 @@ extern int GHOST_HMDgetOpenDeviceIndex(void);
extern const char *GHOST_HMDgetDeviceName(int index);
extern const char *GHOST_HMDgetVendorName(int index);
extern float GHOST_HMDgetDeviceIPD(void);
+extern void GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[16]);
+extern void GHOST_HMDgetRightModelviewMatrix(float rightMatrix[16]);
+extern void GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[16]);
+extern void GHOST_HMDgetRightProjectionMatrix(float rightMatrix[16]);
#ifdef __cplusplus
}
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index ddf84e1..4bbbbb8 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -120,7 +120,7 @@ void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
GHOST_TUns32 *height)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
system->getMainDisplayDimensions(*width, *height);
}
@@ -167,7 +167,7 @@ GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return system->disposeWindow(window);
}
@@ -178,7 +178,7 @@ int GHOST_ValidWindow(GHOST_SystemHandle systemhandle,
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return (int) system->validWindow(window);
}
@@ -196,7 +196,7 @@ GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
bstereoVisual = true;
else
bstereoVisual = false;
-
+
system->beginFullScreen(*setting, &window, bstereoVisual);
return (GHOST_WindowHandle)window;
@@ -225,7 +225,7 @@ int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return (int) system->processEvents(waitForEvent ? true : false);
}
@@ -234,7 +234,7 @@ int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
system->dispatchEvents();
}
@@ -242,7 +242,7 @@ void GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return system->addEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle);
}
@@ -338,7 +338,7 @@ GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
GHOST_TInt32 *y)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return system->getCursorPosition(*x, *y);
}
@@ -349,7 +349,7 @@ GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
GHOST_TInt32 y)
{
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
-
+
return system->setCursorPosition(x, y);
}
@@ -383,7 +383,7 @@ GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_TSuccess result;
bool isdown = false;
-
+
result = system->getModifierKeyState(mask, isdown);
*isDown = (int) isdown;
@@ -399,7 +399,7 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
GHOST_TSuccess result;
bool isdown = false;
-
+
result = system->getButtonState(mask, isdown);
*isDown = (int) isdown;
@@ -425,7 +425,7 @@ void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 c
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
{
GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
-
+
return event->getType();
}
@@ -450,7 +450,7 @@ GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
{
GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
-
+
return event->getData();
}
@@ -459,7 +459,7 @@ GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
{
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
-
+
return timertask->getTimerProc();
}
@@ -469,7 +469,7 @@ void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
GHOST_TimerProcPtr timerproc)
{
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
-
+
timertask->setTimerProc(timerproc);
}
@@ -488,13 +488,13 @@ void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
GHOST_TUserDataPtr userdata)
{
GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
-
+
timertask->setUserData(userdata);
}
-int GHOST_GetValid(GHOST_WindowHandle windowhandle)
+int GHOST_GetValid(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
@@ -526,7 +526,7 @@ void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
const char *title)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
window->setTitle(title);
}
@@ -662,16 +662,16 @@ GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return window->setModifiedState(isUnsavedChanges);
-}
+}
GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
GHOST_TWindowOrder order)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return window->setOrder(order);
}
@@ -709,7 +709,7 @@ GHOST_TUns16 GHOST_GetNumOfAASamples(GHOST_WindowHandle windowhandle)
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
{
GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
-
+
return window->activateDrawingContext();
}
@@ -1012,4 +1012,43 @@ float GHOST_HMDgetDeviceIPD()
#endif
}
+void GHOST_HMDgetLeftModelviewMatrix(float leftMatrix[16])
+{
+#ifdef WITH_OPENHMD
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
+ ohmd->getLeftEyeGLModelviewMatrix(leftMatrix);
+#else
+#endif
+}
+
+void GHOST_HMDgetRightModelviewMatrix(float rightMatrix[16])
+{
+#ifdef WITH_OPENHMD
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
+ ohmd->getRightEyeGLModelviewMatrix(rightMatrix);
+#else
+#endif
+}
+
+void GHOST_HMDgetLeftProjectionMatrix(float leftMatrix[16])
+{
+#ifdef WITH_OPENHMD
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
+ ohmd->getLeftEyeGLProjectionMatrix(leftMatrix);
+#else
+#endif
+}
+
+void GHOST_HMDgetRightProjectionMatrix(float rightMatrix[16])
+{
+#ifdef WITH_OPENHMD
+ GHOST_ISystem *system = GHOST_ISystem::getSystem();
+ GHOST_OpenHMDManager *ohmd = system->getOpenHMDManager();
+ ohmd->getRightEyeGLProjectionMatrix(rightMatrix);
+#else
+#endif
+}
#endif
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h
index d13a711..b475c87 100644
--- a/source/blender/blenkernel/BKE_camera.h
+++ b/source/blender/blenkernel/BKE_camera.h
@@ -141,6 +141,7 @@ void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_set
struct Object *BKE_camera_multiview_render(struct Scene *scene, struct Object *camera, const char *viewname);
void BKE_camera_multiview_view_matrix(struct RenderData *rd, struct Object *camera, const bool is_left, float r_viewmat[4][4]);
+void BKE_camera_multiview_proj_matrix(const bool is_left, float r_projmat[4][4]);
void BKE_camera_multiview_model_matrix(struct RenderData *rd, struct Object *camera, const char *viewname, float r_modelmat[4][4]);
float BKE_camera_multiview_shift_x(struct RenderData *rd, struct Object *camera, const char *viewname);
void BKE_camera_multiview_params(struct RenderData *rd, struct CameraParams *params, struct Object *camera, const char *viewname);
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 1f6f211e..789b309 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -96,7 +96,7 @@ void *BKE_camera_add(Main *bmain, const char *name)
Camera *BKE_camera_copy(Camera *cam)
{
Camera *camn;
-
+
camn = BKE_libblock_copy(&cam->id);
id_lib_extern((ID *)camn->dof_ob);
@@ -118,20 +118,20 @@ void BKE_camera_make_local(Camera *cam)
* - only local users: set flag
* - mixed: make copy
*/
-
+
if (cam->id.lib == NULL) return;
if (cam->id.us == 1) {
id_clear_lib_data(bmain, &cam->id);
return;
}
-
+
for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
if (ob->data == cam) {
if (ob->id.lib) is_lib = true;
else is_local = true;
}
}
-
+
if (is_local && is_lib == false) {
id_clear_lib_data(bmain, &cam->id);
}
@@ -176,7 +176,7 @@ void BKE_camera_object_mode(RenderData *rd, Object *cam_ob)
/* get the camera's dof value, takes the dof object into account */
float BKE_camera_object_dof_distance(Object *ob)
{
- Camera *cam = (Camera *)ob->data;
+ Camera *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list