diff --git a/intern/ghost/intern/GHOST_ContextCGL.mm b/intern/ghost/intern/GHOST_ContextCGL.mm index 687173ded09..7af243846c2 100644 --- a/intern/ghost/intern/GHOST_ContextCGL.mm +++ b/intern/ghost/intern/GHOST_ContextCGL.mm @@ -217,7 +217,7 @@ static void makeAttribList(std::vector &attribs, attribs.push_back(NSOpenGLPFAOpenGLProfile); 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); if (softwareGL) { @@ -250,7 +250,8 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() static const bool needAlpha = false; #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 attribs; attribs.reserve(40); @@ -287,7 +288,7 @@ GHOST_TSuccess GHOST_ContextCGL::initializeDrawingContext() if (m_metalView) { if (m_defaultFramebuffer == 0) { - // Create a virtual framebuffer + /* Create a virtual frame-buffer. */ [m_openGLContext makeCurrentContext]; metalInitFramebuffer(); initClearGL(); @@ -342,11 +343,11 @@ void GHOST_ContextCGL::metalInit() /* clang-format on */ id 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 retain]; - // Create shaders for blit operation + /* Create shaders for blit operation. */ NSString *source = @R"msl( using namespace metal; @@ -387,7 +388,7 @@ void GHOST_ContextCGL::metalInit() "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]; desc.fragmentFunction = [library newFunctionWithName:@"fragment_shader"]; @@ -460,7 +461,7 @@ void GHOST_ContextCGL::metalUpdateFramebuffer() "GHOST_ContextCGL::metalUpdateFramebuffer: CVPixelBufferCreate failed!"); } - // Create an OpenGL texture + /* Create an OpenGL texture. */ CVOpenGLTextureCacheRef cvGLTexCache = nil; cvret = CVOpenGLTextureCacheCreate(kCFAllocatorDefault, nil, @@ -485,7 +486,7 @@ void GHOST_ContextCGL::metalUpdateFramebuffer() unsigned int glTex; glTex = CVOpenGLTextureGetName(cvGLTex); - // Create a Metal texture + /* Create a Metal texture. */ CVMetalTextureCacheRef cvMetalTexCache = nil; cvret = CVMetalTextureCacheCreate( kCFAllocatorDefault, nil, m_metalLayer.device, nil, &cvMetalTexCache); diff --git a/intern/ghost/intern/GHOST_ContextEGL.cpp b/intern/ghost/intern/GHOST_ContextEGL.cpp index 0fee200ea1a..a64b2aef6a5 100644 --- a/intern/ghost/intern/GHOST_ContextEGL.cpp +++ b/intern/ghost/intern/GHOST_ContextEGL.cpp @@ -283,8 +283,8 @@ GHOST_TSuccess GHOST_ContextEGL::setSwapInterval(int interval) GHOST_TSuccess GHOST_ContextEGL::getSwapInterval(int &intervalOut) { - // This is a bit of a kludge because there does not seem to - // be a way to query the swap interval with EGL. + /* This is a bit of a kludge because there does not seem to + * be a way to query the swap interval with EGL. */ intervalOut = m_swap_interval; return GHOST_kSuccess; @@ -365,21 +365,21 @@ static const std::string &api_string(EGLenum api) 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 attrib_list; EGLint num_config = 0; if (m_stereoVisual) 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()) { return GHOST_kFailure; } #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) { s_d3dcompiler = LoadLibrary(D3DCOMPILER); @@ -410,13 +410,13 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() if (!bindAPI(m_api)) goto error; - // build attribute list + /* Build attribute list. */ attrib_list.reserve(20); 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, - // but some implementations (ANGLE) do not seem to care. + /* According to the spec it seems that you are required to set EGL_RENDERABLE_TYPE, + * but some implementations (ANGLE) do not seem to care. */ if (m_contextMajorVersion == 1) { attrib_list.push_back(EGL_RENDERABLE_TYPE); @@ -469,7 +469,7 @@ GHOST_TSuccess GHOST_ContextEGL::initializeDrawingContext() #endif if (m_nativeWindow == 0) { - // off-screen surface + /* Off-screen surface. */ attrib_list.push_back(EGL_SURFACE_TYPE); 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))) goto error; - // A common error is to assume that ChooseConfig worked because it returned EGL_TRUE - if (num_config != 1) // num_config should be exactly 1 + /* A common error is to assume that ChooseConfig worked because it returned EGL_TRUE. */ + if (num_config != 1) /* `num_config` should be exactly 1. */ goto error; if (m_nativeWindow != 0) { diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index ddb34a8afd9..b5b3fab838d 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -335,10 +335,11 @@ void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD) if (!WIN32_CHK(::wglMakeCurrent(dummyHDC, dummyHGLRC))) 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"); + } - // 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 free((void *)m_dummyRenderer); diff --git a/intern/ghost/intern/GHOST_DisplayManager.cpp b/intern/ghost/intern/GHOST_DisplayManager.cpp index fe12a76753d..9abc652378a 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.cpp +++ b/intern/ghost/intern/GHOST_DisplayManager.cpp @@ -51,7 +51,7 @@ GHOST_TSuccess GHOST_DisplayManager::initialize(void) 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; } @@ -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 capabilities[4]; double field, score; - double best = 1e12; // A big number + double best = 1e12; /* A big number. */ 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++) { - // Store the capabilities of the display device + /* Store the capabilities of the display device. */ capabilities[0] = m_settings[display][i].xPixels; capabilities[1] = m_settings[display][i].yPixels; capabilities[2] = m_settings[display][i].bpp; 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; for (int j = 0; j < 4; j++) { field = capabilities[j] - criteria[j]; diff --git a/intern/ghost/intern/GHOST_DropTargetX11.cpp b/intern/ghost/intern/GHOST_DropTargetX11.cpp index 8758a27930e..dba1d305144 100644 --- a/intern/ghost/intern/GHOST_DropTargetX11.cpp +++ b/intern/ghost/intern/GHOST_DropTargetX11.cpp @@ -115,8 +115,10 @@ GHOST_DropTargetX11::~GHOST_DropTargetX11() /* Based on: https://stackoverflow.com/a/2766963/432509 */ typedef enum DecodeState_e { - STATE_SEARCH = 0, ///< searching for an ampersand to convert - STATE_CONVERTING ///< convert the two proceeding characters from hex + /** Searching for an ampersand to convert. */ + STATE_SEARCH = 0, + /** Convert the two proceeding characters from hex. */ + STATE_CONVERTING } DecodeState_e; void GHOST_DropTargetX11::UrlDecode(char *decodedOut, int bufferSize, const char *encodedIn) diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h index 537717b1717..0095cedb8c8 100644 --- a/intern/ghost/intern/GHOST_EventDragnDrop.h +++ b/intern/ghost/intern/GHOST_EventDragnDrop.h @@ -90,7 +90,7 @@ class GHOST_EventDragnDrop : public GHOST_Event { ~GHOST_EventDragnDrop() { - // Free the dropped object data + /* Free the dropped object data. */ if (m_dragnDropEventData.data == NULL) return; diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index 15befb9afcb..6ddc362ac77 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -108,12 +108,12 @@ GHOST_TSuccess GHOST_EventManager::addConsumer(GHOST_IEventConsumer *consumer) GHOST_TSuccess success; 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( m_consumers.begin(), m_consumers.end(), consumer); if (iter == m_consumers.end()) { - // Add the consumer + /* Add the consumer. */ m_consumers.push_back(consumer); success = GHOST_kSuccess; } @@ -128,11 +128,11 @@ GHOST_TSuccess GHOST_EventManager::removeConsumer(GHOST_IEventConsumer *consumer GHOST_TSuccess success; 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); if (iter != m_consumers.end()) { - // Remove the consumer + /* Remove the consumer. */ m_consumers.erase(iter); success = GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index 079ad67f737..0317c175273 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -22,51 +22,51 @@ #include #include -#include // for error/info reporting -#include // for memory functions +#include /* For error/info reporting. */ +#include /* For memory functions. */ #ifdef DEBUG_NDOF_MOTION -// printable version of each GHOST_TProgress value +/* Printable version of each GHOST_TProgress value. */ static const char *progress_string[] = { "not started", "starting", "in progress", "finishing", "finished"}; #endif #ifdef DEBUG_NDOF_BUTTONS static const char *ndof_button_names[] = { - // used internally, never sent + /* used internally, never sent */ "NDOF_BUTTON_NONE", - // these two are available from any 3Dconnexion device + /* these two are available from any 3Dconnexion device */ "NDOF_BUTTON_MENU", "NDOF_BUTTON_FIT", - // standard views + /* standard views */ "NDOF_BUTTON_TOP", "NDOF_BUTTON_BOTTOM", "NDOF_BUTTON_LEFT", "NDOF_BUTTON_RIGHT", "NDOF_BUTTON_FRONT", "NDOF_BUTTON_BACK", - // more views + /* more views */ "NDOF_BUTTON_ISO1", "NDOF_BUTTON_ISO2", - // 90 degree rotations + /* 90 degree rotations */ "NDOF_BUTTON_ROLL_CW", "NDOF_BUTTON_ROLL_CCW", "NDOF_BUTTON_SPIN_CW", "NDOF_BUTTON_SPIN_CCW", "NDOF_BUTTON_TILT_CW", "NDOF_BUTTON_TILT_CCW", - // device control + /* device control */ "NDOF_BUTTON_ROTATE", "NDOF_BUTTON_PANZOOM", "NDOF_BUTTON_DOMINANT", "NDOF_BUTTON_PLUS", "NDOF_BUTTON_MINUS", - // keyboard emulation + /* keyboard emulation */ "NDOF_BUTTON_ESC", "NDOF_BUTTON_ALT", "NDOF_BUTTON_SHIFT", "NDOF_BUTTON_CTRL", - // general-purpose buttons + /* general-purpose buttons */ "NDOF_BUTTON_1", "NDOF_BUTTON_2", "NDOF_BUTTON_3", @@ -77,17 +77,17 @@ static const char *ndof_button_names[] = { "NDOF_BUTTON_8", "NDOF_BUTTON_9", "NDOF_BUTTON_10", - // more general-purpose buttons + /* more general-purpose buttons */ "NDOF_BUTTON_A", "NDOF_BUTTON_B", "NDOF_BUTTON_C", - // the end + /* the end */ "NDOF_BUTTON_LAST"}; #endif -// shared by the latest 3Dconnexion hardware -// SpacePilotPro uses all of these -// smaller devices use only some, based on button mask +/* Shared by the latest 3Dconnexion hardware + * SpacePilotPro uses all of these + * smaller devices use only some, based on button mask. */ static const NDOF_ButtonT Modern3Dx_HID_map[] = { NDOF_BUTTON_MENU, NDOF_BUTTON_FIT, NDOF_BUTTON_TOP, NDOF_BUTTON_LEFT, 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, }; -// this is the older SpacePilot (sans Pro) -// thanks to polosson for info about this device +/* This is the older SpacePilot (sans Pro) + * thanks to polosson for info about this device. */ static const NDOF_ButtonT SpacePilot_HID_map[] = { 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_RIGHT, NDOF_BUTTON_FRONT, NDOF_BUTTON_ESC, NDOF_BUTTON_ALT, 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_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[] = { @@ -146,7 +146,7 @@ static const int genericButtonCount = sizeof(Generic_HID_map) / sizeof(NDOF_Butt GHOST_NDOFManager::GHOST_NDOFManager(GHOST_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_buttonMask(0), m_hidMap(Generic_HID_map), @@ -157,37 +157,37 @@ GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System &sys) m_motionEventPending(false), m_deadZone(0.0f) { - // to avoid the rare situation where one triple is updated and - // the other is not, initialize them both here: + /* To avoid the rare situation where one triple is updated and + * the other is not, initialize them both here: */ memset(m_translation, 0, sizeof(m_translation)); memset(m_rotation, 0, sizeof(m_rotation)); } bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short product_id) { - // call this function until it returns true - // it's a good idea to stop calling it after that, as it will "forget" - // whichever device it already found + /* Call this function until it returns true + * it's a good idea to stop calling it after that, as it will "forget" + * whichever device it already found */ - // default to safe generic behavior for "unknown" devices - // unidentified devices will emit motion events like normal - // rogue buttons do nothing by default, but can be customized by the user + /* Default to safe generic behavior for "unknown" devices + * unidentified devices will emit motion events like normal + * rogue buttons do nothing by default, but can be customized by the user. */ m_deviceType = NDOF_UnknownDevice; m_hidMap = Generic_HID_map; m_buttonCount = genericButtonCount; m_buttonMask = 0; - // "mystery device" owners can help build a HID_map for their hardware - // A few users have already contributed information about several older devices - // that I don't have access to. Thanks! + /* "mystery device" owners can help build a HID_map for their hardware + * A few users have already contributed information about several older devices + * that I don't have access to. Thanks! */ switch (vendor_id) { - case 0x046D: // Logitech (3Dconnexion was a subsidiary) + case 0x046D: /* Logitech (3Dconnexion was a subsidiary). */ switch (product_id) { - // -- current devices -- - case 0xC626: // full-size SpaceNavigator - case 0xC628: // the "for Notebooks" one + /* -- current devices -- */ + case 0xC626: /* full-size SpaceNavigator */ + case 0xC628: /* the "for Notebooks" one */ puts("ndof: using SpaceNavigator"); m_deviceType = NDOF_SpaceNavigator; m_buttonCount = 2; @@ -209,12 +209,12 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ puts("ndof: using SpaceMouse Pro"); m_deviceType = NDOF_SpaceMousePro; 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_hidMap = Modern3Dx_HID_map; break; - // -- older devices -- + /* -- older devices -- */ case 0xC625: puts("ndof: using 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); } break; - case 0x256F: // 3Dconnexion + case 0x256F: /* 3Dconnexion */ switch (product_id) { - case 0xC62E: // plugged in - case 0xC62F: // wireless + case 0xC62E: /* Plugged in. */ + case 0xC62F: /* Wireless. */ puts("ndof: using SpaceMouse Wireless"); m_deviceType = NDOF_SpaceMouseWireless; m_buttonCount = 2; m_hidMap = Modern3Dx_HID_map; break; - case 0xC631: // plugged in - case 0xC632: // wireless + case 0xC631: /* Plugged in. */ + case 0xC632: /* Wireless. */ puts("ndof: using SpaceMouse Pro Wireless"); m_deviceType = NDOF_SpaceMouseProWireless; 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_hidMap = Modern3Dx_HID_map; break; @@ -364,16 +364,16 @@ void GHOST_NDOFManager::updateButton(int button_number, bool press, uint64_t tim int mask = 1 << button_number; if (press) { - m_buttons |= mask; // set this button's bit + m_buttons |= mask; /* Set this button's bit. */ } 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) { - button_bits &= m_buttonMask; // discard any "garbage" bits + button_bits &= m_buttonMask; /* Discard any "garbage" 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) { 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; } 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); } m_deadZone = dz; @@ -426,22 +426,22 @@ bool GHOST_NDOFManager::sendMotionEvent() if (!m_motionEventPending) 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(); if (window == NULL) { - m_motionState = GHOST_kNotStarted; // avoid large 'dt' times when changing windows - return false; // delivery will fail, so don't bother sending + m_motionState = GHOST_kNotStarted; /* Avoid large `dt` times when changing windows. */ + return false; /* Delivery will fail, so don't bother sending. */ } GHOST_EventNDOFMotion *event = new GHOST_EventNDOFMotion(m_motionTime, window); GHOST_TEventNDOFMotionData *data = (GHOST_TEventNDOFMotionData *)event->getData(); - // scale axis values here to normalize them to around +/- 1 - // they are scaled again for overall sensitivity in the WM based on user prefs + /* Scale axis values here to normalize them to around +/- 1 + * 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->ty = scale * m_translation[1]; @@ -451,24 +451,24 @@ bool GHOST_NDOFManager::sendMotionEvent() data->ry = scale * m_rotation[1]; 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; bool weHaveMotion = !nearHomePosition(data, m_deadZone); - // determine what kind of motion event to send (Starting, InProgress, Finishing) - // and where that leaves this NDOF manager (NotStarted, InProgress, Finished) + /* Determine what kind of motion event to send `(Starting, InProgress, Finishing)` + * and where that leaves this NDOF manager `(NotStarted, InProgress, Finished)`. */ switch (m_motionState) { case GHOST_kNotStarted: case GHOST_kFinished: if (weHaveMotion) { data->progress = GHOST_kStarting; 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; } else { - // send no event and keep current state + /* Send no event and keep current state. */ #ifdef DEBUG_NDOF_MOTION printf("ndof motion ignored -- %s\n", progress_string[data->progress]); #endif @@ -479,20 +479,22 @@ bool GHOST_NDOFManager::sendMotionEvent() case GHOST_kInProgress: if (weHaveMotion) { data->progress = GHOST_kInProgress; - // remain 'InProgress' + /* Remain 'InProgress'. */ } else { data->progress = GHOST_kFinishing; m_motionState = GHOST_kFinished; } break; - default:; // will always be one of the above + default: + /* Will always be one of the above. */ + break; } #ifdef DEBUG_NDOF_MOTION 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", m_translation[0], m_translation[1], diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h index 7be129c327c..9c2824e57fb 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.h +++ b/intern/ghost/intern/GHOST_NDOFManager.h @@ -28,7 +28,7 @@ typedef enum { NDOF_UnknownDevice, - // current devices + /* Current devices. */ NDOF_SpaceNavigator, NDOF_SpaceExplorer, NDOF_SpacePilotPro, @@ -37,51 +37,51 @@ typedef enum { NDOF_SpaceMouseProWireless, NDOF_SpaceMouseEnterprise, - // older devices + /* Older devices. */ NDOF_SpacePilot, NDOF_Spaceball5000, NDOF_SpaceTraveler } NDOF_DeviceT; -// NDOF device button event types +/* NDOF device button event types */ typedef enum { - // used internally, never sent + /* Used internally, never sent. */ NDOF_BUTTON_NONE, - // these two are available from any 3Dconnexion device + /* These two are available from any 3Dconnexion device. */ NDOF_BUTTON_MENU, NDOF_BUTTON_FIT, - // standard views + /* Standard views. */ NDOF_BUTTON_TOP, NDOF_BUTTON_BOTTOM, NDOF_BUTTON_LEFT, NDOF_BUTTON_RIGHT, NDOF_BUTTON_FRONT, NDOF_BUTTON_BACK, - // more views + /* More views. */ NDOF_BUTTON_ISO1, NDOF_BUTTON_ISO2, - // 90 degree rotations - // these don't all correspond to physical buttons + /* 90 degree rotations. + * These don't all correspond to physical buttons. */ NDOF_BUTTON_ROLL_CW, NDOF_BUTTON_ROLL_CCW, NDOF_BUTTON_SPIN_CW, NDOF_BUTTON_SPIN_CCW, NDOF_BUTTON_TILT_CW, NDOF_BUTTON_TILT_CCW, - // device control + /* Device control. */ NDOF_BUTTON_ROTATE, NDOF_BUTTON_PANZOOM, NDOF_BUTTON_DOMINANT, NDOF_BUTTON_PLUS, NDOF_BUTTON_MINUS, - // keyboard emulation + /* Keyboard emulation. */ NDOF_BUTTON_ESC, NDOF_BUTTON_ALT, NDOF_BUTTON_SHIFT, NDOF_BUTTON_CTRL, - // general-purpose buttons - // users can assign functions via keymap editor + /* General-purpose buttons. + * Users can assign functions via keymap editor. */ NDOF_BUTTON_1, NDOF_BUTTON_2, NDOF_BUTTON_3, @@ -92,11 +92,11 @@ typedef enum { NDOF_BUTTON_8, NDOF_BUTTON_9, NDOF_BUTTON_10, - // more general-purpose buttons + /* More general-purpose buttons. */ NDOF_BUTTON_A, NDOF_BUTTON_B, NDOF_BUTTON_C, - // the end + /* The end. */ NDOF_BUTTON_LAST } 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; - // 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); - // filter out small/accidental/uncalibrated motions by - // setting up a "dead zone" around home position - // set to 0 to disable - // 0.1 is a safe and reasonable value + /** + * Filter out small/accidental/un-calibrated motions by + * setting up a "dead zone" around home position + * set to 0 to disable + * 0.1 is a safe and reasonable value. + */ void setDeadZone(float); - // the latest raw axis data from the device - // NOTE: axis data should be in blender view coordinates - // +X is to the right - // +Y is up - // +Z is out of the screen - // for rotations, look from origin to each +axis - // 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) + /** + * The latest raw axis data from the device. + * + * \note axis data should be in blender view coordinates + * - +X is to the right. + * - +Y is up. + * - +Z is out of the screen. + * - for rotations, look from origin to each +axis. + * - 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 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 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(); protected: @@ -157,12 +170,12 @@ class GHOST_NDOFManager { int m_translation[3]; int m_rotation[3]; - int m_buttons; // bit field + int m_buttons; /* Bit field. */ - uint64_t m_motionTime; // in milliseconds - uint64_t m_prevMotionTime; // time of most recent Motion event sent + uint64_t m_motionTime; /* In milliseconds. */ + uint64_t m_prevMotionTime; /* Time of most recent motion event sent. */ GHOST_TProgress m_motionState; bool m_motionEventPending; - float m_deadZone; // discard motion with each component < this + float m_deadZone; /* Discard motion with each component < this. */ }; diff --git a/intern/ghost/intern/GHOST_Rect.cpp b/intern/ghost/intern/GHOST_Rect.cpp index 8ef9486f35a..78c88cb0a71 100644 --- a/intern/ghost/intern/GHOST_Rect.cpp +++ b/intern/ghost/intern/GHOST_Rect.cpp @@ -26,14 +26,14 @@ void GHOST_Rect::inset(int32_t i) { if (i > 0) { - // Grow the rectangle + /* Grow the rectangle. */ m_l -= i; m_r += i; m_t -= i; m_b += i; } 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; if (getWidth() > i2) { 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); GHOST_TVisibility v; if (lt && rt && lb && rb) { - // All points inside, rectangle is inside this + /* All points inside, rectangle is inside this. */ v = GHOST_kFullyVisible; } else if (!(lt || rt || lb || rb)) { - // None of the points inside - // Check to see whether the rectangle is larger than this one + /* None of the points inside. + * 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)) { v = GHOST_kPartiallyVisible; } @@ -76,7 +76,7 @@ GHOST_TVisibility GHOST_Rect::getVisibility(GHOST_Rect &r) const } } else { - // Some of the points inside, rectangle is partially inside + /* Some of the points inside, rectangle is partially inside. */ v = GHOST_kPartiallyVisible; } return v; diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index f6659cf50dc..d09c167cb95 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -72,7 +72,7 @@ GHOST_ITimerTask *GHOST_System::installTimer(uint64_t delay, GHOST_TimerTask *timer = new GHOST_TimerTask(millis + delay, interval, timerProc, userData); if (timer) { 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); } else { @@ -208,7 +208,7 @@ bool GHOST_System::getFullScreen(void) void GHOST_System::dispatchEvents() { #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) { 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_ModifierKeys keys; - // Get the state of all modifier keys + /* Get the state of all modifier keys. */ GHOST_TSuccess success = getModifierKeys(keys); if (success) { - // Isolate the state of the key requested + /* Isolate the state of the key requested. */ isDown = keys.get(mask); } 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_Buttons buttons; - // Get the state of all mouse buttons + /* Get the state of all mouse buttons. */ GHOST_TSuccess success = getButtons(buttons); if (success) { - // Isolate the state of the mouse button requested + /* Isolate the state of the mouse button requested. */ isDown = buttons.get(mask); } return success; @@ -311,7 +311,7 @@ GHOST_TSuccess GHOST_System::init() m_eventPrinter = new GHOST_EventPrinter(); m_eventManager->addConsumer(m_eventPrinter); } -#endif // WITH_GHOST_DEBUG +#endif /* WITH_GHOST_DEBUG */ if (m_timerManager && m_windowManager && m_eventManager) { return GHOST_kSuccess; @@ -359,7 +359,7 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window **window, if (alphaBackground) 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. */ GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager"); diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp index f2f1b26b8e5..0309a4f9c52 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.cpp +++ b/intern/ghost/intern/GHOST_SystemSDL.cpp @@ -143,7 +143,7 @@ GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GLSettings glSetti { GHOST_Context *context = new GHOST_ContextSDL(0, NULL, - 0, // profile bit + 0, /* Profile bit. */ 3, 3, 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_AUDIOSTOP, GHOST_kKeyMediaStop); 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); default: @@ -315,7 +315,10 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event) SDL_WindowEvent &sdl_sub_evt = sdl_event->window; GHOST_WindowSDL *window = findGhostWindow( 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) { 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()); 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 (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 - * 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 */ 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 { // setCursorPosition(x_new, y_new); /* wrap but don't accumulate */ @@ -659,8 +662,8 @@ bool GHOST_SystemSDL::generateWindowExposeEvents() bool GHOST_SystemSDL::processEvents(bool waitForEvent) { - // Get all the current events -- translate them into - // ghost events and call base class pushEvent() method. + /* Get all the current events - translate them into + * ghost events and call base class #pushEvent() method. */ bool anyProcessed = false; @@ -679,7 +682,7 @@ bool GHOST_SystemSDL::processEvents(bool waitForEvent) if (maxSleep >= 0) { 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) return NULL; - // It is not entirely safe to do this as the backptr may point - // to a window that has recently been removed. - // We should always check the window manager's list of windows - // and only process events on these windows. + /* It is not entirely safe to do this as the backptr may point + * to a window that has recently been removed. + * We should always check the window manager's list of windows + * and only process events on these windows. */ const std::vector &win_vec = m_windowManager->getWindows(); diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 172fcbeb3de..e36bfd1aaeb 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -396,15 +396,15 @@ GHOST_IWindow *GHOST_SystemX11::createWindow(const char *title, */ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GLSettings glSettings) { - // During development: - // try 4.x compatibility profile - // try 3.3 compatibility profile - // fall back to 3.0 if needed - // - // Final Blender 2.8: - // try 4.x core profile - // try 3.3 core profile - // no fallbacks + /* During development: + * try 4.x compatibility profile + * try 3.3 compatibility profile + * fall back to 3.0 if needed + * + * Final Blender 2.8: + * try 4.x core profile + * try 3.3 core profile + * no fall-backs. */ const bool debug_context = (glSettings.flags & GHOST_glDebugContext) != 0; @@ -2014,7 +2014,7 @@ void GHOST_SystemX11::getClipboard_xcout(const XEvent *evt, return; } - // not using INCR mechanism, just read the property + /* Not using INCR mechanism, just read the property. */ XGetWindowProperty(m_display, win, m_atom.XCLIP_OUT, diff --git a/intern/ghost/intern/GHOST_TimerManager.cpp b/intern/ghost/intern/GHOST_TimerManager.cpp index 195135f5f85..0c88150381f 100644 --- a/intern/ghost/intern/GHOST_TimerManager.cpp +++ b/intern/ghost/intern/GHOST_TimerManager.cpp @@ -55,7 +55,7 @@ GHOST_TSuccess GHOST_TimerManager::addTimer(GHOST_TimerTask *timer) { GHOST_TSuccess success; if (!getTimerFound(timer)) { - // Add the timer task + /* Add the timer task. */ m_timers.push_back(timer); success = GHOST_kSuccess; } @@ -70,7 +70,7 @@ GHOST_TSuccess GHOST_TimerManager::removeTimer(GHOST_TimerTask *timer) GHOST_TSuccess success; TTimerVector::iterator iter = std::find(m_timers.begin(), m_timers.end(), timer); if (iter != m_timers.end()) { - // Remove the timer task + /* Remove the timer task. */ m_timers.erase(iter); delete timer; success = GHOST_kSuccess; @@ -113,14 +113,14 @@ bool GHOST_TimerManager::fireTimer(uint64_t time, GHOST_TimerTask *task) { uint64_t next = task->getNext(); - // Check if the timer should be fired + /* Check if the timer should be fired. */ if (time > next) { - // Fire the timer + /* Fire the timer. */ GHOST_TimerProcPtr timerProc = task->getTimerProc(); uint64_t start = task->getStart(); 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 numCalls = (next - start) / interval; numCalls++; diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index eec4bc5f7d0..4cb80884209 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -45,7 +45,7 @@ GHOST_TSuccess GHOST_WindowManager::addWindow(GHOST_IWindow *window) GHOST_TSuccess success = GHOST_kFailure; if (window) { if (!getWindowFound(window)) { - // Store the pointer to the window + /* Store the pointer to the window. */ m_windows.push_back(window); success = GHOST_kSuccess; } diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index d0c8cfb9e73..71062a4b6d6 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -34,7 +34,7 @@ static constexpr size_t base_dpi = 96; struct window_t { GHOST_WindowWayland *w; wl_surface *surface; - // outputs on which the window is currently shown on + /* Outputs on which the window is currently shown on. */ std::unordered_set outputs; uint16_t dpi = 0; int scale = 1; @@ -154,8 +154,8 @@ static bool update_scale(GHOST_WindowWayland *window) if (scale > 0 && window->scale() != scale) { window->scale() = scale; - // using the real DPI will cause wrong scaling of the UI - // use a multiplier for the default DPI as workaround + /* Using the real DPI will cause wrong scaling of the UI + * use a multiplier for the default DPI as workaround. */ window->dpi() = scale * base_dpi; wl_surface_set_buffer_scale(window->surface(), scale); return true; diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h index 2e09f8952cb..f13f321a2c6 100644 --- a/intern/rigidbody/RBI_api.h +++ b/intern/rigidbody/RBI_api.h @@ -64,7 +64,7 @@ typedef struct rbConstraint rbConstraint; /* Setup ---------------------------- */ /* 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]); /* Delete the given dynamics world, and free any extra data it may require */ diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index a0e3d5dc142..dbf285feb92 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -39,14 +39,14 @@ struct Scene; #define DO_INLINE MALWAYS_INLINE -/* goal defines */ +/* Goal defines. */ #define SOFTGOALSNAP 0.999f /* This is approximately the smallest number that can be * represented by a float, given its precision. */ #define ALMOST_ZERO FLT_EPSILON -/* Bits to or into the ClothVertex.flags. */ +/* Bits to or into the #ClothVertex.flags. */ typedef enum eClothVertexFlag { CLOTH_VERT_FLAG_PINNED = (1 << 0), CLOTH_VERT_FLAG_NOSELFCOLL = (1 << 1), /* vertex NOT used for self collisions */ @@ -150,7 +150,7 @@ typedef struct ClothSpring { float target[3]; } ClothSpring; -// some macro enhancements for vector treatment +/* Some macro enhancements for vector treatment. */ #define VECSUBADDSS(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_SPRINGS_FLAGS; -///////////////////////////////////////////////// -// collision.c -//////////////////////////////////////////////// +/* -------------------------------------------------------------------- */ +/* collision.c */ struct CollPair; @@ -225,20 +224,17 @@ typedef struct ColliderContacts { int totcollisions; } ColliderContacts; -// needed for implicit.c +/* needed for implicit.c */ int cloth_bvh_collision(struct Depsgraph *depsgraph, struct Object *ob, struct ClothModifierData *clmd, float step, float dt); -//////////////////////////////////////////////// +/* -------------------------------------------------------------------- */ +/* cloth.c */ -///////////////////////////////////////////////// -// cloth.c -//////////////////////////////////////////////// - -// needed for modifier.c +/* Needed for modifier.c */ void cloth_free_modifier_extern(struct ClothModifierData *clmd); void cloth_free_modifier(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); -// needed for collision.c +/* Needed for collision.c */ 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_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3], const float dir_new[3]); -//////////////////////////////////////////////// - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/armature_pose.cc b/source/blender/blenkernel/intern/armature_pose.cc index 09e1c7d6615..2b2268c6302 100644 --- a/source/blender/blenkernel/intern/armature_pose.cc +++ b/source/blender/blenkernel/intern/armature_pose.cc @@ -42,7 +42,7 @@ using BoneNameSet = blender::Set; using ActionApplier = blender::FunctionRef; -// Forward declarations. +/* Forward declarations. */ BoneNameSet pose_apply_find_selected_bones(const bArmature *armature, const bPose *pose); void pose_apply_disable_fcurves_for_unselected_bones(bAction *action, const BoneNameSet &selected_bone_names); diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index c57adae485f..efd0fc71b20 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -231,7 +231,7 @@ static bool rule_avoid_collision(BoidRule *rule, int n, neighbors = 0, nearest = 0; bool ret = 0; - // check deflector objects first + /* Check deflector objects first. */ if (acbr->options & BRULE_ACOLL_WITH_DEFLECTORS && bbd->sim->colliders) { ParticleCollision col; 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) { neighbors = BLI_kdtree_3d_range_search_with_len_squared_cb(bbd->sim->psys->tree, pa->prev_state.co, diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 1b628b16802..fc1721eaf3a 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -547,7 +547,7 @@ static float eff_calc_visibility(ListBase *colliders, return visibility; } -// noise function for wind e.g. +/* Noise function for wind e.g. */ static float wind_func(struct RNG *rng, float strength) { int random = (BLI_rng_get_int(rng) + 1) % 128; /* max 2357 */ diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 2b48683a3a8..1d8dc97d2af 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -1545,7 +1545,7 @@ static void emit_from_particles(Object *flow_ob, float dt) { 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; ParticleSystem *psys = ffs->psys; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 941db80b76c..89de37d6e4b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -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 * 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 * needs reconsideration, doesn't seem to be a big stopper for real * production artists. diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h index 8c20e3d3988..437dacfa80b 100644 --- a/source/blender/blenlib/BLI_dlrbTree.h +++ b/source/blender/blenlib/BLI_dlrbTree.h @@ -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 */ -// 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_Comparator_FP cmp_cb, DLRBT_NAlloc_FP new_cb, @@ -145,7 +146,7 @@ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, void *data); /* 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); /* Node Operations (Manual) --------------------- */ diff --git a/source/blender/blenlib/intern/BLI_mmap.c b/source/blender/blenlib/intern/BLI_mmap.c index 71510b62ba1..c25e89df818 100644 --- a/source/blender/blenlib/intern/BLI_mmap.c +++ b/source/blender/blenlib/intern/BLI_mmap.c @@ -31,11 +31,11 @@ #ifndef WIN32 # include # include -# include // for mmap -# include // for read close +# include /* For mmap. */ +# include /* For read close. */ #else # include "BLI_winstuff.h" -# include // for open close read +# include /* For open close read. */ #endif struct BLI_mmap_file { diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 58b109eca10..0a213fa8696 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -410,7 +410,7 @@ MINLINE float pingpongf(float value, float scale) return fabsf(fractf((value - scale) / (scale * 2.0f)) * scale * 2.0f - scale); } -// Square. +/* Square. */ MINLINE int square_s(short a) { @@ -442,7 +442,7 @@ MINLINE double square_d(double a) return a * a; } -// Cube. +/* Cube. */ MINLINE int cube_s(short a) { @@ -474,7 +474,7 @@ MINLINE double cube_d(double a) return a * a * a; } -// Min/max +/* Min/max */ MINLINE float min_ff(float a, float b) { diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index beeae175869..d5c9c5cd5e6 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -30,7 +30,7 @@ # 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_string.h" # include "BLI_utildefines.h" diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index b368650eaca..e56c1995363 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -132,7 +132,7 @@ static void sequencer_init_preview_region(ARegion *region) region->v2d.max[0] = 12000.0f; region->v2d.max[1] = 12000.0f; 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; } @@ -852,7 +852,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) Object *ob; 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; } } @@ -1405,7 +1405,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } 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) { @@ -1745,7 +1745,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) /* New Settings */ 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 * size should not be zero due to sanity check above diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc index 1a0d7e52b0f..13993c06d51 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cc @@ -25,7 +25,7 @@ namespace blender::compositor { -// this part has been copied from the double edge mask +/* This part has been copied from the double edge mask. */ static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, const unsigned int *limask, @@ -35,163 +35,163 @@ static void do_adjacentKeepBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ /* Test the four corners */ - /* upper left corner */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the right, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the right, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the right, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the right, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -205,214 +205,218 @@ static void do_adjacentBleedBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ /* Test the four corners */ - /* upper left corner */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - rw] || - !lomask[x + 1]) { // test if outer mask is empty underneath or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - rw] || - !lomask[x - 1]) { // test if outer mask is empty underneath or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x - 1]) { /* Test if outer mask is empty underneath or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the right, are empty in the inner mask, + * But filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty above or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x + rw] || + !lomask[x + 1]) { /* Test if outer mask is empty above or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel above, or to the left, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel above, or to the left, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x + rw] || + !lomask[x - 1]) { /* Test if outer mask is empty above or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the left, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the left, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel to the left, or to the right, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel to the left, or to the right, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * but filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if pixel underneath, or above, are empty in the inner mask, - // but filled in the outer mask + /* Test if pixel underneath, or above, are empty in the inner mask, + * But filled in the outer mask. */ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -426,155 +430,155 @@ static void do_allKeepBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size - /* Test the four corners */ - /* upper left corner */ + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ + /* Test the four corners. */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the right + /* Test if the inner mask is empty underneath or to the right. */ if (!limask[x - rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the left + /* Test if the inner mask is empty underneath or to the left. */ if (!limask[x - rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the right + /* Test if inner mask is empty above or to the right. */ if (!limask[x + rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the left + /* Test if inner mask is empty above or to the left. */ if (!limask[x + rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -588,207 +592,210 @@ static void do_allBleedBorders(unsigned int t, unsigned int *rsize) { int x; - unsigned int isz = 0; // inner edge size - unsigned int osz = 0; // outer edge size - unsigned int gsz = 0; // gradient fill area size + unsigned int isz = 0; /* Inner edge size. */ + unsigned int osz = 0; /* Outer edge size. */ + unsigned int gsz = 0; /* Gradient fill area size. */ /* Test the four corners */ - /* upper left corner */ + /* Upper left corner. */ x = t - rw + 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the right + /* Test if the inner mask is empty underneath or to the right. */ if (!limask[x - rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - rw] || - !lomask[x + 1]) { // test if outer mask is empty underneath or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* upper right corner */ + /* Upper right corner. */ x = t; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if the inner mask is empty underneath or to the left + /* Test if the inner mask is empty underneath or to the left. */ if (!limask[x - rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x - 1]) { /* Test if outer mask is empty above or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower left corner */ + /* Lower left corner. */ x = 0; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the right + /* Test if inner mask is empty above or to the right. */ if (!limask[x + rw] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x + rw] || - !lomask[x + 1]) { // test if outer mask is empty underneath or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty underneath or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } - /* lower right corner */ + /* Lower right corner. */ x = rw - 1; - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty above or to the left + /* Test if inner mask is empty above or to the left. */ if (!limask[x + rw] || !limask[x - 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x + rw] || - !lomask[x - 1]) { // test if outer mask is empty underneath or to the left - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x - 1]) { /* Test if outer mask is empty underneath or to the left. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } /* Test the TOP row of pixels in buffer, except corners */ for (x = t - 1; x >= (t - rw) + 2; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the BOTTOM row of pixels in buffer, except corners */ for (x = rw - 2; x; x--) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty to the left or to the right + /* Test if inner mask is empty to the left or to the right. */ if (!limask[x - 1] || !limask[x + 1]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ if (!lomask[x - 1] || - !lomask[x + 1]) { // test if outer mask is empty to the left or to the right - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + !lomask[x + 1]) { /* Test if outer mask is empty to the left or to the right. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the LEFT edge of pixels in buffer, except corners */ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } /* Test the RIGHT edge of pixels in buffer, except corners */ for (x = t - rw; x > rw; x -= rw) { - // test if inner mask is filled + /* Test if inner mask is filled. */ if (limask[x]) { - // test if inner mask is empty underneath or above + /* Test if inner mask is empty underneath or above. */ if (!limask[x - rw] || !limask[x + rw]) { - isz++; // increment inner edge size - lres[x] = 4; // flag pixel as inner edge + isz++; /* Increment inner edge size. */ + lres[x] = 4; /* Flag pixel as inner edge. */ } else { - res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge + res[x] = 1.0f; /* Pixel is just part of inner mask, and it's not an edge. */ } } - else if (lomask[x]) { // inner mask was empty, test if outer mask is filled - if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above - osz++; // increment outer edge size - lres[x] = 3; // flag pixel as outer edge + else if (lomask[x]) { /* Inner mask was empty, test if outer mask is filled. */ + if (!lomask[x - rw] || + !lomask[x + rw]) { /* Test if outer mask is empty underneath or above. */ + osz++; /* Increment outer edge size. */ + lres[x] = 3; /* Flag pixel as outer edge. */ } else { - gsz++; // increment the gradient pixel count - lres[x] = 2; // flag pixel as gradient + gsz++; /* Increment the gradient pixel count. */ + lres[x] = 2; /* Flag pixel as gradient. */ } } } - rsize[0] = isz; // fill in our return sizes for edges + fill + rsize[0] = isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = osz; rsize[2] = gsz; } @@ -804,13 +811,14 @@ static void do_allEdgeDetection(unsigned int t, unsigned int in_osz, unsigned int in_gsz) { - int x; // x = pixel loop counter - int a; // a = pixel loop counter - int dx; // dx = delta x - int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop - int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop - int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop - int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop + int x; /* Pixel loop counter. */ + int a; /* Pixel loop counter. */ + int dx; /* Delta x. */ + int pix_prevRow; /* Pixel one row behind the one we are testing in a loop. */ + int pix_nextRow; /* Pixel one row in front of the one we are testing in a loop. */ + int pix_prevCol; /* Pixel one column behind the one we are testing in a loop. */ + int pix_nextCol; /* Pixel one column in front of the one we are testing in a loop. */ + /* Test all rows between the FIRST and LAST rows, excluding left and right edges */ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) { a = x - 2; @@ -819,8 +827,8 @@ static void do_allEdgeDetection(unsigned int t, pix_prevCol = a + 1; pix_nextCol = a - 1; while (a > dx - 2) { - if (!limask[a]) { // if the inner mask is empty - if (lomask[a]) { // if the outer mask is full + if (!limask[a]) { /* If the inner mask is empty. */ + if (lomask[a]) { /* If the outer mask is full. */ /* * Next we test all 4 directions around the current pixel: next/prev/up/down * The test ensures that the outer mask is empty and that the inner mask @@ -831,23 +839,23 @@ static void do_allEdgeDetection(unsigned int t, (!lomask[pix_prevCol] && !limask[pix_prevCol]) || (!lomask[pix_nextRow] && !limask[pix_nextRow]) || (!lomask[pix_prevRow] && !limask[pix_prevRow])) { - in_osz++; // increment the outer boundary pixel count - lres[a] = 3; // flag pixel as part of outer edge + in_osz++; /* Increment the outer boundary pixel count. */ + lres[a] = 3; /* Flag pixel as part of outer edge. */ } - else { // it's not a boundary pixel, but it is a gradient pixel - in_gsz++; // increment the gradient pixel count - lres[a] = 2; // flag pixel as gradient + else { /* It's not a boundary pixel, but it is a gradient pixel. */ + in_gsz++; /* Increment the gradient pixel count. */ + lres[a] = 2; /* Flag pixel as gradient. */ } } } else { if (!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] || !limask[pix_prevRow]) { - in_isz++; // increment the inner boundary pixel count - lres[a] = 4; // flag pixel as part of inner edge + in_isz++; /* Increment the inner boundary pixel count. */ + lres[a] = 4; /* Flag pixel as part of inner edge. */ } else { - res[a] = 1.0f; // pixel is part of inner mask, but not at an edge + res[a] = 1.0f; /* Pixel is part of inner mask, but not at an edge. */ } } a--; @@ -858,7 +866,7 @@ static void do_allEdgeDetection(unsigned int t, } } - rsize[0] = in_isz; // fill in our return sizes for edges + fill + rsize[0] = in_isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = in_osz; rsize[2] = in_gsz; } @@ -874,13 +882,13 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int in_osz, unsigned int in_gsz) { - int x; // x = pixel loop counter - int a; // a = pixel loop counter - int dx; // dx = delta x - int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop - int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop - int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop - int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop + int x; /* Pixel loop counter. */ + int a; /* Pixel loop counter. */ + int dx; /* Delta x. */ + int pix_prevRow; /* Pixel one row behind the one we are testing in a loop. */ + int pix_nextRow; /* Pixel one row in front of the one we are testing in a loop. */ + int pix_prevCol; /* Pixel one column behind the one we are testing in a loop. */ + int pix_nextCol; /* Pixel one column in front of the one we are testing in a loop. */ /* Test all rows between the FIRST and LAST rows, excluding left and right edges */ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) { a = x - 2; @@ -889,8 +897,8 @@ static void do_adjacentEdgeDetection(unsigned int t, pix_prevCol = a + 1; pix_nextCol = a - 1; while (a > dx - 2) { - if (!limask[a]) { // if the inner mask is empty - if (lomask[a]) { // if the outer mask is full + if (!limask[a]) { /* If the inner mask is empty. */ + if (lomask[a]) { /* If the outer mask is full. */ /* * Next we test all 4 directions around the current pixel: next/prev/up/down * The test ensures that the outer mask is empty and that the inner mask @@ -901,12 +909,12 @@ static void do_adjacentEdgeDetection(unsigned int t, (!lomask[pix_prevCol] && !limask[pix_prevCol]) || (!lomask[pix_nextRow] && !limask[pix_nextRow]) || (!lomask[pix_prevRow] && !limask[pix_prevRow])) { - in_osz++; // increment the outer boundary pixel count - lres[a] = 3; // flag pixel as part of outer edge + in_osz++; /* Increment the outer boundary pixel count. */ + lres[a] = 3; /* Flag pixel as part of outer edge. */ } - else { // it's not a boundary pixel, but it is a gradient pixel - in_gsz++; // increment the gradient pixel count - lres[a] = 2; // flag pixel as gradient + else { /* It's not a boundary pixel, but it is a gradient pixel. */ + in_gsz++; /* Increment the gradient pixel count. */ + lres[a] = 2; /* Flag pixel as gradient. */ } } } @@ -915,22 +923,22 @@ static void do_adjacentEdgeDetection(unsigned int t, (!limask[pix_prevCol] && lomask[pix_prevCol]) || (!limask[pix_nextRow] && lomask[pix_nextRow]) || (!limask[pix_prevRow] && lomask[pix_prevRow])) { - in_isz++; // increment the inner boundary pixel count - lres[a] = 4; // flag pixel as part of inner edge + in_isz++; /* Increment the inner boundary pixel count. */ + lres[a] = 4; /* Flag pixel as part of inner edge. */ } else { - res[a] = 1.0f; // pixel is part of inner mask, but not at an edge + res[a] = 1.0f; /* Pixel is part of inner mask, but not at an edge. */ } } a--; - pix_prevRow--; // advance all four "surrounding" pixel pointers + pix_prevRow--; /* Advance all four "surrounding" pixel pointers. */ pix_nextRow--; pix_prevCol--; pix_nextCol--; } } - rsize[0] = in_isz; // fill in our return sizes for edges + fill + rsize[0] = in_isz; /* Fill in our return sizes for edges + fill. */ rsize[1] = in_osz; rsize[2] = in_gsz; } @@ -945,12 +953,12 @@ static void do_createEdgeLocationBuffer(unsigned int t, unsigned int isz, unsigned int gsz) { - int x; // x = pixel loop counter - int a; // a = temporary pixel index buffer loop counter - unsigned int ud; // ud = unscaled edge distance - unsigned int dmin; // dmin = minimum edge distance + int x; /* Pixel loop counter. */ + int a; /* Temporary pixel index buffer loop counter. */ + unsigned int ud; /* Unscaled edge distance. */ + unsigned int dmin; /* Minimum edge distance. */ - unsigned int rsl; // long used for finding fast 1.0/sqrt + unsigned int rsl; /* Long used for finding fast `1.0/sqrt`. */ unsigned int gradientFillOffset; /* For looping inner edge pixel indexes, represents current position from offset. */ @@ -1025,36 +1033,37 @@ static void do_createEdgeLocationBuffer(unsigned int t, */ /* clang-format on */ - gradientFillOffset = 0; // since there are likely "more" of these, put it first. :) - *innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes - *outerEdgeOffset = (*innerEdgeOffset) + isz; // set start of outer edge indexes - /* set the accumulators to correct positions */ // set up some accumulator variables for loops - gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective - innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each - outerAccum = *outerEdgeOffset; // section fills up its allocated space in gbuf - // uses dmin=row, rsl=col + gradientFillOffset = 0; /* Since there are likely "more" of these, put it first. :). */ + *innerEdgeOffset = gradientFillOffset + gsz; /* Set start of inner edge indexes. */ + *outerEdgeOffset = (*innerEdgeOffset) + isz; /* Set start of outer edge indexes. */ + /* Set the accumulators to correct positions */ /* Set up some accumulator variables for loops. + */ + gradientAccum = gradientFillOffset; /* Each accumulator variable starts at its respective. */ + innerAccum = *innerEdgeOffset; /* Section's offset so when we start filling, each. */ + outerAccum = *outerEdgeOffset; /* Section fills up its allocated space in gbuf. */ + /* Uses `dmin=row`, `rsl=col`. */ for (x = 0, dmin = 0; x < t; x += rw, dmin++) { for (rsl = 0; rsl < rw; rsl++) { a = x + rsl; - if (lres[a] == 2) { // it is a gradient pixel flagged by 2 - ud = gradientAccum << 1; // double the index to reach correct unsigned short location - gbuf[ud] = dmin; // insert pixel's row into gradient pixel location buffer - gbuf[ud + 1] = rsl; // insert pixel's column into gradient pixel location buffer - gradientAccum++; // increment gradient index buffer pointer + if (lres[a] == 2) { /* It is a gradient pixel flagged by 2. */ + ud = gradientAccum << 1; /* Double the index to reach correct unsigned short location. */ + gbuf[ud] = dmin; /* Insert pixel's row into gradient pixel location buffer. */ + gbuf[ud + 1] = rsl; /* Insert pixel's column into gradient pixel location buffer. */ + gradientAccum++; /* Increment gradient index buffer pointer. */ } - else if (lres[a] == 3) { // it is an outer edge pixel flagged by 3 - ud = outerAccum << 1; // double the index to reach correct unsigned short location - gbuf[ud] = dmin; // insert pixel's row into outer edge pixel location buffer - gbuf[ud + 1] = rsl; // insert pixel's column into outer edge pixel location buffer - outerAccum++; // increment outer edge index buffer pointer - res[a] = 0.0f; // set output pixel intensity now since it won't change later + else if (lres[a] == 3) { /* It is an outer edge pixel flagged by 3. */ + ud = outerAccum << 1; /* Double the index to reach correct unsigned short location. */ + gbuf[ud] = dmin; /* Insert pixel's row into outer edge pixel location buffer. */ + gbuf[ud + 1] = rsl; /* Insert pixel's column into outer edge pixel location buffer. */ + outerAccum++; /* Increment outer edge index buffer pointer. */ + res[a] = 0.0f; /* Set output pixel intensity now since it won't change later. */ } - else if (lres[a] == 4) { // it is an inner edge pixel flagged by 4 - ud = innerAccum << 1; // double int index to reach correct unsigned short location - gbuf[ud] = dmin; // insert pixel's row into inner edge pixel location buffer - gbuf[ud + 1] = rsl; // insert pixel's column into inner edge pixel location buffer - innerAccum++; // increment inner edge index buffer pointer - res[a] = 1.0f; // set output pixel intensity now since it won't change later + else if (lres[a] == 4) { /* It is an inner edge pixel flagged by 4. */ + ud = innerAccum << 1; /* Double int index to reach correct unsigned short location. */ + gbuf[ud] = dmin; /* Insert pixel's row into inner edge pixel location buffer. */ + gbuf[ud + 1] = rsl; /* Insert pixel's column into inner edge pixel location buffer. */ + innerAccum++; /* Increment inner edge index buffer pointer. */ + res[a] = 1.0f; /* Set output pixel intensity now since it won't change later. */ } } } @@ -1069,21 +1078,21 @@ static void do_fillGradientBuffer(unsigned int rw, unsigned int innerEdgeOffset, unsigned int outerEdgeOffset) { - int x; // x = pixel loop counter - int a; // a = temporary pixel index buffer loop counter - int fsz; // size of the frame - unsigned int rsl; // long used for finding fast 1.0/sqrt - float rsf; // float used for finding fast 1.0/sqrt - const float rsopf = 1.5f; // constant float used for finding fast 1.0/sqrt + int x; /* Pixel loop counter. */ + int a; /* Temporary pixel index buffer loop counter. */ + int fsz; /* Size of the frame. */ + unsigned int rsl; /* Long used for finding fast `1.0/sqrt`. */ + float rsf; /* Float used for finding fast `1.0/sqrt`. */ + const float rsopf = 1.5f; /* Constant float used for finding fast `1.0/sqrt`. */ unsigned int gradientFillOffset; unsigned int t; - unsigned int ud; // ud = unscaled edge distance - unsigned int dmin; // dmin = minimum edge distance - float odist; // odist = current outer edge distance - float idist; // idist = current inner edge distance - int dx; // dx = X-delta (used for distance proportion calculation) - int dy; // dy = Y-delta (used for distance proportion calculation) + unsigned int ud; /* Unscaled edge distance. */ + unsigned int dmin; /* Minimum edge distance. */ + float odist; /* Current outer edge distance. */ + float idist; /* Current inner edge distance. */ + int dx; /* X-delta (used for distance proportion calculation) */ + int dy; /* Y-delta (used for distance proportion calculation) */ /* * The general algorithm used to color each gradient pixel is: @@ -1146,92 +1155,95 @@ static void do_fillGradientBuffer(unsigned int rw, for (x = gsz - 1; x >= 0; x--) { gradientFillOffset = x << 1; - t = gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x] - fsz = gbuf[gradientFillOffset + 1]; // calculate row of pixel indexed by gbuf[x] - dmin = 0xffffffff; // reset min distance to edge pixel + t = gbuf[gradientFillOffset]; /* Calculate column of pixel indexed by `gbuf[x]`. */ + fsz = gbuf[gradientFillOffset + 1]; /* Calculate row of pixel indexed by `gbuf[x]`. */ + dmin = 0xffffffff; /* Reset min distance to edge pixel. */ for (a = outerEdgeOffset + osz - 1; a >= outerEdgeOffset; - a--) { // loop through all outer edge buffer pixels + a--) { /* Loop through all outer edge buffer pixels. */ ud = a << 1; - dy = t - gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row - dx = fsz - gbuf[ud + 1]; // set dy to gradient pixel row - outer edge pixel column - ud = dx * dx + dy * dy; // compute sum of squares - if (ud < dmin) { // if our new sum of squares is less than the current minimum - dmin = ud; // set a new minimum equal to the new lower value + dy = t - gbuf[ud]; /* Set dx to gradient pixel column - outer edge pixel row. */ + dx = fsz - gbuf[ud + 1]; /* Set dy to gradient pixel row - outer edge pixel column. */ + ud = dx * dx + dy * dy; /* Compute sum of squares. */ + if (ud < dmin) { /* If our new sum of squares is less than the current minimum. */ + dmin = ud; /* Set a new minimum equal to the new lower value. */ } } - odist = (float)(dmin); // cast outer min to a float - rsf = odist * 0.5f; // - rsl = *(unsigned int *)&odist; // use some peculiar properties of the way bits are stored - rsl = 0x5f3759df - (rsl >> 1); // in floats vs. unsigned ints to compute an approximate - odist = *(float *)&rsl; // reciprocal square root + odist = (float)(dmin); /* Cast outer min to a float. */ + rsf = odist * 0.5f; + rsl = *(unsigned int *)&odist; /* Use some peculiar properties of the way bits are stored. */ + rsl = 0x5f3759df - (rsl >> 1); /* In floats vs. unsigned ints to compute an approximate. */ + odist = *(float *)&rsl; /* Reciprocal square root. */ odist = odist * (rsopf - (rsf * odist * - odist)); // -- ** this line can be iterated for more accuracy ** -- - dmin = 0xffffffff; // reset min distance to edge pixel + odist)); /* -- This line can be iterated for more accuracy. -- */ + dmin = 0xffffffff; /* Reset min distance to edge pixel. */ for (a = innerEdgeOffset + isz - 1; a >= innerEdgeOffset; - a--) { // loop through all inside edge pixels + a--) { /* Loop through all inside edge pixels. */ ud = a << 1; - dy = t - gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel - dx = fsz - gbuf[ud + 1]; // compute delta in X from gradient pixel to inside edge pixel - ud = dx * dx + dy * dy; // compute sum of squares - if (ud < dmin) { // if our new sum of squares is less than the current minimum we've found - dmin = ud; // set a new minimum equal to the new lower value + dy = t - gbuf[ud]; /* Compute delta in Y from gradient pixel to inside edge pixel. */ + dx = fsz - gbuf[ud + 1]; /* Compute delta in X from gradient pixel to inside edge pixel. */ + ud = dx * dx + dy * dy; /* Compute sum of squares. */ + if (ud < + dmin) { /* If our new sum of squares is less than the current minimum we've found. */ + dmin = ud; /* Set a new minimum equal to the new lower value. */ } } - idist = (float)(dmin); // cast inner min to a float - rsf = idist * 0.5f; // - rsl = *(unsigned int *)&idist; // - rsl = 0x5f3759df - (rsl >> 1); // see notes above - idist = *(float *)&rsl; // - idist = idist * (rsopf - (rsf * idist * idist)); // - /* - * Note once again that since we are using reciprocals of distance values our - * proportion is already the correct intensity, and does not need to be - * subtracted from 1.0 like it would have if we used real distances. - */ - /* - * Here we reconstruct the pixel's memory location in the CompBuf by - * Pixel Index = Pixel Column + ( Pixel Row * Row Width ) - */ + /* Cast inner min to a float. */ + idist = (float)(dmin); + rsf = idist * 0.5f; + rsl = *(unsigned int *)&idist; + + /* See notes above. */ + rsl = 0x5f3759df - (rsl >> 1); + idist = *(float *)&rsl; + idist = idist * (rsopf - (rsf * idist * idist)); + + /* NOTE: once again that since we are using reciprocals of distance values our + * proportion is already the correct intensity, and does not need to be + * subtracted from 1.0 like it would have if we used real distances. */ + + /* Here we reconstruct the pixel's memory location in the CompBuf by + * `Pixel Index = Pixel Column + ( Pixel Row * Row Width )`. */ res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] = - (idist / (idist + odist)); // set intensity + (idist / (idist + odist)); /* Set intensity. */ } } -// end of copy +/* End of copy. */ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float *res) { - unsigned int *lres; // lres = unsigned int pointer to output pixel buffer (for bit operations) - unsigned int *limask; // limask = unsigned int pointer to inner mask (for bit operations) - unsigned int *lomask; // lomask = unsigned int pointer to outer mask (for bit operations) + unsigned int *lres; /* Pointer to output pixel buffer (for bit operations). */ + unsigned int *limask; /* Pointer to inner mask (for bit operations). */ + unsigned int *lomask; /* Pointer to outer mask (for bit operations). */ - int rw; // rw = pixel row width - int t; // t = total number of pixels in buffer - 1 (used for loop starts) - int fsz; // size of the frame + int rw; /* Pixel row width. */ + int t; /* Total number of pixels in buffer - 1 (used for loop starts). */ + int fsz; /* Size of the frame. */ - unsigned int isz = 0; // size (in pixels) of inside edge pixel index buffer - unsigned int osz = 0; // size (in pixels) of outside edge pixel index buffer - unsigned int gsz = 0; // size (in pixels) of gradient pixel index buffer - unsigned int rsize[3]; // size storage to pass to helper functions + unsigned int isz = 0; /* Size (in pixels) of inside edge pixel index buffer. */ + unsigned int osz = 0; /* Size (in pixels) of outside edge pixel index buffer. */ + unsigned int gsz = 0; /* Size (in pixels) of gradient pixel index buffer. */ + unsigned int rsize[3]; /* Size storage to pass to helper functions. */ unsigned int innerEdgeOffset = - 0; // offset into final buffer where inner edge pixel indexes start + 0; /* Offset into final buffer where inner edge pixel indexes start. */ unsigned int outerEdgeOffset = - 0; // offset into final buffer where outer edge pixel indexes start + 0; /* Offset into final buffer where outer edge pixel indexes start. */ - unsigned short *gbuf; // gradient/inner/outer pixel location index buffer + unsigned short *gbuf; /* Gradient/inner/outer pixel location index buffer. */ - if (true) { // if both input sockets have some data coming in... + if (true) { /* If both input sockets have some data coming in... */ - rw = this->getWidth(); // width of a row of pixels - t = (rw * this->getHeight()) - 1; // determine size of the frame + rw = this->getWidth(); /* Width of a row of pixels. */ + t = (rw * this->getHeight()) - 1; /* Determine size of the frame. */ memset(res, 0, - sizeof(float) * (t + 1)); // clear output buffer (not all pixels will be written later) + sizeof(float) * + (t + 1)); /* Clear output buffer (not all pixels will be written later). */ - lres = (unsigned int *)res; // unsigned int pointer to output buffer (for bit level ops) - limask = (unsigned int *)imask; // unsigned int pointer to input mask (for bit level ops) - lomask = (unsigned int *)omask; // unsigned int pointer to output mask (for bit level ops) + lres = (unsigned int *)res; /* Pointer to output buffer (for bit level ops).. */ + limask = (unsigned int *)imask; /* Pointer to input mask (for bit level ops).. */ + lomask = (unsigned int *)omask; /* Pointer to output mask (for bit level ops).. */ /* * The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the @@ -1258,52 +1270,52 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float * * Each version has slightly different criteria for detecting an edge pixel. */ - if (this->m_adjacentOnly) { // if "adjacent only" inner edge mode is turned on - if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on + if (this->m_adjacentOnly) { /* If "adjacent only" inner edge mode is turned on. */ + if (this->m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */ do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize); } - else { // "bleed out" buffer edge mode is turned on + else { /* "bleed out" buffer edge mode is turned on. */ do_adjacentBleedBorders(t, rw, limask, lomask, lres, res, rsize); } - // set up inner edge, outer edge, and gradient buffer sizes after border pass + /* Set up inner edge, outer edge, and gradient buffer sizes after border pass. */ isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; - // detect edges in all non-border pixels in the buffer + /* Detect edges in all non-border pixels in the buffer. */ do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } - else { // "all" inner edge mode is turned on - if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on + else { /* "all" inner edge mode is turned on. */ + if (this->m_keepInside) { /* If "keep inside" buffer edge mode is turned on. */ do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize); } - else { // "bleed out" buffer edge mode is turned on + else { /* "bleed out" buffer edge mode is turned on. */ do_allBleedBorders(t, rw, limask, lomask, lres, res, rsize); } - // set up inner edge, outer edge, and gradient buffer sizes after border pass + /* Set up inner edge, outer edge, and gradient buffer sizes after border pass. */ isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; - // detect edges in all non-border pixels in the buffer + /* Detect edges in all non-border pixels in the buffer. */ do_allEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } - // set edge and gradient buffer sizes once again... - // the sizes in rsize[] may have been modified - // by the do_*EdgeDetection() function. + /* Set edge and gradient buffer sizes once again... + * the sizes in rsize[] may have been modified + * by the `do_*EdgeDetection()` function. */ isz = rsize[0]; osz = rsize[1]; gsz = rsize[2]; - // calculate size of pixel index buffer needed + /* Calculate size of pixel index buffer needed. */ fsz = gsz + isz + osz; - // allocate edge/gradient pixel index buffer + /* Allocate edge/gradient pixel index buffer. */ gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM"); do_createEdgeLocationBuffer( t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz); do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset); - // free the gradient index buffer + /* Free the gradient index buffer. */ MEM_freeN(gbuf); } } diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc index 2be6e4d1be7..a4c48828f17 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc @@ -126,7 +126,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float *buffer = src->getBuffer(); 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) { return; } @@ -135,8 +135,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, xy = 3; } - // 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! + /* 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! */ if (src_width < 3) { xy &= ~1; } @@ -147,32 +147,32 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, return; } - // see "Recursive Gabor Filtering" by Young/VanVliet - // all factors here in double.prec. - // Required, because for single.prec it seems to blow up if sigma > ~200 + /* See "Recursive Gabor Filtering" by Young/VanVliet + * all factors here in double.prec. + * Required, because for single.prec it seems to blow up if sigma > ~200 */ if (sigma >= 3.556f) { 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; } q2 = q * q; sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q); - // 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 + /* 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. */ cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc; cf[2] = -q2 * (3.38246 + 3.0 * q) / sc; - // 0 & 3 unchanged + /* 0 & 3 unchanged. */ cf[3] = q2 * q / sc; cf[0] = 1.0 - cf[1] - cf[2] - cf[3]; - // Triggs/Sdika border corrections, - // 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), - // found one other implementation by Cristoph Lampert, - // 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, - // though maybe this had something to with the precision errors + /* Triggs/Sdika border corrections, + * 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), + * found one other implementation by Cristoph Lampert, + * 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, + * 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]) * (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]); @@ -210,12 +210,12 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, } \ (void)0 - // intermediate buffers + /* Intermediate buffers. */ sz = MAX2(src_width, src_height); X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); - if (xy & 1) { // H + if (xy & 1) { /* H. */ int offset; for (y = 0; y < src_height; y++) { 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; const int add = src_width * num_channels; @@ -257,7 +257,6 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, #undef YVV } -/// FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() { this->addInputSocket(DataType::Value); @@ -336,8 +335,6 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) } } - // newBuf-> - this->m_iirgaus = copy; } unlockMutex(); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc index 8e3960e1a15..bdabd67cc07 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc @@ -153,8 +153,8 @@ bool RNANodeQuery::contains(const char *prop_identifier, const char *rna_path_co return false; } - // 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. + /* 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. */ const bool start_ok = substr == prop_identifier || substr[-1] == '.'; if (!start_ok) { return false; diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 1b24e2b7ad2..a015491e2d7 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -58,15 +58,15 @@ #include "intern/eval/deg_eval_copy_on_write.h" -// 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 -// 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 -// be plausible. -// -// This ensures that data does not look plausible, making it much easier to -// catch usage of invalid state. +/* 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 + * 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 + * be plausible. + * + * This ensures that data does not look plausible, making it much easier to + * catch usage of invalid state. */ #undef INVALIDATE_ON_FLUSH namespace blender::deg { diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index f2bbd6d5084..5a629058c81 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -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) { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { 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); } 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) { if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) { 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); } edit = pid->cache->edit; diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index 9c675c93a2e..0d243a812fa 100644 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -707,7 +707,7 @@ void Controller::ComputeSteerableViewMap() 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))); - //float c = qGray(qimg.pixel(x, y)); + // float c = qGray(qimg.pixel(x, y)); //img[i]->setPixel(x, y, qGray(qimg.pixel(x, y))); } } diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 0941338160d..3ad902a241d 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -28,7 +28,7 @@ # define _USE_MATH_DEFINES #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 #include diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index c02035be4ac..837dadaa719 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -210,7 +210,7 @@ typedef struct FMod_Envelope { } FMod_Envelope; /* cycling/repetition modifier data */ -// TODO: we can only do complete cycles... +/* TODO: we can only do complete cycles. */ typedef struct FMod_Cycles { /** Extrapolation mode to use before first keyframe. */ short before_mode; diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 34f50b23c77..63bf587d7fb 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -1102,7 +1102,7 @@ typedef enum eRotLimit_Flags { /* distance limit constraint */ /* bDistLimitConstraint->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), /* as for all Limit constraints - allow to be used during transform? */ LIMITDIST_TRANSFORM = (1 << 1), diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c index 06eb632378c..9985499772e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.c +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c @@ -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 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(para, ax, dot_v3v3(co, ax) * (1 - cos_a)); diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index b7989349ebe..c9af2fced65 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -269,9 +269,9 @@ bool SEQ_transform_seqbase_shuffle_ex(ListBase *seqbasep, } test->machine += channel_delta; - SEQ_time_update_sequence( - evil_scene, - test); // XXX: I don't think this is needed since were only moving vertically, Campbell. + + /* 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)) {