Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMGUIZMO: fixed compiler warnings #230

Merged
merged 1 commit into from
Mar 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions ImGuizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ namespace IMGUIZMO_NAMESPACE
return static_cast<int>(lhs) != rhs;
}

static bool operator==(OPERATION lhs, int rhs)
{
return static_cast<int>(lhs) == rhs;
}

static bool Intersects(OPERATION lhs, OPERATION rhs)
{
return (lhs & rhs) != 0;
Expand Down Expand Up @@ -323,9 +318,6 @@ namespace IMGUIZMO_NAMESPACE
vec_t component[4];
};

matrix_t(const matrix_t& other) { memcpy(&m16[0], &other.m16[0], sizeof(float) * 16); }
matrix_t() {}

operator float* () { return m16; }
operator const float* () const { return m16; }
void Translation(float _x, float _y, float _z) { this->Translation(makeVect(_x, _y, _z)); }
Expand Down Expand Up @@ -1229,14 +1221,14 @@ namespace IMGUIZMO_NAMESPACE
}
const bool usingAxis = (gContext.mbUsing && type == MT_ROTATE_Z - axis);
const int circleMul = (hasRSC && !usingAxis ) ? 1 : 2;

ImVec2* circlePos = (ImVec2*)alloca(sizeof(ImVec2) * (circleMul * halfCircleSegmentCount + 1));

float angleStart = atan2f(cameraToModelNormalized[(4 - axis) % 3], cameraToModelNormalized[(3 - axis) % 3]) + ZPI * 0.5f;

for (int i = 0; i < circleMul * halfCircleSegmentCount + 1; i++)
{
float ng = angleStart + circleMul * ZPI * ((float)i / (float)halfCircleSegmentCount);
float ng = angleStart + (float)circleMul * ZPI * ((float)i / (float)halfCircleSegmentCount);
vec_t axisPos = makeVect(cosf(ng), sinf(ng), 0.f);
vec_t pos = makeVect(axisPos[axis], axisPos[(axis + 1) % 3], axisPos[(axis + 2) % 3]) * gContext.mScreenFactor * rotationDisplayFactor;
circlePos[i] = worldToPos(pos, gContext.mMVP);
Expand Down Expand Up @@ -1314,7 +1306,7 @@ namespace IMGUIZMO_NAMESPACE
scaleDisplay = gContext.mScale;
}

for (unsigned int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
if(!Intersects(op, static_cast<OPERATION>(SCALE_X << i)))
{
Expand Down Expand Up @@ -1401,7 +1393,7 @@ namespace IMGUIZMO_NAMESPACE
scaleDisplay = gContext.mScale;
}

for (unsigned int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
if (!Intersects(op, static_cast<OPERATION>(SCALE_XU << i)))
{
Expand All @@ -1419,11 +1411,12 @@ namespace IMGUIZMO_NAMESPACE
{
bool hasTranslateOnAxis = Contains(op, static_cast<OPERATION>(TRANSLATE_X << i));
float markerScale = hasTranslateOnAxis ? 1.4f : 1.0f;
ImVec2 baseSSpace = worldToPos(dirAxis * 0.1f * gContext.mScreenFactor, gContext.mMVPLocal);
//ImVec2 baseSSpace = worldToPos(dirAxis * 0.1f * gContext.mScreenFactor, gContext.mMVPLocal);
//ImVec2 worldDirSSpaceNoScale = worldToPos(dirAxis * markerScale * gContext.mScreenFactor, gContext.mMVP);
ImVec2 worldDirSSpace = worldToPos((dirAxis * markerScale * scaleDisplay[i]) * gContext.mScreenFactor, gContext.mMVPLocal);

/*if (gContext.mbUsing && (gContext.mActualID == -1 || gContext.mActualID == gContext.mEditingID))
#if 0
if (gContext.mbUsing && (gContext.mActualID == -1 || gContext.mActualID == gContext.mEditingID))
{
drawList->AddLine(baseSSpace, worldDirSSpaceNoScale, IM_COL32(0x40, 0x40, 0x40, 0xFF), 3.f);
drawList->AddCircleFilled(worldDirSSpaceNoScale, 6.f, IM_COL32(0x40, 0x40, 0x40, 0xFF));
Expand All @@ -1434,6 +1427,7 @@ namespace IMGUIZMO_NAMESPACE
drawList->AddLine(baseSSpace, worldDirSSpace, colors[i + 1], 3.f);
}
*/
#endif
drawList->AddCircleFilled(worldDirSSpace, 12.f, colors[i + 1]);
}
}
Expand Down Expand Up @@ -1484,7 +1478,7 @@ namespace IMGUIZMO_NAMESPACE
// draw
bool belowAxisLimit = false;
bool belowPlaneLimit = false;
for (unsigned int i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
vec_t dirPlaneX, dirPlaneY, dirAxis;
ComputeTripodAxisAndVisibility(i, dirAxis, dirPlaneX, dirPlaneY, belowAxisLimit, belowPlaneLimit);
Expand Down Expand Up @@ -1581,7 +1575,7 @@ namespace IMGUIZMO_NAMESPACE
{
numAxes = 0;
float bestDot = 0.f;
for (unsigned int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
vec_t dirPlaneNormalWorld;
dirPlaneNormalWorld.TransformVector(directionUnary[i], gContext.mModelSource);
Expand Down Expand Up @@ -1845,7 +1839,7 @@ namespace IMGUIZMO_NAMESPACE
}

// compute
for (unsigned int i = 0; i < 3 && type == MT_NONE; i++)
for (int i = 0; i < 3 && type == MT_NONE; i++)
{
if(!Intersects(op, static_cast<OPERATION>(SCALE_X << i)))
{
Expand Down Expand Up @@ -1884,7 +1878,7 @@ namespace IMGUIZMO_NAMESPACE
type = MT_SCALE_XYZ;
}

for (unsigned int i = 0; i < 3 && type == MT_NONE; i++)
for (int i = 0; i < 3 && type == MT_NONE; i++)
{
if (!Intersects(op, static_cast<OPERATION>(SCALE_XU << i)))
{
Expand All @@ -1900,7 +1894,7 @@ namespace IMGUIZMO_NAMESPACE
{
bool hasTranslateOnAxis = Contains(op, static_cast<OPERATION>(TRANSLATE_X << i));
float markerScale = hasTranslateOnAxis ? 1.4f : 1.0f;
ImVec2 baseSSpace = worldToPos(dirAxis * 0.1f * gContext.mScreenFactor, gContext.mMVPLocal);
//ImVec2 baseSSpace = worldToPos(dirAxis * 0.1f * gContext.mScreenFactor, gContext.mMVPLocal);
//ImVec2 worldDirSSpaceNoScale = worldToPos(dirAxis * markerScale * gContext.mScreenFactor, gContext.mMVP);
ImVec2 worldDirSSpace = worldToPos((dirAxis * markerScale) * gContext.mScreenFactor, gContext.mMVPLocal);

Expand Down Expand Up @@ -1935,7 +1929,7 @@ namespace IMGUIZMO_NAMESPACE
vec_t modelViewPos;
modelViewPos.TransformPoint(gContext.mModel.v.position, gContext.mViewMat);

for (unsigned int i = 0; i < 3 && type == MT_NONE; i++)
for (int i = 0; i < 3 && type == MT_NONE; i++)
{
if(!Intersects(op, static_cast<OPERATION>(ROTATE_X << i)))
{
Expand Down Expand Up @@ -1992,7 +1986,7 @@ namespace IMGUIZMO_NAMESPACE
const vec_t screenCoord = makeVect(io.MousePos - ImVec2(gContext.mX, gContext.mY));

// compute
for (unsigned int i = 0; i < 3 && type == MT_NONE; i++)
for (int i = 0; i < 3 && type == MT_NONE; i++)
{
vec_t dirPlaneX, dirPlaneY, dirAxis;
bool belowAxisLimit, belowPlaneLimit;
Expand Down Expand Up @@ -2782,7 +2776,7 @@ namespace IMGUIZMO_NAMESPACE
}

const ImVec2 panelCorners[2] = { panelPosition[iPanel], panelPosition[iPanel] + panelSize[iPanel] };
bool insidePanel = localx > panelCorners[0].x && localx < panelCorners[1].x&& localy > panelCorners[0].y && localy < panelCorners[1].y;
bool insidePanel = localx > panelCorners[0].x && localx < panelCorners[1].x && localy > panelCorners[0].y && localy < panelCorners[1].y;
int boxCoordInt = int(boxCoord.x * 9.f + boxCoord.y * 3.f + boxCoord.z);
IM_ASSERT(boxCoordInt < 27);
boxes[boxCoordInt] |= insidePanel && (!isDraging) && gContext.mbMouseOver;
Expand All @@ -2801,7 +2795,7 @@ namespace IMGUIZMO_NAMESPACE
int cx = boxCoordInt / 9;
int cy = (boxCoordInt - cx * 9) / 3;
int cz = boxCoordInt % 3;
interpolationDir = makeVect(1.f - cx, 1.f - cy, 1.f - cz);
interpolationDir = makeVect(1.f - (float)cx, 1.f - (float)cy, 1.f - (float)cz);
interpolationDir.Normalize();

if (fabsf(Dot(interpolationDir, referenceUp)) > 1.0f - 0.01f)
Expand Down