Cleanup: reserve C++ comments for disabled code

Use C comments for plain text.
This commit is contained in:
Campbell Barton 2021-07-20 15:01:05 +10:00
parent fe2f43a15c
commit 77e927b58f
39 changed files with 798 additions and 772 deletions

@ -217,7 +217,7 @@ static void makeAttribList(std::vector<NSOpenGLPixelFormatAttribute> &attribs,
attribs.push_back(NSOpenGLPFAOpenGLProfile); attribs.push_back(NSOpenGLPFAOpenGLProfile);
attribs.push_back(coreProfile ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy); attribs.push_back(coreProfile ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy);
// Pixel Format Attributes for the windowed NSOpenGLContext /* Pixel Format Attributes for the windowed NSOpenGLContext. */
attribs.push_back(NSOpenGLPFADoubleBuffer); attribs.push_back(NSOpenGLPFADoubleBuffer);
if (softwareGL) { if (softwareGL) {
@ -250,7 +250,8 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
static const bool needAlpha = false; static const bool needAlpha = false;
#endif #endif
static bool softwareGL = getenv("BLENDER_SOFTWAREGL"); // command-line argument would be better /* Command-line argument would be better. */
static bool softwareGL = getenv("BLENDER_SOFTWAREGL");
std::vector<NSOpenGLPixelFormatAttribute> attribs; std::vector<NSOpenGLPixelFormatAttribute> attribs;
attribs.reserve(40); attribs.reserve(40);
@ -287,7 +288,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext()
if (m_metalView) { if (m_metalView) {
if (m_defaultFramebuffer == 0) { if (m_defaultFramebuffer == 0) {
// Create a virtual framebuffer /* Create a virtual frame-buffer. */
[m_openGLContext makeCurrentContext]; [m_openGLContext makeCurrentContext];
metalInitFramebuffer(); metalInitFramebuffer();
initClearGL(); initClearGL();
@ -342,11 +343,11 @@ void GHOST_ContextCGL::metalInit()
/* clang-format on */ /* clang-format on */
id<MTLDevice> device = m_metalLayer.device; id<MTLDevice> device = m_metalLayer.device;
// Create a command queue for blit/present operation /* Create a command queue for blit/present operation. */
m_metalCmdQueue = (MTLCommandQueue *)[device newCommandQueue]; m_metalCmdQueue = (MTLCommandQueue *)[device newCommandQueue];
[m_metalCmdQueue retain]; [m_metalCmdQueue retain];
// Create shaders for blit operation /* Create shaders for blit operation. */
NSString *source = @R"msl( NSString *source = @R"msl(
using namespace metal; using namespace metal;
@ -387,7 +388,7 @@ void GHOST_ContextCGL::metalInit()
"GHOST_ContextCGL::metalInit: newLibraryWithSource:options:error: failed!"); "GHOST_ContextCGL::metalInit: newLibraryWithSource:options:error: failed!");
} }
// Create a render pipeline for blit operation /* Create a render pipeline for blit operation. */
MTLRenderPipelineDescriptor *desc = [[[MTLRenderPipelineDescriptor alloc] init] autorelease]; MTLRenderPipelineDescriptor *desc = [[[MTLRenderPipelineDescriptor alloc] init] autorelease];
desc.fragmentFunction = [library newFunctionWithName:@"fragment_shader"]; desc.fragmentFunction = [library newFunctionWithName:@"fragment_shader"];
@ -460,7 +461,7 @@ void GHOST_ContextCGL::metalUpdateFramebuffer()
"GHOST_ContextCGL::metalUpdateFramebuffer: CVPixelBufferCreate failed!"); "GHOST_ContextCGL::metalUpdateFramebuffer: CVPixelBufferCreate failed!");
} }
// Create an OpenGL texture /* Create an OpenGL texture. */
CVOpenGLTextureCacheRef cvGLTexCache = nil; CVOpenGLTextureCacheRef cvGLTexCache = nil;
cvret = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, cvret = CVOpenGLTextureCacheCreate(kCFAllocatorDefault,
nil, nil,
@ -485,7 +486,7 @@ void GHOST_ContextCGL::metalUpdateFramebuffer()
unsigned int glTex; unsigned int glTex;
glTex = CVOpenGLTextureGetName(cvGLTex); glTex = CVOpenGLTextureGetName(cvGLTex);
// Create a Metal texture /* Create a Metal texture. */
CVMetalTextureCacheRef cvMetalTexCache = nil; CVMetalTextureCacheRef cvMetalTexCache = nil;
cvret = CVMetalTextureCacheCreate( cvret = CVMetalTextureCacheCreate(
kCFAllocatorDefault, nil, m_metalLayer.device, nil, &cvMetalTexCache); kCFAllocatorDefault, nil, m_metalLayer.device, nil, &cvMetalTexCache);

@ -283,8 +283,8 @@ GHOST_TSuccess GHOST_ContextEGL::setSwapInterval(int interval)
GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut) GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut)
{ {
// This is a bit of a kludge because there does not seem to /* This is a bit of a kludge because there does not seem to
// be a way to query the swap interval with EGL. * be a way to query the swap interval with EGL. */
intervalOut = m_swap_interval; intervalOut = m_swap_interval;
return GHOST_kSuccess; return GHOST_kSuccess;
@ -365,21 +365,21 @@ static const std::string &api_string(EGLenum api)
GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
{ {
// objects have to be declared here due to the use of goto /* Objects have to be declared here due to the use of `goto`. */
std::vector<EGLint> attrib_list; std::vector<EGLint> attrib_list;
EGLint num_config = 0; EGLint num_config = 0;
if (m_stereoVisual) if (m_stereoVisual)
fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n"); fprintf(stderr, "Warning! Stereo OpenGL ES contexts are not supported.\n");
m_stereoVisual = false; // It doesn't matter what the Window wants. m_stereoVisual = false; /* It doesn't matter what the Window wants. */
if (!initContextEGLEW()) { if (!initContextEGLEW()) {
return GHOST_kFailure; return GHOST_kFailure;
} }
#ifdef WITH_GL_ANGLE #ifdef WITH_GL_ANGLE
// d3dcompiler_XX.dll needs to be loaded before ANGLE will work /* `d3dcompiler_XX.dll` needs to be loaded before ANGLE will work. */
if (s_d3dcompiler == NULL) { if (s_d3dcompiler == NULL) {
s_d3dcompiler = LoadLibrary(D3DCOMPILER); s_d3dcompiler = LoadLibrary(D3DCOMPILER);
@ -410,13 +410,13 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
if (!bindAPI(m_api)) if (!bindAPI(m_api))
goto error; goto error;
// build attribute list /* Build attribute list. */
attrib_list.reserve(20); attrib_list.reserve(20);
if (m_api == EGL_OPENGL_ES_API && EGLEW_VERSION_1_2) { if (m_api == EGL_OPENGL_ES_API && EGLEW_VERSION_1_2) {
// According to the spec it seems that you are required to set EGL_RENDERABLE_TYPE, /* According to the spec it seems that you are required to set EGL_RENDERABLE_TYPE,
// but some implementations (ANGLE) do not seem to care. * but some implementations (ANGLE) do not seem to care. */
if (m_contextMajorVersion == 1) { if (m_contextMajorVersion == 1) {
attrib_list.push_back(EGL_RENDERABLE_TYPE); attrib_list.push_back(EGL_RENDERABLE_TYPE);
@ -469,7 +469,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
#endif #endif
if (m_nativeWindow == 0) { if (m_nativeWindow == 0) {
// off-screen surface /* Off-screen surface. */
attrib_list.push_back(EGL_SURFACE_TYPE); attrib_list.push_back(EGL_SURFACE_TYPE);
attrib_list.push_back(EGL_PBUFFER_BIT); attrib_list.push_back(EGL_PBUFFER_BIT);
} }
@ -479,8 +479,8 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext()
if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config))) if (!EGL_CHK(::eglChooseConfig(m_display, &(attrib_list[0]), &m_config, 1, &num_config)))
goto error; goto error;
// A common error is to assume that ChooseConfig worked because it returned EGL_TRUE /* A common error is to assume that ChooseConfig worked because it returned EGL_TRUE. */
if (num_config != 1) // num_config should be exactly 1 if (num_config != 1) /* `num_config` should be exactly 1. */
goto error; goto error;
if (m_nativeWindow != 0) { if (m_nativeWindow != 0) {

@ -335,10 +335,11 @@ void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC))) if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC)))
goto finalize; goto finalize;
if (GLEW_CHK(glewInit()) != GLEW_OK) if (GLEW_CHK(glewInit()) != GLEW_OK) {
fprintf(stderr, "Warning! Dummy GLEW/WGLEW failed to initialize properly.\n"); fprintf(stderr, "Warning! Dummy GLEW/WGLEW failed to initialize properly.\n");
}
// the following are not technially WGLEW, but they also require a context to work /* The following are not technically WGLEW, but they also require a context to work. */
#ifndef NDEBUG #ifndef NDEBUG
free((void *)m_dummyRenderer); free((void *)m_dummyRenderer);

@ -51,7 +51,7 @@ GHOST_TSuccess GHOST_DisplayManager::initialize(void)
GHOST_TSuccess GHOST_DisplayManager::getNumDisplays(uint8_t & /*numDisplays*/) const GHOST_TSuccess GHOST_DisplayManager::getNumDisplays(uint8_t & /*numDisplays*/) const
{ {
// Don't know if we have a display... /* Don't know if we have a display. */
return GHOST_kFailure; return GHOST_kFailure;
} }
@ -120,18 +120,18 @@ GHOST_TSuccess GHOST_DisplayManager::findMatch(uint8_t display,
(int)setting.xPixels, (int)setting.yPixels, (int)setting.bpp, (int)setting.frequency}; (int)setting.xPixels, (int)setting.yPixels, (int)setting.bpp, (int)setting.frequency};
int capabilities[4]; int capabilities[4];
double field, score; double field, score;
double best = 1e12; // A big number double best = 1e12; /* A big number. */
int found = 0; int found = 0;
// Look at all the display modes /* Look at all the display modes. */
for (int i = 0; (i < (int)m_settings[display].size()); i++) { for (int i = 0; (i < (int)m_settings[display].size()); i++) {
// Store the capabilities of the display device /* Store the capabilities of the display device. */
capabilities[0] = m_settings[display][i].xPixels; capabilities[0] = m_settings[display][i].xPixels;
capabilities[1] = m_settings[display][i].yPixels; capabilities[1] = m_settings[display][i].yPixels;
capabilities[2] = m_settings[display][i].bpp; capabilities[2] = m_settings[display][i].bpp;
capabilities[3] = m_settings[display][i].frequency; capabilities[3] = m_settings[display][i].frequency;
// Match against all the fields of the display settings /* Match against all the fields of the display settings. */
score = 0; score = 0;
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
field = capabilities[j] - criteria[j]; field = capabilities[j] - criteria[j];

@ -115,8 +115,10 @@ GHOST_DropTargetX11::~GHOST_DropTargetX11()
/* Based on: https://stackoverflow.com/a/2766963/432509 */ /* Based on: https://stackoverflow.com/a/2766963/432509 */
typedef enum DecodeState_e { typedef enum DecodeState_e {
STATE_SEARCH = 0, ///< searching for an ampersand to convert /** Searching for an ampersand to convert. */
STATE_CONVERTING ///< convert the two proceeding characters from hex STATE_SEARCH = 0,
/** Convert the two proceeding characters from hex. */
STATE_CONVERTING
} DecodeState_e; } DecodeState_e;
void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char *encodedIn) void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char *encodedIn)

@ -90,7 +90,7 @@ class GHOST_EventDragnDrop : public GHOST_Event {
~GHOST_EventDragnDrop() ~GHOST_EventDragnDrop()
{ {
// Free the dropped object data /* Free the dropped object data. */
if (m_dragnDropEventData.data == NULL) if (m_dragnDropEventData.data == NULL)
return; return;

@ -108,12 +108,12 @@ GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer *consumer)
GHOST_TSuccess success; GHOST_TSuccess success;
GHOST_ASSERT(consumer, "invalid consumer"); GHOST_ASSERT(consumer, "invalid consumer");
// Check to see whether the consumer is already in our list /* Check to see whether the consumer is already in our list. */
TConsumerVector::const_iterator iter = std::find( TConsumerVector::const_iterator iter = std::find(
m_consumers.begin(), m_consumers.end(), consumer); m_consumers.begin(), m_consumers.end(), consumer);
if (iter == m_consumers.end()) { if (iter == m_consumers.end()) {
// Add the consumer /* Add the consumer. */
m_consumers.push_back(consumer); m_consumers.push_back(consumer);
success = GHOST_kSuccess; success = GHOST_kSuccess;
} }
@ -128,11 +128,11 @@ GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer *consumer
GHOST_TSuccess success; GHOST_TSuccess success;
GHOST_ASSERT(consumer, "invalid consumer"); GHOST_ASSERT(consumer, "invalid consumer");
// Check to see whether the consumer is in our list /* Check to see whether the consumer is in our list. */
TConsumerVector::iterator iter = std::find(m_consumers.begin(), m_consumers.end(), consumer); TConsumerVector::iterator iter = std::find(m_consumers.begin(), m_consumers.end(), consumer);
if (iter != m_consumers.end()) { if (iter != m_consumers.end()) {
// Remove the consumer /* Remove the consumer. */
m_consumers.erase(iter); m_consumers.erase(iter);
success = GHOST_kSuccess; success = GHOST_kSuccess;
} }

@ -22,51 +22,51 @@
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <stdio.h> // for error/info reporting #include <stdio.h> /* For error/info reporting. */
#include <string.h> // for memory functions #include <string.h> /* For memory functions. */
#ifdef DEBUG_NDOF_MOTION #ifdef DEBUG_NDOF_MOTION
// printable version of each GHOST_TProgress value /* Printable version of each GHOST_TProgress value. */
static const char *progress_string[] = { static const char *progress_string[] = {
"not started", "starting", "in progress", "finishing", "finished"}; "not started", "starting", "in progress", "finishing", "finished"};
#endif #endif
#ifdef DEBUG_NDOF_BUTTONS #ifdef DEBUG_NDOF_BUTTONS
static const char *ndof_button_names[] = { static const char *ndof_button_names[] = {
// used internally, never sent /* used internally, never sent */
"NDOF_BUTTON_NONE", "NDOF_BUTTON_NONE",
// these two are available from any 3Dconnexion device /* these two are available from any 3Dconnexion device */
"NDOF_BUTTON_MENU", "NDOF_BUTTON_MENU",
"NDOF_BUTTON_FIT", "NDOF_BUTTON_FIT",
// standard views /* standard views */
"NDOF_BUTTON_TOP", "NDOF_BUTTON_TOP",
"NDOF_BUTTON_BOTTOM", "NDOF_BUTTON_BOTTOM",
"NDOF_BUTTON_LEFT", "NDOF_BUTTON_LEFT",
"NDOF_BUTTON_RIGHT", "NDOF_BUTTON_RIGHT",
"NDOF_BUTTON_FRONT", "NDOF_BUTTON_FRONT",
"NDOF_BUTTON_BACK", "NDOF_BUTTON_BACK",
// more views /* more views */
"NDOF_BUTTON_ISO1", "NDOF_BUTTON_ISO1",
"NDOF_BUTTON_ISO2", "NDOF_BUTTON_ISO2",
// 90 degree rotations /* 90 degree rotations */
"NDOF_BUTTON_ROLL_CW", "NDOF_BUTTON_ROLL_CW",
"NDOF_BUTTON_ROLL_CCW", "NDOF_BUTTON_ROLL_CCW",
"NDOF_BUTTON_SPIN_CW", "NDOF_BUTTON_SPIN_CW",
"NDOF_BUTTON_SPIN_CCW", "NDOF_BUTTON_SPIN_CCW",
"NDOF_BUTTON_TILT_CW", "NDOF_BUTTON_TILT_CW",
"NDOF_BUTTON_TILT_CCW", "NDOF_BUTTON_TILT_CCW",
// device control /* device control */
"NDOF_BUTTON_ROTATE", "NDOF_BUTTON_ROTATE",
"NDOF_BUTTON_PANZOOM", "NDOF_BUTTON_PANZOOM",
"NDOF_BUTTON_DOMINANT", "NDOF_BUTTON_DOMINANT",
"NDOF_BUTTON_PLUS", "NDOF_BUTTON_PLUS",
"NDOF_BUTTON_MINUS", "NDOF_BUTTON_MINUS",
// keyboard emulation /* keyboard emulation */
"NDOF_BUTTON_ESC", "NDOF_BUTTON_ESC",
"NDOF_BUTTON_ALT", "NDOF_BUTTON_ALT",
"NDOF_BUTTON_SHIFT", "NDOF_BUTTON_SHIFT",
"NDOF_BUTTON_CTRL", "NDOF_BUTTON_CTRL",
// general-purpose buttons /* general-purpose buttons */
"NDOF_BUTTON_1", "NDOF_BUTTON_1",
"NDOF_BUTTON_2", "NDOF_BUTTON_2",
"NDOF_BUTTON_3", "NDOF_BUTTON_3",
@ -77,17 +77,17 @@ static const char *ndof_button_names[] = {
"NDOF_BUTTON_8", "NDOF_BUTTON_8",
"NDOF_BUTTON_9", "NDOF_BUTTON_9",
"NDOF_BUTTON_10", "NDOF_BUTTON_10",
// more general-purpose buttons /* more general-purpose buttons */
"NDOF_BUTTON_A", "NDOF_BUTTON_A",
"NDOF_BUTTON_B", "NDOF_BUTTON_B",
"NDOF_BUTTON_C", "NDOF_BUTTON_C",
// the end /* the end */
"NDOF_BUTTON_LAST"}; "NDOF_BUTTON_LAST"};
#endif #endif
// shared by the latest 3Dconnexion hardware /* Shared by the latest 3Dconnexion hardware
// SpacePilotPro uses all of these * SpacePilotPro uses all of these
// smaller devices use only some, based on button mask * smaller devices use only some, based on button mask. */
static const NDOF_ButtonT Modern3Dx_HID_map[] = { static const NDOF_ButtonT Modern3Dx_HID_map[] = {
NDOF_BUTTON_MENU, NDOF_BUTTON_FIT, NDOF_BUTTON_TOP, NDOF_BUTTON_LEFT, NDOF_BUTTON_MENU, NDOF_BUTTON_FIT, NDOF_BUTTON_TOP, NDOF_BUTTON_LEFT,
NDOF_BUTTON_RIGHT, NDOF_BUTTON_FRONT, NDOF_BUTTON_BOTTOM, NDOF_BUTTON_BACK, NDOF_BUTTON_RIGHT, NDOF_BUTTON_FRONT, NDOF_BUTTON_BOTTOM, NDOF_BUTTON_BACK,
@ -116,15 +116,15 @@ static const NDOF_ButtonT SpaceExplorer_HID_map[] = {
NDOF_BUTTON_ROTATE, NDOF_BUTTON_ROTATE,
}; };
// this is the older SpacePilot (sans Pro) /* This is the older SpacePilot (sans Pro)
// thanks to polosson for info about this device * thanks to polosson for info about this device. */
static const NDOF_ButtonT SpacePilot_HID_map[] = { static const NDOF_ButtonT SpacePilot_HID_map[] = {
NDOF_BUTTON_1, NDOF_BUTTON_2, NDOF_BUTTON_3, NDOF_BUTTON_4, NDOF_BUTTON_1, NDOF_BUTTON_2, NDOF_BUTTON_3, NDOF_BUTTON_4,
NDOF_BUTTON_5, NDOF_BUTTON_6, NDOF_BUTTON_TOP, NDOF_BUTTON_LEFT, NDOF_BUTTON_5, NDOF_BUTTON_6, NDOF_BUTTON_TOP, NDOF_BUTTON_LEFT,
NDOF_BUTTON_RIGHT, NDOF_BUTTON_FRONT, NDOF_BUTTON_ESC, NDOF_BUTTON_ALT, NDOF_BUTTON_RIGHT, NDOF_BUTTON_FRONT, NDOF_BUTTON_ESC, NDOF_BUTTON_ALT,
NDOF_BUTTON_SHIFT, NDOF_BUTTON_CTRL, NDOF_BUTTON_FIT, NDOF_BUTTON_MENU, NDOF_BUTTON_SHIFT, NDOF_BUTTON_CTRL, NDOF_BUTTON_FIT, NDOF_BUTTON_MENU,
NDOF_BUTTON_PLUS, NDOF_BUTTON_MINUS, NDOF_BUTTON_DOMINANT, NDOF_BUTTON_ROTATE, NDOF_BUTTON_PLUS, NDOF_BUTTON_MINUS, NDOF_BUTTON_DOMINANT, NDOF_BUTTON_ROTATE,
NDOF_BUTTON_NONE // the CONFIG button -- what does it do? NDOF_BUTTON_NONE /* the CONFIG button -- what does it do? */
}; };
static const NDOF_ButtonT Generic_HID_map[] = { static const NDOF_ButtonT Generic_HID_map[] = {
@ -146,7 +146,7 @@ static const int genericButtonCount = sizeof(Generic_HID_map) / sizeof(NDOF_Butt
GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys) GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys)
: m_system(sys), : m_system(sys),
m_deviceType(NDOF_UnknownDevice), // each platform has its own device detection code m_deviceType(NDOF_UnknownDevice), /* Each platform has its own device detection code. */
m_buttonCount(genericButtonCount), m_buttonCount(genericButtonCount),
m_buttonMask(0), m_buttonMask(0),
m_hidMap(Generic_HID_map), m_hidMap(Generic_HID_map),
@ -157,37 +157,37 @@ GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys)
m_motionEventPending(false), m_motionEventPending(false),
m_deadZone(0.0f) m_deadZone(0.0f)
{ {
// to avoid the rare situation where one triple is updated and /* To avoid the rare situation where one triple is updated and
// the other is not, initialize them both here: * the other is not, initialize them both here: */
memset(m_translation, 0, sizeof(m_translation)); memset(m_translation, 0, sizeof(m_translation));
memset(m_rotation, 0, sizeof(m_rotation)); memset(m_rotation, 0, sizeof(m_rotation));
} }
bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short product_id) bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short product_id)
{ {
// call this function until it returns true /* Call this function until it returns true
// it's a good idea to stop calling it after that, as it will "forget" * it's a good idea to stop calling it after that, as it will "forget"
// whichever device it already found * whichever device it already found */
// default to safe generic behavior for "unknown" devices /* Default to safe generic behavior for "unknown" devices
// unidentified devices will emit motion events like normal * unidentified devices will emit motion events like normal
// rogue buttons do nothing by default, but can be customized by the user * rogue buttons do nothing by default, but can be customized by the user. */
m_deviceType = NDOF_UnknownDevice; m_deviceType = NDOF_UnknownDevice;
m_hidMap = Generic_HID_map; m_hidMap = Generic_HID_map;
m_buttonCount = genericButtonCount; m_buttonCount = genericButtonCount;
m_buttonMask = 0; m_buttonMask = 0;
// "mystery device" owners can help build a HID_map for their hardware /* "mystery device" owners can help build a HID_map for their hardware
// A few users have already contributed information about several older devices * A few users have already contributed information about several older devices
// that I don't have access to. Thanks! * that I don't have access to. Thanks! */
switch (vendor_id) { switch (vendor_id) {
case 0x046D: // Logitech (3Dconnexion was a subsidiary) case 0x046D: /* Logitech (3Dconnexion was a subsidiary). */
switch (product_id) { switch (product_id) {
// -- current devices -- /* -- current devices -- */
case 0xC626: // full-size SpaceNavigator case 0xC626: /* full-size SpaceNavigator */
case 0xC628: // the "for Notebooks" one case 0xC628: /* the "for Notebooks" one */
puts("ndof: using SpaceNavigator"); puts("ndof: using SpaceNavigator");
m_deviceType = NDOF_SpaceNavigator; m_deviceType = NDOF_SpaceNavigator;
m_buttonCount = 2; m_buttonCount = 2;
@ -209,12 +209,12 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
puts("ndof: using SpaceMouse Pro"); puts("ndof: using SpaceMouse Pro");
m_deviceType = NDOF_SpaceMousePro; m_deviceType = NDOF_SpaceMousePro;
m_buttonCount = 27; m_buttonCount = 27;
// ^^ actually has 15 buttons, but their HID codes range from 0 to 26 /* ^^ actually has 15 buttons, but their HID codes range from 0 to 26 */
m_buttonMask = 0x07C0F137; m_buttonMask = 0x07C0F137;
m_hidMap = Modern3Dx_HID_map; m_hidMap = Modern3Dx_HID_map;
break; break;
// -- older devices -- /* -- older devices -- */
case 0xC625: case 0xC625:
puts("ndof: using SpacePilot"); puts("ndof: using SpacePilot");
m_deviceType = NDOF_SpacePilot; m_deviceType = NDOF_SpacePilot;
@ -236,21 +236,21 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ
printf("ndof: unknown Logitech product %04hx\n", product_id); printf("ndof: unknown Logitech product %04hx\n", product_id);
} }
break; break;
case 0x256F: // 3Dconnexion case 0x256F: /* 3Dconnexion */
switch (product_id) { switch (product_id) {
case 0xC62E: // plugged in case 0xC62E: /* Plugged in. */
case 0xC62F: // wireless case 0xC62F: /* Wireless. */
puts("ndof: using SpaceMouse Wireless"); puts("ndof: using SpaceMouse Wireless");
m_deviceType = NDOF_SpaceMouseWireless; m_deviceType = NDOF_SpaceMouseWireless;
m_buttonCount = 2; m_buttonCount = 2;
m_hidMap = Modern3Dx_HID_map; m_hidMap = Modern3Dx_HID_map;
break; break;
case 0xC631: // plugged in case 0xC631: /* Plugged in. */
case 0xC632: // wireless case 0xC632: /* Wireless. */
puts("ndof: using SpaceMouse Pro Wireless"); puts("ndof: using SpaceMouse Pro Wireless");
m_deviceType = NDOF_SpaceMouseProWireless; m_deviceType = NDOF_SpaceMouseProWireless;
m_buttonCount = 27; m_buttonCount = 27;
// ^^ actually has 15 buttons, but their HID codes range from 0 to 26 /* ^^ actually has 15 buttons, but their HID codes range from 0 to 26. */
m_buttonMask = 0x07C0F137; m_buttonMask = 0x07C0F137;
m_hidMap = Modern3Dx_HID_map; m_hidMap = Modern3Dx_HID_map;
break; break;
@ -364,16 +364,16 @@ void GHOST_NDOFManager::updateButton(int button_number, bool press, uint64_t tim
int mask = 1 << button_number; int mask = 1 << button_number;
if (press) { if (press) {
m_buttons |= mask; // set this button's bit m_buttons |= mask; /* Set this button's bit. */
} }
else { else {
m_buttons &= ~mask; // clear this button's bit m_buttons &= ~mask; /* Clear this button's bit. */
} }
} }
void GHOST_NDOFManager::updateButtons(int button_bits, uint64_t time) void GHOST_NDOFManager::updateButtons(int button_bits, uint64_t time)
{ {
button_bits &= m_buttonMask; // discard any "garbage" bits button_bits &= m_buttonMask; /* Discard any "garbage" bits. */
int diff = m_buttons ^ button_bits; int diff = m_buttons ^ button_bits;
@ -390,11 +390,11 @@ void GHOST_NDOFManager::updateButtons(int button_bits, uint64_t time)
void GHOST_NDOFManager::setDeadZone(float dz) void GHOST_NDOFManager::setDeadZone(float dz)
{ {
if (dz < 0.0f) { if (dz < 0.0f) {
// negative values don't make sense, so clamp at zero /* Negative values don't make sense, so clamp at zero. */
dz = 0.0f; dz = 0.0f;
} }
else if (dz > 0.5f) { else if (dz > 0.5f) {
// warn the rogue user/developer, but allow it /* Warn the rogue user/developer, but allow it. */
GHOST_PRINTF("ndof: dead zone of %.2f is rather high...\n", dz); GHOST_PRINTF("ndof: dead zone of %.2f is rather high...\n", dz);
} }
m_deadZone = dz; m_deadZone = dz;
@ -426,22 +426,22 @@ bool GHOST_NDOFManager::sendMotionEvent()
if (!m_motionEventPending) if (!m_motionEventPending)
return false; return false;
m_motionEventPending = false; // any pending motion is handled right now m_motionEventPending = false; /* Any pending motion is handled right now. */
GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow(); GHOST_IWindow *window = m_system.getWindowManager()->getActiveWindow();
if (window == NULL) { if (window == NULL) {
m_motionState = GHOST_kNotStarted; // avoid large 'dt' times when changing windows m_motionState = GHOST_kNotStarted; /* Avoid large `dt` times when changing windows. */
return false; // delivery will fail, so don't bother sending return false; /* Delivery will fail, so don't bother sending. */
} }
GHOST_EventNDOFMotion *event = new GHOST_EventNDOFMotion(m_motionTime, window); GHOST_EventNDOFMotion *event = new GHOST_EventNDOFMotion(m_motionTime, window);
GHOST_TEventNDOFMotionData *data = (GHOST_TEventNDOFMotionData *)event->getData(); GHOST_TEventNDOFMotionData *data = (GHOST_TEventNDOFMotionData *)event->getData();
// scale axis values here to normalize them to around +/- 1 /* Scale axis values here to normalize them to around +/- 1
// they are scaled again for overall sensitivity in the WM based on user prefs * they are scaled again for overall sensitivity in the WM based on user preferences. */
const float scale = 1.0f / 350.0f; // 3Dconnexion devices send +/- 350 usually const float scale = 1.0f / 350.0f; /* 3Dconnexion devices send +/- 350 usually */
data->tx = scale * m_translation[0]; data->tx = scale * m_translation[0];
data->ty = scale * m_translation[1]; data->ty = scale * m_translation[1];
@ -451,24 +451,24 @@ bool GHOST_NDOFManager::sendMotionEvent()
data->ry = scale * m_rotation[1]; data->ry = scale * m_rotation[1];
data->rz = scale * m_rotation[2]; data->rz = scale * m_rotation[2];
data->dt = 0.001f * (m_motionTime - m_prevMotionTime); // in seconds data->dt = 0.001f * (m_motionTime - m_prevMotionTime); /* In seconds. */
m_prevMotionTime = m_motionTime; m_prevMotionTime = m_motionTime;
bool weHaveMotion = !nearHomePosition(data, m_deadZone); bool weHaveMotion = !nearHomePosition(data, m_deadZone);
// determine what kind of motion event to send (Starting, InProgress, Finishing) /* Determine what kind of motion event to send `(Starting, InProgress, Finishing)`
// and where that leaves this NDOF manager (NotStarted, InProgress, Finished) * and where that leaves this NDOF manager `(NotStarted, InProgress, Finished)`. */
switch (m_motionState) { switch (m_motionState) {
case GHOST_kNotStarted: case GHOST_kNotStarted:
case GHOST_kFinished: case GHOST_kFinished:
if (weHaveMotion) { if (weHaveMotion) {
data->progress = GHOST_kStarting; data->progress = GHOST_kStarting;
m_motionState = GHOST_kInProgress; m_motionState = GHOST_kInProgress;
// prev motion time will be ancient, so just make up a reasonable time delta /* Previous motion time will be ancient, so just make up a reasonable time delta. */
data->dt = 0.0125f; data->dt = 0.0125f;
} }
else { else {
// send no event and keep current state /* Send no event and keep current state. */
#ifdef DEBUG_NDOF_MOTION #ifdef DEBUG_NDOF_MOTION
printf("ndof motion ignored -- %s\n", progress_string[data->progress]); printf("ndof motion ignored -- %s\n", progress_string[data->progress]);
#endif #endif
@ -479,20 +479,22 @@ bool GHOST_NDOFManager::sendMotionEvent()
case GHOST_kInProgress: case GHOST_kInProgress:
if (weHaveMotion) { if (weHaveMotion) {
data->progress = GHOST_kInProgress; data->progress = GHOST_kInProgress;
// remain 'InProgress' /* Remain 'InProgress'. */
} }
else { else {
data->progress = GHOST_kFinishing; data->progress = GHOST_kFinishing;
m_motionState = GHOST_kFinished; m_motionState = GHOST_kFinished;
} }
break; break;
default:; // will always be one of the above default:
/* Will always be one of the above. */
break;
} }
#ifdef DEBUG_NDOF_MOTION #ifdef DEBUG_NDOF_MOTION
printf("ndof motion sent -- %s\n", progress_string[data->progress]); printf("ndof motion sent -- %s\n", progress_string[data->progress]);
// show details about this motion event /* Show details about this motion event. */
printf(" T=(%d,%d,%d) R=(%d,%d,%d) raw\n", printf(" T=(%d,%d,%d) R=(%d,%d,%d) raw\n",
m_translation[0], m_translation[0],
m_translation[1], m_translation[1],

@ -28,7 +28,7 @@
typedef enum { typedef enum {
NDOF_UnknownDevice, NDOF_UnknownDevice,
// current devices /* Current devices. */
NDOF_SpaceNavigator, NDOF_SpaceNavigator,
NDOF_SpaceExplorer, NDOF_SpaceExplorer,
NDOF_SpacePilotPro, NDOF_SpacePilotPro,
@ -37,51 +37,51 @@ typedef enum {
NDOF_SpaceMouseProWireless, NDOF_SpaceMouseProWireless,
NDOF_SpaceMouseEnterprise, NDOF_SpaceMouseEnterprise,
// older devices /* Older devices. */
NDOF_SpacePilot, NDOF_SpacePilot,
NDOF_Spaceball5000, NDOF_Spaceball5000,
NDOF_SpaceTraveler NDOF_SpaceTraveler
} NDOF_DeviceT; } NDOF_DeviceT;
// NDOF device button event types /* NDOF device button event types */
typedef enum { typedef enum {
// used internally, never sent /* Used internally, never sent. */
NDOF_BUTTON_NONE, NDOF_BUTTON_NONE,
// these two are available from any 3Dconnexion device /* These two are available from any 3Dconnexion device. */
NDOF_BUTTON_MENU, NDOF_BUTTON_MENU,
NDOF_BUTTON_FIT, NDOF_BUTTON_FIT,
// standard views /* Standard views. */
NDOF_BUTTON_TOP, NDOF_BUTTON_TOP,
NDOF_BUTTON_BOTTOM, NDOF_BUTTON_BOTTOM,
NDOF_BUTTON_LEFT, NDOF_BUTTON_LEFT,
NDOF_BUTTON_RIGHT, NDOF_BUTTON_RIGHT,
NDOF_BUTTON_FRONT, NDOF_BUTTON_FRONT,
NDOF_BUTTON_BACK, NDOF_BUTTON_BACK,
// more views /* More views. */
NDOF_BUTTON_ISO1, NDOF_BUTTON_ISO1,
NDOF_BUTTON_ISO2, NDOF_BUTTON_ISO2,
// 90 degree rotations /* 90 degree rotations.
// these don't all correspond to physical buttons * These don't all correspond to physical buttons. */
NDOF_BUTTON_ROLL_CW, NDOF_BUTTON_ROLL_CW,
NDOF_BUTTON_ROLL_CCW, NDOF_BUTTON_ROLL_CCW,
NDOF_BUTTON_SPIN_CW, NDOF_BUTTON_SPIN_CW,
NDOF_BUTTON_SPIN_CCW, NDOF_BUTTON_SPIN_CCW,
NDOF_BUTTON_TILT_CW, NDOF_BUTTON_TILT_CW,
NDOF_BUTTON_TILT_CCW, NDOF_BUTTON_TILT_CCW,
// device control /* Device control. */
NDOF_BUTTON_ROTATE, NDOF_BUTTON_ROTATE,
NDOF_BUTTON_PANZOOM, NDOF_BUTTON_PANZOOM,
NDOF_BUTTON_DOMINANT, NDOF_BUTTON_DOMINANT,
NDOF_BUTTON_PLUS, NDOF_BUTTON_PLUS,
NDOF_BUTTON_MINUS, NDOF_BUTTON_MINUS,
// keyboard emulation /* Keyboard emulation. */
NDOF_BUTTON_ESC, NDOF_BUTTON_ESC,
NDOF_BUTTON_ALT, NDOF_BUTTON_ALT,
NDOF_BUTTON_SHIFT, NDOF_BUTTON_SHIFT,
NDOF_BUTTON_CTRL, NDOF_BUTTON_CTRL,
// general-purpose buttons /* General-purpose buttons.
// users can assign functions via keymap editor * Users can assign functions via keymap editor. */
NDOF_BUTTON_1, NDOF_BUTTON_1,
NDOF_BUTTON_2, NDOF_BUTTON_2,
NDOF_BUTTON_3, NDOF_BUTTON_3,
@ -92,11 +92,11 @@ typedef enum {
NDOF_BUTTON_8, NDOF_BUTTON_8,
NDOF_BUTTON_9, NDOF_BUTTON_9,
NDOF_BUTTON_10, NDOF_BUTTON_10,
// more general-purpose buttons /* More general-purpose buttons. */
NDOF_BUTTON_A, NDOF_BUTTON_A,
NDOF_BUTTON_B, NDOF_BUTTON_B,
NDOF_BUTTON_C, NDOF_BUTTON_C,
// the end /* The end. */
NDOF_BUTTON_LAST NDOF_BUTTON_LAST
} NDOF_ButtonT; } NDOF_ButtonT;
@ -107,40 +107,53 @@ class GHOST_NDOFManager {
{ {
} }
// whether multi-axis functionality is available (via the OS or driver) /**
// does not imply that a device is plugged in or being used * Whether multi-axis functionality is available (via the OS or driver)
* does not imply that a device is plugged in or being used.
*/
virtual bool available() = 0; virtual bool available() = 0;
// each platform's device detection should call this /**
// use standard USB/HID identifiers * Rach platform's device detection should call this
* use standard USB/HID identifiers.
*/
bool setDevice(unsigned short vendor_id, unsigned short product_id); bool setDevice(unsigned short vendor_id, unsigned short product_id);
// filter out small/accidental/uncalibrated motions by /**
// setting up a "dead zone" around home position * Filter out small/accidental/un-calibrated motions by
// set to 0 to disable * setting up a "dead zone" around home position
// 0.1 is a safe and reasonable value * set to 0 to disable
* 0.1 is a safe and reasonable value.
*/
void setDeadZone(float); void setDeadZone(float);
// the latest raw axis data from the device /**
// NOTE: axis data should be in blender view coordinates * The latest raw axis data from the device.
// +X is to the right *
// +Y is up * \note axis data should be in blender view coordinates
// +Z is out of the screen * - +X is to the right.
// for rotations, look from origin to each +axis * - +Y is up.
// rotations are + when CCW, - when CW * - +Z is out of the screen.
// each platform is responsible for getting axis data into this form * - for rotations, look from origin to each +axis.
// these values should not be scaled (just shuffled or flipped) * - rotations are + when CCW, - when CW.
* Each platform is responsible for getting axis data into this form
* these values should not be scaled (just shuffled or flipped).
*/
void updateTranslation(const int t[3], uint64_t time); void updateTranslation(const int t[3], uint64_t time);
void updateRotation(const int r[3], uint64_t time); void updateRotation(const int r[3], uint64_t time);
// the latest raw button data from the device /**
// use HID button encoding (not NDOF_ButtonT) * The latest raw button data from the device
* use HID button encoding (not #NDOF_ButtonT).
*/
void updateButton(int button_number, bool press, uint64_t time); void updateButton(int button_number, bool press, uint64_t time);
void updateButtons(int button_bits, uint64_t time); void updateButtons(int button_bits, uint64_t time);
// NDOFButton events are sent immediately /* #NDOFButton events are sent immediately */
// processes and sends most recent raw data as an NDOFMotion event /**
// returns whether an event was sent * Processes and sends most recent raw data as an #NDOFMotion event
* returns whether an event was sent.
*/
bool sendMotionEvent(); bool sendMotionEvent();
protected: protected:
@ -157,12 +170,12 @@ class GHOST_NDOFManager {
int m_translation[3]; int m_translation[3];
int m_rotation[3]; int m_rotation[3];
int m_buttons; // bit field int m_buttons; /* Bit field. */
uint64_t m_motionTime; // in milliseconds uint64_t m_motionTime; /* In milliseconds. */
uint64_t m_prevMotionTime; // time of most recent Motion event sent uint64_t m_prevMotionTime; /* Time of most recent motion event sent. */
GHOST_TProgress m_motionState; GHOST_TProgress m_motionState;
bool m_motionEventPending; bool m_motionEventPending;
float m_deadZone; // discard motion with each component < this float m_deadZone; /* Discard motion with each component < this. */
}; };

@ -26,14 +26,14 @@
void GHOST_Rect::inset(int32_t i) void GHOST_Rect::inset(int32_t i)
{ {
if (i > 0) { if (i > 0) {
// Grow the rectangle /* Grow the rectangle. */
m_l -= i; m_l -= i;
m_r += i; m_r += i;
m_t -= i; m_t -= i;
m_b += i; m_b += i;
} }
else if (i < 0) { else if (i < 0) {
// Shrink the rectangle, check for insets larger than half the size /* Shrink the rectangle, check for insets larger than half the size. */
int32_t i2 = i * 2; int32_t i2 = i * 2;
if (getWidth() > i2) { if (getWidth() > i2) {
m_l += i; m_l += i;
@ -62,12 +62,12 @@ GHOST_TVisibility GHOST_Rect::getVisibility(GHOST_Rect &r) const
bool rb = isInside(r.m_r, r.m_b); bool rb = isInside(r.m_r, r.m_b);
GHOST_TVisibility v; GHOST_TVisibility v;
if (lt && rt && lb && rb) { if (lt && rt && lb && rb) {
// All points inside, rectangle is inside this /* All points inside, rectangle is inside this. */
v = GHOST_kFullyVisible; v = GHOST_kFullyVisible;
} }
else if (!(lt || rt || lb || rb)) { else if (!(lt || rt || lb || rb)) {
// None of the points inside /* None of the points inside.
// Check to see whether the rectangle is larger than this one * Check to see whether the rectangle is larger than this one. */
if ((r.m_l < m_l) && (r.m_t < m_t) && (r.m_r > m_r) && (r.m_b > m_b)) { if ((r.m_l < m_l) && (r.m_t < m_t) && (r.m_r > m_r) && (r.m_b > m_b)) {
v = GHOST_kPartiallyVisible; v = GHOST_kPartiallyVisible;
} }
@ -76,7 +76,7 @@ GHOST_TVisibility GHOST_Rect::getVisibility(GHOST_Rect &r) const
} }
} }
else { else {
// Some of the points inside, rectangle is partially inside /* Some of the points inside, rectangle is partially inside. */
v = GHOST_kPartiallyVisible; v = GHOST_kPartiallyVisible;
} }
return v; return v;

@ -72,7 +72,7 @@ GHOST_ITimerTask *GHOST_System::installTimer(uint64_t delay,
GHOST_TimerTask *timer = new GHOST_TimerTask(millis + delay, interval, timerProc, userData); GHOST_TimerTask *timer = new GHOST_TimerTask(millis + delay, interval, timerProc, userData);
if (timer) { if (timer) {
if (m_timerManager->addTimer(timer) == GHOST_kSuccess) { if (m_timerManager->addTimer(timer) == GHOST_kSuccess) {
// Check to see whether we need to fire the timer right away /* Check to see whether we need to fire the timer right away. */
m_timerManager->fireTimers(millis); m_timerManager->fireTimers(millis);
} }
else { else {
@ -208,7 +208,7 @@ bool GHOST_System::getFullScreen(void)
void GHOST_System::dispatchEvents() void GHOST_System::dispatchEvents()
{ {
#ifdef WITH_INPUT_NDOF #ifdef WITH_INPUT_NDOF
// NDOF Motion event is sent only once per dispatch, so do it now: /* NDOF Motion event is sent only once per dispatch, so do it now: */
if (m_ndofManager) { if (m_ndofManager) {
m_ndofManager->sendMotionEvent(); m_ndofManager->sendMotionEvent();
} }
@ -260,10 +260,10 @@ GHOST_TSuccess GHOST_System::pushEvent(GHOST_IEvent *event)
GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool &isDown) const GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bool &isDown) const
{ {
GHOST_ModifierKeys keys; GHOST_ModifierKeys keys;
// Get the state of all modifier keys /* Get the state of all modifier keys. */
GHOST_TSuccess success = getModifierKeys(keys); GHOST_TSuccess success = getModifierKeys(keys);
if (success) { if (success) {
// Isolate the state of the key requested /* Isolate the state of the key requested. */
isDown = keys.get(mask); isDown = keys.get(mask);
} }
return success; return success;
@ -272,10 +272,10 @@ GHOST_TSuccess GHOST_System::getModifierKeyState(GHOST_TModifierKeyMask mask, bo
GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool &isDown) const GHOST_TSuccess GHOST_System::getButtonState(GHOST_TButtonMask mask, bool &isDown) const
{ {
GHOST_Buttons buttons; GHOST_Buttons buttons;
// Get the state of all mouse buttons /* Get the state of all mouse buttons. */
GHOST_TSuccess success = getButtons(buttons); GHOST_TSuccess success = getButtons(buttons);
if (success) { if (success) {
// Isolate the state of the mouse button requested /* Isolate the state of the mouse button requested. */
isDown = buttons.get(mask); isDown = buttons.get(mask);
} }
return success; return success;
@ -311,7 +311,7 @@ GHOST_TSuccess GHOST_System::init()
m_eventPrinter = new GHOST_EventPrinter(); m_eventPrinter = new GHOST_EventPrinter();
m_eventManager->addConsumer(m_eventPrinter); m_eventManager->addConsumer(m_eventPrinter);
} }
#endif // WITH_GHOST_DEBUG #endif /* WITH_GHOST_DEBUG */
if (m_timerManager && m_windowManager && m_eventManager) { if (m_timerManager && m_windowManager && m_eventManager) {
return GHOST_kSuccess; return GHOST_kSuccess;
@ -359,7 +359,7 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window,
if (alphaBackground) if (alphaBackground)
glSettings.flags |= GHOST_glAlphaBackground; glSettings.flags |= GHOST_glAlphaBackground;
/* note: don't use getCurrentDisplaySetting() because on X11 we may /* NOTE: don't use #getCurrentDisplaySetting() because on X11 we may
* be zoomed in and the desktop may be bigger than the viewport. */ * be zoomed in and the desktop may be bigger than the viewport. */
GHOST_ASSERT(m_displayManager, GHOST_ASSERT(m_displayManager,
"GHOST_System::createFullScreenWindow(): invalid display manager"); "GHOST_System::createFullScreenWindow(): invalid display manager");

@ -143,7 +143,7 @@ GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GLSettings glSetti
{ {
GHOST_Context *context = new GHOST_ContextSDL(0, GHOST_Context *context = new GHOST_ContextSDL(0,
NULL, NULL,
0, // profile bit 0, /* Profile bit. */
3, 3,
3, 3,
GHOST_OPENGL_SDL_CONTEXT_FLAGS, GHOST_OPENGL_SDL_CONTEXT_FLAGS,
@ -279,7 +279,7 @@ static GHOST_TKey convertSDLKey(SDL_Scancode key)
GXMAP(type, SDL_SCANCODE_AUDIOPLAY, GHOST_kKeyMediaPlay); GXMAP(type, SDL_SCANCODE_AUDIOPLAY, GHOST_kKeyMediaPlay);
GXMAP(type, SDL_SCANCODE_AUDIOSTOP, GHOST_kKeyMediaStop); GXMAP(type, SDL_SCANCODE_AUDIOSTOP, GHOST_kKeyMediaStop);
GXMAP(type, SDL_SCANCODE_AUDIOPREV, GHOST_kKeyMediaFirst); GXMAP(type, SDL_SCANCODE_AUDIOPREV, GHOST_kKeyMediaFirst);
// GXMAP(type,XF86XK_AudioRewind, GHOST_kKeyMediaFirst); // GXMAP(type, XF86XK_AudioRewind, GHOST_kKeyMediaFirst);
GXMAP(type, SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast); GXMAP(type, SDL_SCANCODE_AUDIONEXT, GHOST_kKeyMediaLast);
default: default:
@ -315,7 +315,10 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
SDL_WindowEvent &sdl_sub_evt = sdl_event->window; SDL_WindowEvent &sdl_sub_evt = sdl_event->window;
GHOST_WindowSDL *window = findGhostWindow( GHOST_WindowSDL *window = findGhostWindow(
SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID)); SDL_GetWindowFromID_fallback(sdl_sub_evt.windowID));
// assert(window != NULL); // can be NULL on close window. /* Can be NULL on close window. */
#if 0
assert(window != NULL);
#endif
switch (sdl_sub_evt.event) { switch (sdl_sub_evt.event) {
case SDL_WINDOWEVENT_EXPOSED: case SDL_WINDOWEVENT_EXPOSED:
@ -376,14 +379,14 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
bounds.wrapPoint(x_new, y_new, 8, window->getCursorGrabAxis()); bounds.wrapPoint(x_new, y_new, 8, window->getCursorGrabAxis());
window->getCursorGrabAccum(x_accum, y_accum); window->getCursorGrabAccum(x_accum, y_accum);
// can't use setCursorPosition because the mouse may have no focus! /* Can't use #setCursorPosition because the mouse may have no focus! */
if (x_new != x_root || y_new != y_root) { if (x_new != x_root || y_new != y_root) {
if (1) { //xme.time > m_last_warp) { if (1 /* `xme.time > m_last_warp` */ ) {
/* when wrapping we don't need to add an event because the /* when wrapping we don't need to add an event because the
* setCursorPosition call will cause a new event after */ * #setCursorPosition call will cause a new event after */
SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win); /* wrap */ SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win); /* wrap */
window->setCursorGrabAccum(x_accum + (x_root - x_new), y_accum + (y_root - y_new)); window->setCursorGrabAccum(x_accum + (x_root - x_new), y_accum + (y_root - y_new));
// m_last_warp= lastEventTime(xme.time); // m_last_warp = lastEventTime(xme.time);
} }
else { else {
// setCursorPosition(x_new, y_new); /* wrap but don't accumulate */ // setCursorPosition(x_new, y_new); /* wrap but don't accumulate */
@ -659,8 +662,8 @@ bool GHOST_SystemSDL::generateWindowExposeEvents()
bool GHOST_SystemSDL::processEvents(bool waitForEvent) bool GHOST_SystemSDL::processEvents(bool waitForEvent)
{ {
// Get all the current events -- translate them into /* Get all the current events - translate them into
// ghost events and call base class pushEvent() method. * ghost events and call base class #pushEvent() method. */
bool anyProcessed = false; bool anyProcessed = false;
@ -679,7 +682,7 @@ bool GHOST_SystemSDL::processEvents(bool waitForEvent)
if (maxSleep >= 0) { if (maxSleep >= 0) {
SDL_WaitEventTimeout(NULL, next - getMilliSeconds()); SDL_WaitEventTimeout(NULL, next - getMilliSeconds());
// SleepTillEvent(m_display, next - getMilliSeconds()); // X11 // SleepTillEvent(m_display, next - getMilliSeconds()); /* X11. */
} }
} }
} }
@ -707,10 +710,10 @@ GHOST_WindowSDL *GHOST_SystemSDL::findGhostWindow(SDL_Window *sdl_win)
if (sdl_win == NULL) if (sdl_win == NULL)
return NULL; return NULL;
// It is not entirely safe to do this as the backptr may point /* It is not entirely safe to do this as the backptr may point
// to a window that has recently been removed. * to a window that has recently been removed.
// We should always check the window manager's list of windows * We should always check the window manager's list of windows
// and only process events on these windows. * and only process events on these windows. */
const std::vector<GHOST_IWindow *> &win_vec = m_windowManager->getWindows(); const std::vector<GHOST_IWindow *> &win_vec = m_windowManager->getWindows();

@ -396,15 +396,15 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title,
*/ */
GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSettings) GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSettings)
{ {
// During development: /* During development:
// try 4.x compatibility profile * try 4.x compatibility profile
// try 3.3 compatibility profile * try 3.3 compatibility profile
// fall back to 3.0 if needed * fall back to 3.0 if needed
// *
// Final Blender 2.8: * Final Blender 2.8:
// try 4.x core profile * try 4.x core profile
// try 3.3 core profile * try 3.3 core profile
// no fallbacks * no fall-backs. */
const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0; const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0;
@ -2014,7 +2014,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt,
return; return;
} }
// not using INCR mechanism, just read the property /* Not using INCR mechanism, just read the property. */
XGetWindowProperty(m_display, XGetWindowProperty(m_display,
win, win,
m_atom.XCLIP_OUT, m_atom.XCLIP_OUT,

@ -55,7 +55,7 @@ GHOST_TSuccess GHOST_TimerManager::addTimer(GHOST_TimerTask *timer)
{ {
GHOST_TSuccess success; GHOST_TSuccess success;
if (!getTimerFound(timer)) { if (!getTimerFound(timer)) {
// Add the timer task /* Add the timer task. */
m_timers.push_back(timer); m_timers.push_back(timer);
success = GHOST_kSuccess; success = GHOST_kSuccess;
} }
@ -70,7 +70,7 @@ GHOST_TSuccess GHOST_TimerManager::removeTimer(GHOST_TimerTask *timer)
GHOST_TSuccess success; GHOST_TSuccess success;
TTimerVector::iterator iter = std::find(m_timers.begin(), m_timers.end(), timer); TTimerVector::iterator iter = std::find(m_timers.begin(), m_timers.end(), timer);
if (iter != m_timers.end()) { if (iter != m_timers.end()) {
// Remove the timer task /* Remove the timer task. */
m_timers.erase(iter); m_timers.erase(iter);
delete timer; delete timer;
success = GHOST_kSuccess; success = GHOST_kSuccess;
@ -113,14 +113,14 @@ bool GHOST_TimerManager::fireTimer(uint64_t time, GHOST_TimerTask *task)
{ {
uint64_t next = task->getNext(); uint64_t next = task->getNext();
// Check if the timer should be fired /* Check if the timer should be fired. */
if (time > next) { if (time > next) {
// Fire the timer /* Fire the timer. */
GHOST_TimerProcPtr timerProc = task->getTimerProc(); GHOST_TimerProcPtr timerProc = task->getTimerProc();
uint64_t start = task->getStart(); uint64_t start = task->getStart();
timerProc(task, time - start); timerProc(task, time - start);
// Update the time at which we will fire it again /* Update the time at which we will fire it again. */
uint64_t interval = task->getInterval(); uint64_t interval = task->getInterval();
uint64_t numCalls = (next - start) / interval; uint64_t numCalls = (next - start) / interval;
numCalls++; numCalls++;

@ -45,7 +45,7 @@ GHOST_TSuccess GHOST_WindowManager::addWindow(GHOST_IWindow *window)
GHOST_TSuccess success = GHOST_kFailure; GHOST_TSuccess success = GHOST_kFailure;
if (window) { if (window) {
if (!getWindowFound(window)) { if (!getWindowFound(window)) {
// Store the pointer to the window /* Store the pointer to the window. */
m_windows.push_back(window); m_windows.push_back(window);
success = GHOST_kSuccess; success = GHOST_kSuccess;
} }

@ -34,7 +34,7 @@ static constexpr size_t base_dpi = 96;
struct window_t { struct window_t {
GHOST_WindowWayland *w; GHOST_WindowWayland *w;
wl_surface *surface; wl_surface *surface;
// outputs on which the window is currently shown on /* Outputs on which the window is currently shown on. */
std::unordered_set<const output_t *> outputs; std::unordered_set<const output_t *> outputs;
uint16_t dpi = 0; uint16_t dpi = 0;
int scale = 1; int scale = 1;
@ -154,8 +154,8 @@ static bool update_scale(GHOST_WindowWayland *window)
if (scale > 0 && window->scale() != scale) { if (scale > 0 && window->scale() != scale) {
window->scale() = scale; window->scale() = scale;
// using the real DPI will cause wrong scaling of the UI /* Using the real DPI will cause wrong scaling of the UI
// use a multiplier for the default DPI as workaround * use a multiplier for the default DPI as workaround. */
window->dpi() = scale * base_dpi; window->dpi() = scale * base_dpi;
wl_surface_set_buffer_scale(window->surface(), scale); wl_surface_set_buffer_scale(window->surface(), scale);
return true; return true;

@ -64,7 +64,7 @@ typedef struct rbConstraint rbConstraint;
/* Setup ---------------------------- */ /* Setup ---------------------------- */
/* Create a new dynamics world instance */ /* Create a new dynamics world instance */
// TODO: add args to set the type of constraint solvers, etc. /* TODO: add args to set the type of constraint solvers, etc. */
rbDynamicsWorld *RB_dworld_new(const float gravity[3]); rbDynamicsWorld *RB_dworld_new(const float gravity[3]);
/* Delete the given dynamics world, and free any extra data it may require */ /* Delete the given dynamics world, and free any extra data it may require */

@ -39,14 +39,14 @@ struct Scene;
#define DO_INLINE MALWAYS_INLINE #define DO_INLINE MALWAYS_INLINE
/* goal defines */ /* Goal defines. */
#define SOFTGOALSNAP 0.999f #define SOFTGOALSNAP 0.999f
/* This is approximately the smallest number that can be /* This is approximately the smallest number that can be
* represented by a float, given its precision. */ * represented by a float, given its precision. */
#define ALMOST_ZERO FLT_EPSILON #define ALMOST_ZERO FLT_EPSILON
/* Bits to or into the ClothVertex.flags. */ /* Bits to or into the #ClothVertex.flags. */
typedef enum eClothVertexFlag { typedef enum eClothVertexFlag {
CLOTH_VERT_FLAG_PINNED = (1 << 0), CLOTH_VERT_FLAG_PINNED = (1 << 0),
CLOTH_VERT_FLAG_NOSELFCOLL = (1 << 1), /* vertex NOT used for self collisions */ CLOTH_VERT_FLAG_NOSELFCOLL = (1 << 1), /* vertex NOT used for self collisions */
@ -150,7 +150,7 @@ typedef struct ClothSpring {
float target[3]; float target[3];
} ClothSpring; } ClothSpring;
// some macro enhancements for vector treatment /* Some macro enhancements for vector treatment. */
#define VECSUBADDSS(v1, v2, aS, v3, bS) \ #define VECSUBADDSS(v1, v2, aS, v3, bS) \
{ \ { \
*(v1) -= *(v2)*aS + *(v3)*bS; \ *(v1) -= *(v2)*aS + *(v3)*bS; \
@ -211,9 +211,8 @@ typedef enum {
CLOTH_SPRING_FLAG_NEEDED = (1 << 2), /* Springs has values to be applied. */ CLOTH_SPRING_FLAG_NEEDED = (1 << 2), /* Springs has values to be applied. */
} CLOTH_SPRINGS_FLAGS; } CLOTH_SPRINGS_FLAGS;
///////////////////////////////////////////////// /* -------------------------------------------------------------------- */
// collision.c /* collision.c */
////////////////////////////////////////////////
struct CollPair; struct CollPair;
@ -225,20 +224,17 @@ typedef struct ColliderContacts {
int totcollisions; int totcollisions;
} ColliderContacts; } ColliderContacts;
// needed for implicit.c /* needed for implicit.c */
int cloth_bvh_collision(struct Depsgraph *depsgraph, int cloth_bvh_collision(struct Depsgraph *depsgraph,
struct Object *ob, struct Object *ob,
struct ClothModifierData *clmd, struct ClothModifierData *clmd,
float step, float step,
float dt); float dt);
//////////////////////////////////////////////// /* -------------------------------------------------------------------- */
/* cloth.c */
///////////////////////////////////////////////// /* Needed for modifier.c */
// cloth.c
////////////////////////////////////////////////
// needed for modifier.c
void cloth_free_modifier_extern(struct ClothModifierData *clmd); void cloth_free_modifier_extern(struct ClothModifierData *clmd);
void cloth_free_modifier(struct ClothModifierData *clmd); void cloth_free_modifier(struct ClothModifierData *clmd);
void clothModifier_do(struct ClothModifierData *clmd, void clothModifier_do(struct ClothModifierData *clmd,
@ -250,18 +246,16 @@ void clothModifier_do(struct ClothModifierData *clmd,
int cloth_uses_vgroup(struct ClothModifierData *clmd); int cloth_uses_vgroup(struct ClothModifierData *clmd);
// needed for collision.c /* Needed for collision.c */
void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving, bool self); void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving, bool self);
// needed for button_object.c /* Needed for button_object.c */
void cloth_clear_cache(struct Object *ob, struct ClothModifierData *clmd, float framenr); void cloth_clear_cache(struct Object *ob, struct ClothModifierData *clmd, float framenr);
void cloth_parallel_transport_hair_frame(float mat[3][3], void cloth_parallel_transport_hair_frame(float mat[3][3],
const float dir_old[3], const float dir_old[3],
const float dir_new[3]); const float dir_new[3]);
////////////////////////////////////////////////
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -42,7 +42,7 @@ using BoneNameSet = blender::Set<std::string>;
using ActionApplier = using ActionApplier =
blender::FunctionRef<void(PointerRNA *, bAction *, const AnimationEvalContext *)>; blender::FunctionRef<void(PointerRNA *, bAction *, const AnimationEvalContext *)>;
// Forward declarations. /* Forward declarations. */
BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose); BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose);
void pose_apply_disable_fcurves_for_unselected_bones(bAction *action, void pose_apply_disable_fcurves_for_unselected_bones(bAction *action,
const BoneNameSet &selected_bone_names); const BoneNameSet &selected_bone_names);

@ -231,7 +231,7 @@ static bool rule_avoid_collision(BoidRule *rule,
int n, neighbors = 0, nearest = 0; int n, neighbors = 0, nearest = 0;
bool ret = 0; bool ret = 0;
// check deflector objects first /* Check deflector objects first. */
if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) { if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) {
ParticleCollision col; ParticleCollision col;
BVHTreeRayHit hit; BVHTreeRayHit hit;
@ -293,7 +293,7 @@ static bool rule_avoid_collision(BoidRule *rule,
} }
} }
// check boids in own system /* Check boids in own system. */
if (acbr->options & BRULE_ACOLL_WITH_BOIDS) { if (acbr->options & BRULE_ACOLL_WITH_BOIDS) {
neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(bbd->sim->psys->tree, neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(bbd->sim->psys->tree,
pa->prev_state.co, pa->prev_state.co,

@ -547,7 +547,7 @@ static float eff_calc_visibility(ListBase *colliders,
return visibility; return visibility;
} }
// noise function for wind e.g. /* Noise function for wind e.g. */
static float wind_func(struct RNG *rng, float strength) static float wind_func(struct RNG *rng, float strength)
{ {
int random = (BLI_rng_get_int(rng) + 1) % 128; /* max 2357 */ int random = (BLI_rng_get_int(rng) + 1) % 128; /* max 2357 */

@ -1545,7 +1545,7 @@ static void emit_from_particles(Object *flow_ob,
float dt) float dt)
{ {
if (ffs && ffs->psys && ffs->psys->part && if (ffs && ffs->psys && ffs->psys->part &&
ELEM(ffs->psys->part->type, PART_EMITTER, PART_FLUID)) // is particle system selected ELEM(ffs->psys->part->type, PART_EMITTER, PART_FLUID)) /* Is particle system selected. */
{ {
ParticleSimulationData sim; ParticleSimulationData sim;
ParticleSystem *psys = ffs->psys; ParticleSystem *psys = ffs->psys;

@ -1653,7 +1653,7 @@ static void object_update_from_subsurf_ccg(Object *object)
* *
* All this is defeating all the designs we need to follow to allow safe * All this is defeating all the designs we need to follow to allow safe
* threaded evaluation, but this is as good as we can make it within the * threaded evaluation, but this is as good as we can make it within the
* current sculpt//evaluated mesh design. This is also how we've survived * current sculpt/evaluated mesh design. This is also how we've survived
* with old DerivedMesh based solutions. So, while this is all wrong and * with old DerivedMesh based solutions. So, while this is all wrong and
* needs reconsideration, doesn't seem to be a big stopper for real * needs reconsideration, doesn't seem to be a big stopper for real
* production artists. * production artists.

@ -137,7 +137,8 @@ short BLI_dlrbTree_contains(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, void *
*/ */
/* Add the given data to the tree, and return the node added */ /* Add the given data to the tree, and return the node added */
// NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned /* NOTE: for duplicates, the update_cb is called (if available),
* and the existing node is returned. */
DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree,
DLRBT_Comparator_FP cmp_cb, DLRBT_Comparator_FP cmp_cb,
DLRBT_NAlloc_FP new_cb, DLRBT_NAlloc_FP new_cb,
@ -145,7 +146,7 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree,
void *data); void *data);
/* Remove the given element from the tree and balance again */ /* Remove the given element from the tree and balance again */
// FIXME: this is not implemented yet... /* FIXME: this is not implemented yet... */
// void BLI_dlrbTree_remove(DLRBT_Tree *tree, DLRBT_Node *node); // void BLI_dlrbTree_remove(DLRBT_Tree *tree, DLRBT_Node *node);
/* Node Operations (Manual) --------------------- */ /* Node Operations (Manual) --------------------- */

@ -31,11 +31,11 @@
#ifndef WIN32 #ifndef WIN32
# include <signal.h> # include <signal.h>
# include <stdlib.h> # include <stdlib.h>
# include <sys/mman.h> // for mmap # include <sys/mman.h> /* For mmap. */
# include <unistd.h> // for read close # include <unistd.h> /* For read close. */
#else #else
# include "BLI_winstuff.h" # include "BLI_winstuff.h"
# include <io.h> // for open close read # include <io.h> /* For open close read. */
#endif #endif
struct BLI_mmap_file { struct BLI_mmap_file {

@ -410,7 +410,7 @@ MINLINE float pingpongf(float value, float scale)
return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale); return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale);
} }
// Square. /* Square. */
MINLINE int square_s(short a) MINLINE int square_s(short a)
{ {
@ -442,7 +442,7 @@ MINLINE double square_d(double a)
return a * a; return a * a;
} }
// Cube. /* Cube. */
MINLINE int cube_s(short a) MINLINE int cube_s(short a)
{ {
@ -474,7 +474,7 @@ MINLINE double cube_d(double a)
return a * a * a; return a * a * a;
} }
// Min/max /* Min/max */
MINLINE float min_ff(float a, float b) MINLINE float min_ff(float a, float b)
{ {

@ -30,7 +30,7 @@
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
# define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY # define WIN32_SKIP_HKEY_PROTECTION /* Need to use HKEY. */
# include "BLI_path_util.h" # include "BLI_path_util.h"
# include "BLI_string.h" # include "BLI_string.h"
# include "BLI_utildefines.h" # include "BLI_utildefines.h"

@ -132,7 +132,7 @@ static void sequencer_init_preview_region(ARegion *region)
region->v2d.max[0] = 12000.0f; region->v2d.max[0] = 12000.0f;
region->v2d.max[1] = 12000.0f; region->v2d.max[1] = 12000.0f;
region->v2d.cur = region->v2d.tot; region->v2d.cur = region->v2d.tot;
region->v2d.align = V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y); region->v2d.align = V2D_ALIGN_FREE; /* `(V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y)` */
region->v2d.keeptot = V2D_KEEPTOT_FREE; region->v2d.keeptot = V2D_KEEPTOT_FREE;
} }
@ -852,7 +852,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
Object *ob; Object *ob;
for (ob = bmain->objects.first; ob; ob = ob->id.next) { for (ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->flag & 8192) { // OB_POSEMODE = 8192 if (ob->flag & 8192) { /* OB_POSEMODE = 8192. */
ob->mode |= OB_MODE_POSE; ob->mode |= OB_MODE_POSE;
} }
} }
@ -1405,7 +1405,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
} }
if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) { if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) {
sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE sce->r.ffcodecdata.audio_codec = 0x0; /* `CODEC_ID_NONE` */
} }
SEQ_ALL_BEGIN (sce->ed, seq) { SEQ_ALL_BEGIN (sce->ed, seq) {
@ -1745,7 +1745,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
/* New Settings */ /* New Settings */
if (!MAIN_VERSION_ATLEAST(bmain, 252, 5)) { if (!MAIN_VERSION_ATLEAST(bmain, 252, 5)) {
brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space brush->flag |= BRUSH_SPACE_ATTEN; /* Explicitly enable adaptive space. */
/* spacing was originally in pixels, convert it to percentage for new version /* spacing was originally in pixels, convert it to percentage for new version
* size should not be zero due to sanity check above * size should not be zero due to sanity check above

@ -126,7 +126,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
float *buffer = src->getBuffer(); float *buffer = src->getBuffer();
const uint8_t num_channels = src->get_num_channels(); const uint8_t num_channels = src->get_num_channels();
// <0.5 not valid, though can have a possibly useful sort of sharpening effect /* <0.5 not valid, though can have a possibly useful sort of sharpening effect. */
if (sigma < 0.5f) { if (sigma < 0.5f) {
return; return;
} }
@ -135,8 +135,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
xy = 3; xy = 3;
} }
// XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels, /* XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
// so just skipping blur along faulty direction if src's def is below that limit! * so just skipping blur along faulty direction if src's def is below that limit! */
if (src_width < 3) { if (src_width < 3) {
xy &= ~1; xy &= ~1;
} }
@ -147,32 +147,32 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
return; return;
} }
// see "Recursive Gabor Filtering" by Young/VanVliet /* See "Recursive Gabor Filtering" by Young/VanVliet
// all factors here in double.prec. * all factors here in double.prec.
// Required, because for single.prec it seems to blow up if sigma > ~200 * Required, because for single.prec it seems to blow up if sigma > ~200 */
if (sigma >= 3.556f) { if (sigma >= 3.556f) {
q = 0.9804f * (sigma - 3.556f) + 2.5091f; q = 0.9804f * (sigma - 3.556f) + 2.5091f;
} }
else { // sigma >= 0.5 else { /* `sigma >= 0.5`. */
q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f; q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
} }
q2 = q * q; q2 = q * q;
sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q); sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
// no gabor filtering here, so no complex multiplies, just the regular coefs. /* No gabor filtering here, so no complex multiplies, just the regular coefs.
// all negated here, so as not to have to recalc Triggs/Sdika matrix * all negated here, so as not to have to recalc Triggs/Sdika matrix. */
cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc; cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc;
cf[2] = -q2 * (3.38246 + 3.0 * q) / sc; cf[2] = -q2 * (3.38246 + 3.0 * q) / sc;
// 0 & 3 unchanged /* 0 & 3 unchanged. */
cf[3] = q2 * q / sc; cf[3] = q2 * q / sc;
cf[0] = 1.0 - cf[1] - cf[2] - cf[3]; cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
// Triggs/Sdika border corrections, /* Triggs/Sdika border corrections,
// it seems to work, not entirely sure if it is actually totally correct, * it seems to work, not entirely sure if it is actually totally correct,
// Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark), * Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
// found one other implementation by Cristoph Lampert, * found one other implementation by Cristoph Lampert,
// but neither seem to be quite the same, result seems to be ok so far anyway. * but neither seem to be quite the same, result seems to be ok so far anyway.
// Extra scale factor here to not have to do it in filter, * Extra scale factor here to not have to do it in filter,
// though maybe this had something to with the precision errors * though maybe this had something to with the precision errors */
sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) *
(1.0 + cf[2] + (cf[1] - cf[3]) * cf[3])); (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3]));
tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]); tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]);
@ -210,12 +210,12 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
} \ } \
(void)0 (void)0
// intermediate buffers /* Intermediate buffers. */
sz = MAX2(src_width, src_height); sz = MAX2(src_width, src_height);
X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
if (xy & 1) { // H if (xy & 1) { /* H. */
int offset; int offset;
for (y = 0; y < src_height; y++) { for (y = 0; y < src_height; y++) {
const int yx = y * src_width; const int yx = y * src_width;
@ -232,7 +232,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
} }
} }
} }
if (xy & 2) { // V if (xy & 2) { /* V. */
int offset; int offset;
const int add = src_width * num_channels; const int add = src_width * num_channels;
@ -257,7 +257,6 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
#undef YVV #undef YVV
} }
///
FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() FastGaussianBlurValueOperation::FastGaussianBlurValueOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(DataType::Value);
@ -336,8 +335,6 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
} }
} }
// newBuf->
this->m_iirgaus = copy; this->m_iirgaus = copy;
} }
unlockMutex(); unlockMutex();

@ -153,8 +153,8 @@ bool RNANodeQuery::contains(const char *prop_identifier, const char *rna_path_co
return false; return false;
} }
// If substr != prop_identifier, it means that the substring is found further in prop_identifier, /* If substr != prop_identifier, it means that the substring is found further in prop_identifier,
// and that thus index -1 is a valid memory location. * and that thus index -1 is a valid memory location. */
const bool start_ok = substr == prop_identifier || substr[-1] == '.'; const bool start_ok = substr == prop_identifier || substr[-1] == '.';
if (!start_ok) { if (!start_ok) {
return false; return false;

@ -58,15 +58,15 @@
#include "intern/eval/deg_eval_copy_on_write.h" #include "intern/eval/deg_eval_copy_on_write.h"
// Invalidate data-block data when update is flushed on it. /* Invalidate data-block data when update is flushed on it.
// *
// The idea of this is to help catching cases when area is accessing data which * The idea of this is to help catching cases when area is accessing data which
// is not yet evaluated, which could happen due to missing relations. The issue * is not yet evaluated, which could happen due to missing relations. The issue
// is that usually that data will be kept from previous frame, and it looks to * is that usually that data will be kept from previous frame, and it looks to
// be plausible. * be plausible.
// *
// This ensures that data does not look plausible, making it much easier to * This ensures that data does not look plausible, making it much easier to
// catch usage of invalid state. * catch usage of invalid state. */
#undef INVALIDATE_ON_FLUSH #undef INVALIDATE_ON_FLUSH
namespace blender::deg { namespace blender::deg {

@ -368,7 +368,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
else if (pset->edittype == PE_TYPE_SOFTBODY && pid->type == PTCACHE_TYPE_SOFTBODY) { else if (pset->edittype == PE_TYPE_SOFTBODY && pid->type == PTCACHE_TYPE_SOFTBODY) {
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME; pset->flag |= PE_FADE_TIME;
// NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB; /* Nice to have but doesn't work: `pset->brushtype = PE_BRUSH_COMB;`. */
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
} }
edit = pid->cache->edit; edit = pid->cache->edit;
@ -377,7 +377,7 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
else if (pset->edittype == PE_TYPE_CLOTH && pid->type == PTCACHE_TYPE_CLOTH) { else if (pset->edittype == PE_TYPE_CLOTH && pid->type == PTCACHE_TYPE_CLOTH) {
if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
pset->flag |= PE_FADE_TIME; pset->flag |= PE_FADE_TIME;
// NICE TO HAVE but doesn't work: pset->brushtype = PE_BRUSH_COMB; /* Nice to have but doesn't work: `pset->brushtype = PE_BRUSH_COMB;`. */
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL); PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
} }
edit = pid->cache->edit; edit = pid->cache->edit;

@ -707,7 +707,7 @@ void Controller::ComputeSteerableViewMap()
for (unsigned int x = 0; x < img[i]->width(); ++x) { for (unsigned int x = 0; x < img[i]->width(); ++x) {
//img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)) / 255.0f); //img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)) / 255.0f);
img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y))); img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)));
//float c = qGray(qimg.pixel(x, y)); // float c = qGray(qimg.pixel(x, y));
//img[i]->setPixel(x, y, qGray(qimg.pixel(x, y))); //img[i]->setPixel(x, y, qGray(qimg.pixel(x, y)));
} }
} }

@ -28,7 +28,7 @@
# define _USE_MATH_DEFINES # define _USE_MATH_DEFINES
#endif #endif
// NOTE: Keep first, BLI_path_util conflicts with OIIO's format. /* NOTE: Keep first, #BLI_path_util conflicts with OIIO's format. */
#include "openimageio_api.h" #include "openimageio_api.h"
#include <OpenImageIO/imageio.h> #include <OpenImageIO/imageio.h>
#include <memory> #include <memory>

@ -210,7 +210,7 @@ typedef struct FMod_Envelope {
} FMod_Envelope; } FMod_Envelope;
/* cycling/repetition modifier data */ /* cycling/repetition modifier data */
// TODO: we can only do complete cycles... /* TODO: we can only do complete cycles. */
typedef struct FMod_Cycles { typedef struct FMod_Cycles {
/** Extrapolation mode to use before first keyframe. */ /** Extrapolation mode to use before first keyframe. */
short before_mode; short before_mode;

@ -1102,7 +1102,7 @@ typedef enum eRotLimit_Flags {
/* distance limit constraint */ /* distance limit constraint */
/* bDistLimitConstraint->flag */ /* bDistLimitConstraint->flag */
typedef enum eDistLimit_Flag { typedef enum eDistLimit_Flag {
/* "soft" cushion effect when reaching the limit sphere */ // NOT IMPLEMENTED! /* "soft" cushion effect when reaching the limit sphere */ /* NOT IMPLEMENTED! */
LIMITDIST_USESOFT = (1 << 0), LIMITDIST_USESOFT = (1 << 0),
/* as for all Limit constraints - allow to be used during transform? */ /* as for all Limit constraints - allow to be used during transform? */
LIMITDIST_TRANSFORM = (1 << 1), LIMITDIST_TRANSFORM = (1 << 1),

@ -47,7 +47,7 @@ static void rotate(float new_co[3], float a, const float ax[3], const float co[3
float cos_a = cosf(a * (float)(2 * M_PI)); float cos_a = cosf(a * (float)(2 * M_PI));
float sin_a = sinf(a * (float)(2 * M_PI)); float sin_a = sinf(a * (float)(2 * M_PI));
// x' = xcosa + n(n.x)(1-cosa) + (x*n)sina /* `x' = xcosa + n(n.x)(1-cosa) + (x*n)sina`. */
mul_v3_v3fl(perp, co, cos_a); mul_v3_v3fl(perp, co, cos_a);
mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a)); mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a));

@ -269,9 +269,9 @@ bool SEQ_transform_seqbase_shuffle_ex(ListBase *seqbasep,
} }
test->machine += channel_delta; test->machine += channel_delta;
SEQ_time_update_sequence(
evil_scene, /* XXX: I don't think this is needed since were only moving vertically, Campbell. */
test); // XXX: I don't think this is needed since were only moving vertically, Campbell. SEQ_time_update_sequence(evil_scene, test);
} }
if ((test->machine < 1) || (test->machine > MAXSEQ)) { if ((test->machine < 1) || (test->machine > MAXSEQ)) {