CMake error while installing Bullet Physics (PYTHON_LIBRARY set to NOTFOUND)

Hello everyone I’m trying to install Bullet Physics in my Ubuntu 18.04 LTS.

I managed to install cmake successfully, but as soon as I try to run

./build_cmake_pybullet_double.sh 

it shows me the error

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: PYTHON_LIBRARY (ADVANCED) 

I already installed python3-pip and other libraries, but why is this error happening?

(In usr/lib there are the following folders python2.7, python3, python3.6, python3.7)

Thanks in advance!

Does D&D physics enable a perpetual motion machine?

For various reasons perpetual motion machines are impossible in real life. They violate the laws of thermodynamics and cannot be created. It has been established, however, that D&D is not a physics simulator and the normal rules of physics do not apply.

Inspired by Shalvenay and MikeQ in chat. I was wondering, can a perpetual motion machine be made in D&D?


Imagine the following scenario:

Timmy the Tinkerer is going to a tinkering competition. The premise is simple; build the most magical device without using magic. The rules are as follows:

  • Magic cannot be used to create the item, and the item itself must not be magical.
  • It must be permanent, any item that relies on a once/day ability to sustain it will not count.
  • It must obey the physics of the material plane. No planar trickery is allowed.

Timmy decides he would love to make a perpetual motion machine.

Given these rules and using any officially available content; is it possible for Timmy to do this? For bonus points, how can he do it?

Technology stack for physics software

I have a project idea for a physics formula-simulation software with a possibility to extend it with custom plugins. I’m currently thinking about the tech-stack to use.

Thinking of the users and their background I’d say it’d would be most useful for people in academia and in my experience most of them know Python pretty well, which would give them the opportunity to write plugins in Python.

For the simulation part, I’m currently thinking 2d and 3d simulatins of various physics models, C++ could be used since it has various existing libraries in that field.

So my current outline is to use Python for the core, user interface, plugin interface. And to use C++ for the simulation part and use an interface library such as pybind11 or similar for the connection.

Does anyone have any experience with this type of software and has some input regarding the options of the tech-stack to use?

Golf Physics “Game”

Continuation of this post

I wrote a program in pygame that basically acts as a physics engine for a ball. You can hit the ball around and your strokes are counted, as well as an extra stroke for going out of bounds. Recently, I added a few things like air resistance, and rewrote my movement physics to make it easier to bounce. I’m wondering if the physics approach is good. Also, is there any way to convert everything into SI units? Right now, my air drag is an arbitrary value.

import math import pygame as pg   class Colors:      BLACK = (0, 0, 0)     WHITE = (255, 255, 255)     RED = (255, 0, 0)     GREEN = (0, 255, 0)     BLUE = (0, 0, 255)      YELLOW = (255, 255, 0)     GOLD = (255, 215, 0)     GRAY = (100, 100, 100)      NIGHT =  (20, 24, 82)     DAY = (135, 206, 235)     MOON = (245, 243, 206)     SMOKE = (96, 96, 96)    class Constants:      SCREEN_WIDTH = 1500     SCREEN_HEIGHT = 800     WINDOW_COLOR = Colors.NIGHT      TICKRATE = 60     GAME_SPEED = .35      LINE_COLOR = Colors.GOLD     ALINE_COLOR = Colors.GOLD      X_BOUNDS_BARRIER = 1     Y_BOUNDS_BARRIER = 1     BOUNCE_FUZZ = 0      START_X = int(.5 * SCREEN_WIDTH)     START_Y = int(.99 * SCREEN_HEIGHT)      AIR_DRAG = .3     GRAVITY = 9.80665   class Fonts:      pg.font.init()     strokeFont = pg.font.SysFont("monospace", 50)     STROKECOLOR = Colors.YELLOW      powerFont = pg.font.SysFont("arial", 15, bold=True)     POWERCOLOR = Colors.GREEN      angleFont = pg.font.SysFont("arial", 15, bold=True)     ANGLECOLOR = Colors.GREEN      penaltyFont = pg.font.SysFont("georgia", 40, bold=True)     PENALTYCOLOR = Colors.RED      toggleBoundsFont = pg.font.SysFont("geneva", 20)     TOGGLEBOUNDSCOLOR = Colors.RED      resistMultiplierFont = pg.font.SysFont("courier new", 13)     RESISTMULTIPLIERCOLOR = Colors.RED      powerMultiplierFont = pg.font.SysFont("courier new", 13)     POWERMULTIPLIERCOLOR = Colors.RED   class Ball(object):     def __init__(self, x, y, dx = 0, dy = 0, bounce = .8, radius = 10, color=Colors.SMOKE, outlinecolor=Colors.RED, density=1):         self.color = color         self.outlinecolor = outlinecolor         self.x = x         self.y = y         self.dx = dx         self.dy = dy         self.ax = 0         self.ay = Constants.GRAVITY         self.dt = Constants.GAME_SPEED         self.bounce = bounce         self.radius = radius         self.mass = 4/3 * math.pi * self.radius**3 * density      def show(self, window):         pg.draw.circle(window, self.outlinecolor, (int(self.x), int(self.y)), self.radius)         pg.draw.circle(window, self.color, (int(self.x), int(self.y)), self.radius - int(.4 * self.radius))      def update(self, update_frame):         update_frame += 1          self.vx += self.ax * self.dt         self.vy += self.ay * self.dt          if resist_multiplier:             drag = 6*math.pi * self.radius * resist_multiplier * Constants.AIR_DRAG             air_resist_x = -drag * self.vx / self.mass             air_resist_y = -drag * self.vy / self.mass              self.vx += air_resist_x/self.dt             self.vy += air_resist_y/self.dt          self.x += self.vx * self.dt         self.y += self.vy * self.dt          bounced, stop, shoot = False, False, True          # Top & Bottom         if self.y + self.radius > Constants.SCREEN_HEIGHT:             self.y = Constants.SCREEN_HEIGHT - self.radius             self.vy = -self.vy             bounced = True             print('    Bounce!')          if self.y - self.radius < Constants.Y_BOUNDS_BARRIER:             self.y = Constants.Y_BOUNDS_BARRIER + self.radius             self.vy = -self.vy             bounced = True             print('    Bounce!')          # Speed/Resistance Rectangles         if (self.x >= .875*Constants.SCREEN_WIDTH + self.radius) and (self.y + self.radius >= .98*Constants.SCREEN_HEIGHT):             self.x = .88*Constants.SCREEN_WIDTH + self.radius             self.y = .98*Constants.SCREEN_HEIGHT - self.radius             self.x = .87*Constants.SCREEN_WIDTH + self.radius             self.vy, self.vx = -self.vy, -2 * abs(self.vx)             bounced = True          if (self.x <= .1175*Constants.SCREEN_WIDTH + self.radius) and (self.y + self.radius >= .98*Constants.SCREEN_HEIGHT):             self.x = .118*Constants.SCREEN_WIDTH + self.radius             self.y = .98*Constants.SCREEN_HEIGHT - self.radius             self.x = .119*Constants.SCREEN_WIDTH + self.radius             self.vy, self.vx = -self.vy, 2 * abs(self.vx)             bounced = True          if x_bounded:             if (self.x - self.radius < Constants.X_BOUNDS_BARRIER):                 self.x = Constants.X_BOUNDS_BARRIER + self.radius                 self.vx = -self.vx                 bounced = True              if (self.x + self.radius > Constants.SCREEN_WIDTH - Constants.X_BOUNDS_BARRIER):                 self.x = Constants.SCREEN_WIDTH - Constants.X_BOUNDS_BARRIER - self.radius                 self.vx = -self.vx                 bounced = True          if self.vx > 1000:             self.vx = 1000             self.y = Constants.SCREEN_HEIGHT/4          if bounced:             self.vx *= self.bounce             self.vy *= self.bounce          print(f'\n    Update Frame: {update_frame}',                '        x-pos: %spx' % round(self.x),                '        y-pos: %spx' % round(self.y),                '        x-vel: %spx/u' % round(self.vx),                '        y-vel: %spx/u' % round(self.vy),                sep='\n', end='\n\n')          return update_frame, shoot, stop      @staticmethod     def quadrant(x, y, xm, ym):         if ym < y and xm > x:             return 1         elif ym < y and xm < x:             return 2         elif ym > y and xm < x:             return 3         elif ym > y and xm > x:             return 4         else:             return False   def draw_window():     clock.tick(Constants.TICKRATE)      window.fill(Constants.WINDOW_COLOR)      resist_multiplier_text = 'Air Resistance: {:2.2f} m/s'.format(resist_multiplier)     resist_multiplier_label = Fonts.resistMultiplierFont.render(resist_multiplier_text, 1, Fonts.RESISTMULTIPLIERCOLOR)     pg.draw.rect(window, Colors.BLACK, (.8875*Constants.SCREEN_WIDTH, .98*Constants.SCREEN_HEIGHT, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))     pg.draw.arrow(window, Colors.MOON, Colors.GREEN, (.8875*Constants.SCREEN_WIDTH, .99*Constants.SCREEN_HEIGHT), (.88*Constants.SCREEN_WIDTH, .99*Constants.SCREEN_HEIGHT), 3, 3)     pg.draw.arrow(window, Colors.MOON, Colors.GREEN, (Constants.SCREEN_WIDTH, .975*Constants.SCREEN_HEIGHT), (.88*Constants.SCREEN_WIDTH, .975*Constants.SCREEN_HEIGHT), 3)     window.blit(resist_multiplier_label, (.8925*Constants.SCREEN_WIDTH, .98*Constants.SCREEN_HEIGHT))      power_multiplier_text = f'Swing Strength: {int(power_multiplier*100)}%'     power_multiplier_label = Fonts.powerMultiplierFont.render(power_multiplier_text, 1, Fonts.POWERMULTIPLIERCOLOR)     pg.draw.rect(window, Colors.BLACK, (0, .98*Constants.SCREEN_HEIGHT, .1125*Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))     pg.draw.arrow(window, Colors.MOON, Colors.GREEN, (.1125*Constants.SCREEN_WIDTH, .99*Constants.SCREEN_HEIGHT), (.12*Constants.SCREEN_WIDTH, .99*Constants.SCREEN_HEIGHT), 3, 3)     pg.draw.arrow(window, Colors.MOON, Colors.GREEN, (0, .975*Constants.SCREEN_HEIGHT), (.12*Constants.SCREEN_WIDTH, .975*Constants.SCREEN_HEIGHT), 3)     window.blit(power_multiplier_label, (.005*Constants.SCREEN_WIDTH, .98*Constants.SCREEN_HEIGHT))      if not shoot:         pg.draw.arrow(window, Constants.ALINE_COLOR, Constants.ALINE_COLOR, aline[0], aline[1], 5)         pg.draw.arrow(window, Constants.LINE_COLOR, Constants.LINE_COLOR, line[0], line[1], 5)      stroke_text = 'Strokes: %s' % strokes     stroke_label = Fonts.strokeFont.render(stroke_text, 1, Fonts.STROKECOLOR)     if not strokes:         window.blit(stroke_label, (Constants.SCREEN_WIDTH - .21 * Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT - .985 * Constants.SCREEN_HEIGHT))     else:         window.blit(stroke_label, (Constants.SCREEN_WIDTH - (.21+.02*math.floor(math.log10(strokes))) * Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT - .985 * Constants.SCREEN_HEIGHT))      power_text = 'Shot Strength: %sN' % power_display     power_label = Fonts.powerFont.render(power_text, 1, Fonts.POWERCOLOR)     if not shoot: window.blit(power_label, (cursor_pos[0] + .008 * Constants.SCREEN_WIDTH, cursor_pos[1]))      angle_text = 'Angle: %s°' % angle_display     angle_label = Fonts.angleFont.render(angle_text, 1, Fonts.ANGLECOLOR)     if not shoot: window.blit(angle_label, (ball.x - .06 * Constants.SCREEN_WIDTH, ball.y - .01 * Constants.SCREEN_HEIGHT))      if penalty:         penalty_text = f'Out of Bounds! +1 Stroke'         penalty_label = Fonts.penaltyFont.render(penalty_text, 1, Fonts.PENALTYCOLOR)         penalty_rect = penalty_label.get_rect(center=(Constants.SCREEN_WIDTH/2, .225*Constants.SCREEN_HEIGHT))         window.blit(penalty_label, penalty_rect)          toggle_bounds_text = "Use [b] to toggle bounds"         toggle_bounds_label = Fonts.toggleBoundsFont.render(toggle_bounds_text, 1, Fonts.TOGGLEBOUNDSCOLOR)         toggle_bounds_rect = toggle_bounds_label.get_rect(center=(Constants.SCREEN_WIDTH/2, .275*Constants.SCREEN_HEIGHT))         window.blit(toggle_bounds_label, toggle_bounds_rect)      ball.show(window)      pg.display.flip()   def angle(cursor_pos):     x, y, xm, ym = ball.x, ball.y, cursor_pos[0], cursor_pos[1]     if x-xm:         angle = math.atan((y - ym) / (x - xm))     elif y > ym:         angle = math.pi/2     else:         angle = 3*math.pi/2      q = ball.quadrant(x,y,xm,ym)     if q: angle = math.pi*math.floor(q/2) - angle      if round(angle*deg) == 360:         angle = 0      if x > xm and not round(angle*deg):         angle = math.pi      return angle   def arrow(screen, lcolor, tricolor, start, end, trirad, thickness=2):     pg.draw.line(screen, lcolor, start, end, thickness)     rotation = (math.atan2(start[1] - end[1], end[0] - start[0])) + math.pi/2     pg.draw.polygon(screen, tricolor, ((end[0] + trirad * math.sin(rotation),                                         end[1] + trirad * math.cos(rotation)),                                        (end[0] + trirad * math.sin(rotation - 120*rad),                                         end[1] + trirad * math.cos(rotation - 120*rad)),                                        (end[0] + trirad * math.sin(rotation + 120*rad),                                         end[1] + trirad * math.cos(rotation + 120*rad)))) setattr(pg.draw, 'arrow', arrow)   def distance(x, y):     return math.sqrt(x**2 + y**2)   def update_values(quit, rkey, skey, shoot, xb, yb, strokes, x_bounded):     for event in pg.event.get():         if event.type == pg.QUIT:             quit = True          if event.type == pg.KEYDOWN:             if event.key == pg.K_ESCAPE:                 quit = True              if event.key == pg.K_RIGHT:                 if rkey != max(resist_dict):                     rkey += 1              if event.key == pg.K_LEFT:                 if rkey != min(resist_dict):                     rkey -= 1              if event.key == pg.K_UP:                 if skey != max(strength_dict):                     skey += 1              if event.key == pg.K_DOWN:                 if skey != min(strength_dict):                     skey -= 1              if event.key == pg.K_b:                 x_bounded = not x_bounded              if event.key == pg.K_q:                 rkey = min(resist_dict)                 skey = max(strength_dict)                 x_bounded = True              if event.key == pg.K_e:                 rkey = max(resist_dict)                 skey = max(strength_dict)                 x_bounded = False           if event.type == pg.MOUSEBUTTONDOWN:             if not shoot:                 shoot, stop = True, False                 strokes, xb, yb = hit_ball(strokes)      return quit, rkey, skey, shoot, xb, yb, strokes, x_bounded   def hit_ball(strokes):     x, y = ball.x, ball.y     xb, yb = ball.x, ball.y     power = power_multiplier/4 * distance(line_ball_x, line_ball_y)     print('\n\nBall Hit!')     print('\npower: %sN' % round(power, 2))     ang = angle(cursor_pos)     print('angle: %s°' % round(ang * deg, 2))     print('cos(a): %s' % round(math.cos(ang), 2)), print('sin(a): %s' % round(math.sin(ang), 2))      ball.vx, ball.vy = power * math.cos(ang), -power * math.sin(ang)      strokes += 1      return strokes, xb, yb   def initialize():     pg.init()     pg.display.set_caption('Golf')     window = pg.display.set_mode((Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT))     pg.event.set_grab(True)     pg.mouse.set_cursor((8, 8), (0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0))      return window   rad, deg = math.pi/180, 180/math.pi x, y, power, ang, strokes = [0]*5 xb, yb = None, None shoot, penalty, stop, quit, x_bounded = [False]*5 p_ticks, update_frame = 0, 0  ball = Ball(Constants.START_X, Constants.START_Y)  clock = pg.time.Clock()  strength_dict = {0: .01, 1: .02, 2: .04, 3: .08, 4: .16, 5: .25, 6: .50, 7: .75, 8: 1}; skey = 6 resist_dict = {0: 0, 1: .01, 2: .02, 3: .03, 4: .04, 5: .05, 6: .1, 7: .2, 8: .3, 9: .4, 10: .5, 11: .6, 12: .7,                13: .8, 14: .9, 15: 1, 16: 1.25, 17: 1.5, 18: 1.75, 19: 2, 20: 2.5, 21: 3, 22: 3.5, 23: 4, 24: 4.5,                25: 5}; rkey = 7   if __name__ == '__main__':      window = initialize()     while not quit:         power_multiplier = strength_dict[skey]         resist_multiplier = resist_dict[rkey]          seconds = (pg.time.get_ticks()-p_ticks)/1000         if seconds > 1.2: penalty = False          cursor_pos = pg.mouse.get_pos()         line = [(ball.x, ball.y), cursor_pos]         line_ball_x, line_ball_y = cursor_pos[0] - ball.x, cursor_pos[1] - ball.y          aline = [(ball.x, ball.y), (ball.x + .015 * Constants.SCREEN_WIDTH, ball.y)]          if not shoot:             power_display = round(                 distance(line_ball_x, line_ball_y) * power_multiplier/5)              angle_display = round(angle(cursor_pos) * deg)          else:             if stop or (abs(ball.vy) < 5 and abs(ball.vx) < 1 and abs(ball.y - (Constants.START_Y - 2)) <= Constants.BOUNCE_FUZZ):                 shoot = False                 #ball.y = Constants.START_Y                 print('\nThe ball has come to a rest!')                 update_frame = 0             else:                 update_frame, shoot, stop = ball.update(update_frame)              if not Constants.X_BOUNDS_BARRIER < ball.x < Constants.SCREEN_WIDTH:                 shoot = False                 print(f'\nOut of Bounds! Pos: {round(ball.x), round(ball.y)}')                 penalty = True                 p_ticks = pg.time.get_ticks()                 strokes += 1                  if Constants.X_BOUNDS_BARRIER < xb < Constants.SCREEN_WIDTH:                     ball.x = xb                 else:                     ball.x = Constants.START_X                 ball.y = yb          quit, rkey, skey, shoot, xb, yb, strokes, x_bounded = update_values(quit, rkey, skey, shoot, xb, yb, strokes, x_bounded)          draw_window()      print("\nShutting down...")     pg.quit() 

Choosing technology stack for a realtime, physics based .io game

As this is the first time we are going to make an online massive multiplayer (MMO) game, we need the community advice to choose reliable technology stack. The game is not turn-based like chess, but it is real-time and physics based game like these game are

  • https://agar.io/
  • http://slither.io/
  • http://diep.io

This image shows how we see the client-server architecture. There are thousands of players, and there are many rooms, each room contains up to 100 players. Each player is like an active spectator – he sends his input controls and waits for the server to tell what happened to render it on client’s screen. The server is authoritative, it contains the game world and based on client inputs advances the world state. Client inputs should be delivered to the server reliably. Server should talk to client by sending both reliable (level start event) and unreliable (player position) messages.

After some research we assume the following technology stack will enable us to make the game:

  • Phaser (rendering, communicating to server)
  • Node.js as server with socket.io for networking and Box2d for physics simulation
  • deployment on AWS

Our priority is to make the game prototype ASAP to validate the idea and technological limits. If the proof of concept will work as we expect we would like to develop the game using the same technology stack if possible.

I know this is highly subjective question but would like to hear some opinions, pros and cons to get some idea where and what to look for. Thanks in advance.

Handling strange physics behaviour while sliding between coplanar surfaces

We’ve got a character setup based around manually resolving collisions, and we’re using bullet to do so. Our characters have a kinematic rigidbody to push things around, but their movement and positioning is done using a separate (pair caching) ghost object. Every physics tick we iterate over all contacts for that ghost and resolve collision either by depenetrating 100% when it’s ground, or by depenetrating gradually/not at all with walls or other characters. We then apply our ghost’s new position to the kinematic rigidbody so that can interact with other physics objects.

Unfortunately, when moving around a flat world made up of a bunch of coplanar blocks, when the characters moves from one block to another it will often do one of two things;

  • Fall through the cracks
  • Get bumped upward a significant distance (we’re talking up to half a unit/meter with a character that is 2 units/meters tall)

enter image description here

Debugging this tells me sometimes these contact points are unexpected, and not something I want to resolve by depenetrating 100%. Gravity moving the character downward can result in a contact point that is closer to the side of the terrain block than the top, and it will give you a normal/distance accordingly (blue arrow). Resolving that with 100% depenetration will just push you in between the blocks, while not counteracting the gravity forces. This would explain the falling through the cracks. But I don’t know why I sometimes get contact points with normals pointing straight up, but with a distance that would place the collider far above the ground (purple arrow).

I’ve come to the point where I feel like my only option to handle character movement like this is by not colliding with the ground at all, and just spherecast downwards at the character’s position on the horizontal plane just to place it down on the ground properly.

Now obviously I want to get rid of this behaviour. And seeing how you don’t see this happen in many games, I’m lead to believe others have solved this issue somehow. Has anyone here encountered similar issues, and how did you go about fixing them?