Esempio n. 1
0
void plParticleFadeVolumeEffect::PrepareEffect(const plEffectTargetInfo &target)
{
    hsPoint3 viewLoc = target.fContext.fPipeline->GetViewPositionWorld();
    hsVector3 viewDir = target.fContext.fPipeline->GetViewDirWorld();

    // Nuking out the setting of viewDir.fZ to 0 when we aren't centering
    // about Z (fIgnoreZ == true), because we still want to center our
    // volume about the camera (rather than push the camera to the edge of
    // the cylinder) in that case, so we don't get artifacts when we look
    // straight up or down. mf

    hsPoint3 signs(viewDir.fX >= 0 ? 1.f : -1.f, viewDir.fY >= 0 ? 1.f : -1.f, viewDir.fZ >= 0 ? 1.f : -1.f);

    fMax.fX = viewLoc.fX + (viewDir.fX + signs.fX) * fLength;
    fMin.fX = fMax.fX - 2.f * signs.fX * fLength;

    fMax.fY = viewLoc.fY + (viewDir.fY + signs.fY) * fLength;
    fMin.fY = fMax.fY - 2.f * signs.fY * fLength;

    fMax.fZ = viewLoc.fZ + (viewDir.fZ + signs.fZ) * fLength;
    fMin.fZ = fMax.fZ - 2.f * signs.fZ * fLength;

    fNorm.fX = 1.f / (fMax.fX - fMin.fX);
    fNorm.fY = 1.f / (fMax.fY - fMin.fY);
    fNorm.fZ = 1.f / (fMax.fZ - fMin.fZ);
}
Esempio n. 2
0
File: kill.c Progetto: sng7ca/ygg
void main(int argc, char *argv[])
{
	register char c;
	register int sig;

	/* kill by default */
	sig = SIGKILL;
	/* parse options */
	while (--argc && **++argv == '-')
		while (c = *++*argv)
			switch (c) {
			case 'n':	/* signum */
				sig = atoi(*++argv, 10);
				/*
				 * more portable check is separate ==s
				 * for each signal, but efficiency 
				 * will be damaged, so use internal
				 * ygg's signum representation as 2^n
				 */
				/* check here to avoid syscall */
				if (!((sig & (SIGHUP | SIGINT | SIGQUIT |
					     SIGILL | SIGTRAP | SIGIOT |
					     SIGEMT | SIGFPE | SIGKILL |
					     SIGBUS | SIGSEGV | SIGSYS |
					     SIGPIPE | SIGALRM | SIGTERM |
					     SIGUSR1 | SIGUSR2 | SIGCLD |
					     SIGPWR | SIGTSTP)) &&
				      ispwr(sig)))
					exit(1);
				++argv, argc -= 2;
				goto end;
			case 's':	/* sigstr */
				sig = signs(*++argv);
				if (sig == -1)
					exit(1);
				++argv, argc -= 2;
				goto end;
			case 'v':	/* version */
				printf(stdout, "kill 0.0\n");
				exit(0);
			case 'h':	/* help */
				printf(stdout, "usage: kill ...\n");
				exit(0);
			default:	/* unknown option */
				printf(stderr, "kill: %c == ?\n", c);
				exit(1);
			}
end:
	/* no file specified */
	if (!argc)
		perror("usage: kill [-n <signum>] [-s <sigstr>] "
		       "[-h] [-v] <pid0> [pid1] ...\n");
	/* parse pid's */
	for (; argc--; argv++)
		if (kill(atoi(*argv, 10), sig) == -1)
			printf(stderr, "kill: kill %s err\n", *argv);
	exit(0);
}
Esempio n. 3
0
std::string CFormulaParser::makePolandNotation(std::string formula)
{
	std::stack<char> stack;
	std::string result,num;
	std::map<char, std::map<char, char>> priorities = makePriorityList();
	char signs_raw[] = { '+','-','*','/','^','(',')' };
	std::vector<char> signs(signs_raw, signs_raw + 7);
	bool stacked=false;
	for (std::string::iterator it = formula.begin(); it != formula.end(); it++)
	{
		if (*it >= '0' && *it <= '9' || *it == '.' || (*it=='-' &&  (it==formula.begin() || std::find(signs.begin(), signs.end(), *(it-1)) != signs.end())))
		{
			num.push_back(*it);

		} else {
			if (num.length() > 0)
			{
				result.push_back(makeOperand(num));
				num.erase();
			}
			if (std::find(signs.begin(), signs.end(), *it) != signs.end())
			{
				stacked = false;
				while (!stacked)
				{
					switch (priorities[!stack.empty() ? stack.top() : 0][*it])
					{
					case 4:
						throw "Error in parsing formula";
						break;
					case 1:
						stack.push(*it);
						stacked = true;
						break;
					case 2:
						result.push_back(stack.top());
						stack.pop();
						break;
					case 3:
						stack.pop();
						stacked = true;
						break;
					default:
						throw "Error in parsing formula";
					}
				}
			}
			else {
				result.push_back(*it);
			}
		}
	}
	if (num.length() > 0)
	{
		result.push_back(makeOperand(num));
		num.erase();
	}
	while (!stack.empty())
	{
		result.push_back(stack.top());
		stack.pop();
	}
	return result;
}